Hi, I noticed one small possible error in the openssh-2.3.0p1/contrib/redhat/sshd.init script. In the stop option: stop) echo -n "Shutting down sshd: " if [ -f $PID_FILE ] ; then killproc sshd [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sshd fi echo Shouldn't there be RETVAL=$? after killproc sshd ? If this is the case here's a patch: --- sshd.init~ Mon Oct 16 04:25:17 2000 +++ sshd.init Tue Nov 7 15:06:16 2000 @@ -72,6 +72,7 @@ echo -n "Shutting down sshd: " if [ -f $PID_FILE ] ; then killproc sshd + RETVAL=$? [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sshd fi echo -Jarno -- Jarno Huuskonen - System Administrator | Jarno.Huuskonen at uku.fi University of Kuopio - Computer Centre | Work: +358 17 162822 PO BOX 1627, 70211 Kuopio, Finland | Mobile: +358 40 5388169
On Tue, 7 Nov 2000, Jarno Huuskonen wrote:> > I noticed one small possible error in the > openssh-2.3.0p1/contrib/redhat/sshd.init script. > In the stop option: > stop) > echo -n "Shutting down sshd: " > if [ -f $PID_FILE ] ; then > killproc sshd > [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sshd > fi > echo > > Shouldn't there be RETVAL=$? after killproc sshd ?Yeah, RETVAL seems to have been omitted by mistake. The problem has been there for a while now. Luckily enough, sshd won't break too badly for it. :-/ -- Pekka Savola "Tell me of difficulties surmounted, Pekka.Savola at netcore.fi not those you stumble over and fall"
Donald Smith Staff IP Engineer IP Network Engineering Security 303-226-9939 Office 303-226-0688 fax 720-320-1537 cell> -----Original Message----- > From: Jarno Huuskonen [mailto:jhuuskon at messi.uku.fi] > Sent: Tuesday, November 07, 2000 6:11 AM > To: openssh-unix-dev at mindrot.org > Subject: RedHat sshd.init script typo ? > > > Hi, > > I noticed one small possible error in the > openssh-2.3.0p1/contrib/redhat/sshd.init script. > In the stop option: > stop) > echo -n "Shutting down sshd: " > if [ -f $PID_FILE ] ; then > killproc sshd > [ $RETVAL -eq 0 ] && rm -fWhy bother assigning RETVAL then comparing it to 0. How about a comment explaining $? # The return value from killproc is stored in $? (normal sh behavior) then [ $? -eq 0 ] && rm -f /var/lock/subsys/sshd> fi > echoThis saves an assignment helps newbies understand that in borneshell $? is the decimal value returned by the last synchronously executed command.> > Shouldn't there be RETVAL=$? after killproc sshd ? > If this is the case here's a patch: > > --- sshd.init~ Mon Oct 16 04:25:17 2000 > +++ sshd.init Tue Nov 7 15:06:16 2000 > @@ -72,6 +72,7 @@ > echo -n "Shutting down sshd: " > if [ -f $PID_FILE ] ; then > killproc sshd > + RETVAL=$? > [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sshd > fi > echo > > -Jarno > > -- > Jarno Huuskonen - System Administrator | Jarno.Huuskonen at uku.fi > University of Kuopio - Computer Centre | Work: +358 17 162822 > PO BOX 1627, 70211 Kuopio, Finland | Mobile: +358 40 5388169 >
Donald Smith Staff IP Engineer IP Network Engineering Security 303-226-9939 Office 303-226-0688 fax 720-320-1537 cell> -----Original Message----- > From: Jim Knoble [mailto:jmknoble at jmknoble.cx] > Sent: Tuesday, November 07, 2000 10:37 AM > To: openssh-unix-dev at mindrot.org > Subject: Re: RedHat sshd.init script typo ? > > > Circa 2000-Nov-07 09:57:48 -0700 dixit Smith, Donald : > > : Why bother assigning RETVAL then comparing it to 0. How > about a comment > : explaining $? > : # The return value from killproc is stored in $? (normal sh > behavior) then > : [ $? -eq 0 ] && rm -f > /var/lock/subsys/sshd > : > fi > : > echo > : This saves an assignment helps newbies understand that in > borneshell $? is > : the decimal value returned by the last synchronously > executed command. > > The init script ought to 'exit ${RETVAL}' as its last action; that's > why to save the value of $? in RETVAL (though i can think of a much > better name for that variable...).Ok if you exit $(The_Return_Value_Of_The_killproc_AND_the_return_value_of_the_rm_Of_the_loc k) then I guess this makes sense. Odviously if the lock can't be removed that error should be reported also.> > -- > jim knoble | jmknoble at jmknoble.cx | http://www.jmknoble.cx/ >
On Tue, Nov 07, 2000 at 09:57:48AM -0700, Smith, Donald wrote:> Why bother assigning RETVAL then comparing it to 0. How about a comment > explaining $?Initscripts are not sh intros. But the point is that RH uses RETVAL in *every* initscript---and the value stored is used in return $RETVAL which is then used by various initfunctions to display the exit status of services with text and color. Mate