[Bug 2641] Add systemd notify code to to track running server

bugzilla-daemon at mindrot.org bugzilla-daemon at mindrot.org
Tue Apr 2 10:21:33 AEDT 2024


https://bugzilla.mindrot.org/show_bug.cgi?id=2641

Luca Boccassi <luca.boccassi at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Attachment #3802|0                           |1
        is obsolete|                            |

--- Comment #27 from Luca Boccassi <luca.boccassi at gmail.com> ---
Created attachment 3804
  --> https://bugzilla.mindrot.org/attachment.cgi?id=3804&action=edit
standalone notify and timestamp patch

> That's more tricky as the reload is called from signal handler context and we can't use snprint() there to format the usec part of the message. We'd have to refactor how sshd manages SIGHUP restarts.
>
> That would make some other things easier, but it's still a bigger change.

I went back and had a look at this, and unless I am missing something
the reloading message is not being sent from the signal handler?

The handler is sighup_handler which just sets a boolean and returns,
following the usual pattern:

https://anongit.mindrot.org/openssh.git/tree/sshd.c#n298

but the notification message is sent from the platform_pre_restart()
hook, which is called from the main context from the main loop via
sighup_restart():

https://anongit.mindrot.org/openssh.git/tree/sshd.c#n304

This already does some logging, which uses format strings. Also
platform_pre_restart() already calls oom_adjust_restore() which also
uses format strings.

So I went ahead and did the necessary modifications in the latest
version, which also simplified the message handling as it can log
unconditionally now, and added the timestamp too.
I've tested this and seems to work just fine on Debian testing, I can
change ssh.service to Type=notify-reload and reloading works just fine,
including the state transitions.

-- 
You are receiving this mail because:
You are watching someone on the CC list of the bug.
You are watching the assignee of the bug.


More information about the openssh-bugs mailing list