diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-10-10 19:09:08 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-10-10 19:09:08 +0000 |
commit | 904af20dfd5dd6cfa44e12748131539d6003a9ec (patch) | |
tree | ab3fdd9e536f6881832974caed34e16be36da2e8 /bin | |
parent | 27a99718a2c8aeca06926bf8187f6b0f28eab501 (diff) |
The special case code for "test -x" over NFS was incorrect. The
right thing to do is to try access(2) first (since that occurs on the
NFS server side) and only check for the absence of an execute bit
when access(2) succeeds. Closes PR 3465
Diffstat (limited to 'bin')
-rw-r--r-- | bin/ksh/c_test.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/bin/ksh/c_test.c b/bin/ksh/c_test.c index 4ac5db54ae1..3e57eebc4a2 100644 --- a/bin/ksh/c_test.c +++ b/bin/ksh/c_test.c @@ -1,4 +1,4 @@ -/* $OpenBSD: c_test.c,v 1.9 2003/02/28 09:45:09 jmc Exp $ */ +/* $OpenBSD: c_test.c,v 1.10 2003/10/10 19:09:07 millert Exp $ */ /* * test(1); version 7-like -- author Erik Baalbergen @@ -458,10 +458,12 @@ test_eaccess(path, mode) } #endif /* !HAVE_DEV_FD */ - /* On most (all?) unixes, access() says everything is executable for + res = eaccess(path, mode); + /* + * On most (all?) unixes, access() says everything is executable for * root - avoid this on files by using stat(). */ - if ((mode & X_OK) && ksheuid == 0) { + if (res == 0 && ksheuid == 0 && (mode & X_OK)) { struct stat statb; if (stat(path, &statb) < 0) @@ -471,13 +473,7 @@ test_eaccess(path, mode) else res = (statb.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)) ? 0 : -1; - /* Need to check other permissions? If so, use access() as - * this will deal with root on NFS. - */ - if (res == 0 && (mode & (R_OK|W_OK))) - res = eaccess(path, mode); - } else - res = eaccess(path, mode); + } return res; } |