0

I have the following script:

$ ls -al setprog.sh 
-rwsrwxr-x 1 root root 52 Αυγ   2 10:23 setprog.sh


$ cat setprog.sh 
#!/bin/bash

while [ True ]
do
    echo $(whoami)
done

When running it

$ ./setprog.sh 
pkaramol
pkaramol
pkaramol

Why the process owner indicated by ps (real user) and and the user by whom the program is executed (effective user?) match? Shouldn't the one of them be root given that the script is owned by him?

$ ps aux | grep -i setpr
pkaramol 10294 18.0  0.0  12888  3268 pts/0    S+   10:45   0:00 /bin/bash ./setprog.sh
pkaramol 16746  0.0  0.0  14432  1104 pts/1    S+   10:45   0:00 grep --color=auto -i setpr
pkaramol
  • 2,587
  • 4
  • 36
  • 71
  • 1
    Why `echo $(whoami)` instead of just `whoami`? Why test on the _string_ `True` and not `while true`? – Kusalananda Aug 02 '18 at 07:53
  • Because if I echo `whoami` instead of `$(whoami)` it will stdout the string `whoami` instead of the result of the command `whoami`; `True` vs `true` does not make much of a difference; – pkaramol Aug 02 '18 at 07:55
  • What I __did__ notice through is that whenever I edit the file, the `setuid` bit is gone; – pkaramol Aug 02 '18 at 07:56

0 Answers0