<?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: su to another user in a script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/su-to-another-user-in-a-script/m-p/2963642#M814550</link>
    <description>Do it this way;&lt;BR /&gt;&lt;BR /&gt;su - usera -c "&lt;PATH&gt;/test.sh"&lt;BR /&gt;&lt;BR /&gt;And that will run it properly as user usera.&lt;BR /&gt;&lt;/PATH&gt;</description>
    <pubDate>Thu, 01 May 2003 13:48:50 GMT</pubDate>
    <dc:creator>Stefan Farrelly</dc:creator>
    <dc:date>2003-05-01T13:48:50Z</dc:date>
    <item>
      <title>su to another user in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/su-to-another-user-in-a-script/m-p/2963641#M814549</link>
      <description>I know this is not something that can be done, however, I need to do it.&lt;BR /&gt;I have a simple script&lt;BR /&gt;test.sh&lt;BR /&gt;whoami&lt;BR /&gt;&lt;BR /&gt;I do the chown and the chmod&lt;BR /&gt;chown usera test.sh&lt;BR /&gt;chmod 4555 test.sh&lt;BR /&gt;&lt;BR /&gt;ll&lt;BR /&gt;-rwsr-xr-x   1 usera     users           33 May  1 10:17 test.sh&lt;BR /&gt;&lt;BR /&gt;now when I run the script when logged in as another users say userb it says that I'm userb. :) I need this to say usera so that I can use this script to move files into a directory protected by usera without giving permission to userb. The completed version of this script will be used to log the transaction and keep a protected history of the files going into that directory. Hope this makes sense, and thanks for your help. ;)</description>
      <pubDate>Thu, 01 May 2003 13:36:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/su-to-another-user-in-a-script/m-p/2963641#M814549</guid>
      <dc:creator>ken_5</dc:creator>
      <dc:date>2003-05-01T13:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: su to another user in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/su-to-another-user-in-a-script/m-p/2963642#M814550</link>
      <description>Do it this way;&lt;BR /&gt;&lt;BR /&gt;su - usera -c "&lt;PATH&gt;/test.sh"&lt;BR /&gt;&lt;BR /&gt;And that will run it properly as user usera.&lt;BR /&gt;&lt;/PATH&gt;</description>
      <pubDate>Thu, 01 May 2003 13:48:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/su-to-another-user-in-a-script/m-p/2963642#M814550</guid>
      <dc:creator>Stefan Farrelly</dc:creator>
      <dc:date>2003-05-01T13:48:50Z</dc:date>
    </item>
    <item>
      <title>Re: su to another user in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/su-to-another-user-in-a-script/m-p/2963643#M814551</link>
      <description>This command would require me to type the password for usera. That would allow userb to login directly to that account and execute the command without using the script. Is there a way to pass the password within the script?</description>
      <pubDate>Thu, 01 May 2003 14:16:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/su-to-another-user-in-a-script/m-p/2963643#M814551</guid>
      <dc:creator>ken_5</dc:creator>
      <dc:date>2003-05-01T14:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: su to another user in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/su-to-another-user-in-a-script/m-p/2963644#M814552</link>
      <description>Just figured it out. There has to be a #!/usr/bin/sh on the first line of the script or it will fail to change to the new userid. Thanks for your help. :)</description>
      <pubDate>Thu, 01 May 2003 14:28:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/su-to-another-user-in-a-script/m-p/2963644#M814552</guid>
      <dc:creator>ken_5</dc:creator>
      <dc:date>2003-05-01T14:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: su to another user in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/su-to-another-user-in-a-script/m-p/2963645#M814553</link>
      <description>Instead of a suid shell script (which is a security hole), try installing sudo&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/sudo-1.6.6/" target="_blank"&gt;http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/sudo-1.6.6/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;and configure userb in the sudoers file to only be able to run your script:&lt;BR /&gt;&lt;BR /&gt;userb ALL=(usera) /path/to/test.sh&lt;BR /&gt;&lt;BR /&gt;Then userb can do&lt;BR /&gt;&lt;BR /&gt;sudo -u usera /path/to/test.sh&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;userb wil not need to know usera's password, the script will not need to be suid, and you will get a log of all actions in your syslog (depending on how you have /etc/syslog.conf configured).</description>
      <pubDate>Thu, 01 May 2003 14:43:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/su-to-another-user-in-a-script/m-p/2963645#M814553</guid>
      <dc:creator>Bill Douglass</dc:creator>
      <dc:date>2003-05-01T14:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: su to another user in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/su-to-another-user-in-a-script/m-p/2963646#M814554</link>
      <description>you actually have two options.&lt;BR /&gt;&lt;BR /&gt;have the script execute as root... this will not require any password to execute the above script.  this is the recommended way.  &lt;BR /&gt;&lt;BR /&gt;if you can't do this and you need to pass a password you could use expect.  expect is downloadable from here &lt;A href="http://expect.nist.gov/" target="_blank"&gt;http://expect.nist.gov/&lt;/A&gt;&lt;BR /&gt;and very easy to use.  you just type what you want the script to do basically.  I'm attaching a copy of one of my expect scripts&lt;BR /&gt; - my script is an example but it telnets into a server and executes things.... but you can use it to automate almost anything</description>
      <pubDate>Thu, 01 May 2003 15:02:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/su-to-another-user-in-a-script/m-p/2963646#M814554</guid>
      <dc:creator>John Meissner</dc:creator>
      <dc:date>2003-05-01T15:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: su to another user in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/su-to-another-user-in-a-script/m-p/2963647#M814555</link>
      <description>I had read about expect and sudo in other posts, however, I did not want to have to install and document anything new on the system. Nor, research the security risks. ;)&lt;BR /&gt;but I'm sure they would both work from what I've read.&lt;BR /&gt;thanks</description>
      <pubDate>Thu, 01 May 2003 16:28:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/su-to-another-user-in-a-script/m-p/2963647#M814555</guid>
      <dc:creator>ken_5</dc:creator>
      <dc:date>2003-05-01T16:28:36Z</dc:date>
    </item>
  </channel>
</rss>

