mbox series

[0/4] Refactor OpenSSH init.d script

Message ID 20240612183136.2145705-1-fiona.klute@gmx.de
Headers show
Series Refactor OpenSSH init.d script | expand

Message

Fiona Klute June 12, 2024, 6:31 p.m. UTC
This series is the result of running "/etc/init.d/S50sshd restart"
over an SSH connection and finding that not only it destroyed my SSH
session, the SSH server also did not come back up. The main issue
there was the use of "killall sshd" instead of stopping only the
listening server (patch 1). I assume restarting the SSH server on a
Buildroot-created system is not a common use case, I need a reload to
reset its state during automated tests.

I took the opportunity to make some more improvements: style cleanup
(patch 2), implementing "reload" using SIGHUP (patch 3), and checking
for a running instance before starting a new one (patch 4).

The added checks for a currently running service before start/stop is
a slight change in behavior, there will be a non-zero exit code when
trying to start when sshd is already running, or stop when it's not. I
consider this useful to find errors in scripts instead of masking
them, but I don't mind removing that if it's considered a problem.

It'd be easy enough to remove the checkpatch error about
DAEMON/PIDFILE variables, too, but I'm not sure if that would make
sense: While the PIDFILE matches the required pattern it's not set by
the init script, it's the sshd default.

Fiona Klute (4):
  package/openssh: don't kill open sessions on restart
  package/openssh: fix init script indentation
  package/openssh: implement "reload" using SIGHUP
  package/openssh: check running instance on "start"

 .checkpackageignore     |  2 +-
 package/openssh/S50sshd | 61 ++++++++++++++++++++++++++++++-----------
 2 files changed, 46 insertions(+), 17 deletions(-)

--
2.45.1