<?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: &amp;quot;su problem&amp;quot; with script in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/quot-su-problem-quot-with-script/m-p/2624481#M930</link>
    <description>Yes, you can't put the "su -c" inside the script you are running as su.  Once you you do the su you are in another shell and disconnected from the script.  &lt;BR /&gt;It seems you have a few choices though. &lt;BR /&gt;As Eugen says, you can change the owner of the script to bsp and then make it setuid.  Security-wise it is not recommended to have setuid scripts as then can be comprised more easily than binaries.  But in this situation, it may be acceptable.&lt;BR /&gt;Otherise, you can create a wrapper script that does the su -c and calls the other script.  But if you do this, the user running it will be prompted for a password.&lt;BR /&gt;Another option is to use something like sudo or Symark's Powerbroker that lets you run a program as another user.</description>
    <pubDate>Tue, 04 Dec 2001 14:51:37 GMT</pubDate>
    <dc:creator>Bernie Vande Griend</dc:creator>
    <dc:date>2001-12-04T14:51:37Z</dc:date>
    <item>
      <title>"su problem" with script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/quot-su-problem-quot-with-script/m-p/2624478#M927</link>
      <description>When I execute a particular script from the command line like :  su bsp -c app.start&lt;BR /&gt;the script gets started as user bsp without any issue. (the script is owned by root but some users are authorised to start it up.)&lt;BR /&gt;&lt;BR /&gt;How do I add the above "su "syntax within the script itself so that the users can just type in "app.start" and the binaries gets started always as user "bsp" ?&lt;BR /&gt;&lt;BR /&gt;The extract of the script is as below (Can someone let me know where to place "su bsp -c" option in the script in the fifth line here?)&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;BSE=/app/bse&lt;BR /&gt;BSE_TMP=/app/bse/tmp&lt;BR /&gt;echo 'Initialize Printer Daemon\n'&lt;BR /&gt;if [ -x ${BSE}/bin/pdaemon${REL} ];then&lt;BR /&gt;     if [ -f ${BSE_TMP}/pd_lock ]; then&lt;BR /&gt;       echo "Printer Daemon already running"&lt;BR /&gt;        else&lt;BR /&gt;         if ${BSE}/bin/pdaemon${REL} ;then&lt;BR /&gt;          echo 'Printer Daemon Initialized\n'&lt;BR /&gt;           else                     &lt;BR /&gt;          echo 'Cannot Initialize Printer Daemon\n'&lt;BR /&gt;                fi&lt;BR /&gt;        fi&lt;BR /&gt;else&lt;BR /&gt;        echo 'Cannot Initialize Printer Daemon\n'&lt;BR /&gt;fi&lt;BR /&gt;exit 0 &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 04 Dec 2001 02:08:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/quot-su-problem-quot-with-script/m-p/2624478#M927</guid>
      <dc:creator>Krishnan Viswanathan</dc:creator>
      <dc:date>2001-12-04T02:08:10Z</dc:date>
    </item>
    <item>
      <title>Re: "su problem" with script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/quot-su-problem-quot-with-script/m-p/2624479#M928</link>
      <description>Hello&lt;BR /&gt;&lt;BR /&gt;If you're root, you can use 'su' to change to any account or execute any command as another user without typing the password. Regular users however don't have this capability since it would allow anyone to run any program as any other user.&lt;BR /&gt;&lt;BR /&gt;The solution for you seems to be sudo (try man sudo). Sudo allows users to execute certain commands (you specify) as another user or even as root.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Paga&lt;BR /&gt;</description>
      <pubDate>Tue, 04 Dec 2001 04:04:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/quot-su-problem-quot-with-script/m-p/2624479#M928</guid>
      <dc:creator>Marco Paganini</dc:creator>
      <dc:date>2001-12-04T04:04:21Z</dc:date>
    </item>
    <item>
      <title>Re: "su problem" with script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/quot-su-problem-quot-with-script/m-p/2624480#M929</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;chown bsp &amp;lt;script&amp;gt;&lt;BR /&gt;chmod +s &amp;lt;script&amp;gt;&lt;BR /&gt;&lt;BR /&gt;This will set user id on execution, ie, when somebody runs the script, the script will not run as the user that launched the script but the user that owns the script.&lt;BR /&gt;&lt;BR /&gt;E.</description>
      <pubDate>Tue, 04 Dec 2001 08:47:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/quot-su-problem-quot-with-script/m-p/2624480#M929</guid>
      <dc:creator>Eugen Cocalea</dc:creator>
      <dc:date>2001-12-04T08:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: "su problem" with script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/quot-su-problem-quot-with-script/m-p/2624481#M930</link>
      <description>Yes, you can't put the "su -c" inside the script you are running as su.  Once you you do the su you are in another shell and disconnected from the script.  &lt;BR /&gt;It seems you have a few choices though. &lt;BR /&gt;As Eugen says, you can change the owner of the script to bsp and then make it setuid.  Security-wise it is not recommended to have setuid scripts as then can be comprised more easily than binaries.  But in this situation, it may be acceptable.&lt;BR /&gt;Otherise, you can create a wrapper script that does the su -c and calls the other script.  But if you do this, the user running it will be prompted for a password.&lt;BR /&gt;Another option is to use something like sudo or Symark's Powerbroker that lets you run a program as another user.</description>
      <pubDate>Tue, 04 Dec 2001 14:51:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/quot-su-problem-quot-with-script/m-p/2624481#M930</guid>
      <dc:creator>Bernie Vande Griend</dc:creator>
      <dc:date>2001-12-04T14:51:37Z</dc:date>
    </item>
    <item>
      <title>Re: "su problem" with script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/quot-su-problem-quot-with-script/m-p/2624482#M931</link>
      <description>Hi there.&lt;BR /&gt;Just my two cents.&lt;BR /&gt;Invoking an user can be done in two ways :&lt;BR /&gt;&lt;BR /&gt;su bsp -c ...&lt;BR /&gt;&lt;BR /&gt;this invokes the user and tries to execute the command&lt;BR /&gt;&lt;BR /&gt;su - bsp -c&lt;BR /&gt;Invoking the user, taking the environment of the user ( variables etc from .login and .profile ) and then executing the command.&lt;BR /&gt;&lt;BR /&gt;Mostly we use the su in the second way.&lt;BR /&gt;Rgds&lt;BR /&gt;Alexander M. Ermes</description>
      <pubDate>Wed, 05 Dec 2001 13:54:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/quot-su-problem-quot-with-script/m-p/2624482#M931</guid>
      <dc:creator>Alexander M. Ermes</dc:creator>
      <dc:date>2001-12-05T13:54:03Z</dc:date>
    </item>
    <item>
      <title>Re: "su problem" with script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/quot-su-problem-quot-with-script/m-p/2624483#M932</link>
      <description>Thanks all your help. &lt;BR /&gt;The script under question needs to started by a normal user and as the server is also running several other applications, part of service guard etc, we would not like to give "sudo" access for application users. All I need to know is if there is a way to incoporate the 'su' syntax which I mentioned earlier in the script itself. The application user will type in the password if prompted by the script. (I need to incorporate the syntax in several other similar scripts which is owned by root)&lt;BR /&gt;I tried several combinations but each time I got an error in the fifth line. &lt;BR /&gt;Thanks all once again.</description>
      <pubDate>Wed, 05 Dec 2001 17:31:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/quot-su-problem-quot-with-script/m-p/2624483#M932</guid>
      <dc:creator>Krishnan Viswanathan</dc:creator>
      <dc:date>2001-12-05T17:31:36Z</dc:date>
    </item>
  </channel>
</rss>

