sgid suid help --need clarification


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers sgid suid help --need clarification
# 1  
Old 03-05-2007
sgid suid help --need clarification

I'm writing this command/script to allow students to vi a private file of mine
in a private directory of mine. chmod 700 dir chmod 660 file

however since i own the directory and file; the script has to be ran by me so to speak, im just not sure how to set about doing this.

the script is simple enough

chmod 777 directory


but the script would only execute these statements for me. How do I get it to work for someone else? short of changing the owner to root or something like that

Last edited by StrengthThaDon; 03-05-2007 at 07:08 PM..
# 2  
Old 03-05-2007
Quote:
Originally Posted by StrengthThaDon
I'm writing this command/script to allow students to vi a private file of mine
in a private directory of mine. chmod 700 dir chmod 660 file

however since i own the directory and file; the script has to be ran by me so to speak, im just not sure how to set about doing this.

the script is simple enough

chmod 777 directory


but the script would only execute these statements for me. How do I get it to work for someone else? short of changing the owner to root or something like that
You would need to write a binary executable to implement something like this.

To run something with your uid (as you) the suid bit is required.

The suid is only valid for binary executables and not for scripts.
# 3  
Old 03-05-2007
Quote:
Originally Posted by sb008
You would need to write a binary executable to implement something like this.

To run something with your uid (as you) the suid bit is required.

The suid is only valid for binary executables and not for scripts.
this is a description of the assignment, your responses have led me to believe he's given us something impossible to do. I'll ask him to clarify this in an email but I wanted to be sure I know exactly what I'm asking.

assignment:
write a command which will allow any students to vi (including modify) a private file (owned by you, perms 660) in a private directory (owned by you, permissions 700)

Now you're saying what he's asking is impossible to do? Don't mean to bug anyone
# 4  
Old 03-05-2007
Quote:
Originally Posted by sb008
You would need to write a binary executable to implement something like this.

To run something with your uid (as you) the suid bit is required.

The suid is only valid for binary executables and not for scripts.
That depends completely on the OS. For example this: will allow me to modify the file as another user using test.sh as a wrapper on Solaris.

Code:
 6843    1 drwxr-xr-x   3 reborg   other         512 Mar  6 00:07 /home/reborg/
 6844    1 drwx------   2 reborg   other         512 Mar  6 00:04 /home/reborg/test
 6846    1 -rw-rw----   1 reborg   other          13 Mar  6 00:07 /home/reborg/test/test
 6847    1 -rwsr-sr-x   1 reborg   other          38 Mar  6 00:05 /home/reborg/test.sh

# 5  
Old 03-05-2007
Quote:
Originally Posted by reborg
That depends completely on the OS. For example this: will allow me to modify the file as another user using test.sh as a wrapper on Solaris.

Code:
 6843    1 drwxr-xr-x   3 reborg   other         512 Mar  6 00:07 /home/reborg/
 6844    1 drwx------   2 reborg   other         512 Mar  6 00:04 /home/reborg/test
 6846    1 -rw-rw----   1 reborg   other          13 Mar  6 00:07 /home/reborg/test/test
 6847    1 -rwsr-sr-x   1 reborg   other          38 Mar  6 00:05 /home/reborg/test.sh

Not on my Solaris unless test.sh is a binary executable.
# 6  
Old 03-06-2007
thanks guys, it turns out it wasn't as difficult as I thought it would be
I just needed to set the s-bit on my script
I wasn't using setid in it
it turned out fine
now I can go watch heroes again Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Difference between inbuilt suid programs and user defined root suid programs under bash shell?

Hey guys, Suppose i run passwd via bash shell. It is a suid program, which temporarily runs as root(owner) and modifies the user entries. However, when i write a C file and give 4755 permission and root ownership to the 'a.out' file , it doesn't run as root in bash shell. I verified this by... (2 Replies)
Discussion started by: syncmaster
2 Replies

2. Cybersecurity

the SUID of lpq

Hello My system is Debian-503-amd64. After I installed the "lpr" package, I found that some files with SUID bit come from this package. As: ls -l /usr/bin/lp* .... -rwsr-sr-x 1 root lp 31800 2008-05-20 /usr/bin/lpq -rwsr-sr-x 1 root lp 28504 2008-05-20 /usr/bin/lpr -rwsr-sr-x 1... (1 Reply)
Discussion started by: ZR_Lang
1 Replies

3. UNIX for Advanced & Expert Users

Weird SUID issue

Hi, I am setting up SUID permissions on a binary. It gets set for most of the users, however, 1 in 10 users is unable to set these. For those who works: > chmod 6555 Test > ls -l Test -r-sr-sr-x 1 A B 5524 Nov 15 14:53 Test For those where it doesn't work: > chmod 6555 Test... (14 Replies)
Discussion started by: vibhor_agarwali
14 Replies

4. UNIX for Dummies Questions & Answers

suid sgid problem in script

hi I have problem with understanding setuid and setgid in system I have following users: $id -a marek uid=1001(marek) gid=1001(marek) groups=1001(marek),1002(uzivatelia) $id -a cepi uid=1000(cepi) gid=1000(cepi)... (7 Replies)
Discussion started by: wakatana
7 Replies

5. AIX

suid not working on AIX ?

Hello, I'm running AIX 6.1 box. I tried to use suid on binary file but it doesn't work. (I set suid on /usr/bin/sleep and tried to run it as user1(sleep owner is bin) - and program still runs as user1. It shoud run as bin isn't it ? - This test run as expected on Linux box) Filesystem is... (3 Replies)
Discussion started by: vilius
3 Replies

6. UNIX for Advanced & Expert Users

SUID not working

Hi Senario: I have previleges to edit a file F but User B does not have sufficient privs to edit it. In order for B to edit it I tried an indirect way. I created a script to edit F and SUID this script so that B can execute it with the privs of me. But this is not working . can some one help... (3 Replies)
Discussion started by: Pankaj Mishra
3 Replies

7. Solaris

SUID and SGID searching...

Hi all, Thanks for all replays and for reading in advance (as per usual) Anyhow I have been asked to come up with a list of programs that have SUID root permissions and also for any programs with SGID permissions. Has anyone got any idea with out going through each program indiviually how I... (2 Replies)
Discussion started by: B14speedfreak
2 Replies

8. UNIX for Dummies Questions & Answers

what is suid ?

what is SUID ? can someone explain or point me to a link ? thanks simon2000 (2 Replies)
Discussion started by: simon2000
2 Replies

9. Cybersecurity

suid files???

Hi all, Where can i find list of suid and gid files common for the system, let's say RedHat 7.1? Thank you all Regards :D (1 Reply)
Discussion started by: solvman
1 Replies

10. Programming

SUID bit???

Hi all I'm getting file info through stat( char *filename, struct stat *buf) Taking all the file attributes to buf->st_mode, How can i check the suid bit in there, if suid bit mask is 0004000?? Thank you all (1 Reply)
Discussion started by: solvman
1 Replies
Login or Register to Ask a Question