Debian Bug report logs - #778913
openssh-server: init (at least systemd) doesn't notice when sshd fails to start and reports success

version graph

Package: openssh-server; Maintainer for openssh-server is Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>; Source for openssh-server is src:openssh (PTS, buildd, popcon).

Reported by: Christoph Anton Mitterer <calestyo@scientia.net>

Date: Sat, 21 Feb 2015 18:12:02 UTC

Severity: important

Tags: patch

Found in version openssh/1:6.7p1-3

Fixed in version openssh/1:7.1p1-5

Done: Colin Watson <cjwatson@debian.org>

Bug is archived. No further changes may be made.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>:
Bug#778913; Package openssh-server. (Sat, 21 Feb 2015 18:12:06 GMT) (full text, mbox, link).


Acknowledgement sent to Christoph Anton Mitterer <calestyo@scientia.net>:
New Bug report received and forwarded. Copy sent to Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>. (Sat, 21 Feb 2015 18:12:07 GMT) (full text, mbox, link).


Message #5 received at submit@bugs.debian.org (full text, mbox, reply):

From: Christoph Anton Mitterer <calestyo@scientia.net>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: openssh-server: init (at least systemd) doesn't notice when sshd fails to start and reports success
Date: Sat, 21 Feb 2015 19:08:56 +0100
Package: openssh-server
Version: 1:6.7p1-3
Severity: important


Hi.

I've just tried that with systemd now,... starting the ssh service
there always yields in a success (status 0, green "OK"), even when
it actually failed to start.

Simply add some invalid config option to sshd_config, restart and
you'll se.
Only when you go in "deeper" like systemctl status ssh.service, you'll
see the actual error messages.


Cheers,
Chris.



Information forwarded to debian-bugs-dist@lists.debian.org, Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>:
Bug#778913; Package openssh-server. (Sun, 22 Feb 2015 11:51:08 GMT) (full text, mbox, link).


Acknowledgement sent to Colin Watson <cjwatson@debian.org>:
Extra info received and forwarded to list. Copy sent to Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>. (Sun, 22 Feb 2015 11:51:08 GMT) (full text, mbox, link).


Message #10 received at 778913@bugs.debian.org (full text, mbox, reply):

From: Colin Watson <cjwatson@debian.org>
To: Christoph Anton Mitterer <calestyo@scientia.net>, 778913@bugs.debian.org
Subject: Re: Bug#778913: openssh-server: init (at least systemd) doesn't notice when sshd fails to start and reports success
Date: Sun, 22 Feb 2015 11:46:26 +0000
On Sat, Feb 21, 2015 at 07:08:56PM +0100, Christoph Anton Mitterer wrote:
> I've just tried that with systemd now,... starting the ssh service
> there always yields in a success (status 0, green "OK"), even when
> it actually failed to start.
> 
> Simply add some invalid config option to sshd_config, restart and
> you'll se.
> Only when you go in "deeper" like systemctl status ssh.service, you'll
> see the actual error messages.

Thanks.  Do you think this would be suitable?  It seems to have the
right effect here.

diff --git a/debian/systemd/ssh.service b/debian/systemd/ssh.service
index ff28d39..cccafde 100644
--- a/debian/systemd/ssh.service
+++ b/debian/systemd/ssh.service
@@ -5,6 +5,7 @@ ConditionPathExists=!/etc/ssh/sshd_not_to_be_run
 
 [Service]
 EnvironmentFile=-/etc/default/ssh
+ExecStartPre=/usr/sbin/sshd -t
 ExecStart=/usr/sbin/sshd -D $SSHD_OPTS
 ExecReload=/bin/kill -HUP $MAINPID
 KillMode=process

-- 
Colin Watson                                       [cjwatson@debian.org]



Information forwarded to debian-bugs-dist@lists.debian.org, Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>:
Bug#778913; Package openssh-server. (Sun, 22 Feb 2015 17:12:10 GMT) (full text, mbox, link).


Acknowledgement sent to Christoph Anton Mitterer <calestyo@scientia.net>:
Extra info received and forwarded to list. Copy sent to Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>. (Sun, 22 Feb 2015 17:12:10 GMT) (full text, mbox, link).


Message #15 received at 778913@bugs.debian.org (full text, mbox, reply):

From: Christoph Anton Mitterer <calestyo@scientia.net>
To: 778913@bugs.debian.org
Subject: Re: Bug#778913: openssh-server: init (at least systemd) doesn't notice when sshd fails to start and reports success
Date: Sun, 22 Feb 2015 18:09:28 +0100
[Message part 1 (text/plain, inline)]
On Sun, 2015-02-22 at 11:46 +0000, Colin Watson wrote: 
> Thanks.  Do you think this would be suitable?  It seems to have the
> right effect here.
> +ExecStartPre=/usr/sbin/sshd -t

Well I'm a bit unsure... it practically fixes the problem, but
a) It still doesn't catch any cases when sshd crashes for any other
reason (and I think it should since systemd is also designed to have
watchdog capabilities and that like).

b) There's probably a short time between the -t check and running the
daemon, in which the config could change again.

