<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Blocking shell escapes for sudoers in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/blocking-shell-escapes-for-sudoers/m-p/3270579#M178577</link>
    <description>I have never had a need to do this, but can't you tell sudo to keep certain environment variables with the env_reset and env_keep parameters in the Defaults section of the sudoers file?&lt;BR /&gt;&lt;BR /&gt;Setting env_reset to "on" and env_keep to "EXINIT" should preserve the EXINIT environment variable in the sudo-spawned process.&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 07 May 2004 14:48:58 GMT</pubDate>
    <dc:creator>Charlie Rubeor</dc:creator>
    <dc:date>2004-05-07T14:48:58Z</dc:date>
    <item>
      <title>Blocking shell escapes for sudoers</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/blocking-shell-escapes-for-sudoers/m-p/3270574#M178572</link>
      <description>Hi,&lt;BR /&gt; &lt;BR /&gt;I need to grant some DBAs writeable editing of system config files (e.g. like /etc/services).&lt;BR /&gt; &lt;BR /&gt;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.&lt;BR /&gt; &lt;BR /&gt;The catch is how to prevent the shell escape from vi, which would give sudoers a root shell.&lt;BR /&gt; &lt;BR /&gt;Let alone for vi, this would be easy to disable by simply setting the escape shell explicitly.&lt;BR /&gt; &lt;BR /&gt;e.g.&lt;BR /&gt; &lt;BR /&gt;EXINIT="set shell=/usr/bin/false" /usr/bin/vi /etc/services&lt;BR /&gt; &lt;BR /&gt;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.&lt;BR /&gt; &lt;BR /&gt;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).&lt;BR /&gt; &lt;BR /&gt;But before doing this I'm sure someone of you will come around with a more tangible solution.&lt;BR /&gt; &lt;BR /&gt;Rgd.&lt;BR /&gt;Ralph</description>
      <pubDate>Fri, 07 May 2004 06:26:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/blocking-shell-escapes-for-sudoers/m-p/3270574#M178572</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2004-05-07T06:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: Blocking shell escapes for sudoers</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/blocking-shell-escapes-for-sudoers/m-p/3270575#M178573</link>
      <description>if you want to run a single command, wonder if you can fire up secure shell running vi ?&lt;BR /&gt;maybe this will not work with sudoers ?</description>
      <pubDate>Fri, 07 May 2004 10:13:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/blocking-shell-escapes-for-sudoers/m-p/3270575#M178573</guid>
      <dc:creator>Tom Dineen_2</dc:creator>
      <dc:date>2004-05-07T10:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: Blocking shell escapes for sudoers</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/blocking-shell-escapes-for-sudoers/m-p/3270576#M178574</link>
      <description>Hmmm... not sure why the DBAs would need to be munging around in the /etc/services file in the first place... as I recall from my previous job, it's not necessary (at least for the RDBMS).&lt;BR /&gt;&lt;BR /&gt;That 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.)</description>
      <pubDate>Fri, 07 May 2004 10:30:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/blocking-shell-escapes-for-sudoers/m-p/3270576#M178574</guid>
      <dc:creator>Jeff_Traigle</dc:creator>
      <dc:date>2004-05-07T10:30:11Z</dc:date>
    </item>
    <item>
      <title>Re: Blocking shell escapes for sudoers</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/blocking-shell-escapes-for-sudoers/m-p/3270577#M178575</link>
      <description>have you thought of this:&lt;BR /&gt;&lt;BR /&gt;they don't need to actually vi /etc/services.  they only need to overwrite it.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;Cmnd_alias CPSERVICES = /usr/bin/cp /home/dba/services /etc/services&lt;BR /&gt;&lt;BR /&gt;this could get a bit tedious if you have quite a few config files to give access.</description>
      <pubDate>Fri, 07 May 2004 11:32:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/blocking-shell-escapes-for-sudoers/m-p/3270577#M178575</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2004-05-07T11:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: Blocking shell escapes for sudoers</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/blocking-shell-escapes-for-sudoers/m-p/3270578#M178576</link>
      <description>I faced a similar problem with sudo and created  a short shell script called vin (vi 'no-shell'), and placed it in /usr/bin.  I then gave sudo access to the appropriate people.&lt;BR /&gt;&lt;BR /&gt;[morpheus|jdonovan]&lt;BR /&gt;$ cat /usr/bin/vin&lt;BR /&gt;SHELL=/bin/false&lt;BR /&gt;/usr/bin/vi $1&lt;BR /&gt; &lt;BR /&gt;[morpheus|jdonovan]&lt;BR /&gt;$ ll /usr/bin/vin&lt;BR /&gt;-rwxr-xr-x   1 root       sys             32 Mar 21 06:00 /usr/bin/vin</description>
      <pubDate>Fri, 07 May 2004 12:05:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/blocking-shell-escapes-for-sudoers/m-p/3270578#M178576</guid>
      <dc:creator>James A. Donovan</dc:creator>
      <dc:date>2004-05-07T12:05:22Z</dc:date>
    </item>
    <item>
      <title>Re: Blocking shell escapes for sudoers</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/blocking-shell-escapes-for-sudoers/m-p/3270579#M178577</link>
      <description>I have never had a need to do this, but can't you tell sudo to keep certain environment variables with the env_reset and env_keep parameters in the Defaults section of the sudoers file?&lt;BR /&gt;&lt;BR /&gt;Setting env_reset to "on" and env_keep to "EXINIT" should preserve the EXINIT environment variable in the sudo-spawned process.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 07 May 2004 14:48:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/blocking-shell-escapes-for-sudoers/m-p/3270579#M178577</guid>
      <dc:creator>Charlie Rubeor</dc:creator>
      <dc:date>2004-05-07T14:48:58Z</dc:date>
    </item>
    <item>
      <title>Re: Blocking shell escapes for sudoers</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/blocking-shell-escapes-for-sudoers/m-p/3270580#M178578</link>
      <description>Charlie,&lt;BR /&gt; &lt;BR /&gt;I didn't know these env_(reset|keep)  settings exist because the sudoer's manpage of my version of sudo doesn't mention them.&lt;BR /&gt;Having had a look at &lt;A href="http://www.courtesan.com/" target="_blank"&gt;http://www.courtesan.com/&lt;/A&gt; I soon discovered that in fact the release I am using is pretty dated.&lt;BR /&gt; &lt;BR /&gt;# sudo -V|head -1    &lt;BR /&gt;Sudo version 1.6.3p4&lt;BR /&gt; &lt;BR /&gt;while 1.6.7 seems to be the current release.&lt;BR /&gt;And indeed the online manpage of sudoers mentions the env_* settings.&lt;BR /&gt; &lt;BR /&gt;Therefore I think it would probably be the best to update to the new release.&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt;Jim,&lt;BR /&gt; &lt;BR /&gt;your solution most likely will also work, and looks pretty straight forward.&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt;Curt,&lt;BR /&gt; &lt;BR /&gt;of course, your solution looks even better as it avoids the use of vi altogether.&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt;Jeff,&lt;BR /&gt; &lt;BR /&gt;yet another way that will work,&lt;BR /&gt;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).&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt;Tom,&lt;BR /&gt; &lt;BR /&gt;did you mean a restricted shell like HP-UX rsh (not to be confused with other Unices'  remote shell)?</description>
      <pubDate>Mon, 10 May 2004 02:21:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/blocking-shell-escapes-for-sudoers/m-p/3270580#M178578</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2004-05-10T02:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: Blocking shell escapes for sudoers</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/blocking-shell-escapes-for-sudoers/m-p/3270581#M178579</link>
      <description>I know this thread is old, but it was still helpful for me (thanks guys) and will add how I applied it:&lt;BR /&gt;&lt;BR /&gt;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):&lt;BR /&gt;&lt;BR /&gt;HOLDER=$SHELL&lt;BR /&gt;SHELL=/bin/false        &lt;BR /&gt;vi $CFG_FILE  # shell esc no longer works&lt;BR /&gt;SHELL=$HOLDER&lt;BR /&gt;# to test: try vi $CFG_FILE here and esc works again&lt;BR /&gt;&lt;BR /&gt;Cheers!&lt;BR /&gt;</description>
      <pubDate>Wed, 13 Dec 2006 11:39:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/blocking-shell-escapes-for-sudoers/m-p/3270581#M178579</guid>
      <dc:creator>Steve Horvath</dc:creator>
      <dc:date>2006-12-13T11:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: Blocking shell escapes for sudoers</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/blocking-shell-escapes-for-sudoers/m-p/3270582#M178580</link>
      <description>So what's going to stop people from doing things like ":e /etc/passwd" and ":w /etc/sudoers" from that vi session?</description>
      <pubDate>Wed, 13 Dec 2006 13:14:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/blocking-shell-escapes-for-sudoers/m-p/3270582#M178580</guid>
      <dc:creator>Heironimus</dc:creator>
      <dc:date>2006-12-13T13:14:03Z</dc:date>
    </item>
  </channel>
</rss>

