From 89a3a364c2ec0cf093e776f3921d88dff8234539 Mon Sep 17 00:00:00 2001 From: Maxim Konovalov Date: Wed, 6 Mar 2002 11:20:13 +0000 Subject: [PATCH] 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 --- bin/test/test.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/bin/test/test.c b/bin/test/test.c index e40af5dbb07..2a5955f9920 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: -- 2.45.2