From cf3dfe920659a7d5f1781f92a711d7fe909d109e Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Sun, 15 Oct 2017 18:51:22 +0200 Subject: [PATCH] No longer hard-code permission checks --- src/makefile.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/makefile.c b/src/makefile.c index cf55bea..4ea5635 100644 --- a/src/makefile.c +++ b/src/makefile.c @@ -29,6 +29,7 @@ #include +#include #include #include #include @@ -2431,19 +2432,20 @@ static int _dist_check(Configure * configure, char const * target, if(mode[0] == '\0' || *p != '\0') return error_set_print(PROGNAME, 1, "%s: %s%s%s", target, "Invalid permissions \"", mode, "\""); - if((configure->prefs->flags & PREFS_S) && (m & 04000)) + if((configure->prefs->flags & PREFS_S) && (m & S_ISUID)) error_set_print(PROGNAME, 0, "%s: %s", target, "Installed as a SUID file"); - if((configure->prefs->flags & PREFS_S) && (m & 04000)) + if((configure->prefs->flags & PREFS_S) && (m & S_ISUID)) error_set_print(PROGNAME, 0, "%s: %s", target, "Installed as a SGID file"); - if((configure->prefs->flags & PREFS_S) && (m & 0111)) + if((configure->prefs->flags & PREFS_S) + && (m & (S_IXUSR | S_IXGRP | S_IXOTH))) error_set_print(PROGNAME, 0, "%s: %s", target, "Installed as an executable file"); - if((configure->prefs->flags & PREFS_S) && (m & 0020)) + if((configure->prefs->flags & PREFS_S) && (m & S_IWGRP)) error_set_print(PROGNAME, 0, "%s: %s", target, "Installed as a group-writable file"); - if((configure->prefs->flags & PREFS_S) && (m & 0002)) + if((configure->prefs->flags & PREFS_S) && (m & S_IWOTH)) error_set_print(PROGNAME, 0, "%s: %s", target, "Installed as a writable file"); return 0;