Cheers,
Chris.
[smime.p7s (application/x-pkcs7-signature, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>:
Bug#778913; Package openssh-server. (Sun, 22 Feb 2015 17:57:07 GMT) (full text, mbox, link).


Acknowledgement sent to Colin Watson <cjwatson@debian.org>:
Extra info received and forwarded to list. Copy sent to Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>. (Sun, 22 Feb 2015 17:57:08 GMT) (full text, mbox, link).


Message #20 received at 778913@bugs.debian.org (full text, mbox, reply):

From: Colin Watson <cjwatson@debian.org>
To: Christoph Anton Mitterer <calestyo@scientia.net>, 778913@bugs.debian.org
Subject: Re: Bug#778913: openssh-server: init (at least systemd) doesn't notice when sshd fails to start and reports success
Date: Sun, 22 Feb 2015 17:53:06 +0000
On Sun, Feb 22, 2015 at 06:09:28PM +0100, Christoph Anton Mitterer wrote:
> On Sun, 2015-02-22 at 11:46 +0000, Colin Watson wrote: 
> > Thanks.  Do you think this would be suitable?  It seems to have the
> > right effect here.
> > +ExecStartPre=/usr/sbin/sshd -t
> 
> Well I'm a bit unsure... it practically fixes the problem, but
> a) It still doesn't catch any cases when sshd crashes for any other
> reason (and I think it should since systemd is also designed to have
> watchdog capabilities and that like).
> 
> b) There's probably a short time between the -t check and running the
> daemon, in which the config could change again.

Well, um, in either case, isn't it pretty weird that "systemctl status"
shows the unit as failed while the boot progress system shows it as OK?
Feels like a systemd bug to me.

-- 
Colin Watson                                       [cjwatson@debian.org]



Information forwarded to debian-bugs-dist@lists.debian.org, Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>:
Bug#778913; Package openssh-server. (Sun, 22 Feb 2015 18:03:08 GMT) (full text, mbox, link).


Acknowledgement sent to Christoph Anton Mitterer <calestyo@scientia.net>:
Extra info received and forwarded to list. Copy sent to Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>. (Sun, 22 Feb 2015 18:03:08 GMT) (full text, mbox, link).


Message #25 received at 778913@bugs.debian.org (full text, mbox, reply):

From: Christoph Anton Mitterer <calestyo@scientia.net>
To: 778913@bugs.debian.org
Cc: pkg-systemd-maintainers@lists.alioth.debian.org
Subject: Re: Bug#778913: openssh-server: init (at least systemd) doesn't notice when sshd fails to start and reports success
Date: Sun, 22 Feb 2015 19:01:01 +0100
[Message part 1 (text/plain, inline)]
On Sun, 2015-02-22 at 17:53 +0000, Colin Watson wrote: 
> Well, um, in either case, isn't it pretty weird that "systemctl status"
> shows the unit as failed while the boot progress system shows it as OK?
> Feels like a systemd bug to me.
Arguably, I'mm CCing the systemd guys, perhaps they can help out!

The exit status returned by sshd is 255 (anyhow special to systemd?): 
# /usr/sbin/sshd -D -p 50000
/etc/ssh/sshd_config line 151: AuthorizedKeysCommand must be an absolute path
# echo $?
255



