Re: setuid from shellscript isn't permanent

2008-07-19 Thread Chet Ramey

Mr Aras wrote:
Hi, 


I've got a shell script for installing a binary. In this script I set the
binary to mode 4755. When I 'ls' the binary from within the shell script I
see that it has the setuid bit set. When I exit the shell script, the binary
is no longer setuid.

I can setuid the binary from outside the shell script.

How can I setuid from within a shell script and have it stay that way?

e.g.

$ ./setuid_test_script.sh
mode of `/nfsroot/bin/busybox' changed to 4755 (rwsr-xr-x)
-rwsr-xr-x 1 root root 515956 2008-07-18 11:46 /nfsroot/bin/busybox

$ ls /nfsroot/bin/busybox
-rwxr-xr-x 1 root root 515956 2008-07-18 11:45 /nfsroot/bin/busybox

$ sudo chmod 4755 /nfsroot/bin/busybox

$ ls -al /nfsroot/bin/busybox
-rwsr-xr-x 1 root root 515956 2008-07-18 11:46 /nfsroot/bin/busybox


Impossible to say without more information.  There's nothing in bash
itself that would cause it to remove the setuid bit from arbitrary
files created during a script's execution.

Chet

--
``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRU[EMAIL PROTECTED]http://cnswww.cns.cwru.edu/~chet/




Re: setuid from shellscript isn't permanent

2008-07-19 Thread Bob Proulx
Mr Aras wrote:
> $ ./setuid_test_script.sh
> mode of `/nfsroot/bin/busybox' changed to 4755 (rwsr-xr-x)
> -rwsr-xr-x 1 root root 515956 2008-07-18 11:46 /nfsroot/bin/busybox
> 
> $ ls /nfsroot/bin/busybox
> -rwxr-xr-x 1 root root 515956 2008-07-18 11:45 /nfsroot/bin/busybox

With only this information I would have to guess that even though you
have a command that it doing the chmod one way that there must be
another command that is changing it back.

Try running with 'bash -x ./setuid_test_script.sh' in order to trace
your script commands.  I expect to see that there is another one that
you are not expecting that is running.

Bob