[PATCH/cygwin] Fix cygwin specific Makefile and a bug in the ssh-host-config script

Daniel Kahn Gillmor dkg at fifthhorseman.net
Sat Nov 8 01:46:42 EST 2008

On Fri 2008-11-07 05:54:58 -0500, Corinna Vinschen wrote:

> diff -u -p -r1.22 ssh-host-config
> --- contrib/cygwin/ssh-host-config	14 Jul 2008 02:12:54 -0000	1.22
> +++ contrib/cygwin/ssh-host-config	7 Nov 2008 10:49:30 -0000
> @@ -456,7 +456,7 @@ done
>  # Check for running ssh/sshd processes first. Refuse to do anything while
>  # some ssh processes are still running
> -if ps -ef | grep -v grep | grep -q ssh
> +if ps -ef | grep -v grep | grep -q 'sshd*$'
>  then
>    echo
>    csih_error "There are still ssh processes running. Please shut them down first."

Sorry: i should have offered a solution to the grep -v grep thing
instead of just pointing out the problem.  One way to avoid grep
matching itself when scanning the process table is to use a
non-self-matching regex.

So for example, instead of doing:

  ps -ef | grep -q 'sshd'

You could do:

  ps -ef | grep -q '[s]shd'

which means the same thing from a regex perspective, but does not

[0 dkg at squeak ~]$ echo 'grep -q sshd' | grep 'sshd'
grep -q sshd
[0 dkg at squeak ~]$ echo 'grep -q [s]shd' | grep '[s]shd'
[1 dkg at squeak ~]$ 

Most non-literals like $ (meaning end of line) are sufficient for this
also, since

  grep -q sshd$

does not self-match:

[0 dkg at squeak ~]$ echo 'grep -q sshd$' | grep -q sshd$
[1 dkg at squeak ~]$ 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 826 bytes
Desc: not available
Url : http://lists.mindrot.org/pipermail/openssh-unix-dev/attachments/20081107/dc5f6b98/attachment.bin 

More information about the openssh-unix-dev mailing list