Ubuntu: SUID not working?



Question:

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?


Solution:1

From man 2 execve, section NOTES:

Linux ignores the set-user-ID and set-group-ID bits on scripts.  

Also see:


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »