- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Blocking shell escapes for sudoers
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2004 11:26 PM
05-06-2004 11:26 PM
I need to grant some DBAs writeable editing of system config files (e.g. like /etc/services).
Since I don't like changing group membership of these files to dba, nor even assigning an ACL to them, I would like to put the vi command under sudo.
The catch is how to prevent the shell escape from vi, which would give sudoers a root shell.
Let alone for vi, this would be easy to disable by simply setting the escape shell explicitly.
e.g.
EXINIT="set shell=/usr/bin/false" /usr/bin/vi /etc/services
The problem with this approach is that sudo sees the supposed environment variable EXINIT as a sudo qualifier which it doesn't find a sudoers definition for.
Maybe one could compile a vi version (e.g. from GNU) where one deliberately disables the shell escape functionality (viz. some sort of restricted vi).
But before doing this I'm sure someone of you will come around with a more tangible solution.
Rgd.
Ralph
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2004 03:13 AM
05-07-2004 03:13 AM
Re: Blocking shell escapes for sudoers
maybe this will not work with sudoers ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2004 03:30 AM
05-07-2004 03:30 AM
SolutionThat being said, however, the most secure way I can think of to handle this is create a small setuid C program wrapper around the commands they need to insert and remove from the file. Has two benefits that I see... 1.) keeps them from doing anything to the file other than what they really need to do and 2.) doesn't allow them access to a shell as root. Not difficult to do... small amount of code that should be fairly easy to find online. (Been a while since I needed anything like that and don't have it handy.)
Jeff Traigle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2004 04:32 AM
05-07-2004 04:32 AM
Re: Blocking shell escapes for sudoers
they don't need to actually vi /etc/services. they only need to overwrite it.
all they need is read permissions to make a copy of the file and from there use vi to make their changes. then they can do a sudo to copy their changes to /etc/services.
Cmnd_alias CPSERVICES = /usr/bin/cp /home/dba/services /etc/services
this could get a bit tedious if you have quite a few config files to give access.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2004 05:05 AM
05-07-2004 05:05 AM
Re: Blocking shell escapes for sudoers
[morpheus|jdonovan]
$ cat /usr/bin/vin
SHELL=/bin/false
/usr/bin/vi $1
[morpheus|jdonovan]
$ ll /usr/bin/vin
-rwxr-xr-x 1 root sys 32 Mar 21 06:00 /usr/bin/vin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2004 07:48 AM
05-07-2004 07:48 AM
Re: Blocking shell escapes for sudoers
Setting env_reset to "on" and env_keep to "EXINIT" should preserve the EXINIT environment variable in the sudo-spawned process.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2004 07:21 PM
05-09-2004 07:21 PM
Re: Blocking shell escapes for sudoers
I didn't know these env_(reset|keep) settings exist because the sudoer's manpage of my version of sudo doesn't mention them.
Having had a look at http://www.courtesan.com/ I soon discovered that in fact the release I am using is pretty dated.
# sudo -V|head -1
Sudo version 1.6.3p4
while 1.6.7 seems to be the current release.
And indeed the online manpage of sudoers mentions the env_* settings.
Therefore I think it would probably be the best to update to the new release.
Jim,
your solution most likely will also work, and looks pretty straight forward.
Curt,
of course, your solution looks even better as it avoids the use of vi altogether.
Jeff,
yet another way that will work,
but requires the extra work of writing a wrapper, though I'm convinced I could also write it in Perl (which knows all the required syscalls for that but is much easier than C to me).
Tom,
did you mean a restricted shell like HP-UX rsh (not to be confused with other Unices' remote shell)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2006 03:39 AM
12-13-2006 03:39 AM
Re: Blocking shell escapes for sudoers
I have a situation where a handful operational tasks are required with root priviliges, so I wrote a menu driven script run under sudo. One task is editing a few config files, so I came accross this thread when googling "sudo vi shell escape" :) Based on Jim's suggestion above, I came up with the following (excerpt from my wrapper script):
HOLDER=$SHELL
SHELL=/bin/false
vi $CFG_FILE # shell esc no longer works
SHELL=$HOLDER
# to test: try vi $CFG_FILE here and esc works again
Cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2006 05:14 AM
12-13-2006 05:14 AM