[SC.LUG] set user id

Garry Stanway sc at mailman.lug.org.uk
Sun Jul 13 17:41:00 2003


Hi,

I am a relatively new Linux user in Helsby and I have just subscribed to
the list. I wonder if someone can help me with what should be quite a
trivial task.

I want to run a shell script with root permissions without first doing

su

password

Simple I hear you all cry. Just create the script as root and then use 

chmod 4755 script

and it should work.

I have done this many times and can't get the result I want.

To try and see what is going on I created a test setup thus. In my home
directory I have created a folder called testdir and set its permissions
to

drwxr-xr-x 

so you need to be root to put anything in there.

Next, as root I created the following script called testsu containing
the following text

mkdir testdir/test

I set its permissions to

-rwsr-xr-x

Then, I exit from root back to my normal user. Great I thought, if I do 

./testsu

the script should pop into root user mode, create the directory in
testdir and then quit. Yes? No!

What am I doing wrong?

I am running RedHat 9 with a 2.4.18 kernel on a home built celeron based
machine (not that is should make any difference).

I am sure I am making a really dumb mistake somewhere and will kick
myself when I find out.

Many tbanks in advance

Garry Stanway