LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-26-2009, 10:33 AM   #1
RaptorX
Member
 
Registered: Jun 2009
Location: Emden, Germany
Distribution: Slackware 12.2, Slax 6.1
Posts: 254

Rep: Reputation: 37
[help] setuid not working?


Hi...

I am trying to suid a small script which mounts a series of images.
I know that i can use sudo for that but the problem is that I dont want my brother to have access to the mount command at all.

I read about suid, and I thought i did it correctly:
Code:
[/home/temp]ls -al
total 45144880
-rwsr-sr-x 1 root    root         101 2009-08-26 15:48 mountemall.sh*
-rw-r--r-- 1 raptorx users 4634970112 2005-02-20 05:46 tumc.d01.kod.img
-rw-r--r-- 1 raptorx users 4673501184 2005-02-21 23:13 tumc.d02.kod.img
-rw-r--r-- 1 raptorx users 4642347008 2005-02-21 17:32 tumc.d03.kod.img
the command I issued was "chmod 6755 mountemall.sh".

When i try to run the script as a normal user, it tells me that only root can run mount (of course) but I thought that it would run as root and simply not make an error for mount.

Am I understanding suid correctly? and if so, did I do it correctly?

Last edited by RaptorX; 08-26-2009 at 10:56 AM.
 
Old 08-26-2009, 11:21 AM   #2
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
As I understand it, suid on shell scripts has been pretty roundly disabled. Read here for some commentary on that topic: http://www.tuxation.com/setuid-on-shell-scripts.html
 
Old 08-26-2009, 11:27 AM   #3
RaptorX
Member
 
Registered: Jun 2009
Location: Emden, Germany
Distribution: Slackware 12.2, Slax 6.1
Posts: 254

Original Poster
Rep: Reputation: 37
thanks for the pointer... actually I did read that suid can open security holes, but in my case i did not want to allow mount in sudo...

can I look for a work around?
can i add this script to sudo and expect it to work? this is basically the script:

Code:
let num=1
for img in $(ls -X1 | grep img); do
mount -o loop $img /tmp/cdrom$num
let num=$num+1
done
what i do not want is to allow mount in general in the sudo file. But if I can allow that script i guess i can live with that.
 
Old 08-26-2009, 11:46 AM   #4
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Given the circumstances, you could add your user as a sudoer with rights to run /bin/mount. (Be sure to use the fully-qualified path in both the sudoers file and in your script.)

See the manpages for sudoers(5) for examples. Also, use visudo(8) to edit it.
 
Old 08-26-2009, 11:52 AM   #5
RaptorX
Member
 
Registered: Jun 2009
Location: Emden, Germany
Distribution: Slackware 12.2, Slax 6.1
Posts: 254

Original Poster
Rep: Reputation: 37
as i said I did NOT want to allow mount in sudo, because my brother would mount other things that i dont want him to... Thats why i was looking for suid... I will try to allow my script in sudo.


--
EDIT

what i did is that i allowed my script in the sudo file instead of the mount command so he can mount only the images that i allow him to mount.

Last edited by RaptorX; 08-26-2009 at 12:08 PM.
 
Old 08-26-2009, 11:58 AM   #6
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Derr, I misread. Yes, you can allow the FQ path to your script in sudoers. Alternatively: I haven't tested this, but you could likely put something together using e.g. python or php. Both have access to system commands on unix-like OSes. Then AFAIK that could be made suid.

Last edited by anomie; 08-26-2009 at 11:59 AM.
 
Old 08-27-2009, 01:07 AM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
@RaptorX; you only give your user sudo access to mount etc. You don't give it to other users, inc your brother. That's the whole point.
ie you define both the user and the cmd that's allowed.
Don't be confused by idiots who give

sudo su -

rights away.
 
Old 08-27-2009, 09:15 AM   #8
RaptorX
Member
 
Registered: Jun 2009
Location: Emden, Germany
Distribution: Slackware 12.2, Slax 6.1
Posts: 254

Original Poster
Rep: Reputation: 37
Quote:
Originally Posted by anomie View Post
Derr, I misread. Yes, you can allow the FQ path to your script in sudoers. Alternatively: I haven't tested this, but you could likely put something together using e.g. python or php. Both have access to system commands on unix-like OSes. Then AFAIK that could be made suid.
Actually thats pretty neat, I will do that... in the mean time i have it setup with the script.

Quote:
Originally Posted by chrism01 View Post
@RaptorX; you only give your user sudo access to mount etc. You don't give it to other users, inc your brother. That's the whole point.
ie you define both the user and the cmd that's allowed.
Don't be confused by idiots who give

sudo su -

rights away.
yes I totally agree with you there... I only allow specific commands in sudoers, nothing more... but the thing was that I wanted to allow brother123 to mount some specific images and nothing else, I thought of allowing each mount command by separate but the time I would have to spend on that was not worth it...

I already had a little script with the list of commands he could use to mount the images so I just added THAT script to sudoers. Now he can mount only what the script says he can mount and as the file is owned by root he cannot modify it at all. I win.

Last edited by RaptorX; 08-27-2009 at 09:22 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
setuid() Loser Linux - Software 1 11-05-2008 03:37 AM
sudo stopped working: "must be setuid root" quincy_the_penquin Linux - Software 4 04-30-2007 06:37 AM
setuid not working? ahz10 Linux - Security 7 02-09-2007 03:32 PM
setuid int0x80 Linux - Security 3 12-02-2005 01:33 PM
Setuid SirTurbo Linux - General 1 03-26-2003 06:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration