On Ubuntu 16.04.1:
test.sh
script:
#!/bin/bash
IAM=$(whoami)
ID=$(id -u $IAM)
echo "${IAM}"
echo "${ID}"
Andromeda $ ls -al | grep test.sh
-rwsrwxrwx 1 pkaramol pkaramol 71 Δεκ 8 07:52 test.sh
As pkaramol
(uid
=1000)
Andromeda $ ./test.sh
pkaramol
1000
As testuser
(uid
=1001)
Andromeda $ su testuser
Password:
testuser@Andromeda:/home/pkaramol/Desktop$ ./test.sh
testuser
1001
Given that the suid
has been set, why, in the second run, do we not see pkaramol
and 1000
in the output? Isn't the script supposed to be executed with the file owner's id?
From
man 2 execve
, section NOTES:Also see: