From: Henning Schild <henning.schild@siemens.com>
To: Harald Seiler <hws@denx.de>
Cc: <isar-users@googlegroups.com>,
Claudius Heine <claudius.heine.ext@siemens.com>
Subject: Re: [PATCH v3] sshd-regen-keys: Fix sshd deadlock on boot
Date: Tue, 28 May 2019 21:48:48 +0200 [thread overview]
Message-ID: <20190528214848.4ed89f52@md1za8fc.ad001.siemens.net> (raw)
In-Reply-To: <20190528202511.52b8d976@md1za8fc.ad001.siemens.net>
Am Tue, 28 May 2019 20:25:11 +0200
schrieb "[ext] Henning Schild" <henning.schild@siemens.com>:
> Looking at the recent rootfs postprocessing scripts and how we stop
> putting magic into install hooks i thought about this one again.
>
> This is all nice but it does not solve the real problem. You have to
> be aware that you get the ssh key problem when building and later
> deploying a debian like we do. Once you are aware you might discover
> this handy package.
>
> I think we should have bitbake magic that installs this package as
> soon as sshd gets installed. Which could be tricky if sshd gets
> pulled as dep ...
The probably most lighweight way will be to bbwarn in a postprocess if
sshd installed and sshd-regen-keys is not. I will send a patch.
Henning
> Henning
>
> Am Wed, 19 Dec 2018 14:54:04 +0100
> schrieb Harald Seiler <hws@denx.de>:
>
> > Currently, when sshd-regen-keys runs dpkg-reconfigure, this
> > will lead to a call to `systemctl restart ssh`. This call blocks
> > forever because of course the sshd-regen-keys unit, which is a
> > dependency of sshd, hasn't finished at this point and can't do so
> > because it is waiting as well.
> >
> > To circumvent this deadlock, this commit changes sshd-regen-keys'
> > behavior so sshd is first disabled and only reenabled after the
> > job is done.
> >
> > Signed-off-by: Harald Seiler <hws@denx.de>
> > ---
> > Changes for v2:
> > - Remove `systemctl start --no-block ssh` call as it looks like
> > this is not needed.
> >
> > Changes for v3:
> > - Bump version number to 0.2
> >
> > .../sshd-regen-keys/files/sshd-regen-keys.service | 2 +-
> > .../sshd-regen-keys/files/sshd-regen-keys.sh | 18
> > ++++++++++++++++++ .../{sshd-regen-keys_0.1.bb =>
> > sshd-regen-keys_0.2.bb} | 7 +++++-- 3 files changed, 24
> > insertions(+), 3 deletions(-) create mode 100644
> > meta/recipes-support/sshd-regen-keys/files/sshd-regen-keys.sh rename
> > meta/recipes-support/sshd-regen-keys/{sshd-regen-keys_0.1.bb =>
> > sshd-regen-keys_0.2.bb} (58%)
> >
> > diff --git
> > a/meta/recipes-support/sshd-regen-keys/files/sshd-regen-keys.service
> > b/meta/recipes-support/sshd-regen-keys/files/sshd-regen-keys.service
> > index 3b8231f..a05e1a9 100644 ---
> > a/meta/recipes-support/sshd-regen-keys/files/sshd-regen-keys.service
> > +++
> > b/meta/recipes-support/sshd-regen-keys/files/sshd-regen-keys.service
> > @@ -10,7 +10,7 @@ ConditionPathIsReadWrite=/etc Type=oneshot
> > RemainAfterExit=yes Environment=DEBIAN_FRONTEND=noninteractive
> > -ExecStart=/bin/sh -c "rm -v /etc/ssh/ssh_host_*_key*;
> > dpkg-reconfigure openssh-server"
> > +ExecStart=/usr/sbin/sshd-regen-keys.sh
> > ExecStartPost=-/bin/systemctl disable sshd-regen-keys.service
> > StandardOutput=syslog StandardError=syslog diff --git
> > a/meta/recipes-support/sshd-regen-keys/files/sshd-regen-keys.sh
> > b/meta/recipes-support/sshd-regen-keys/files/sshd-regen-keys.sh new
> > file mode 100644 index 0000000..11fca3b --- /dev/null
> > +++ b/meta/recipes-support/sshd-regen-keys/files/sshd-regen-keys.sh
> > @@ -0,0 +1,18 @@
> > +#!/usr/bin/env sh
> > +
> > +echo -n "SSH server is "
> > +if systemctl is-enabled ssh; then
> > + SSHD_ENABLED="true"
> > + systemctl disable --no-reload ssh
> > +fi
> > +
> > +echo "Removing keys ..."
> > +rm -v /etc/ssh/ssh_host_*_key*
> > +
> > +echo "Regenerating keys ..."
> > +dpkg-reconfigure openssh-server
> > +
> > +if test -n $SSHD_ENABLED; then
> > + echo "Reenabling ssh server ..."
> > + systemctl enable --no-reload ssh
> > +fi
> > diff --git
> > a/meta/recipes-support/sshd-regen-keys/sshd-regen-keys_0.1.bb
> > b/meta/recipes-support/sshd-regen-keys/sshd-regen-keys_0.2.bb
> > similarity index 58% rename from
> > meta/recipes-support/sshd-regen-keys/sshd-regen-keys_0.1.bb rename
> > to meta/recipes-support/sshd-regen-keys/sshd-regen-keys_0.2.bb index
> > 02e9e25..6f12414 100644 ---
> > a/meta/recipes-support/sshd-regen-keys/sshd-regen-keys_0.1.bb +++
> > b/meta/recipes-support/sshd-regen-keys/sshd-regen-keys_0.2.bb @@
> > -6,9 +6,12 @@ MAINTAINER = "isar-users
> > <isar-users@googlegroups.com>" DEBIAN_DEPENDS = "openssh-server,
> > systemd" SRC_URI = "file://postinst \
> > - file://sshd-regen-keys.service"
> > + file://sshd-regen-keys.service \
> > + file://sshd-regen-keys.sh"
> >
> > +do_install[cleandirs] = "${D}/lib/systemd/system \
> > + ${D}/usr/sbin"
> > do_install() {
> > - install -v -d -m 755 "${D}/lib/systemd/system"
> > install -v -m 644 "${WORKDIR}/sshd-regen-keys.service"
> > "${D}/lib/systemd/system/sshd-regen-keys.service"
> > + install -v -m 755 "${WORKDIR}/sshd-regen-keys.sh"
> > "${D}/usr/sbin/sshd-regen-keys.sh" }
> >
>
prev parent reply other threads:[~2019-05-28 19:48 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-13 8:56 [PATCH] " Harald Seiler
2018-12-13 9:41 ` Claudius Heine
2018-12-13 9:48 ` Harald Seiler
2018-12-13 10:03 ` Claudius Heine
2018-12-13 10:09 ` Jan Kiszka
2018-12-13 12:40 ` Henning Schild
2018-12-13 12:46 ` Henning Schild
2018-12-13 13:00 ` Harald Seiler
2018-12-13 13:18 ` Henning Schild
2018-12-19 11:43 ` [PATCH v2] " Harald Seiler
2018-12-19 12:41 ` Henning Schild
2018-12-19 13:54 ` [PATCH v3] " Harald Seiler
2018-12-19 14:09 ` Henning Schild
2019-01-07 12:42 ` Maxim Yu. Osipov
2019-05-28 18:25 ` Henning Schild
2019-05-28 19:48 ` Henning Schild [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=20190528214848.4ed89f52@md1za8fc.ad001.siemens.net \
--to=henning.schild@siemens.com \
--cc=claudius.heine.ext@siemens.com \
--cc=hws@denx.de \
--cc=isar-users@googlegroups.com \
/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