Skip to content

Commit

Permalink
Move the fgrep replacement to hostkey-rotate.sh.
Browse files Browse the repository at this point in the history
The fgrep replacement for buggy greps doesn't work in the sftp-glob test
so move it to just where we know it's needed.
  • Loading branch information
daztucker committed Sep 24, 2021
1 parent f703954 commit 9b2ee74
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
19 changes: 19 additions & 0 deletions regress/hostkey-rotate.sh
Expand Up @@ -3,6 +3,25 @@

tid="hostkey rotate"

#
# GNU (f)grep <=2.18, as shipped by FreeBSD<=12 and NetBSD<=9 will occasionally
# fail to find ssh host keys in the hostkey-rotate test. If we have those
# versions, use awk instead.
# See # https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=258616
#
case `grep --version 2>&1 | awk '/GNU grep/{print $4}'` in
2.19) fgrep=good ;;
1.*|2.?|2.?.?|2.1?) fgrep=bad ;; # stock GNU grep
2.5.1*) fgrep=bad ;; # FreeBSD and NetBSD
*) fgrep=good ;;
esac
if test "x$fgrep" = "xbad"; then
fgrep()
{
awk 'BEGIN{e=1} {if (index($0,"'$1'")>0){e=0;print}} END{exit e}' $2
}
fi

rm -f $OBJ/hkr.* $OBJ/ssh_proxy.orig $OBJ/ssh_proxy.orig

grep -vi 'hostkey' $OBJ/sshd_proxy > $OBJ/sshd_proxy.orig
Expand Down
19 changes: 0 additions & 19 deletions regress/test-exec.sh
Expand Up @@ -79,25 +79,6 @@ if test "x${EGREP}" != "x"; then
}
fi

#
# GNU (f)grep <=2.18, as shipped by FreeBSD<=12 and NetBSD<=9 will occasionally
# fail to find ssh host keys in the hostkey-rotate test. If we have those
# versions, use awk instead.
# See # https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=258616
#
case `grep --version 2>&1 | awk '/GNU grep/{print $4}'` in
2.19) fgrep=good ;;
1.*|2.?|2.?.?|2.1?) fgrep=bad ;; # stock GNU grep
2.5.1*) fgrep=bad ;; # FreeBSD and NetBSD
*) fgrep=good ;;
esac
if test "x$fgrep" = "xbad"; then
fgrep()
{
awk 'BEGIN{e=1} {if (index($0,"'$1'")>0){e=0;print}} END{exit e}' $2
}
fi

SRC=`dirname ${SCRIPT}`

# defaults
Expand Down

0 comments on commit 9b2ee74

Please sign in to comment.