I have a simple C program that does this
int
main(void)
{
printf("getuid: %d\n", getuid());
printf("geteuid: %d\n", geteuid();
return 0;
}
The owner of the executable of my program is the user "A", this executable have special permissions on user and group fields (sticky bits), and can be executed by anyone.
Here is the output with my user "A".
getuid: 1000 geteuid: 1000
Which corresponds to the id's of A.
If I run it with another user "B" I have this as output:
getuid: 1001 geteuid: 1000
So far so good since a file with SUID always runs as the user owning the file, regardless of which user issues the command.
However if I run the file with the ltrace program, I get:
getuid: 1001 geteuid: 1001
Can someone explain this behavior to me, is this normal ?