From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6803364431668445184 X-Received: by 2002:aca:56c2:: with SMTP id k185mr3362977oib.141.1584034735853; Thu, 12 Mar 2020 10:38:55 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:aca:49cc:: with SMTP id w195ls1661660oia.10.gmail; Thu, 12 Mar 2020 10:38:55 -0700 (PDT) X-Received: by 2002:aca:3196:: with SMTP id x144mr3635451oix.77.1584034735550; Thu, 12 Mar 2020 10:38:55 -0700 (PDT) Received: by 2002:aca:4854:0:0:0:0:0 with SMTP id v81msoia; Thu, 12 Mar 2020 10:07:59 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuwNv/01GJ8A4mExPQlkQCabwlCapxoKnLXXrnUU2XK4j1M2pzwO4weXun+L0qEGOPrabv2B3tZJQ== X-Received: by 2002:a9d:4c15:: with SMTP id l21mr7409363otf.185.1584032878814; Thu, 12 Mar 2020 10:07:58 -0700 (PDT) X-Google-Thread-Subscription: Yes X-Google-Web-Client: true Date: Thu, 12 Mar 2020 10:07:58 -0700 (PDT) From: cedric_hombourger@mentor.com To: isar-users Message-Id: In-Reply-To: <20200312164837.20377-1-Quirin.Gylstorff@siemens.com> References: <20200312164837.20377-1-Quirin.Gylstorff@siemens.com> Subject: Re: [PATCH] sshd-regen-keys: fix race condition MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_364_130220660.1584032878677" X-Google-Token: EO7YqfMFCaOZG1wqxEg0 X-Google-IP: 139.181.48.2 X-TUID: DWbDyPR57AkU ------=_Part_364_130220660.1584032878677 Content-Type: multipart/alternative; boundary="----=_Part_365_187606125.1584032878677" ------=_Part_365_187606125.1584032878677 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On Thursday, March 12, 2020 at 5:48:39 PM UTC+1, Q. Gylstorff wrote: > > From: Quirin Gylstorff > > > Systemd waits with starting service until a oneshot is finished this leads > to a race condition if you try to restart a service in a oneshot. > > very good catch! > "Behavior of oneshot is similar to simple; however, the service manager > will consider > the unit started after the main process exits. It will then start > follow-up units. > RemainAfterExit= is particularly useful for this type of service. > Type=oneshot is the > implied default if neither Type= nor ExecStart= are specified."[1] > > [1]: man systemd.service > > Signed-off-by: Quirin Gylstorff > > --- > .../sshd-regen-keys/files/sshd-regen-keys.service | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > 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 a05e1a9..4c4dc0e 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 > @@ -7,7 +7,7 @@ Before=shutdown.target sshd.service > ConditionPathIsReadWrite=/etc > > [Service] > -Type=oneshot > +Type=simple > RemainAfterExit=yes > Environment=DEBIAN_FRONTEND=noninteractive > ExecStart=/usr/sbin/sshd-regen-keys.sh > -- > 2.20.1 > > ------=_Part_365_187606125.1584032878677 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable


On Thursday, March 12, 2020 at 5:48:39 PM UTC+1, Q= . Gylstorff wrote:
From: Quirin= Gylstorff <quirin....@siemens.com>

Systemd waits with starting service until a oneshot is finished this le= ads
to a race condition if you try to restart a service in a oneshot.


very good catch!
=C2=A0<= /div>
"Behavior of oneshot= is similar to simple; however, the service manager will consider
the unit started after the main process exits. It will then start follo= w-up units.
RemainAfterExit=3D is particularly useful for this type of service. =C2= =A0Type=3Doneshot is the
implied default if neither Type=3D nor ExecStart=3D are specified."= ;[1]

[1]: man systemd.service

Signed-off-by: Quirin Gylstorff <quirin....@siemens.com>
---
=C2=A0.../sshd-regen-keys/files/sshd-regen-keys.service =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | 2 +-
=C2=A01 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/recipes-support/sshd-regen-keys/files/sshd-regen= -keys.service b/meta/recipes-support/sshd-regen-keys/files/sshd-r= egen-keys.service
index a05e1a9..4c4dc0e 100644
--- a/meta/recipes-support/sshd-regen-keys/files/sshd-regen-k= eys.service
+++ b/meta/recipes-support/sshd-regen-keys/files/sshd-regen-k= eys.service
@@ -7,7 +7,7 @@ Before=3Dshutdown.target sshd.service
=C2=A0ConditionPathIsReadWrite=3D/etc
=C2=A0
=C2=A0[Service]
-Type=3Doneshot
+Type=3Dsimple
=C2=A0RemainAfterExit=3Dyes
=C2=A0Environment=3DDEBIAN_FRONTEND=3Dnoninteractive
=C2=A0ExecStart=3D/usr/sbin/sshd-regen-keys.sh
--=20
2.20.1

------=_Part_365_187606125.1584032878677-- ------=_Part_364_130220660.1584032878677--