From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from ptx.hi.pengutronix.de ([2001:6f8:1178:2:5054:ff:fec0:8e10] ident=Debian-exim) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1W081u-00057f-Nu for ptxdist@pengutronix.de; Mon, 06 Jan 2014 12:07:34 +0100 Received: from mol by ptx.hi.pengutronix.de with local (Exim 4.80) (envelope-from ) id 1W081u-0007BK-MQ for ptxdist@pengutronix.de; Mon, 06 Jan 2014 12:07:34 +0100 Date: Mon, 6 Jan 2014 12:07:34 +0100 From: Michael Olbrich Message-ID: <20140106110734.GG2156@pengutronix.de> References: <1387379605-6643-1-git-send-email-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1387379605-6643-1-git-send-email-u.kleine-koenig@pengutronix.de> Subject: Re: [ptxdist] [PATCH] openssh: improve rc.once script to support locations other than /etc/ssh Reply-To: ptxdist@pengutronix.de List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: ptxdist-bounces@pengutronix.de Errors-To: ptxdist-bounces@pengutronix.de To: ptxdist@pengutronix.de On Wed, Dec 18, 2013 at 04:13:25PM +0100, Uwe Kleine-K=F6nig wrote: > This is done by parsing the sshd_config using awk for the location of > the key files being used. > = > Note that the dependency on awk is a weak one because if awk isn't > available the script simply falls back to the default location. > = > Signed-off-by: Uwe Kleine-K=F6nig > --- > generic/etc/rc.once.d/openssh | 14 ++++++++------ > 1 file changed, 8 insertions(+), 6 deletions(-) > = > diff --git a/generic/etc/rc.once.d/openssh b/generic/etc/rc.once.d/openssh > index 83e6e37..fea8472 100644 > --- a/generic/etc/rc.once.d/openssh > +++ b/generic/etc/rc.once.d/openssh > @@ -2,13 +2,15 @@ > = > PATH=3D/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin > = > -OPENSSH_RSAKEY_DEFAULT=3D"/etc/ssh/ssh_host_rsa_key" > -OPENSSH_DSAKEY_DEFAULT=3D"/etc/ssh/ssh_host_dsa_key" > +get_default_key() { > + key_type=3D$1 > + sshd_config=3D"/etc/ssh/sshd_config" > + > + awk -v type=3D"$key_type" '/^HostKey/ && match($2, "/ssh_host_" type "_= key$") { print $2; found=3D1 } END { exit !found }' "$sshd_config" || echo = "/etc/ssh/ssh_host_${key_type}_key" Can you make this a bit more readable. Like using multiple lines and if [ $? !=3D 0 ]; then ... And I think it should be '/^HostKey\>/'. Michael > +} > = > -test -n "$OPENSSH_RSAKEY" || \ > - OPENSSH_RSAKEY=3D$OPENSSH_RSAKEY_DEFAULT > -test -n "$OPENSSH_DSAKEY" || \ > - OPENSSH_DSAKEY=3D$OPENSSH_DSAKEY_DEFAULT > +OPENSSH_RSAKEY=3D"$(get_default_key rsa)" > +OPENSSH_DSAKEY=3D"$(get_default_key dsa)" > = > gen_key() { > = > -- = > 1.8.4.4 > = > = > -- = > ptxdist mailing list > ptxdist@pengutronix.de -- = Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | -- = ptxdist mailing list ptxdist@pengutronix.de