You are not logged in.
Pages: 1
Hi,
I'm trying to write a small programm using setuid, but I don't get it to work.
Here I'm trying out the example from wikipedia http://en.wikipedia.org/wiki/Setuid#Demonstration
I set the setuid bit, but the programm will still be executed as the same user.
What am I doing wrong?
markus@markus-laptop /tmp % cat > printid.c
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
int main(void) {
printf(
" UID GID \n"
"Real %d Real %d \n"
"Effective %d Effective %d \n",
getuid (), getgid (),
geteuid(), getegid()
);
return 0; /* always good to return something */
}
markus@markus-laptop /tmp % cc printid.c -o printid
markus@markus-laptop /tmp % ./printid
UID GID
Real 1000 Real 100
Effective 1000 Effective 100
markus@markus-laptop /tmp % sudo chown root printid
markus@markus-laptop /tmp % sudo chmod ug+s printid
markus@markus-laptop /tmp % sudo chmod o-rx printid
markus@markus-laptop /tmp % ll printid
-rwsr-s--- 1 root users 5436 19. Mai 12:51 printid*
markus@markus-laptop /tmp % ./printid
UID GID
Real 1000 Real 100
Effective 1000 Effective 100
markus@markus-laptop /tmp %
Offline
Hi,
you’re doing this in /tmp. Check the output of “mount”, maybe /tmp is mounted with the option “nosuid”.
(I don’t have /tmp mounted as tmpfs and your code works for me.)
Offline
you’re doing this in /tmp. Check the output of “mount”, maybe /tmp is mounted with the option “nosuid”.
Thanks, I wouldn't have thought of that.
It was mounted with 'nosuid'.
Offline
Pages: 1