mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
From: Michael Olbrich <m.olbrich@pengutronix.de>
To: ptxdist@pengutronix.de
Subject: Re: [ptxdist] [PATCH] openssh: improve rc.once script to support locations other than /etc/ssh
Date: Mon, 6 Jan 2014 12:07:34 +0100	[thread overview]
Message-ID: <20140106110734.GG2156@pengutronix.de> (raw)
In-Reply-To: <1387379605-6643-1-git-send-email-u.kleine-koenig@pengutronix.de>

On Wed, Dec 18, 2013 at 04:13:25PM +0100, Uwe Kleine-König 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önig <u.kleine-koenig@pengutronix.de>
> ---
>  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=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
>  
> -OPENSSH_RSAKEY_DEFAULT="/etc/ssh/ssh_host_rsa_key"
> -OPENSSH_DSAKEY_DEFAULT="/etc/ssh/ssh_host_dsa_key"
> +get_default_key() {
> +	key_type=$1
> +	sshd_config="/etc/ssh/sshd_config"
> +
> +	awk -v type="$key_type" '/^HostKey/ && match($2, "/ssh_host_" type "_key$") { print $2; found=1 } 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 [ $? != 0 ]; then
...

And I think it should be '/^HostKey\>/'.

Michael

> +}
>  
> -test -n "$OPENSSH_RSAKEY" || \
> -	OPENSSH_RSAKEY=$OPENSSH_RSAKEY_DEFAULT
> -test -n "$OPENSSH_DSAKEY" || \
> -	OPENSSH_DSAKEY=$OPENSSH_DSAKEY_DEFAULT
> +OPENSSH_RSAKEY="$(get_default_key rsa)"
> +OPENSSH_DSAKEY="$(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

      reply	other threads:[~2014-01-06 11:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-18 15:13 Uwe Kleine-König
2014-01-06 11:07 ` Michael Olbrich [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140106110734.GG2156@pengutronix.de \
    --to=m.olbrich@pengutronix.de \
    --cc=ptxdist@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox