I know that enabling setuid on scripts has security issues and so is inactive by default, but expect that it works for executables. I created and executable which shows uid as an output following instructions described in this post: Allow setuid on shell scripts
But it returns same uid (1000) both before and after runningsudo chmod +s ./setuid-test
. I think this means that setuid does not have any effects on my executable, why and how to solve?
The source code:
#include <stdio.h>
#include <unistd.h>
int main(int argc, char** argv) {
printf("%d", geteuid());
return 0;
}
Built and run with
$ gcc -o setuid-test setuid-test.c
$ ./setuid-test
1000
$ sudo chown nobody ./setuid-test; sudo chmod +s ./setuid-test
$ ./setuid-test
1000
When running ls -la
, this is what I get:
me@me:~$ ls -la setuid-test
-rwsrwsr-x 1 nobody me 8572 Aug 19 16:39 setuid-test
me@me:~$ ls -la setuid-test
----returns-----rwsrwsr-x 1 nobody me 8572 Aug 19 16:39 setuid-test
– PHP Learner Aug 19 '14 at 15:09df .
in the directory to find the mount point, thenmount | grep nameofmountpoint
. Is there anosuid
flag listed there? – Mark Plotnick Aug 20 '14 at 10:21mount | grep /home/me
returns/home/me/.Private on /home/me type ecryptfs (ecryptfs_check_dev_ruid,ecryptfs_cipher=xxx,ecryptfs_key_bytes=16,ecryptfs_unlink_sigs,ecryptfs_sig=0123456789abcdef,ecryptfs_fnek_sig=fedcba9876543210)
– PHP Learner Aug 20 '14 at 17:41