Cheers,
Chris.
[smime.p7s (application/x-pkcs7-signature, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>:
Bug#778913; Package openssh-server. (Sun, 22 Feb 2015 18:48:08 GMT) (full text, mbox, link).


Acknowledgement sent to Russ Allbery <rra@debian.org>:
Extra info received and forwarded to list. Copy sent to Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>. (Sun, 22 Feb 2015 18:48:08 GMT) (full text, mbox, link).


Message #30 received at 778913@bugs.debian.org (full text, mbox, reply):

From: Russ Allbery <rra@debian.org>
To: Colin Watson <cjwatson@debian.org>
Cc: Christoph Anton Mitterer <calestyo@scientia.net>, 778913@bugs.debian.org, pkg-systemd-maintainers@lists.alioth.debian.org
Subject: Re: Bug#778913: openssh-server: init (at least systemd) doesn't notice when sshd fails to start and reports success
Date: Sun, 22 Feb 2015 10:45:42 -0800
Colin Watson <cjwatson@debian.org> writes:
> On Sun, Feb 22, 2015 at 06:09:28PM +0100, Christoph Anton Mitterer wrote:

>> Well I'm a bit unsure... it practically fixes the problem, but a) It
>> still doesn't catch any cases when sshd crashes for any other reason
>> (and I think it should since systemd is also designed to have watchdog
>> capabilities and that like).

>> b) There's probably a short time between the -t check and running the
>> daemon, in which the config could change again.

> Well, um, in either case, isn't it pretty weird that "systemctl status"
> shows the unit as failed while the boot progress system shows it as OK?
> Feels like a systemd bug to me.

That's the problem with forking services that don't have status
notification.  The default is Type=simple, which per systemd.service(5):

    If set to simple (the default value if neither Type= nor BusName=
    are specified), it is expected that the process configured with
    ExecStart= is the main process of the service. In this mode, if the
    process offers functionality to other processes on the system, its
    communication channels should be installed before the daemon is
    started up (e.g. sockets set up by systemd, via socket activation),
    as systemd will immediately proceed starting follow-up units.

That last clause is exactly the problem that you're running into.  A
Type=simple service says to run the command and immediately assume
success.

Type=forking plus PIDFile should be a minor improvement, assuming sshd
does all of its checking before it forks.  The best systemd behavior,
though, would come from adding sd_notify support so that sshd can
affirmatively tell systemd whether it succeeded in startup or not, and
then using Type=notify.  Then sshd startup won't be considered complete
until the sshd daemon calls sd_notify, and the correct status will be
reported if it exits for some reason before doing so.

-- 
Russ Allbery (rra@debian.org)               <http://www.eyrie.org/~eagle/>



Information forwarded to debian-bugs-dist@lists.debian.org, Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>:
Bug#778913; Package openssh-server. (Sun, 29 Mar 2015 23:21:05 GMT) (full text, mbox, link).


Acknowledgement sent to Michael Biebl <biebl@debian.org>:
Extra info received and forwarded to list. Copy sent to Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>. (Sun, 29 Mar 2015 23:21:05 GMT) (full text, mbox, link).


Message #35 received at 778913@bugs.debian.org (full text, mbox, reply):

From: Michael Biebl <biebl@debian.org>
To: Russ Allbery <rra@debian.org>, Colin Watson <cjwatson@debian.org>
Cc: pkg-systemd-maintainers@lists.alioth.debian.org, Christoph Anton Mitterer <calestyo@scientia.net>, 778913@bugs.debian.org
Subject: Re: Bug#778913: openssh-server: init (at least systemd) doesn't notice when sshd fails to start and reports success
Date: Mon, 30 Mar 2015 01:17:59 +0200
[Message part 1 (text/plain, inline)]
Am 22.02.2015 um 19:45 schrieb Russ Allbery:
> That's the problem with forking services that don't have status
> notification.  The default is Type=simple, which per systemd.service(5):
> 
>     If set to simple (the default value if neither Type= nor BusName=
>     are specified), it is expected that the process configured with
>     ExecStart= is the main process of the service. In this mode, if the
>     process offers functionality to other processes on the system, its
>     communication channels should be installed before the daemon is
>     started up (e.g. sockets set up by systemd, via socket activation),
>     as systemd will immediately proceed starting follow-up units.
> 
> That last clause is exactly the problem that you're running into.  A
> Type=simple service says to run the command and immediately assume
> success.
> 
> Type=forking plus PIDFile should be a minor improvement, assuming sshd
> does all of its checking before it forks.  The best systemd behavior,
> though, would come from adding sd_notify support so that sshd can
> affirmatively tell systemd whether it succeeded in startup or not, and
> then using Type=notify.  Then sshd startup won't be considered complete
> until the sshd daemon calls sd_notify, and the correct status will be
> reported if it exits for some reason before doing so.
> 

Russ' explanation is excellent and exactly the problem you are running into.

If you change the service file to Type=forking as Russ advised, this
would be a slight improvement, as systemd would now detect the failure
to start the daemon. It has a gotcha though. Since you use
Restart=on-failure, systemd would restart the ssh daemon on config
errors, until it hits the restart limit. This would look like this then:

# systemctl start ssh.service
Job for ssh.service failed. See 'systemctl status ssh.service' and
'journalctl -xn' for details.
# systemctl status ssh.service
● ssh.service - OpenBSD Secure Shell server
   Loaded: loaded (/etc/systemd/system/ssh.service; enabled)
   Active: failed (Result: start-limit) since Mo 2015-03-30 00:59:07
CEST; 2s ago
  Process: 11646 ExecStart=/usr/sbin/sshd $SSHD_OPTS (code=exited,
status=255)
 Main PID: 3849 (code=exited, status=255)

Mär 30 00:59:06 pluto systemd[1]: Failed to start OpenBSD Secure Shell
server.
Mär 30 00:59:06 pluto systemd[1]: Unit ssh.service entered failed state.
Mär 30 00:59:07 pluto systemd[1]: ssh.service start request repeated too
quickly, refusing to start.
Mär 30 00:59:07 pluto systemd[1]: Failed to start OpenBSD Secure Shell
server.
Mär 30 00:59:07 pluto systemd[1]: Unit ssh.service entered failed state.


Not really what we want either.

As Russ pointed out, using sd_notify would be the best option, but it's
too late for jessie, but maybe something to consider for stretch.

So I suggest using the Type=forking option but also setting
RestartPreventExitStatus=255 [1], since 255 seems to be the return code
on config errors and I don't think it makes sense to restart in that case.

The resulting ssh.service would look like

[Unit]
Description=OpenBSD Secure Shell server
After=network.target auditd.service
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run

[Service]
EnvironmentFile=-/etc/default/ssh
ExecStart=/usr/sbin/sshd $SSHD_OPTS
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
Type=forking
PIDFile=/var/run/sshd.pid
RestartPreventExitStatus=255

[Install]
WantedBy=multi-user.target
Alias=sshd.service


With those changes, ssh.service ssems to behave "as expected" on failures.


Michael

[1]
http://www.freedesktop.org/software/systemd/man/systemd.service.html#RestartPreventExitStatus=
-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>:
Bug#778913; Package openssh-server. (Mon, 30 Mar 2015 02:06:09 GMT) (full text, mbox, link).


Acknowledgement sent to Christoph Anton Mitterer <calestyo@scientia.net>:
Extra info received and forwarded to list. Copy sent to Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>. (Mon, 30 Mar 2015 02:06:09 GMT) (full text, mbox, link).


Message #40 received at 778913@bugs.debian.org (full text, mbox, reply):

From: Christoph Anton Mitterer <calestyo@scientia.net>
To: 778913@bugs.debian.org
Subject: Re: Bug#778913: openssh-server: init (at least systemd) doesn't notice when sshd fails to start and reports success
Date: Mon, 30 Mar 2015 04:02:01 +0200
[Message part 1 (text/plain, inline)]
Hi Michael.

Your proposal seems to be a good solution for now. Maybe Colin can merge
it and it will find it's way into jessie.

As for sd_notify,... a simply google query didn't turn up any existing
patches for that and it may be hard to convince upstream to do it ;)


