commit 7315b8686f3fcbf213113247bea980b0548ec66a
Author: Mattias Andrée <[email protected]>
AuthorDate: Sat Jul 27 22:29:10 2019 +0200
Commit: Michael Forney <[email protected]>
CommitDate: Tue Jul 30 07:40:35 2019 -0700
which: check AT_EACCESS
A file is executable only if the effective user
have permission to execute it. The real user's
permissions do not matter.
Signed-off-by: Mattias Andrée <[email protected]>
diff --git a/which.c b/which.c
index 3f9af6e..abd030e 100644
--- a/which.c
+++ b/which.c
@@ -20,7 +20,7 @@ canexec(int fd, const char *name)
if (fstatat(fd, name, &st, 0) < 0 || !S_ISREG(st.st_mode))
return 0;
- return faccessat(fd, name, X_OK, 0) == 0;
+ return faccessat(fd, name, X_OK, AT_EACCESS) == 0;
}
static int