LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 08-02-2010, 09:27 PM   #1
hackaway
LQ Newbie
 
Registered: Jan 2006
Posts: 2

Rep: Reputation: 0
Using sudoers to restrict editing of certain files


In a recent discussion I had, I was led to believe I could use sudoers to restrict using vi (for example) for the editing of say specific config files. I know how to allow root use of vi and how to lock it down from getting to a bash prompt with NOEXEC tag, but I can't figure out how to restrict the use of vi to only edit certain files. Tutorials and howtos I have checked don't address this. Any ideas?

TIA
 
Old 08-02-2010, 10:42 PM   #2
GlennsPref
Senior Member
 
Registered: Apr 2004
Location: Brisbane, Australia
Distribution: Devuan
Posts: 3,657
Blog Entries: 33

Rep: Reputation: 283Reputation: 283Reputation: 283
Quote:
Hi, Welcome to LQ!

LQ has a fantastic search function that may save you time waiting for an answer to a popular question.

With over 4 million posts to search it's possible the answer has been given.
Not too sure, But...

If you make to files writeable only by the root user, The general user may not save the file on site.

I found a comprehensive article on this, (using an alias for a program name)

http://linuxshellaccount.blogspot.co...tricks-in.html

Aside from that, I use sudo in the opposite way, that is to give me root access through sudo and the wheel group.

When editing /etc/sudoers, su -p and enter root password.

the -p will Preserve Permissions on the file for security integrity.

/etc/sudoers...
Code:
# sudoers file.
....

# Host alias specification

# User alias specification

# Cmnd alias specification

# Defaults specification

# Runas alias specification

# User privilege specification
root	ALL=(ALL) ALL

# Uncomment to allow people in group wheel to run all commands
# %wheel	ALL=(ALL) ALL

# Same thing without a password
%wheel	ALL=(ALL) NOPASSWD: ALL

# Samples
%users  ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
%users  localhost=/sbin/shutdown -h now
This part...
Code:
# Uncomment to allow people in group wheel to run all commands
# %wheel	ALL=(ALL) ALL
you may add your user name and then by adding yourself to the wheel group have access to root privs without su'ing to root.

I'm sure you may do this for programs and applications too, and is covered in the url above.

Hope this helps, Glenn
 
Old 08-02-2010, 10:47 PM   #3
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,126
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
I believe you can list what they are allowed to edit when you specify them in the sudoers


for example

username ALL = /usr/bin/vi /etc/group, /usr/bin/vi /etc/fstab

which would let username edit those files but nothing else
 
Old 08-04-2010, 04:04 AM   #4
GlennsPref
Senior Member
 
Registered: Apr 2004
Location: Brisbane, Australia
Distribution: Devuan
Posts: 3,657
Blog Entries: 33

Rep: Reputation: 283Reputation: 283Reputation: 283
Another thought, "Parental Control".

Mandriva package manager info...
Quote:
drakguard - Parental control tool​ 
Notice: This is an official package supported by Mandriva

This tool allows to configure parental control. It can block access to web sites and restrict connection during a specified timeframe.
Mandriva Blog.ref: http://blog.mandriva.com/
Quote:
"Parental control allows you now to not only check web sites but also applications used by your children"
A net-nanny type program...
other ref. http://rpm.pbone.net/index.php3/stat....i586.rpm.html

Last edited by GlennsPref; 08-04-2010 at 04:07 AM. Reason: nanny
 
Old 08-05-2010, 06:18 PM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by GlennsPref View Post
It can block access to web sites and restrict connection during a specified timeframe.
How does this relate to the OP's question of "use sudoers to restrict using vi (for example) for the editing of say specific config files"?
 
Old 08-05-2010, 11:27 PM   #6
GlennsPref
Senior Member
 
Registered: Apr 2004
Location: Brisbane, Australia
Distribution: Devuan
Posts: 3,657
Blog Entries: 33

Rep: Reputation: 283Reputation: 283Reputation: 283
<edit>You're quite right, unSpawn(about Vi)</edit>
(but in my defence....)
That was a quote from the package manager that I referenced after I looked at the MandrivaBlog and noticed the "netnanny-type-program" had the function of restricting access to programs. (I thought I referenced it....)

Simply, you can stop basic-users, like children, flatmates, or workmates, and subordinates from being able to access certain programs. Just an option I thought of.

Sometimes simple is ample.

I probably wouldn't use this kind of thing for my college mates, but you know, just trying to give solutions/answers. In fact it merely adds to what I have posted.

Regards Glenn

It's pretty simple anyway, just make yourself part of the wheel group, and make sure no-one else is. Then setup /etc/sudoers to suit.

As you know, just 'cause I can read a file, does not mean I can edit it in place.

Last edited by GlennsPref; 08-05-2010 at 11:44 PM. Reason: spelling, my defence
 
Old 08-06-2010, 05:09 AM   #7
LVsFINEST
Member
 
Registered: Aug 2006
Posts: 99

Rep: Reputation: 21
It should be noted that you should not ever edit the /etc/sudoers file directly. Use the visudo command, hopefully your disto has that or similar.

I believe estabroo's example is correct syntax. To restrict files, use a "!":

Code:
username ALL = /usr/bin/vi !/etc/group, /usr/bin/vi !/etc/fstab
 
Old 08-14-2010, 06:43 AM   #8
hackaway
LQ Newbie
 
Registered: Jan 2006
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks

Thank you all for your suggestions. Very helpful!!

Dave
 
  


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
Editing the sudoers file Nagglfar Linux - Newbie 4 03-09-2009 07:16 AM
need HELP with editing sudoers file jTm_316 Linux - Newbie 4 01-10-2009 02:45 AM
/etc/sudoers, editing mickeyboa Fedora 2 07-26-2007 06:31 PM
restrict sudoers by envirnmoent bardinjw Linux - Software 1 07-30-2006 03:22 AM
Help editing /etc/sudoers amer_58 Linux - Newbie 3 07-22-2005 03:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

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