From 7315b8686f3fcbf213113247bea980b0548ec66a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Andr=C3=A9e?= Date: Sat, 27 Jul 2019 22:29:10 +0200 Subject: [PATCH] which: check AT_EACCESS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- which.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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