LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-21-2006, 06:32 PM   #1
curtisf14
LQ Newbie
 
Registered: Jul 2006
Location: Cambridge, MA
Distribution: Ubuntu 6.06 LTS
Posts: 3

Rep: Reputation: 0
chmod question


I have a quick question about chmod. I want the user "nobody" to be able to execute a script I wrote with the user ID set to mine, so I used chmod to change the file permissions:
Code:
chmod u+s myfile
However, it appears that if I call commands from within the script, my user ID no longer is set for that command (I assume it defaults back to "nobody", but I'm not sure). Is there any way to get my user ID to pass down to other commands in the script? Or is there another way to do this altogether?
 
Old 07-21-2006, 06:41 PM   #2
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
If you do that, you are allowing the owner of the file to execute a program as 'root'. If you want the user 'nobody' to execute the program as the owner, then you need the setgid bit set and put 'nobody' in the group.

Not only that, setuids and setgids do not work for shell scripts. So, if yours is, it won't work. It needs to be a real executable, a compiled program.

-twantrd
 
Old 07-21-2006, 07:05 PM   #3
curtisf14
LQ Newbie
 
Registered: Jul 2006
Location: Cambridge, MA
Distribution: Ubuntu 6.06 LTS
Posts: 3

Original Poster
Rep: Reputation: 0
Yes, the file is a bash script. I thought that if the setuid bit is set, then any user executing the script will have the same permissions as the owner of the file. Is this not true? Maybe I would need to change the permissions on "bash", but that's probably not a good idea. Do I need to write an equivalent script in C and compile it?
 
Old 07-21-2006, 09:50 PM   #4
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
Quote:
I thought that if the setuid bit is set, then any user executing the script will have the same permissions as the owner of the file. Is this not true?
My apologies. Yes, if the setuid bit is set, the program will run as the OWNER.

Quote:
Do I need to write an equivalent script in C and compile it?
Yes.

-twantrd
 
Old 07-23-2006, 03:05 AM   #5
curtisf14
LQ Newbie
 
Registered: Jul 2006
Location: Cambridge, MA
Distribution: Ubuntu 6.06 LTS
Posts: 3

Original Poster
Rep: Reputation: 0
Awesome, thanks. Off to write that C script... :-)
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
chmod question Napalm Llama Linux - General 2 06-17-2005 09:17 AM
chmod question tongar Linux - Newbie 2 01-30-2005 02:43 PM
chmod -R question spooge Linux - General 2 01-13-2005 02:58 PM
chmod Question Rawr101 Linux - General 1 09-19-2004 03:17 AM
chmod question odious1 Linux - General 1 11-28-2003 11:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:33 PM.

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