diff options
author | maxim <maxim@FreeBSD.org> | 2002-03-06 11:20:13 +0000 |
---|---|---|
committer | maxim <maxim@FreeBSD.org> | 2002-03-06 11:20:13 +0000 |
commit | 7d6942219698b48fdb39fb2d4a402b775e9f96bf (patch) | |
tree | 2d172db3bd9e602c67cf042fb230cd97911d07f0 /bin | |
parent | 1896fa66ee5d1836a24bdfc34e0b96927028b133 (diff) | |
download | FreeBSD-src-7d6942219698b48fdb39fb2d4a402b775e9f96bf.zip FreeBSD-src-7d6942219698b48fdb39fb2d4a402b775e9f96bf.tar.gz |
Log:
Remove eaccess(2) absence workaround. Add eaccess(2) checks for FILRD,
FILWR, FILEX and FILEXIST cases.
We cannot MFC this because there is no eaccess(2) in -stable yet.
PR: bin/35076
Reviewed by: ru
Approved by: ru
Diffstat (limited to 'bin')
-rw-r--r-- | bin/test/test.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/bin/test/test.c b/bin/test/test.c index e40af5d..2a5955f 100644 --- a/bin/test/test.c +++ b/bin/test/test.c @@ -215,10 +215,6 @@ main(int argc, char **argv) #ifndef SHELL (void)setlocale(LC_CTYPE, ""); #endif - /* XXX work around the absence of an eaccess(2) syscall */ - (void)setgid(getegid()); - (void)setuid(geteuid()); - t_wp = &argv[1]; res = !oexpr(t_lex(*t_wp)); @@ -365,18 +361,18 @@ filstat(char *nm, enum token mode) switch (mode) { case FILRD: - return access(nm, R_OK) == 0; + return (eaccess(nm, R_OK) == 0); case FILWR: - return access(nm, W_OK) == 0; + return (eaccess(nm, W_OK) == 0); case FILEX: - /* XXX work around access(2) false positives for superuser */ - if (access(nm, X_OK) != 0) + /* XXX work around eaccess(2) false positives for superuser */ + if (eaccess(nm, X_OK) != 0) return 0; - if (S_ISDIR(s.st_mode) || getuid() != 0) + if (S_ISDIR(s.st_mode) || geteuid() != 0) return 1; return (s.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) != 0; case FILEXIST: - return access(nm, F_OK) == 0; + return (eaccess(nm, F_OK) == 0); case FILREG: return S_ISREG(s.st_mode); case FILDIR: |