hostkey-rotate, grep and two line search pattern

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

 



Hello,

Regression test hostkey-rotate .

After 'learn new primary' known_hosts contain both rsa keys - old and new one. Function check_key_present use awk to get search pattern and script return two lines.
In such case Solaris grep command return error 41.
Simple test command:
$ grep '1
> 2' /tmp/a
grep: RE error 41: No remembered search string.

It is reported in [1] with patch to change grep to fgrep.
As fgrep use "pattern as a list of fixed strings, separated by newlines" fgrep could be used to resolve issue.


I would like to propose another correction - change logic of check_key_present to search known_hosts for public key. Attached file implement new search. It use 'fgrep ... > /dev/null'. Also 'grep -q ..' works well.


Regards,
Roumen Petrov

[1] http://www.gossamer-threads.com/lists/openssh/dev/60908?do=post_view_threaded

--
Get SSH with X.509 certificate support
http://roumenpetrov.info/openssh/

>From 713508e1694f63bc24247914f69a181ce2722c8f Mon Sep 17 00:00:00 2001
From: Roumen Petrov <openssh@xxxxxxxxxxxxxxxxx>
Date: Tue, 3 Mar 2015 18:43:46 +0200
Subject: [PATCH] regress/hostkey-rotate.sh: rewrite check_key_present to
 search key into known_hosts

---
 regress/hostkey-rotate.sh | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/regress/hostkey-rotate.sh b/regress/hostkey-rotate.sh
index 24df371..5439748 100644
--- a/regress/hostkey-rotate.sh
+++ b/regress/hostkey-rotate.sh
@@ -38,11 +38,10 @@ expect_nkeys() {
 check_key_present() {
 	_type=$1
 	_kfile=$2
-	_prog='print $2 " " $3'
 	test "x$_kfile" = "x" && _kfile="$OBJ/hkr.${_type}.pub"
-	_ktext=`awk "/ $_type / { $_prog }" < $OBJ/known_hosts` || \
+	_kpub=`awk "/$_type /"' { print $2 }' < $_kfile` || \
 		fatal "awk failed"
-	grep -q "$_ktext" $_kfile
+	fgrep "$_kpub" $OBJ/known_hosts > /dev/null
 }
 
 cp $OBJ/sshd_proxy.orig $OBJ/sshd_proxy
-- 
1.8.4

_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@xxxxxxxxxxx
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux