LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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, 01: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, 01: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, 02: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, 02: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, 02:42 AM   #5
raskin
Senior Member
 
Registered: Sep 2005
Location: Russia
Distribution: NixOS (http://nixos.org)
Posts: 1,899

Rep: Reputation: 68
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, 03: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, 03:10 AM   #7
raskin
Senior Member
 
Registered: Sep 2005
Location: Russia
Distribution: NixOS (http://nixos.org)
Posts: 1,899

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

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

but read man sudo, man sudoers
 
Old 07-12-2006, 03: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, 04: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, 04: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 04:41 AM.
 
Old 07-12-2006, 04:44 AM   #11
raskin
Senior Member
 
Registered: Sep 2005
Location: Russia
Distribution: NixOS (http://nixos.org)
Posts: 1,899

Rep: Reputation: 68
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, 04: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, 05:17 AM   #13
raskin
Senior Member
 
Registered: Sep 2005
Location: Russia
Distribution: NixOS (http://nixos.org)
Posts: 1,899

Rep: Reputation: 68
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, 05: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, 05:33 AM   #15
raskin
Senior Member
 
Registered: Sep 2005
Location: Russia
Distribution: NixOS (http://nixos.org)
Posts: 1,899

Rep: Reputation: 68
Mistake.

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

and

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


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 08:40 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