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 11-23-2005, 09:00 PM   #1
hueofwind
Member
 
Registered: Nov 2005
Location: Australia
Posts: 49

Rep: Reputation: 15
why setuid didn't work for my script?


I cannot understand that why setuid doesn't work!

I wrote a script updatedhcpd.sh to restart dhcpd service in which:
/etc/init.d/dhcpd restart
and I set this script setuid attribute like this:
-rwsr-xr-x 1 root root 38 Nov 23 11:44 updatedhcpd.sh

When I run this script as other user, it still fails with the following information:
Shutting down dhcpd: ./dhcpd: line 196: kill: (927) - Operation not permitted
./dhcpd: line 201: kill: (927) - Operation not permitted
rm: cannot remove `/var/run/dhcpd.pid': Permission denied

But it succeeds if I run this script as root. I think when I run this script as other
users, it will be given the root role automatically.

Who can tell me WHY setuid doesn't work here!?
I tried to give setuid to bash also:
chmod +s /bin/bash
but no use!

Thanks!

Henry
 
Old 11-23-2005, 09:16 PM   #2
twsnnva
Member
 
Registered: Oct 2003
Location: Newport News, Va
Distribution: Debian
Posts: 246

Rep: Reputation: 30
Linux ignores the suid bit on scripts. Use sudo.
 
Old 11-23-2005, 09:57 PM   #3
hueofwind
Member
 
Registered: Nov 2005
Location: Australia
Posts: 49

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by twsnnva
Linux ignores the suid bit on scripts. Use sudo.
Thanks! But sudo will prompt to ask for password. I don't like it because I want to
call it in a script. How to use sudo without password?
 
Old 11-23-2005, 11:07 PM   #4
hueofwind
Member
 
Registered: Nov 2005
Location: Australia
Posts: 49

Original Poster
Rep: Reputation: 15
I solved this problem. By using the following command in the /etc/sudoers
user HOST_ALIAS=NOPASSWD:CMD_ALIAS

we can let any other user run the specified CMD_ALIAS without password.

Thanks to anyone helped me!
 
  


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 int0x80 Linux - Security 3 12-02-2005 01:33 PM
I can setuid binaries, but it doesn't work! Help. boing Linux - General 4 03-26-2005 12:18 PM
Bash script to email setuid root files deoren LinuxQuestions.org Member Success Stories 1 01-30-2005 09:56 AM
setuid Help devinWhalen Linux - General 2 12-03-2003 09:57 AM
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 05:48 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