LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-25-2006, 02:34 AM   #1
sunhui
Member
 
Registered: Jan 2006
Location: taiwan
Posts: 156

Rep: Reputation: 30
Restrict command to run


If I want to limit the user can only run part of comamnd in /usr/bin , is it possible ? for example , if I want to limit the user can't use the command /usr/bin/wget , /usr/bin/gcc etc, what can I do ? thx
 
Old 05-25-2006, 02:53 AM   #2
vls
Member
 
Registered: Jan 2005
Location: The grassy knoll
Distribution: Slackware,Debian
Posts: 192

Rep: Reputation: 31
Remove the read and execute bit from the 'other' field of the file permissions on the particular binary:

Shell command:
Quote:
$ chmod 750 /usr/bin/wget
or
Quote:
$ chmod o-rx /usr/bin/wget
 
Old 05-25-2006, 02:57 AM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 681Reputation: 681Reputation: 681Reputation: 681Reputation: 681Reputation: 681
I haven't tried it on binaries, but if the files are on a file system that can use ACLs, you could remove read and execution access for certain users.
read through the man pages for the commands "getfacl" and "setfacl". You may need to install a acl package if it isn't by default.
 
Old 05-25-2006, 03:13 AM   #4
vls
Member
 
Registered: Jan 2005
Location: The grassy knoll
Distribution: Slackware,Debian
Posts: 192

Rep: Reputation: 31
Quote:
Originally Posted by jschiwal
I haven't tried it on binaries, but if the files are on a file system that can use ACLs, you could remove read and execution access for certain users.
read through the man pages for the commands "getfacl" and "setfacl". You may need to install a acl package if it isn't by default.
Ah, yes. My solution would wack all users.

Okay, Non-ACL solution.
Remove the permission as I provided.
Create a special group for users who get to run the command and add them to that group with execute permission. Not too elegant, I know, but you could come up with a script to automate the task I'm sure.

Hmm, does sudo let one restrict command access on basic commands?
 
Old 05-25-2006, 04:06 AM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 681Reputation: 681Reputation: 681Reputation: 681Reputation: 681Reputation: 681
Quote:
Hmm, does sudo let one restrict command access on basic commands
aaron shanty = NOEXEC: /usr/bin/more, /usr/bin/vi, /usr/bin/less
This prevents a person authorized to use sudo from using these programs which provide shell escapes.
entering the commands "!/bin/bash" would give the user full root access.
I don't know how good this protection is. For example, if they copied the command somewere else, could they execute it then?

Look in the "man 5 sudoers" man page for details.

Last edited by jschiwal; 05-25-2006 at 04:11 AM.
 
  


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
Command to run another command against a list of files psweetma Linux - General 3 11-09-2005 05:29 PM
Cannot run CP command! hrudolph Linux - Newbie 12 05-14-2005 10:52 PM
Run a command from anywhere ToothlessRebel Linux - Newbie 4 03-05-2005 01:36 AM
How to run a command Maintech Mandriva 1 11-20-2004 09:41 PM
Run Command csosa Linux - Software 1 09-27-2003 10:41 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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