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