No longer hard-code permission checks

This commit is contained in:
Pierre Pronchery 2017-10-15 18:51:22 +02:00
parent ee0a4e535c
commit cf3dfe9206

View File

@ -29,6 +29,7 @@
#include <System.h> #include <System.h>
#include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h> #include <stdlib.h>
@ -2431,19 +2432,20 @@ static int _dist_check(Configure * configure, char const * target,
if(mode[0] == '\0' || *p != '\0') if(mode[0] == '\0' || *p != '\0')
return error_set_print(PROGNAME, 1, "%s: %s%s%s", target, return error_set_print(PROGNAME, 1, "%s: %s%s%s", target,
"Invalid permissions \"", mode, "\""); "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, error_set_print(PROGNAME, 0, "%s: %s", target,
"Installed as a SUID file"); "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, error_set_print(PROGNAME, 0, "%s: %s", target,
"Installed as a SGID file"); "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, error_set_print(PROGNAME, 0, "%s: %s", target,
"Installed as an executable file"); "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, error_set_print(PROGNAME, 0, "%s: %s", target,
"Installed as a group-writable file"); "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, error_set_print(PROGNAME, 0, "%s: %s", target,
"Installed as a writable file"); "Installed as a writable file");
return 0; return 0;