I have a very simple program:
#define _GNU_SOURCE
#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
void error(char *msg) {
printf(msg);
exit(-1);
}
int main(int argc, char **argv) {
uid_t ruid, euid, suid;
if (getresuid(&ruid, &euid, &suid) < 0)
error("Error getting process uids");
printf("%d %d %d\n", ruid, euid, suid);
}
Compiled as follows:
gcc -o print print.c
Its owned by root, and has the setuid bit set:
-rwsrwxr-x 1 root root 8648 Oct 8 20:10 ./print*
However when I run it, I get the following permissions:
1000 1000 1000
So both the real, effective, and saved set-uid permissions are all me (1000) and not root. Has anyone ran into this? any advice?