Skip to main content

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?!

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$
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:
cp /etc/hosts /etc/hosts.old.$(date +%y%m%d)
which fails with
code:
cp: cannot create regular file `/etc/hosts.old.20110630': permission denied
so i'm inclined believe there's problem setuid part, know works on system - because sudo has no problems running.
code:
~/tmp$ ls -al /usr/bin/sudo  -rwsr-xr-x 2 root root 144508 2011-05-30 06:51 /usr/bin/sudo
please shed light on i'm going wrong?

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

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

After Effect warning: A problem occurred when processing OpenGL commands

Preconditions Failed. - Joomla! Forum - community, help and support