Forum Moderators: bakedjake

Message Too Old, No Replies

understanding setuid

         

ifti

6:22 am on Feb 24, 2004 (gmt 0)

10+ Year Member



i do not understand how setuid/setgid works

hyperbole

6:17 pm on Feb 24, 2004 (gmt 0)

10+ Year Member



Need a little more information to answer the question properly.

setuid and setgid are used for setting the user-id and the group-id (respectively) of a file. The user-id determines who owns the file and group-id determeins what group of people can access the file.

Without knowing more of what you are asking I don't want to launch into a discussion of *nix file permissions and the details of setting uid/gid.

SeanW

3:23 am on Feb 25, 2004 (gmt 0)

10+ Year Member



Setting the s bit on a file means that it can run as the user or group set on the file rather than the person running.

ie

a file owned by root that is set setuid will run as root even if a normal user runs it.

Be very careful using this. Shell scripts generally don't work setuid, the shell knows how bad they are ;)

Sean

MattyMoose

6:43 pm on Feb 25, 2004 (gmt 0)

10+ Year Member



I used to constantly forget the password to one of my Slackware boxes waaaaaay back when, since I rarely needed to access it, since I had 6 other machines running.

I didn't want my roommate getting 'root' on the box, since we were always trying to break each others' boxes, so I kept that one in particular with a really weird password, and I'd tell him that that box was not to be touched, since it "did some very important stuff", just to get him interested. Even though all it did was seti@home "stuff". ;)

Except every time I needed to access it, I'd forget the stupid password. So, I finally got sick of booting from the CD and resetting my root password, so I wrote a nice little C program that did setuid(), and opened a new shell for me. Everytime I forgot the password, I'd log in as my normal user, and just run that program, and reset the root password.

This was before I found out about ssh keys, and that making my life a little easier with forgotten passwords. (one key, stored as an obscure file that I would use if I forgot the password).

Not terribly smart, but it was fun. :)

Weird story, I know, but I thought I'd share. ;)

-MM

daisho

8:30 pm on Mar 24, 2004 (gmt 0)

10+ Year Member



If you don't understand suid/sgid then I'd stay away. You should look at "sudo" which will be safer for you.

daisho.