contrib/solaris/opensshd.in patch

Frank Cusack fcusack at fcusack.com
Sun Jan 20 12:49:48 EST 2002


On Sat, Jan 19, 2002 at 09:02:28AM -0800, Kevin Sindhu wrote:
> Moin mouring! 
>  mouring at etoh.eviladmin.org schrieb am Samstag, den 19. Januar 2002:
> 
> > > pkill is not portable. Its available only on 2.7+ and I agree with
> > > not using pgrep.
> 
> > > Something like:
> 
> > > PID=`ps -a | awk '/[s]shd/{print $1}'`
> 
> > Same problem as the original code.  It could kill all children sshd
> > which would kill your remote session if you are upgrading OpenSSH.

You just need to implement 'pkill -P 1 sshd'.  How about installing a pkill
substitute for systems < 2.7.

/usr/local/bin/pkill:

#! /bin/sh
[ assume -P arg ]

pids=`ps -eo ppid,pid,comm | grep '[ /]'$3'$' |
      awk '{ if ($1 == '$2') print $2 }' 2>/dev/null`
if [ -z "$pids" ]; then
    exit 1
else
    kill $pids
    exit $?
fi

Then the init script is easy.  Or, the above could be in the init script
itself.

/fc




More information about the openssh-unix-dev mailing list