<?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: Force /sbin/sh to act as a login shell in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/force-sbin-sh-to-act-as-a-login-shell/m-p/3798118#M266089</link>
    <description>just try the same thing in your shell and see if it work:&lt;BR /&gt;exex /sbin/sh -sh</description>
    <pubDate>Wed, 31 May 2006 21:36:25 GMT</pubDate>
    <dc:creator>curt larson_1</dc:creator>
    <dc:date>2006-05-31T21:36:25Z</dc:date>
    <item>
      <title>Force /sbin/sh to act as a login shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/force-sbin-sh-to-act-as-a-login-shell/m-p/3798114#M266085</link>
      <description>We're doing something convoluted ;-)&lt;BR /&gt;&lt;BR /&gt;We're forcing a script (needs to run on other unix platforms) to run during ssh key authentication via the ssh option 'command=' which is attached to a public key in authorized_keys2.&lt;BR /&gt;&lt;BR /&gt;The purpose of the command= option is to force a command to a particular key and to exit .. But we want to use this command to record whose public key is being used to login to the userid.  If a command  (SSH_ORIGINAL_COMMAND) was passed along with the ssh command, then the command is read, evaluated then the script exits.  But, if SSH_ORIGINAL_COMMAND was not passed, then we want the person to login normally.  Now with BASH, we can use the '-l' parm to simulate a login shell.  /sbin/sh does not have this capability.  Does anyone know how I can start /bin/sh so that /etc/profile /home/~HOME/.profile gets executed?&lt;BR /&gt;&lt;BR /&gt;This is for the root userid, so /sbin/sh is required&lt;BR /&gt;&lt;BR /&gt;This is part of the code .. Obviously, the HP-UX piece isn't working ;-)&lt;BR /&gt;&lt;BR /&gt;if [ "${SSH_ORIGINAL_COMMAND}" ]&lt;BR /&gt;then&lt;BR /&gt;   logger  $myProg: ${1} from ${SSH_CLIENT%% *} ran COMMAND: "${SSH_ORIGINAL_COMMAND%% *}" as $LOGNAME using ssh&lt;BR /&gt;   eval ${SSH_ORIGINAL_COMMAND}&lt;BR /&gt;else&lt;BR /&gt;   logger  $myProg: ${1} from ${SSH_CLIENT%% *} logged in as $LOGNAME using ssh&lt;BR /&gt;   cat /etc/motd&lt;BR /&gt;   echo "${1} from ${SSH_CLIENT%% *} is loggin in as $LOGNAME"&lt;BR /&gt;   if [[ $myOS = "HP-UX" ]]; then&lt;BR /&gt;      . ./.profile &lt;BR /&gt;      . ./.kshrc &lt;BR /&gt;      exec /sbin/sh&lt;BR /&gt;   elif [[ $myOS = "Linux" ]]; then&lt;BR /&gt;      exec /bin/bash -l&lt;BR /&gt;   else &lt;BR /&gt;      exec /usr/bin/bash -l&lt;BR /&gt;   fi&lt;BR /&gt;&lt;BR /&gt;Thanks for any pointers&lt;BR /&gt;Richard</description>
      <pubDate>Wed, 31 May 2006 20:32:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/force-sbin-sh-to-act-as-a-login-shell/m-p/3798114#M266085</guid>
      <dc:creator>Richard Ross</dc:creator>
      <dc:date>2006-05-31T20:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: Force /sbin/sh to act as a login shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/force-sbin-sh-to-act-as-a-login-shell/m-p/3798115#M266086</link>
      <description>I'm telling this out of my head, I don't have access to an HP-UX this evening to check it out.&lt;BR /&gt;&lt;BR /&gt;For sh or ksh to be a started as a login shell, they must be invoked as "-sh" or "-ksh". If you do a ps -ef, you'll see that login shells should be started that way. But as far as I remember, there is no way to do this directly from the shell or a script, even a symlink won't work. In the past, to do this I found a way by writing a wrapper in C that just ran exec() with -sh as the process name.&lt;BR /&gt;&lt;BR /&gt;Here is a trimmed down snippet that explains how to do it:&lt;BR /&gt;execlp("/bin/sh", "-sh", (char *) 0)&lt;BR /&gt;&lt;BR /&gt;So in your case you put this wrapper in your script to invoke a honest-to-goodness sh as a login shell.&lt;BR /&gt;&lt;BR /&gt;This may be way overkill, but it worked for me. If you nobody else finds a solution, write back and I'll be able to give you a workable snippet tomorrow.&lt;BR /&gt;&lt;BR /&gt;Olivier</description>
      <pubDate>Wed, 31 May 2006 21:02:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/force-sbin-sh-to-act-as-a-login-shell/m-p/3798115#M266086</guid>
      <dc:creator>Olivier Masse</dc:creator>
      <dc:date>2006-05-31T21:02:07Z</dc:date>
    </item>
    <item>
      <title>Re: Force /sbin/sh to act as a login shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/force-sbin-sh-to-act-as-a-login-shell/m-p/3798116#M266087</link>
      <description>from the manual&lt;BR /&gt;&lt;BR /&gt;If the shell is invoked by an exec*() system call and the first character of argument zero (shell parameter 0) is dash (-), the shell is assumed to be a login shell and commands are read first from /etc/profile, then from either .profile in the current directory or $HOME/.profile if either file exists, and finally from the file named by performing parameter substitution on the value of the environment parameter ENV, if the file exists.&lt;BR /&gt;&lt;BR /&gt;so somewhere along the login process, login or another executable is doing an exec () system call to start the shell.&lt;BR /&gt;&lt;BR /&gt;your shell command exec does an exec system call.&lt;BR /&gt;&lt;BR /&gt;maybe from the above poster's information and the exec () system call manual page, you can put together an exec command that will do what you desire</description>
      <pubDate>Wed, 31 May 2006 21:13:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/force-sbin-sh-to-act-as-a-login-shell/m-p/3798116#M266087</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2006-05-31T21:13:38Z</dc:date>
    </item>
    <item>
      <title>Re: Force /sbin/sh to act as a login shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/force-sbin-sh-to-act-as-a-login-shell/m-p/3798117#M266088</link>
      <description>you could try doing using the one line perl program: exec '/sbin/sh' '-sh';&lt;BR /&gt;&lt;BR /&gt;but i don't know if that will work the way you want it to in single user mode but then ssh probably isn't either</description>
      <pubDate>Wed, 31 May 2006 21:28:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/force-sbin-sh-to-act-as-a-login-shell/m-p/3798117#M266088</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2006-05-31T21:28:35Z</dc:date>
    </item>
    <item>
      <title>Re: Force /sbin/sh to act as a login shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/force-sbin-sh-to-act-as-a-login-shell/m-p/3798118#M266089</link>
      <description>just try the same thing in your shell and see if it work:&lt;BR /&gt;exex /sbin/sh -sh</description>
      <pubDate>Wed, 31 May 2006 21:36:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/force-sbin-sh-to-act-as-a-login-shell/m-p/3798118#M266089</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2006-05-31T21:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: Force /sbin/sh to act as a login shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/force-sbin-sh-to-act-as-a-login-shell/m-p/3798119#M266090</link>
      <description>Curt/Olivier&lt;BR /&gt;&lt;BR /&gt;Thanks for your input .. &lt;BR /&gt;&lt;BR /&gt;Curt, The script didn't work as well as the Perl example and Olivier, Not a C person.&lt;BR /&gt;&lt;BR /&gt;I think the easiest way to get around this is to install bash, and just call 'bash -l', but I would still be interested if the Perl wrapper would work.&lt;BR /&gt;&lt;BR /&gt;Thanks again&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 01 Jun 2006 19:08:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/force-sbin-sh-to-act-as-a-login-shell/m-p/3798119#M266090</guid>
      <dc:creator>Richard Ross</dc:creator>
      <dc:date>2006-06-01T19:08:06Z</dc:date>
    </item>
    <item>
      <title>Re: Force /sbin/sh to act as a login shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/force-sbin-sh-to-act-as-a-login-shell/m-p/3798120#M266091</link>
      <description>from &lt;A href="http://perldoc.perl.org/functions/exec.html" target="_blank"&gt;http://perldoc.perl.org/functions/exec.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;here are the two example they have&lt;BR /&gt;&lt;BR /&gt;$shell = '/bin/csh';&lt;BR /&gt;exec $shell '-sh'; &lt;BR /&gt;&lt;BR /&gt;and&lt;BR /&gt;&lt;BR /&gt;exec {'/bin/csh'} '-sh';</description>
      <pubDate>Thu, 01 Jun 2006 21:23:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/force-sbin-sh-to-act-as-a-login-shell/m-p/3798120#M266091</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2006-06-01T21:23:35Z</dc:date>
    </item>
    <item>
      <title>Re: Force /sbin/sh to act as a login shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/force-sbin-sh-to-act-as-a-login-shell/m-p/3798121#M266092</link>
      <description>Curt .. Thanks .. appreciate the follow up</description>
      <pubDate>Fri, 02 Jun 2006 06:29:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/force-sbin-sh-to-act-as-a-login-shell/m-p/3798121#M266092</guid>
      <dc:creator>Richard Ross</dc:creator>
      <dc:date>2006-06-02T06:29:49Z</dc:date>
    </item>
  </channel>
</rss>

