LinuxQuestions.org
Help answer threads with 0 replies.
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 12-14-2003, 10:43 AM   #1
phil1076
Member
 
Registered: Oct 2001
Location: Grand Cayman
Distribution: RH 9.0
Posts: 96

Rep: Reputation: 16
Need clarification re: Running a script as root.


Ok here's the situation. Let's say I have a small bash script that does the following:

mkdir /test/hello
chown joe /test/hello

the "test" directory is owned by root/root and is cdmod'd 755.

and as root I chmod this script with 4755 (to run as root).

I then log in with a non-root account and try to execute it. When I runs I gets access denied. It's my understanding that if a script is marked as run-as-root, every command run from within it will run with root permissions. Why does it not work?
 
Old 12-14-2003, 02:53 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
"It's my understanding that if a script is marked as run-as-root, every command run from within it will run with root permissions."

I don't think so. Try running the script as su and see what happens. Also try running the mkdir and chown commands as user, then as su. I think that they will work as su but not as user.

___________________________________
Be prepared. Create a LifeBoat CD.
http://users.rcn.com/srstites/LifeBo...home.page.html

Steve Stites
 
Old 12-17-2003, 05:33 PM   #3
radev01
LQ Newbie
 
Registered: Dec 2003
Location: South Australia
Distribution: RH 7.3 & AdvServ 2.1
Posts: 2

Rep: Reputation: 0
Sorry I dont understand just what you mean Steve.

I have posted a very similar question in the Red Hat forum
"Can't extract expiry days from shadow"
but no replies as yet

If the user su'd to root then most definitely the commands & script runs.
Problem is the user does not have access to the root password.
If user su'd to themselved then no permissions.

My grasp of run-as-root was the same as Phils.


How does passwd
-r-s--x--x 1 root root 15104 Mar 14 2002 /usr/bin/passwd
when run by a lowly user get access to protected root permission files?

Thanks for replying to Phil anyway

George B
 
Old 12-17-2003, 09:43 PM   #4
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
"Sorry I dont understand just what you mean Steve."

Your experiment was what I was looking for. I meant for Phil to check whether the problem was in the script command itself or in the commands issued within the script.

___________________________________
Be prepared. Create a LifeBoat CD.
http://users.rcn.com/srstites/LifeBo...home.page.html

Steve Stites
 
Old 12-18-2003, 01:12 PM   #5
phil1076
Member
 
Registered: Oct 2001
Location: Grand Cayman
Distribution: RH 9.0
Posts: 96

Original Poster
Rep: Reputation: 16
d

I'll simplifiy:

Let's say I have a directory named "userdrives"..It's owned by root and group-owned by "NTusers". root and NTusers have full rights and everyone else has none. So:

rwxrwx--- root NTusers 4096 userdrives

Now, I want to write a script that will create a subdirectory under userdrives and I want to run this script as a non-root user. For this reason, the run-as-root flag must be set. For example I make a script (makeudrive), as root:

mkdir /userdrives/joe

chmod 755 makeudrive

I then log out and log in as a regular user.

./makeudrive

access denied

This is understandable. I log back in as root and chmod the script with set uid:

chmod 4755 makeudrive

Now, when I log in as a regular user and execute it, I still get access denied. In my opinion everything that the script executes should run as root.

The end goal is to give multiple administrators the rights to create home directories for our Win2k users, without the administrators having root access to the linux box.
 
Old 12-18-2003, 01:55 PM   #6
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
"everything that the script executes should run as root."

It doesn't work that way. It is a basic axiom of Unix security that a process (the script in this case) cannot change to a different user without a trip through security. If a non root process wants to run as root it has to go through security first and ask for the root password.

___________________________________
Be prepared. Create a LifeBoat CD.
http://users.rcn.com/srstites/LifeBo...home.page.html

Steve Stites
 
  


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
Running a script as root with sudo without entering the user password kloss Linux - General 8 10-10-2005 11:39 AM
creating shell script that executes as root regardless of who runs the script? m3kgt Linux - General 13 06-04-2004 10:23 PM
running root-tail from shell script not working Nuk Linux - Newbie 1 04-09-2004 08:56 AM
writing a script running firestarter automatically with kppp without root priviliges melquiades Linux - Newbie 3 08-11-2003 06:50 AM
Running a script as root davee Linux - Newbie 3 02-07-2003 05:27 AM

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

All times are GMT -5. The time now is 08:56 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