Printing the value of getuid() and geteuid() from an executable with SUID-bit (chmod +s) turned-on, seems to result with the original caller ID instead of the owner id if the executable is located within the /tmp directory.
When compiling the exact same code to home directory (and executing chmod +s), this seems to work as expected.
I've searched a lot and could not find any reference to such behavior.
Does anybody know why is this happening?
this source is simple as that:
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
int main(){
printf("%d\n%d\n", getuid(), geteuid());
return 0;
}
nosuid
option. Check the output ofmount
or look in /etc/fstab to confirm.nosuid
option on/tmp
is a default on many distributions, you might want to make an answer out of this comment.