summaryrefslogtreecommitdiffstats
path: root/bin/test
diff options
context:
space:
mode:
authorgreen <green@FreeBSD.org>1999-08-18 00:18:52 +0000
committergreen <green@FreeBSD.org>1999-08-18 00:18:52 +0000
commit74ed588ff93a2531636df620efd02a41fcd952a2 (patch)
treeec25af4500fa33aff371b3d936c21c6872d12f3f /bin/test
parentf352b6efeda0301d20a01dd42199a9ed89583a45 (diff)
downloadFreeBSD-src-74ed588ff93a2531636df620efd02a41fcd952a2.zip
FreeBSD-src-74ed588ff93a2531636df620efd02a41fcd952a2.tar.gz
The new test(1) did not use access() correctly. I don't know why, since
supposedly it's ksh-derived, and it's not broken in pdksh. I've added a test for test running as root: if testing for -x, the file must be mode & 0111 to get "success", rather than just existant. Reviewed by: chris
Diffstat (limited to 'bin/test')
-rw-r--r--bin/test/test.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/bin/test/test.c b/bin/test/test.c
index a4ae0cd..43a26aa 100644
--- a/bin/test/test.c
+++ b/bin/test/test.c
@@ -12,7 +12,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: test.c,v 1.22 1999/08/14 05:38:04 chris Exp $";
+ "$Id: test.c,v 1.23 1999/08/16 09:44:09 sheldonh Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -328,7 +328,12 @@ filstat(nm, mode)
case FILWR:
return access(nm, W_OK) == 0;
case FILEX:
- return access(nm, X_OK) == 0;
+ if (access(nm, X_OK) == 0) {
+ if (getuid() == 0 && (s.st_mode & 0111) == 0)
+ return 0;
+ return 1;
+ }
+ return 1;
case FILEXIST:
return access(nm, F_OK) == 0;
case FILREG:
OpenPOWER on IntegriCloud