LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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-12-2006, 05:43 AM   #16
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled

Quote:
Originally Posted by Braynid
Ok, it's done. I added the given line to /etc/sudoers and added 'sudo' to my script and its ok.

Thanks a log guys!
If you wrote "sudo" in the beginning of the command inside the script file, you're trying to run ping with sudo. Instead run

Code:
sudo scriptname
where scriptname is the script filename which includes the ping command (without sudo). Your sudoers file lets you run the script you wrote using sudo (i.e. with root privileges), and that script then runs ping. If you put sudo inside the script, you're running the script file as a normal user, which works of course if you have read and execute permissions, but then in the script you're actually trying to run ping using sudo, and There You Go - sudoers file only gives you sudo access to the script, not to ping.

Short version: either add ping to the sudoers file too (like the script), which I don't necessarily recommend, or remove "sudo" from inside your script and simply ask users to run the script like "sudo scriptname". Or:

Solution II: write another script, that has inside:

Code:
sudo scriptname
where scriptname is the name of the script that's running ping (got that? sorry if that sounds difficult). Then add scriptname to the sudoers file (you did that already, didn't you?). Now what you're doing is when you run the above script, it will call scriptname (which runs ping) through sudo, and because sudoers permits that, scriptname gets run with root privileges, and should be able to run ping too. Got it?

I haven't tested the above method myself, but there is one thing I'm concerned about. If you grant sudo access to a script file that users could edit, and then sudo would run the commands inside the script as root too, you might actually give the users a chance to obtain root privileges..that sounds a bit scary so I hope I'm wrong and everything I've written here is crap
 
Old 07-12-2006, 05:50 AM   #17
raskin
Senior Member
 
Registered: Sep 2005
Location: Russia
Distribution: NixOS (http://nixos.org)
Posts: 1,899

Rep: Reputation: 68
I guess fears don't have basis: file has rwxr-xr-x ug+s root:root permissions.
 
Old 07-12-2006, 06:15 AM   #18
Braynid
Member
 
Registered: May 2006
Location: Romania
Distribution: CentOS
Posts: 140

Original Poster
Rep: Reputation: 15
Right you are guys, i've missed the fact i used sudo on the script not on 'ping'

I have created a new script with
Code:
{ sudo /usr/bin/bpierderi "$1"; }
It's ok now, and as you have said it's not dangerous, 755 does the job.

I'm really really thankful for all the kind support.
Take care guys!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Help with a recursive chmod script in bash lowpro2k3 Programming 11 07-25-2005 08:03 PM
chmod problems cerealdaemon Linux - General 2 07-22-2005 06:56 AM
chmod problems Harriskaver Linux - Newbie 8 06-04-2005 02:55 PM
CHMOD problems fritz001 Slackware 3 11-05-2004 06:15 AM
chmod problems teacup Linux - General 9 04-22-2003 12:35 AM


All times are GMT -5. The time now is 02:25 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration