<?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 su within a ksh script? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/su-within-a-ksh-script/m-p/2417852#M765710</link>
    <description>Is there a way to use the switch users (su) command within a shell script?&lt;BR /&gt;&lt;BR /&gt;I would like to allow regular users database access under the very-controlled &lt;BR /&gt;script environment without allowing them this access outside of the script.  If &lt;BR /&gt;I could switch users back &amp;amp; forth within the script, I could provide this &lt;BR /&gt;limited service.&lt;BR /&gt;&lt;BR /&gt;Thanks for your help.</description>
    <pubDate>Thu, 27 Jan 2000 15:57:33 GMT</pubDate>
    <dc:creator>Tom Chapel</dc:creator>
    <dc:date>2000-01-27T15:57:33Z</dc:date>
    <item>
      <title>su within a ksh script?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/su-within-a-ksh-script/m-p/2417852#M765710</link>
      <description>Is there a way to use the switch users (su) command within a shell script?&lt;BR /&gt;&lt;BR /&gt;I would like to allow regular users database access under the very-controlled &lt;BR /&gt;script environment without allowing them this access outside of the script.  If &lt;BR /&gt;I could switch users back &amp;amp; forth within the script, I could provide this &lt;BR /&gt;limited service.&lt;BR /&gt;&lt;BR /&gt;Thanks for your help.</description>
      <pubDate>Thu, 27 Jan 2000 15:57:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/su-within-a-ksh-script/m-p/2417852#M765710</guid>
      <dc:creator>Tom Chapel</dc:creator>
      <dc:date>2000-01-27T15:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: su within a ksh script?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/su-within-a-ksh-script/m-p/2417853#M765711</link>
      <description>It is not recommended that you use su inside a script because it can cause &lt;BR /&gt;unpredictable results. Some people do it and never report problems, but most of &lt;BR /&gt;the problems I've seen were related to database access.&lt;BR /&gt;&lt;BR /&gt;Instead, consider using a compiled program with the appropriate access rights &lt;BR /&gt;that the users can execute. This way they can't do anything the script wasn't &lt;BR /&gt;written to do.&lt;BR /&gt;&lt;BR /&gt;If you can't write a program to do it, you can use a script with the setuid bit &lt;BR /&gt;set. This will allow users to run the script, which will then execute as if it &lt;BR /&gt;were being run by the owner of the script itself.&lt;BR /&gt;&lt;BR /&gt;This can lead to a security risk though, because anyone who can edit the script &lt;BR /&gt;or otherwise manipulate things could potentially gain unexpected access. This &lt;BR /&gt;would have to be done on purpose by the user, of course, and shouldn't happen &lt;BR /&gt;by accident.&lt;BR /&gt;&lt;BR /&gt;For more info, see the man page for "chmod" and read about the "s" bit (mode &lt;BR /&gt;4000, or u+s).</description>
      <pubDate>Thu, 27 Jan 2000 16:43:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/su-within-a-ksh-script/m-p/2417853#M765711</guid>
      <dc:creator>Dan Hull</dc:creator>
      <dc:date>2000-01-27T16:43:02Z</dc:date>
    </item>
    <item>
      <title>Re: su within a ksh script?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/su-within-a-ksh-script/m-p/2417854#M765712</link>
      <description>Still unable to solve the problem.  I tried the chmod u+s suggestion with the &lt;BR /&gt;following results:&lt;BR /&gt;&lt;BR /&gt;Here's a look at the small test script.  To be able to properly execute the &lt;BR /&gt;real script any user that runs it must assume the user id of user1.&lt;BR /&gt;[user2] /usr/local/bin&amp;gt; more test1.scr&lt;BR /&gt;id&lt;BR /&gt;exit&lt;BR /&gt;test1.scr: END&lt;BR /&gt;&lt;BR /&gt;With normal permissions, the script returns the current uid 202(user2).&lt;BR /&gt;[user2] /usr/local/bin&amp;gt; ll test1.scr&lt;BR /&gt;-rwxr-xr-x   1 user1    users            8 Jan 28 09:30 test1.scr&lt;BR /&gt;[user2] /usr/local/bin&amp;gt; test1.scr&lt;BR /&gt;uid=202(user2) gid=20(users)&lt;BR /&gt;&lt;BR /&gt;After chmod u+s, but with the same results.&lt;BR /&gt;[user2] /usr/local/bin&amp;gt; ll test1.scr&lt;BR /&gt;-rwsr-xr-x   1 user1    users            8 Jan 28 09:30 test1.scr&lt;BR /&gt;[user2] /usr/local/bin&amp;gt; test1.scr&lt;BR /&gt;uid=202(user2) gid=20(users)&lt;BR /&gt;&lt;BR /&gt;For kicks I tried chmod 4000.....&lt;BR /&gt;[user2] /usr/local/bin&amp;gt; ll test1.scr&lt;BR /&gt;---S------   1 user1    users            8 Jan 28 09:30 test1.scr&lt;BR /&gt;[user2] /usr/local/bin&amp;gt; test1.scr&lt;BR /&gt;ksh: test1.scr: cannot execute&lt;BR /&gt;&lt;BR /&gt;Here's the needed results...but using su on screen.&lt;BR /&gt;[user2] /usr/local/bin&amp;gt; su user1&lt;BR /&gt;Password:&lt;BR /&gt;[user2] /usr/local/bin&amp;gt; test1.scr&lt;BR /&gt;uid=201(user1) gid=20(users)&lt;BR /&gt;&lt;BR /&gt;I'm even willing to try the (not recommended) su inside the script, if it has a &lt;BR /&gt;possibility of working.  I just need to know how to do it.&lt;BR /&gt;Any other ideas out there?&lt;BR /&gt;&lt;BR /&gt;Thanks again for your help.</description>
      <pubDate>Fri, 28 Jan 2000 09:01:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/su-within-a-ksh-script/m-p/2417854#M765712</guid>
      <dc:creator>Tom Chapel</dc:creator>
      <dc:date>2000-01-28T09:01:36Z</dc:date>
    </item>
    <item>
      <title>Re: su within a ksh script?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/su-within-a-ksh-script/m-p/2417855#M765713</link>
      <description>I see what you mean. I haven't tested this, but I don't&lt;BR /&gt;think using the SUID will return the GID you are looking for. What it does is &lt;BR /&gt;allow the script to run stuff as if it had the same permissions it would have &lt;BR /&gt;if launched by the owner of the script. If your goal is to allow users access &lt;BR /&gt;to something they can't run manually, then you should be set. If you actually &lt;BR /&gt;need the "id" command to return a specific value, I don't know what you'll need &lt;BR /&gt;to do.&lt;BR /&gt;&lt;BR /&gt;Note that the large "S" after your chmod 4000 indicates that there is no "x" &lt;BR /&gt;under it, so execute permission is denied.</description>
      <pubDate>Mon, 31 Jan 2000 16:52:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/su-within-a-ksh-script/m-p/2417855#M765713</guid>
      <dc:creator>Dan Hull</dc:creator>
      <dc:date>2000-01-31T16:52:13Z</dc:date>
    </item>
    <item>
      <title>Re: su within a ksh script?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/su-within-a-ksh-script/m-p/2417856#M765714</link>
      <description>I have used the "sticky" bit to allow users to execute a script as if they were &lt;BR /&gt;superuser.  Place all the commands you would like run in the script, the use: &lt;BR /&gt;chown root:sys filename (or appropriate values) then I prefer to use chmod 4711 &lt;BR /&gt;filename.  This will give the user the ability to execute the script as if they &lt;BR /&gt;were su, but will disallow read/write access to all but the su.  I've used this &lt;BR /&gt;method, to allow the average user the ability to reboot the system.  Hopefully &lt;BR /&gt;this helps.&lt;BR /&gt;&lt;BR /&gt;Doug</description>
      <pubDate>Tue, 01 Feb 2000 11:52:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/su-within-a-ksh-script/m-p/2417856#M765714</guid>
      <dc:creator>Doug Van tol</dc:creator>
      <dc:date>2000-02-01T11:52:40Z</dc:date>
    </item>
    <item>
      <title>Re: su within a ksh script?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/su-within-a-ksh-script/m-p/2417857#M765715</link>
      <description>FYI - What you are talking about is called the SUID bit, not the "sticky" bit.&lt;BR /&gt;&lt;BR /&gt;The sticky bit is a different bit (the last one) and is used to tell the system &lt;BR /&gt;to keep the program "stuck" in memory after the first time it is executed. &lt;BR /&gt;That's where it gets its name! It's also known as the "save-text-image on file &lt;BR /&gt;execution" bit.&lt;BR /&gt;&lt;BR /&gt;There's also a SET-Group-ID bit. More info on these bits can be found in the &lt;BR /&gt;man page for CHMOD(1) under the section "Miscellaneous mode bits".</description>
      <pubDate>Tue, 01 Feb 2000 17:03:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/su-within-a-ksh-script/m-p/2417857#M765715</guid>
      <dc:creator>Dan Hull</dc:creator>
      <dc:date>2000-02-01T17:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: su within a ksh script?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/su-within-a-ksh-script/m-p/2417858#M765716</link>
      <description>To Dan &amp;amp; Doug: Thanks for your ideas, but none work for my needs, leaving me &lt;BR /&gt;with only the actual su command within the script.  Dan, you mentioned in your &lt;BR /&gt;first reply "It is not recommended that you use su inside a script because it &lt;BR /&gt;can cause unpredictable results".  I would like to test using the su command &lt;BR /&gt;inside my script, but simply don't know how to implement it.  &lt;BR /&gt;&lt;BR /&gt;How do you answer a prompt and press the enter key within a script? (Using su &lt;BR /&gt;online forces you to type the password, then press enter).&lt;BR /&gt;&lt;BR /&gt;Thanks again for your thoughts.</description>
      <pubDate>Thu, 03 Feb 2000 15:40:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/su-within-a-ksh-script/m-p/2417858#M765716</guid>
      <dc:creator>Tom Chapel</dc:creator>
      <dc:date>2000-02-03T15:40:51Z</dc:date>
    </item>
  </channel>
</rss>

