LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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-12-2006, 12:39 AM   #1
Braynid
Member
 
Registered: May 2006
Location: Romania
Distribution: CentOS
Posts: 140

Rep: Reputation: 15
Chmod script problems


Hello!

So i have a script that has in it the command:

Code:
 ping -n -w4 -i 0.02 -c 100 -q
So, normaly the regular users get:

Code:
ping: cannot flood; minimal interval, allowed for user, is 200ms
I have tried:

Code:
chmod og+s script
And that didn't worked, so i tried to set that in midnight commander and i've set:

'Set user ID in execution'
'Set group ID in execution'

user is root.

I user Ubuntu RC 6.06 server.

So what is to do.. i don't get it.

Thanks.
 
Old 07-12-2006, 12:59 AM   #2
jstephens84
Senior Member
 
Registered: Sep 2004
Location: Nashville
Distribution: Manjaro, RHEL, CentOS
Posts: 2,098

Rep: Reputation: 102Reputation: 102
are you trying to make that script executable or are you trying to excecute the script. if you are trying to execute the script then type
Code:
./script-name
 
Old 07-12-2006, 01:01 AM   #3
jstephens84
Senior Member
 
Registered: Sep 2004
Location: Nashville
Distribution: Manjaro, RHEL, CentOS
Posts: 2,098

Rep: Reputation: 102Reputation: 102
try chmod 755 script.

That says owner will have rwx group will have rx and everyone else will have rx. your script should then be executable.
 
Old 07-12-2006, 01:09 AM   #4
Braynid
Member
 
Registered: May 2006
Location: Romania
Distribution: CentOS
Posts: 140

Original Poster
Rep: Reputation: 15
The script IS 755.
Here are the permisions for the script:
Code:
-rwsr-sr-x  1 root   root         45 2006-07-12 08:18 bpierderi
I want other users then root be able to execute the script withouth the error:

Code:
ping: cannot flood; minimal interval, allowed for user, is 200ms
In order to to that i figured i should grant users root ID for executing the script.
How is it donne?
 
Old 07-12-2006, 01:42 AM   #5
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
Consider using sudo. Sometimes for security reasons (not that it makes sense, but..) suid scripts are not acting as suid. Or write one-call-to-"system" C wrapper.
 
Old 07-12-2006, 02:05 AM   #6
Braynid
Member
 
Registered: May 2006
Location: Romania
Distribution: CentOS
Posts: 140

Original Poster
Rep: Reputation: 15
I don't want to give sudo access for all the users, they might meddle in my stuff. Can I use sudo for that script only? Or please can you give me an example on how to use it?
Thanks.

Quote:
Or write one-call-to-"system" C wrapper.
I don't know what that is...
 
Old 07-12-2006, 02:10 AM   #7
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
That's the very idea of sudo!

ALL ALL = NOPASSWD: /usr/script/ping-flood

but read man sudo, man sudoers
 
Old 07-12-2006, 02:26 AM   #8
Braynid
Member
 
Registered: May 2006
Location: Romania
Distribution: CentOS
Posts: 140

Original Poster
Rep: Reputation: 15
Ok, right you are! Only one problem, from what i have read i don't understand something. Should I add that to the /etc/sudoers file or in my script?
 
Old 07-12-2006, 03:26 AM   #9
Braynid
Member
 
Registered: May 2006
Location: Romania
Distribution: CentOS
Posts: 140

Original Poster
Rep: Reputation: 15
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!
 
Old 07-12-2006, 03:35 AM   #10
Braynid
Member
 
Registered: May 2006
Location: Romania
Distribution: CentOS
Posts: 140

Original Poster
Rep: Reputation: 15
Unfortunately i have been mistakeing, with a normal user i get:
Code:
testa@MainThinkTank:~$ bpierderi
Password:
Sorry, user testa is not allowed to execute '/bin/ping -n -w4 -i 0.02 -c 100 -q    
ip.ip.ip.ip' as root on MainThinkTank.rdsnet.ro.
I am using NOPASSWD and doesn't help!

Last edited by Braynid; 07-12-2006 at 03:41 AM.
 
Old 07-12-2006, 03:44 AM   #11
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
I mean you should have 2 scripts: one a user can run under sudo and one which runs it under sudo. I still recommend you to read man sudo, man sudoers to have idea of this.
 
Old 07-12-2006, 03:52 AM   #12
Braynid
Member
 
Registered: May 2006
Location: Romania
Distribution: CentOS
Posts: 140

Original Poster
Rep: Reputation: 15
I have read the man pages, the command
Code:
ALL ALL = NOPASSWD: /usr/script/ping-flood
should let all users run the script ping-flood witouth promping for password.

I havea script in /usr/bin , say it's ping-flood like you said. I have added the above line to my /etc/sudoers and all users should be able to use it, but it's not working...
 
Old 07-12-2006, 04:17 AM   #13
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
Did you put sudo into or did you made just a script and tried to run "sudo /usr/bin/ping-flood" ?
 
Old 07-12-2006, 04:28 AM   #14
Braynid
Member
 
Registered: May 2006
Location: Romania
Distribution: CentOS
Posts: 140

Original Poster
Rep: Reputation: 15
So here it goes.
In /etc/bash.bashrc:
Code:
function pierderi ()
{
bpierderi $1
}
In /usr/bin/bpierderi;
Code:
 sudo ping -n -w4 -i 0.02 -c 100 -q $1
In /etc/sudoers:
Code:
 ALL ALL = NOPASSWD: /usr/bin/bpierderi
I don't get it. I have tried:
Code:
 testa ALL = NOPASSWD: /usr/bin/bpierderi
and still it ask me for password and after i get:
Code:
Sorry, user testa is not allowed to execute '/bin/ping -n -w4 -i 0.02 -c 100 -q yahoo.com'
 as root on MainThinkTank.rdsnet.ro.
 
Old 07-12-2006, 04:33 AM   #15
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
Mistake.

function pierderi() { sudo /usr/bin/bpierderi "$1"; }

and

ping -n -w4 -i 0.02 -c 100 -q $1
 
  


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

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

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