This question already has an answer here:
- Allow setuid on shell scripts 8 answers
I want to ensure that my program can only be run by user
xyz using root privilege. To do this, I set the setuid bit with:
chmod u+s program1.sh ls -l program1.sh rwsr-x--- 1 root house 1299 May 15 23:54 program1.sh
Also, I added user
xyz to the
house group so that only
xyz and root can run program1.sh.
In program1.sh there is
so that it can show me the effective ID.
program1.sh as root, it shows
root. But running with the
xyz account, it shows
xyz. It seems that it didn't run with root privilege. I don't know what's wrong here.