From e918dd42ecd6ebdfa2a6d7726bc6e4dafc654f31 Mon Sep 17 00:00:00 2001 From: Phil Jones Date: Mon, 17 Jul 2023 18:50:03 +0100 Subject: Use `access()` to check execute permissions. This is the correct way to check if we have execute permissions for a file (rather than checking `S_IXUSR`), and it isn't any slower. Should result in very few differences (on my system, only `cupsd` disappears from the list with this change). --- src/compgen.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compgen.c b/src/compgen.c index af8050d..27368e8 100644 --- a/src/compgen.c +++ b/src/compgen.c @@ -5,6 +5,7 @@ #include #include #include +#include #include "compgen.h" #include "history.h" #include "log.h" @@ -192,7 +193,7 @@ char *compgen() if (fstatat(fd, d->d_name, &sb, 0) == -1) { continue; } - if (!(sb.st_mode & S_IXUSR)) { + if (faccessat(fd, d->d_name, X_OK, 0) == -1) { continue; } if (!S_ISREG(sb.st_mode)) { -- cgit v1.2.3