aboutsummaryrefslogtreecommitdiff
path: root/suidcmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'suidcmd.c')
-rw-r--r--suidcmd.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/suidcmd.c b/suidcmd.c
index a3bbe3a..7c2487d 100644
--- a/suidcmd.c
+++ b/suidcmd.c
@@ -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]);