Suid Not Working?

Suid Not Working?

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?

1 Answer

From man 2 execve, section NOTES:

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

Also see:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sophia Al-Mansoor
Author

Sophia Al-Mansoor

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.