diff options
Diffstat (limited to 'suidcmd.c')
-rw-r--r-- | suidcmd.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -8,6 +8,8 @@ #endif #include <stdio.h> #include <stdlib.h> +#include <sys/types.h> +#include <sys/stat.h> #include <unistd.h> #include <string.h> /* memset(...), strstr(...) */ #include <sys/wait.h> @@ -117,6 +119,15 @@ int main(int argc, char** argv) return 1; } + struct stat buf; + if (stat(argv[0], &buf) != 0) { + perror("stat"); + } + if ((buf.st_mode & S_ISUID) == 0) { + fprintf(stderr, "%s: not set suid\n", argv[0]); + return 1; + } + const char* runpath = getCmd(argv[0]); if (!runpath) { fprintf(stderr, "%s not runnable cmd\n", argv[0]); |