2

I have Ubuntu 20.04 virtual server. I have an executable file script.sh in /opt that has SetUID bit set.

meliwex@linode:/opt$ ls -ld /opt
drwxr-xr-x 2 root root 4096 Dec 19 03:45 /opt
meliwex@linode:/opt$ ls -l
total 4
-rwsr-xr-x 1 root root 125 Dec 19 03:45 script.sh
meliwex@linode:/opt$ 

When I run this file with non-root user the effective UID of the process doesn't change, why?

meliwex@linode:/opt$ ./script.sh&
[1] 1200
meliwex@linode:/opt$ ps -elf | grep -i script.sh
0 S meliwex     1200     733  0  80   0 -  1756 do_wai 03:52 pts/0    00:00:00 /bin/bash ./script.sh
0 S meliwex     1205     733  0  80   0 -  1609 pipe_w 03:52 pts/0    00:00:00 grep --color=auto -i script.sh
meliwex@linode:/opt$ ps -eo pid,ruid,euid | grep -i 1200
   1200  1000  1000
meliwex@linode:/opt$ 

Here I guess it should be: 1200 1000 0

Hayk
  • 123

1 Answers1

1

Setting the suid bit of a shell script is ineffective. Shell scripts aren't forked using exec*() like executable programs are. Instead, the shell does a fopen( shell_script, "r" ); and interprets each input line.