<?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: sudo Runas_Alias needs to source .shrc variables in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/sudo-runas-alias-needs-to-source-shrc-variables/m-p/5298461#M475162</link>
    <description>&lt;P&gt;If your version of sudo is recent enough to support the -i option, try "sudo -u dmadmin -i [some command]".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you don't use either -H or -i, the target user's shell is likely to be looking for the .shrc file from the original user's home directory, not in dmadmin's home directory.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It would also be important to know which shell the dmadmin user is configured to use: ".shrc" is not one of the standard HP-UX /usr/bin/sh login scripts. Perhaps it's executed because the ENV variable is set in some other login script? If so, please keep in mind that modern versions of sudo will remove any environment variables it is not specifically configured to keep. You may have to add something like this to your sudoers file:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Defaults&amp;gt;DMALIAS env_keep+=ENV&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Unless I'm mistaken, that should tell sudo to add ENV to the list of preserved environment variables when sudoing to users listed in Runas_Alias DMALIAS. A relatively recent version of sudo might also be required to support this syntax.)&lt;/P&gt;</description>
    <pubDate>Fri, 12 Aug 2011 06:27:18 GMT</pubDate>
    <dc:creator>Matti_Kurkela</dc:creator>
    <dc:date>2011-08-12T06:27:18Z</dc:date>
    <item>
      <title>sudo Runas_Alias needs to source .shrc variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sudo-runas-alias-needs-to-source-shrc-variables/m-p/5297955#M475150</link>
      <description>&lt;P&gt;I'm configuring a sudo Runas_Alias in the sudoers file on a hp-ux 11.31 system. The&lt;/P&gt;&lt;P&gt;goal is to allow some hp-ux accounts to sudo to a service account and run commands as&lt;/P&gt;&lt;P&gt;that user. Here's the related sudoers entries:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;User_Alias&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DMSTAFF = %dmstaff&lt;BR /&gt;Runas_Alias&amp;nbsp;&amp;nbsp;&amp;nbsp; DMALIAS = dmadmin&lt;BR /&gt;DMSTAFF&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ALL = (DMALIAS) NOPASSWD: ALL&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, testuser1 belongs to the dmstaff hp-ux group, so he is allowed to run&lt;/P&gt;&lt;P&gt;commands as dmadmin like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sudo -u dmadmin [some command]&lt;BR /&gt;or&lt;BR /&gt;sudo -Hu dmadmin [some command] (preserve's target user's home dir)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It works very well and sudo commands are logged to our sudo.log. However, sudo is not sourcing important env variables that dmadmin requires. These env variables are normally sourced from dmadmin's .shrc file in his home directory.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We can simple allow the users to sudo su - dmadmin by defining a simple Cmnd_Alias,&lt;/P&gt;&lt;P&gt;but in that case subsequent commands will not be logged to the sudo.log - a dept.&lt;/P&gt;&lt;P&gt;requirement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2011 16:04:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sudo-runas-alias-needs-to-source-shrc-variables/m-p/5297955#M475150</guid>
      <dc:creator>Mike Patterson</dc:creator>
      <dc:date>2011-08-11T16:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: sudo Runas_Alias needs to source .shrc variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sudo-runas-alias-needs-to-source-shrc-variables/m-p/5298461#M475162</link>
      <description>&lt;P&gt;If your version of sudo is recent enough to support the -i option, try "sudo -u dmadmin -i [some command]".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you don't use either -H or -i, the target user's shell is likely to be looking for the .shrc file from the original user's home directory, not in dmadmin's home directory.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It would also be important to know which shell the dmadmin user is configured to use: ".shrc" is not one of the standard HP-UX /usr/bin/sh login scripts. Perhaps it's executed because the ENV variable is set in some other login script? If so, please keep in mind that modern versions of sudo will remove any environment variables it is not specifically configured to keep. You may have to add something like this to your sudoers file:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Defaults&amp;gt;DMALIAS env_keep+=ENV&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Unless I'm mistaken, that should tell sudo to add ENV to the list of preserved environment variables when sudoing to users listed in Runas_Alias DMALIAS. A relatively recent version of sudo might also be required to support this syntax.)&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2011 06:27:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sudo-runas-alias-needs-to-source-shrc-variables/m-p/5298461#M475162</guid>
      <dc:creator>Matti_Kurkela</dc:creator>
      <dc:date>2011-08-12T06:27:18Z</dc:date>
    </item>
  </channel>
</rss>

