LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices


Reply
  Search this Thread
Old 05-20-2009, 04:55 PM   #1
trey85stang
Senior Member
 
Registered: Sep 2003
Posts: 1,091

Rep: Reputation: 41
sudoers - how to give access to certain directories?


Without changing permissions on a directory tree.. is there anyway to give sudo access to a specific directory so that admin staff could move/copy/edit files in those directories? I have an app that requires specific permissions to work correctly it's either sudo access or root access. Id prefer to stay from giving full sudo access to everyone who needs to modify files in this application directory.

Is this possible or not?

Also is there a way to give ALL permissions minus a specific command (su in particular)??

Thanks,
Trey
 
Old 05-20-2009, 05:52 PM   #2
archShade
Member
 
Registered: Mar 2006
Location: Delft NL
Distribution: Debian; Slackware; windows 7
Posts: 218

Rep: Reputation: 53
You can take a command out of a sudo account by using the ! (not operator) for example to let bill use all commands except su, shutdown, halt and poweroff the line would look like (in /etc/sudoers)

Code:
bill        ALL = (ALL) ALL !su !shutdown !halt !poweroff
this does not seem like a good idea as there may be ways around the exact command. such as using a shell escape from another program.

You can give access to directorys just like you can command. for example if you wanted bill,mike,pete and members of the project group to be able to access /path/to/project/*. you'd use

Code:
User_Alias     THISGROUP = bill, mike, pete

THISGROUP, %project ALL= /path/to/project/*
the user alias statement should be near the top all other statements should be with the main body of statements in sudoers file
 
Old 05-20-2009, 07:00 PM   #3
blackhole54
Senior Member
 
Registered: Mar 2006
Posts: 1,896

Rep: Reputation: 61
Quote:
Originally Posted by archShade View Post
You can take a command out of a sudo account by using the
Code:
User_Alias     THISGROUP = bill, mike, pete

THISGROUP, %project ALL= /path/to/project/*
Using wildcards in path names can be very tricky in sudo. Using the above example, I believe /path/to/project/../../../any/path/I/want/ would match.

Also, if I understand the man page correctly, the above command would allow commands to be run in the indicated directories but not allow files to be modified, which is what I understood the OP wanted. You might look at the sudoedit option for that (if the files to be modified are text files).

There is a SECURITY NOTES section of the sudoers man page the you may wish to look at.

Last edited by blackhole54; 05-20-2009 at 07:02 PM.
 
Old 05-21-2009, 09:24 AM   #4
trey85stang
Senior Member
 
Registered: Sep 2003
Posts: 1,091

Original Poster
Rep: Reputation: 41
Big thanks to both of you guys, I completely forgot about sudoedit. Luckily the admins that will have root access I trust not to use loopholes so thats not a big concern. The biggest concern for me is the directory access. Ill read up on sudoedit.

Thanks for the information, I really appreciate it
 
Old 05-23-2009, 02:30 PM   #5
custangro
Senior Member
 
Registered: Nov 2006
Location: California
Distribution: Fedora , CentOS , RHEL
Posts: 1,979
Blog Entries: 1

Rep: Reputation: 209Reputation: 209Reputation: 209
Quote:
Originally Posted by archShade View Post
You can take a command out of a sudo account by using the ! (not operator) for example to let bill use all commands except su, shutdown, halt and poweroff the line would look like (in /etc/sudoers)

Code:
bill        ALL = (ALL) ALL !su !shutdown !halt !poweroff
this does not seem like a good idea as there may be ways around the exact command. such as using a shell escape from another program.

You can give access to directorys just like you can command. for example if you wanted bill,mike,pete and members of the project group to be able to access /path/to/project/*. you'd use

Code:
User_Alias     THISGROUP = bill, mike, pete

THISGROUP, %project ALL= /path/to/project/*
the user alias statement should be near the top all other statements should be with the main body of statements in sudoers file
FYI...in RHEL 5...

This doesn't work
Code:
bill        ALL = (ALL) ALL !su !shutdown !halt !poweroff
But this does work...

Code:
bill        ALL = (ALL) ALL,!su,!shutdown,!halt,!poweroff


-C
 
  


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
using sudoers files to give privilege to users dolceinter1 Linux - Server 1 11-04-2008 02:37 PM
Apache, trying to give users their own directories anon111 Linux - Software 5 05-23-2006 07:19 PM
I deleted /etc/sudoers and creates a new file call sudoers but now it doesnt for visu abefroman Linux - Software 1 11-10-2005 05:03 PM
Give Access extremebfn Linux - Networking 6 08-31-2004 03:27 AM
How to give access... zolo44 Linux - Newbie 4 01-18-2003 04:53 PM

LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise

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