public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Gylstorff Quirin <quirin.gylstorff@siemens.com>
To: Jan Kiszka <jan.kiszka@siemens.com>,
	isar-users@googlegroups.com, Baurzhan Ismagulov <ibr@ilbers.de>
Subject: Re: [PATCH] sshd-regen-keys: fix race condition
Date: Wed, 29 Apr 2020 10:11:35 +0200	[thread overview]
Message-ID: <99e1c48b-8717-bc56-f2fc-7d3299a15c66@siemens.com> (raw)
In-Reply-To: <82ef1e5c-42c6-8a53-b3d3-cbb3fa6a977b@siemens.com>

The problem as shown at my system was that in sshd-regen-keys calls
dpkg-reconfigure which calls systemd restart ssh. The restart of ssh
is blocked by the oneshot. If you use an onshot without dpkg-reconfigure
it is no problem.

So it is
oneshot.service starts ->  systemd restart some.service -> error
simple.service starts -> systemd restart some.service -> ok

This occures on Debian 10.

Quirin

On 4/28/20 8:22 AM, Jan Kiszka wrote:
> On 13.04.20 18:22, Baurzhan Ismagulov wrote:
>> Hello Quirin,
>>
>> On Thu, Mar 12, 2020 at 05:48:37PM +0100, Q. Gylstorff wrote:
>>> 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.
>>>
>>> "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
>>
>> Could you please help me understand the race you are facing? I've gone 
>> through
>> a couple of scenarios and couldn't identify one.
>>
>>
>> Apart from that, systemctl(1) says for enable:
>>
>> "Note that this does not have the effect of also starting any of the 
>> units
>> being enabled. If this is desired, combine this command with the --now 
>> switch,
>> or invoke start with appropriate arguments later."
>>
>> Similarly, for disable:
>>
>> "Note that this command does not implicitly stop the units that are being
>> disabled. If this is desired, either combine this command with the --now
>> switch, or invoke the stop command with appropriate arguments later."
>>
>> Considering the following scenario:
>>
>> 1. systemd starts ssh. It reads e.g. one key file but not others.
>>
>> 2. systemd starts sshd-regen-keys.sh. It disables ssh but doesn't stop 
>> it, then
>>     removes the keys.
>>
>> 3. sshd continues reading the other keys.
>>
>> Is it possible that sshd finds inconsistent set of keys or doesn't 
>> find the
>> other keys? Shouldn't we specify --now for both enable and disable?
>>
>>
>> With kind regards,
>> Baurzhan.
>>
> 
> Quirin, I think this is still open, and - being about to create another 
> one-shot service - I was wondering whether we need to fix more services.
> 
> Baurzhan, please fix your client settings so that you always preserve CC 
> lists when replying.
> 
> Thanks,
> Jan
> 

-- 
Quirin Gylstorff

Siemens AG
Corporate Technology
Research in Digitalization and Automation
Smart Embedded Systems
CT RDA IOT SES-DE
Otto-Hahn-Ring 6
81739 Muenchen, Germany
Mobile: +49 173 3746683
mailto:quirin.gylstorff@siemens.com
www.siemens.com/ingenuityforlife

Siemens Aktiengesellschaft: Chairman of the Supervisory Board: Jim 
Hagemann Snabe; Managing Board: Joe Kaeser, Chairman, President and 
Chief Executive Officer; Roland Busch, Lisa Davis, Klaus Helmrich, 
Cedrik Neike, Michael Sen, Ralf P. Thomas; Registered offices: Berlin 
and Munich, Germany; Commercial registries: Berlin Charlottenburg, HRB 
12300, Munich, HRB 6684; WEEE-Reg.-No. DE 23691322

Important notice: This e-mail and any attachment thereof contain 
corporate proprietary information. If you have received it by mistake, 
please notify us immediately by reply e-mail and delete this e-mail and 
its attachments from your system. Thank you.

      reply	other threads:[~2020-04-29  8:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-12 16:48 Q. Gylstorff
2020-03-12 17:07 ` cedric_hombourger
2020-04-13 16:22 ` Baurzhan Ismagulov
2020-04-28  6:22   ` Jan Kiszka
2020-04-29  8:11     ` Gylstorff Quirin [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=99e1c48b-8717-bc56-f2fc-7d3299a15c66@siemens.com \
    --to=quirin.gylstorff@siemens.com \
    --cc=ibr@ilbers.de \
    --cc=isar-users@googlegroups.com \
    --cc=jan.kiszka@siemens.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