Thread: Script setuid question
ok, i'm sort of new linux, , trying hand @ few scripts. i've read info >here< checking root permissions, , info >here< setuid bit. understanding following should work... doesn't! please generous enough suggest why?!
my understanding $euid should effective user id of script, , u+s should set setuid bit, should make script run root no matter initiates it. have tried making script things require root privileges eg:code:~/tmp$ cat test #!/bin/bash echo $euid if [[ $euid -ne 0 ]]; echo "not root!" 1>&2; exit 1; fi exit 0 ~/tmp$ sudo chown root:root test ~/tmp$ sudo chmod 755 test ~/tmp$ sudo chmod u+s test ~/tmp$ ls -al test -rwsr-xr-x 1 root root 91 2011-06-30 12:26 test ~/tmp$ ./test 1000 not root! ~/tmp$
which fails withcode:cp /etc/hosts /etc/hosts.old.$(date +%y%m%d)
so i'm inclined believe there's problem setuid part, know works on system - because sudo has no problems running.code:cp: cannot create regular file `/etc/hosts.old.20110630': permission denied
please shed light on i'm going wrong?code:~/tmp$ ls -al /usr/bin/sudo -rwsr-xr-x 2 root root 144508 2011-05-30 06:51 /usr/bin/sudo
take here, reply:
https://answers.launchpad.net/ubuntu/+question/9920
may need compile script, suspect os ignoring setuid of shell script security reasons.
Forum The Ubuntu Forum Community Ubuntu Official Flavours Support General Help [SOLVED] Script setuid question
Ubuntu
Comments
Post a Comment