I suppose an executable file with SetUID bit set should be running as its owner but I cannot really reproduce it. I tried the following.
$ cat prepare.sh cp /bin/bash . chown root.root bash chmod 4770 bash # Verified $ sudo sh prepare.sh $ ./bash $ id -u 1000 $ exit $
$ cat test.c
#include<stdio.h>
#include<unistd.h>
int main(){
printf("%d,%d\n", getuid(), geteuid());
return 0;
}
$ gcc -o test test.c
$ chmod 4770 test # Verified
$ sudo chown root.root test
$ ./test
1000,1000
$ # Why???
However
$ su # ./bash # id -u 0 # ./test 0,0 # exit # exit $
Note: The mount point has no nosuid nor noexec set.
Can anyone explain why it's failing to work on Ubuntu 16.04 LTS?
sudo? There's a bug or a typo in it, though, thechmodis missing a file name.