[hackers] [sbase][PATCH] which: check AT_EACCESS

From: Mattias Andrée <maandree_AT_kth.se>
Date: Sat, 27 Jul 2019 22:29:10 +0200

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 <maandree_AT_kth.se>
---
 which.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/which.c b/which.c
index cc93361..42ed095 100644
--- a/which.c
+++ b/which.c
_AT_@ -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
-- 
2.22.0
Received on Sat Jul 27 2019 - 22:29:10 CEST

This archive was generated by hypermail 2.3.0 : Sat Jul 27 2019 - 23:12:23 CEST