<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>RE: [openssh-unix-dev] Re: contrib/solaris/opensshd.in patch</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2>Here's a try for the PID thing; I also included a startup check for</FONT>
<BR><FONT SIZE=2>a running sshd, just for the kicks.</FONT>
<BR><FONT SIZE=2>Z</FONT>
</P>
<P><FONT SIZE=2>--- opensshd.in.old Fri Jan 18 15:47:21 2002</FONT>
<BR><FONT SIZE=2>+++ opensshd.in.new Tue Jan 22 17:33:42 2002</FONT>
<BR><FONT SIZE=2>@@ -3,11 +3,9 @@</FONT>
<BR><FONT SIZE=2> #</FONT>
<BR><FONT SIZE=2> # Stripped PRNGd out of it for the time being.</FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2>-AWK=/usr/bin/awk</FONT>
<BR><FONT SIZE=2> CAT=/usr/bin/cat</FONT>
<BR><FONT SIZE=2> KILL=/usr/bin/kill</FONT>
<BR><FONT SIZE=2> PS=/usr/bin/ps</FONT>
<BR><FONT SIZE=2>-XARGS=/usr/bin/xargs</FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2> prefix=%%openSSHDir%%</FONT>
<BR><FONT SIZE=2> etcdir=%%configDir%%</FONT>
<BR><FONT SIZE=2>@@ -20,12 +18,6 @@</FONT>
<BR><FONT SIZE=2> HOST_KEY_DSA=$etcdir/ssh_host_dsa_key</FONT>
<BR><FONT SIZE=2> HOST_KEY_RSA=$etcdir/ssh_host_rsa_key</FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2>-killproc() {</FONT>
<BR><FONT SIZE=2>- _procname=$1</FONT>
<BR><FONT SIZE=2>- _signal=$2</FONT>
<BR><FONT SIZE=2>- ${PS} -u root | ${AWK} '/'"$_procname"'$/ {print $1}' | ${XARGS} ${KILL}</FONT>
<BR><FONT SIZE=2>-}</FONT>
<BR><FONT SIZE=2>-</FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2> checkkeys() {</FONT>
<BR><FONT SIZE=2> if [ ! -f $HOST_KEY_RSA1 ]; then</FONT>
<BR><FONT SIZE=2>@@ -39,21 +31,38 @@</FONT>
<BR><FONT SIZE=2> fi</FONT>
<BR><FONT SIZE=2> }</FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2>-stop_service() {</FONT>
<BR><FONT SIZE=2>+find_pid() {</FONT>
<BR><FONT SIZE=2> if [ -r $PIDFILE -a ! -z ${PIDFILE} ]; then</FONT>
<BR><FONT SIZE=2> PID=`${CAT} ${PIDFILE}`</FONT>
<BR><FONT SIZE=2> fi</FONT>
<BR><FONT SIZE=2> if [ ${PID:=0} -gt 1 -a ! "X$PID" = "X " ]; then</FONT>
<BR><FONT SIZE=2>- ${KILL} ${PID}</FONT>
<BR><FONT SIZE=2>+ PROC=`${PS} -ofname= -p $PID`</FONT>
<BR><FONT SIZE=2>+ if [ "${PROC}" = "`basename $SSHD`" ]; then</FONT>
<BR><FONT SIZE=2>+ return</FONT>
<BR><FONT SIZE=2>+ fi</FONT>
<BR><FONT SIZE=2>+ fi</FONT>
<BR><FONT SIZE=2>+ PID=0</FONT>
<BR><FONT SIZE=2>+}</FONT>
<BR><FONT SIZE=2>+</FONT>
<BR><FONT SIZE=2>+</FONT>
<BR><FONT SIZE=2>+stop_service() {</FONT>
<BR><FONT SIZE=2>+ find_pid</FONT>
<BR><FONT SIZE=2>+ if [ ${PID} -gt 1 ]; then</FONT>
<BR><FONT SIZE=2>+ ${KILL} ${PID}</FONT>
<BR><FONT SIZE=2> else</FONT>
<BR><FONT SIZE=2>- echo "Unable to read PID file, killing using alternate method"</FONT>
<BR><FONT SIZE=2>- killproc sshd TERM</FONT>
<BR><FONT SIZE=2>+ echo "Unable to locate the master sshd process."</FONT>
<BR><FONT SIZE=2>+ echo "You may have to manually kill it later."</FONT>
<BR><FONT SIZE=2> fi</FONT>
<BR><FONT SIZE=2> }</FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2> start_service() {</FONT>
<BR><FONT SIZE=2>- # XXX We really should check if the service is already going, but</FONT>
<BR><FONT SIZE=2>- # XXX we will opt out at this time. - Bal</FONT>
<BR><FONT SIZE=2>+ find_pid</FONT>
<BR><FONT SIZE=2>+ if [ ${PID} -gt 1 ]; then</FONT>
<BR><FONT SIZE=2>+ # XXX do we kill running sshd, or abort here?</FONT>
<BR><FONT SIZE=2>+ # ${KILL} ${PID}</FONT>
<BR><FONT SIZE=2>+ echo "sshd already running - use 'restart' to restart."</FONT>
<BR><FONT SIZE=2>+ return</FONT>
<BR><FONT SIZE=2>+ fi</FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2> # Check to see if we have keys that need to be made</FONT>
<BR><FONT SIZE=2> checkkeys</FONT>
</P>
<P><FONT SIZE=2>-- </FONT>
<BR><FONT SIZE=2>Zoran Milojevic</FONT>
<BR><FONT SIZE=2>SS8 Networks Inc. <A HREF="http://www.ss8.com" TARGET="_blank">http://www.ss8.com</A></FONT>
<BR><FONT SIZE=2>"One Better" </FONT>
<BR><FONT SIZE=2>Tel: +1-613-592-2100/x3231 Fax: +1-613-592-9634</FONT>
</P>
<BR>
<P><FONT SIZE=2>> -----Original Message-----</FONT>
<BR><FONT SIZE=2>> From: mouring@etoh.eviladmin.org [<A HREF="mailto:mouring@etoh.eviladmin.org">mailto:mouring@etoh.eviladmin.org</A>]</FONT>
<BR><FONT SIZE=2>> Sent: January 21, 2002 00:36</FONT>
<BR><FONT SIZE=2>> To: Frank Cusack</FONT>
<BR><FONT SIZE=2>> Cc: David Bronder; openssh-unix-dev@mindrot.org</FONT>
<BR><FONT SIZE=2>> Subject: Re: [openssh-unix-dev] Re: contrib/solaris/opensshd.in patch</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> <Nod> And if someone does not send a patch by Wed.. I'll </FONT>
<BR><FONT SIZE=2>> write my own and</FONT>
<BR><FONT SIZE=2>> commit it with the exec-prefix change.</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> - Ben</FONT>
</P>
</BODY>
</HTML>