Since this problem may affect other services as well... is there some
concentrated effort in Debian to identify these?

While systemd is great (in theory) I still feel that we (and others
either) don't use even a fraction of the goodness it could do.
Just look at the other bug that you've just closed before, and the
issues about services depending on "facilities" like "firewall rules
loaded" (network-pre.target is really a very unfortunate solution for
this... how regrettable that upstream went that way, even though better
ideas were in place :( ).
As you said, it's up to the respective package's maintainers, which
effectively means that either nothing of the new nice stuff gets used or
at least not homogeneously over all services.
So in the end, having a powerful framework where the admin can easily
control which "facilites" are mandatory for which services, as I've
proposed, would be up to the user.


Best wishes,
Chris.

[smime.p7s (application/x-pkcs7-signature, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>:
Bug#778913; Package openssh-server. (Mon, 30 Mar 2015 06:36:04 GMT) (full text, mbox, link).


Acknowledgement sent to Michael Biebl <biebl@debian.org>:
Extra info received and forwarded to list. Copy sent to Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>. (Mon, 30 Mar 2015 06:36:04 GMT) (full text, mbox, link).


Message #45 received at 778913@bugs.debian.org (full text, mbox, reply):

From: Michael Biebl <biebl@debian.org>
To: Russ Allbery <rra@debian.org>, Colin Watson <cjwatson@debian.org>
Cc: pkg-systemd-maintainers@lists.alioth.debian.org, Christoph Anton Mitterer <calestyo@scientia.net>, 778913@bugs.debian.org
Subject: Re: Bug#778913: openssh-server: init (at least systemd) doesn't notice when sshd fails to start and reports success
Date: Mon, 30 Mar 2015 08:33:11 +0200
[Message part 1 (text/plain, inline)]
Am 30.03.2015 um 01:17 schrieb Michael Biebl:
> So I suggest using the Type=forking option but also setting
> RestartPreventExitStatus=255 [1], since 255 seems to be the return code
> on config errors and I don't think it makes sense to restart in that case.
> 
> The resulting ssh.service would look like
> 
> [Unit]
> Description=OpenBSD Secure Shell server
> After=network.target auditd.service
> ConditionPathExists=!/etc/ssh/sshd_not_to_be_run
> 
> [Service]
> EnvironmentFile=-/etc/default/ssh
> ExecStart=/usr/sbin/sshd $SSHD_OPTS
> ExecReload=/bin/kill -HUP $MAINPID
> KillMode=process
> Restart=on-failure
> Type=forking
> PIDFile=/var/run/sshd.pid
> RestartPreventExitStatus=255
> 
> [Install]
> WantedBy=multi-user.target
> Alias=sshd.service
> 
> 
> With those changes, ssh.service ssems to behave "as expected" on failures.

I spoke too soon. As it turns out, sshd has a rather strange, or let's
say broken, SIGHUP behaviour (when in daemon mode): It reexecs, i.e.
changes its PID but doesn't write a new /var/run/sshd.pid. Since ssh
runs reload in it's if-up.d hook under systemd, this will break make it
break badly, since systemd will lose track of the sshd main process.

Colin, any idea, why sshd behaves so strange on SIGHUP?




-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>:
Bug#778913; Package openssh-server. (Tue, 12 May 2015 11:48:05 GMT) (full text, mbox, link).


Acknowledgement sent to Michael Biebl <biebl@debian.org>:
Extra info received and forwarded to list. Copy sent to Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>. (Tue, 12 May 2015 11:48:05 GMT) (full text, mbox, link).


Message #50 received at 778913@bugs.debian.org (full text, mbox, reply):

From: Michael Biebl <biebl@debian.org>
To: 778913@bugs.debian.org, Christoph Anton Mitterer <calestyo@scientia.net>
Subject: Re: Bug#778913: openssh-server: init (at least systemd) doesn't notice when sshd fails to start and reports success
Date: Tue, 12 May 2015 13:45:10 +0200
[Message part 1 (text/plain, inline)]
On Mon, 30 Mar 2015 04:02:01 +0200 Christoph Anton Mitterer
<calestyo@scientia.net> wrote:
> Hi Michael.

(since this was targetted at me, you should have CCed me. I don't get
openssh-server bug mail)

> Your proposal seems to be a good solution for now. Maybe Colin can merge
> it and it will find it's way into jessie.

See my followup [1], Type=forking turned up to have it's own set of
problems.

> As for sd_notify,... a simply google query didn't turn up any existing
> patches for that and it may be hard to convince upstream to do it ;)

A patch for that should be not that complicated and might even be worth
shipping downstream if upstream doesn't want to apply it.

> Since this problem may affect other services as well... is there some
> concentrated effort in Debian to identify these?

Not that I'm aware of.

Michael


[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=778913#45

-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>:
Bug#778913; Package openssh-server. (Tue, 12 May 2015 15:09:11 GMT) (full text, mbox, link).


Acknowledgement sent to Michael Biebl <biebl@debian.org>:
Extra info received and forwarded to list. Copy sent to Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>. (Tue, 12 May 2015 15:09:11 GMT) (full text, mbox, link).


Message #55 received at 778913@bugs.debian.org (full text, mbox, reply):

From: Michael Biebl <biebl@debian.org>
To: 778913@bugs.debian.org, Christoph Anton Mitterer <calestyo@scientia.net>
Cc: Debian systemd Maintainers <pkg-systemd-maintainers@lists.alioth.debian.org>
Subject: Re: Bug#778913: openssh-server: init (at least systemd) doesn't notice when sshd fails to start and reports success
Date: Tue, 12 May 2015 17:07:45 +0200
[Message part 1 (text/plain, inline)]
Control: tags -1 + patch

Am 12.05.2015 um 13:45 schrieb Michael Biebl:
> On Mon, 30 Mar 2015 04:02:01 +0200 Christoph Anton Mitterer
>> As for sd_notify,... a simply google query didn't turn up any existing
>> patches for that and it may be hard to convince upstream to do it ;)
> 
> A patch for that should be not that complicated and might even be worth
> shipping downstream if upstream doesn't want to apply it.

Attached is a patch which adds support for sd_notify.
The configure.ac changes are a bit more convoluted then I hoped since 
openssh doesn't use the pkg-config provided macros.


A quick test (with a broken configuration file) at least seems to 
properly error out:


root@pluto:~# systemctl status ssh.service 
● ssh.service - OpenBSD Secure Shell server
   Loaded: loaded (/etc/systemd/system/ssh.service; enabled)
   Active: active (running) since Di 2015-05-12 17:03:28 CEST; 4s ago
 Main PID: 13021 (sshd)
   CGroup: /system.slice/ssh.service
           └─13021 /usr/sbin/sshd -D

Mai 12 17:03:28 pluto sshd[13021]: Server listening on 0.0.0.0 port 22.
Mai 12 17:03:28 pluto sshd[13021]: Server listening on :: port 22.

root@pluto:~# echo foobar >> /etc/ssh/sshd_config 

root@pluto:~# systemctl restart ssh.service 
Job for ssh.service failed. See 'systemctl status ssh.service' and 'journalctl -xn' for details.

root@pluto:~# systemctl status ssh.service 
● ssh.service - OpenBSD Secure Shell server
   Loaded: loaded (/etc/systemd/system/ssh.service; enabled)
   Active: failed (Result: start-limit) since Di 2015-05-12 17:03:51 CEST; 5s ago
  Process: 13053 ExecStart=/usr/sbin/sshd -D $SSHD_OPTS (code=exited, status=255)
 Main PID: 13053 (code=exited, status=255)

Mai 12 17:03:51 pluto sshd[13053]: /etc/ssh/sshd_config: terminating, 1 bad configuration options
Mai 12 17:03:51 pluto systemd[1]: ssh.service: main process exited, code=exited, status=255/n/a
Mai 12 17:03:51 pluto systemd[1]: Failed to start OpenBSD Secure Shell server.
Mai 12 17:03:51 pluto systemd[1]: Unit ssh.service entered failed state.
Mai 12 17:03:51 pluto systemd[1]: ssh.service start request repeated too quickly, refusing to start.
Mai 12 17:03:51 pluto systemd[1]: Failed to start OpenBSD Secure Shell server.
Mai 12 17:03:51 pluto systemd[1]: Unit ssh.service entered failed state.


As you can see, systemd tries to repeatedly start the service until it hits
start-limit.
We should use sd_notify in that case to pass a correct error code to systemd.

The patch is not complete yet, more a PoC.

That said, would be glad if Colin could give it some proper review.
Don't want to spend time on it, if it's unlikely to get merged.


Michael
-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?
[sshd.diff (text/x-patch, attachment)]
[signature.asc (application/pgp-signature, attachment)]

Added tag(s) patch. Request was from Michael Biebl <biebl@debian.org> to 778913-submit@bugs.debian.org. (Tue, 12 May 2015 15:09:11 GMT) (full text, mbox, link).


Information forwarded to debian-bugs-dist@lists.debian.org, Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>:
Bug#778913; Package openssh-server. (Tue, 12 May 2015 15:45:06 GMT) (full text, mbox, link).


Acknowledgement sent to Michael Biebl <biebl@debian.org>:
Extra info received and forwarded to list. Copy sent to Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>. (Tue, 12 May 2015 15:45:06 GMT) (full text, mbox, link).


Message #62 received at 778913@bugs.debian.org (full text, mbox, reply):

From: Michael Biebl <biebl@debian.org>
To: 778913@bugs.debian.org, Christoph Anton Mitterer <calestyo@scientia.net>
Cc: Debian systemd Maintainers <pkg-systemd-maintainers@lists.alioth.debian.org>
Subject: Re: Bug#778913: openssh-server: init (at least systemd) doesn't notice when sshd fails to start and reports success
Date: Tue, 12 May 2015 17:42:46 +0200
[Message part 1 (text/plain, inline)]
Am 12.05.2015 um 17:07 schrieb Michael Biebl:
> root@pluto:~# echo foobar >> /etc/ssh/sshd_config 
> 
> root@pluto:~# systemctl restart ssh.service 
> Job for ssh.service failed. See 'systemctl status ssh.service' and 'journalctl -xn' for details.
> 
> root@pluto:~# systemctl status ssh.service 
> ● ssh.service - OpenBSD Secure Shell server
>    Loaded: loaded (/etc/systemd/system/ssh.service; enabled)
>    Active: failed (Result: start-limit) since Di 2015-05-12 17:03:51 CEST; 5s ago
>   Process: 13053 ExecStart=/usr/sbin/sshd -D $SSHD_OPTS (code=exited, status=255)
>  Main PID: 13053 (code=exited, status=255)
> 
> Mai 12 17:03:51 pluto sshd[13053]: /etc/ssh/sshd_config: terminating, 1 bad configuration options
> Mai 12 17:03:51 pluto systemd[1]: ssh.service: main process exited, code=exited, status=255/n/a
> Mai 12 17:03:51 pluto systemd[1]: Failed to start OpenBSD Secure Shell server.
> Mai 12 17:03:51 pluto systemd[1]: Unit ssh.service entered failed state.
> Mai 12 17:03:51 pluto systemd[1]: ssh.service start request repeated too quickly, refusing to start.
> Mai 12 17:03:51 pluto systemd[1]: Failed to start OpenBSD Secure Shell server.
> Mai 12 17:03:51 pluto systemd[1]: Unit ssh.service entered failed state.
> 
> 
> As you can see, systemd tries to repeatedly start the service until it hits
> start-limit.
> We should use sd_notify in that case to pass a correct error code to systemd.

Or we could use what's been proposed by Colin, i.e.
 ExecStartPre=/usr/bin/sshd -t
or my
 RestartPreventExitStatus=255

The latter has the benefit, that we don't need to parse the config twice
and there is no race condition between ExecStartPre and ExecStart where
the config file might have been modified.

-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>:
Bug#778913; Package openssh-server. (Tue, 12 May 2015 20:57:10 GMT) (full text, mbox, link).


Acknowledgement sent to Michael Biebl <biebl@debian.org>:
Extra info received and forwarded to list. Copy sent to Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>. (Tue, 12 May 2015 20:57:10 GMT) (full text, mbox, link).


Message #67 received at 778913@bugs.debian.org (full text, mbox, reply):

From: Michael Biebl <biebl@debian.org>
To: 778913@bugs.debian.org, Christoph Anton Mitterer <calestyo@scientia.net>
Cc: Debian systemd Maintainers <pkg-systemd-maintainers@lists.alioth.debian.org>
Subject: Re: Bug#778913: openssh-server: init (at least systemd) doesn't notice when sshd fails to start and reports success
Date: Tue, 12 May 2015 22:54:04 +0200
[Message part 1 (text/plain, inline)]
Am 12.05.2015 um 17:42 schrieb Michael Biebl:
> Am 12.05.2015 um 17:07 schrieb Michael Biebl:

>> As you can see, systemd tries to repeatedly start the service until it hits
>> start-limit.
>> We should use sd_notify in that case to pass a correct error code to systemd.
> 
> Or we could use what's been proposed by Colin, i.e.
>  ExecStartPre=/usr/bin/sshd -t
> or my
>  RestartPreventExitStatus=255

Updated patch, adding RestartPreventExitStatus=, attached.

From my limited testing, seems to work fine here.


-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?
[sshd-v2.diff (text/x-patch, attachment)]
[signature.asc (application/pgp-signature, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>:
Bug#778913; Package openssh-server. (Wed, 13 May 2015 00:57:04 GMT) (full text, mbox, link).


Acknowledgement sent to Christoph Anton Mitterer <calestyo@scientia.net>:
Extra info received and forwarded to list. Copy sent to Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>. (Wed, 13 May 2015 00:57:04 GMT) (full text, mbox, link).


Message #72 received at 778913@bugs.debian.org (full text, mbox, reply):

From: Christoph Anton Mitterer <calestyo@scientia.net>
To: Michael Biebl <biebl@debian.org>
Cc: 778913@bugs.debian.org
Subject: Re: Bug#778913: openssh-server: init (at least systemd) doesn't notice when sshd fails to start and reports success
Date: Wed, 13 May 2015 02:55:12 +0200
[Message part 1 (text/plain, inline)]
On Tue, 2015-05-12 at 13:45 +0200, Michael Biebl wrote: 
> (since this was targetted at me, you should have CCed me. I don't get
> openssh-server bug mail)
Sorry,... must have dropped out somehow.

> A patch for that should be not that complicated and might even be worth
> shipping downstream if upstream doesn't want to apply it.
Well I don't know... I just said it "might"... could you propose the
patch upstream? I can do it for you, but I think it would be impolite
and you're probably better suited to do so, should further modifications
be required.


Cheers,
Chris.
[smime.p7s (application/x-pkcs7-signature, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>:
Bug#778913; Package openssh-server. (Thu, 10 Sep 2015 16:15:07 GMT) (full text, mbox, link).


Acknowledgement sent to Michael Biebl <biebl@debian.org>:
Extra info received and forwarded to list. Copy sent to Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>. (Thu, 10 Sep 2015 16:15:07 GMT) (full text, mbox, link).


Message #77 received at 778913@bugs.debian.org (full text, mbox, reply):

From: Michael Biebl <biebl@debian.org>
To: 778913@bugs.debian.org
Subject: Re: Bug#778913: openssh-server: init (at least systemd) doesn't notice when sshd fails to start and reports success
Date: Thu, 10 Sep 2015 18:13:24 +0200
[Message part 1 (text/plain, inline)]
Hi Colin!

On Tue, 12 May 2015 22:54:04 +0200 Michael Biebl <biebl@debian.org> wrote:
> Am 12.05.2015 um 17:42 schrieb Michael Biebl:
> > Am 12.05.2015 um 17:07 schrieb Michael Biebl:
> 
> >> As you can see, systemd tries to repeatedly start the service until it hits
> >> start-limit.
> >> We should use sd_notify in that case to pass a correct error code to systemd.
> > 
> > Or we could use what's been proposed by Colin, i.e.
> >  ExecStartPre=/usr/bin/sshd -t
> > or my
> >  RestartPreventExitStatus=255
> 
> Updated patch, adding RestartPreventExitStatus=, attached.
> 
> From my limited testing, seems to work fine here.

Now that jessie is out the door, it would be a great time to apply this
patch and solve this issue for good.

Did you have time for a review yet?

Cheers,
Michael

-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>:
Bug#778913; Package openssh-server. (Sat, 14 Nov 2015 16:36:04 GMT) (full text, mbox, link).


Acknowledgement sent to Michael Biebl <biebl@debian.org>:
Extra info received and forwarded to list. Copy sent to Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>. (Sat, 14 Nov 2015 16:36:04 GMT) (full text, mbox, link).


Message #82 received at 778913@bugs.debian.org (full text, mbox, reply):

From: Michael Biebl <biebl@debian.org>
To: 778913@bugs.debian.org
Subject: Re: Bug#778913: openssh-server: init (at least systemd) doesn't notice when sshd fails to start and reports success
Date: Sat, 14 Nov 2015 17:33:12 +0100
[Message part 1 (text/plain, inline)]
On Thu, 10 Sep 2015 18:13:24 +0200 Michael Biebl <biebl@debian.org> wrote:
> Hi Colin!
> 
> On Tue, 12 May 2015 22:54:04 +0200 Michael Biebl <biebl@debian.org> wrote:
> > Am 12.05.2015 um 17:42 schrieb Michael Biebl:
> > > Am 12.05.2015 um 17:07 schrieb Michael Biebl:
> > 
> > >> As you can see, systemd tries to repeatedly start the service until it hits
> > >> start-limit.
> > >> We should use sd_notify in that case to pass a correct error code to systemd.
> > > 
> > > Or we could use what's been proposed by Colin, i.e.
> > >  ExecStartPre=/usr/bin/sshd -t
> > > or my
> > >  RestartPreventExitStatus=255
> > 
> > Updated patch, adding RestartPreventExitStatus=, attached.
> > 
> > From my limited testing, seems to work fine here.
> 
> Now that jessie is out the door, it would be a great time to apply this
> patch and solve this issue for good.
> 
> Did you have time for a review yet?

Hi Colin, I didn't receive any feedback on this patch yet.
Would be great if you can have a look so we can fix this issue for good.

Cheers,
Michael


-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>:
Bug#778913; Package openssh-server. (Sun, 20 Dec 2015 01:33:07 GMT) (full text, mbox, link).


Acknowledgement sent to Michael Biebl <biebl@debian.org>:
Extra info received and forwarded to list. Copy sent to Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>. (Sun, 20 Dec 2015 01:33:08 GMT) (full text, mbox, link).


Message #87 received at 778913@bugs.debian.org (full text, mbox, reply):

From: Michael Biebl <biebl@debian.org>
To: 778913@bugs.debian.org, Colin Watson <cjwatson@debian.org>
Subject: Re: Bug#778913: openssh-server: init (at least systemd) doesn't notice when sshd fails to start and reports success
Date: Sun, 20 Dec 2015 02:30:50 +0100
[Message part 1 (text/plain, inline)]
Hi Colin,

it's me again.

Am 14.11.2015 um 17:33 schrieb Michael Biebl:
> Hi Colin, I didn't receive any feedback on this patch yet.
> Would be great if you can have a look so we can fix this issue for good.

Do you have any thoughts/concerns regarding the proposed patch?
If you don't find the patch acceptable, do you have ideas how we can
address this differently?

I think it would be important to fix this properly now that systemd is
the default.

Regards,
Michael

-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>:
Bug#778913; Package openssh-server. (Mon, 21 Dec 2015 22:18:05 GMT) (full text, mbox, link).


Acknowledgement sent to Colin Watson <cjwatson@debian.org>:
Extra info received and forwarded to list. Copy sent to Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>. (Mon, 21 Dec 2015 22:18:05 GMT) (full text, mbox, link).


Message #92 received at 778913@bugs.debian.org (full text, mbox, reply):

From: Colin Watson <cjwatson@debian.org>
To: Michael Biebl <biebl@debian.org>, 778913@bugs.debian.org
Subject: Re: Bug#778913: openssh-server: init (at least systemd) doesn't notice when sshd fails to start and reports success
Date: Mon, 21 Dec 2015 22:14:47 +0000
On Sun, Dec 20, 2015 at 02:30:50AM +0100, Michael Biebl wrote:
> Am 14.11.2015 um 17:33 schrieb Michael Biebl:
> > Hi Colin, I didn't receive any feedback on this patch yet.
> > Would be great if you can have a look so we can fix this issue for good.
> 
> Do you have any thoughts/concerns regarding the proposed patch?
> If you don't find the patch acceptable, do you have ideas how we can
> address this differently?
> 
> I think it would be important to fix this properly now that systemd is
> the default.

Urgh, apologies!  The perils of using a threaded view of a large inbox
by default - I completely missed that you'd sent a patch here.

Your patch looks entirely fine to me.  I've uploaded it to unstable.

Thanks,

-- 
Colin Watson                                       [cjwatson@debian.org]



Reply sent to Colin Watson <cjwatson@debian.org>:
You have taken responsibility. (Mon, 21 Dec 2015 22:36:21 GMT) (full text, mbox, link).


Notification sent to Christoph Anton Mitterer <calestyo@scientia.net>:
Bug acknowledged by developer. (Mon, 21 Dec 2015 22:36:21 GMT) (full text, mbox, link).


Message #97 received at 778913-close@bugs.debian.org (full text, mbox, reply):

From: Colin Watson <cjwatson@debian.org>
To: 778913-close@bugs.debian.org
Subject: Bug#778913: fixed in openssh 1:7.1p1-5
Date: Mon, 21 Dec 2015 22:35:10 +0000
Source: openssh
Source-Version: 1:7.1p1-5

We believe that the bug you reported is fixed in the latest version of
openssh, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 778913@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Colin Watson <cjwatson@debian.org> (supplier of updated openssh package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Format: 1.8
Date: Mon, 21 Dec 2015 22:10:07 +0000
Source: openssh
Binary: openssh-client openssh-client-ssh1 openssh-server openssh-sftp-server ssh ssh-krb5 ssh-askpass-gnome openssh-client-udeb openssh-server-udeb
Architecture: source
Version: 1:7.1p1-5
Distribution: unstable
Urgency: medium
Maintainer: Debian OpenSSH Maintainers <debian-ssh@lists.debian.org>
Changed-By: Colin Watson <cjwatson@debian.org>
Description:
 openssh-client - secure shell (SSH) client, for secure access to remote machines
 openssh-client-ssh1 - secure shell (SSH) client for legacy SSH1 protocol
 openssh-client-udeb - secure shell client for the Debian installer (udeb)
 openssh-server - secure shell (SSH) server, for secure access from remote machines
 openssh-server-udeb - secure shell server for the Debian installer (udeb)
 openssh-sftp-server - secure shell (SSH) sftp server module, for SFTP access from remot
 ssh        - secure shell client and server (metapackage)
 ssh-askpass-gnome - interactive X program to prompt users for a passphrase for ssh-ad
 ssh-krb5   - secure shell client and server (transitional package)
Closes: 778913
Changes:
 openssh (1:7.1p1-5) unstable; urgency=medium
 .
   [ Michael Biebl ]
   * Add systemd readiness notification support (closes: #778913).
Checksums-Sha1:
 b99d2b69b850ef339d79fb614eb2cd0380d0619e 2835 openssh_7.1p1-5.dsc
 d76b0200294fe5eab428126ac06ac5cf0811d563 148576 openssh_7.1p1-5.debian.tar.xz
Checksums-Sha256:
 33bf683efda89e4fa6a2345ecf1b2a79a042452c7d3ce93bf905d8b0178436a0 2835 openssh_7.1p1-5.dsc
 006358f78529480abf526d21ce8777e1a28ae29d9157d825905ed066ff887e94 148576 openssh_7.1p1-5.debian.tar.xz
Files:
 6f6e6d1f9c48c53ef141e517f96bac49 2835 net standard openssh_7.1p1-5.dsc
 af0d6b729f5d651d0716adb6bf4d598c 148576 net standard openssh_7.1p1-5.debian.tar.xz

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Colin Watson <cjwatson@debian.org> -- Debian developer

iQIVAwUBVnh40jk1h9l9hlALAQhWgBAAjj9IF7k9/jNeFGNabRUWobmvBD9a9X8c
IBy4rkT8yuXMEau6GIvATbhbWkaBuEAgL0g4KqGQYApX0YC/JLpQWLeMY5+hPcfG
Rofi8MeDWo4ivW/WW71SQW+Ylo5T0yyGNSv1iTQtpyruHU66C3Bkj+MkgW25Ia6r
rsdJ0KWyLq4UTl1jFw1Ly9PAxgdXAENXCpUt2sghiC2JA1mKh7vaZAtTjTyW5K7B
rneRlqwB/44zOZvgYJnbyS3waGnoOugIpixl1Y8TnFTrN3ZFcbw1lBhOBTb7Smcz
fInGEwd5wa2Got7lN8VFdI1aKMzZE4K6K8EJQ4dGvC93wOKQub/0mnXv6aPlnjRc
6EXvRxsVKWTb8iQMfuZbLTwWx6VLzQwA/SFGewCKuO4nfjqred9MOcRj4NiGfUDk
JTjFXr9WkJXGZffVJkL6mc+ixXPZP26/3mBY/nJVoKP0YtrjJ/YO+tqux1ZDcnPy
fmpHMaREuSxTfcAAdH/+VD9j9SxOSI4OO7ESaU3uNTAYAfNZZrVp0iDVtj9Dbgb+
uMQVuWQ8u8Wq49kRHdfNke/8VtWc5pOlqExioNKjcJlc4l+gvZlj91LCyS3KvbOI
p8HW2jdj/fdBQpGoUw+UA+/NwuXHaCe5xjbZMXDzEa0BIwxuEZNyEOh2FltN+qv5
VkOU7Blll6s=
=rL5c
-----END PGP SIGNATURE-----




Bug archived. Request was from Debbugs Internal Request <owner@bugs.debian.org> to internal_control@bugs.debian.org. (Sun, 24 Jan 2016 07:26:31 GMT) (full text, mbox, link).


Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Thu Jan 4 04:29:58 2018; Machine Name: buxtehude

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.