Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/etc/rc.d /etc/rc.d/sshd: New check cmd and reload precmd.



details:   https://anonhg.NetBSD.org/src/rev/151f8dd100ab
branches:  trunk
changeset: 376013:151f8dd100ab
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Fri May 26 10:44:59 2023 +0000

description:
/etc/rc.d/sshd: New check cmd and reload precmd.

- check cmd: run `sshd -t' to check sshd_config file

- reload precmd: run check cmd before reloading so we don't nuke sshd
  if there's an error in the sshd_config file

(It is still possible to effectively nuke sshd by changing the
configuration tosomething that won't work on your network, but at
least we avoid making sshd just exit on reload when you make a typo
in a config option.)

XXX pullup-9
XXX pullup-10

diffstat:

 etc/rc.d/sshd |  16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diffs (41 lines):

diff -r d2bddff7d0dd -r 151f8dd100ab etc/rc.d/sshd
--- a/etc/rc.d/sshd     Fri May 26 10:39:56 2023 +0000
+++ b/etc/rc.d/sshd     Fri May 26 10:44:59 2023 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: sshd,v 1.32 2022/05/15 11:47:42 martin Exp $
+# $NetBSD: sshd,v 1.33 2023/05/26 10:44:59 riastradh Exp $
 #
 
 # PROVIDE: sshd
@@ -13,7 +13,7 @@ rcvar=$name
 command="/usr/sbin/${name}"
 pidfile="/var/run/${name}.pid"
 required_files="/etc/ssh/sshd_config"
-extra_commands="keygen keyregen reload"
+extra_commands="check keygen keyregen reload"
 
 sshd_motd_unsafe_keys_warning()
 {
@@ -77,8 +77,20 @@ sshd_precmd()
        run_rc_command keygen
 }
 
+sshd_check()
+{
+       sshd -t
+}
+
+sshd_reload_precmd()
+{
+       run_rc_command check
+}
+
+check_cmd=sshd_check
 keygen_cmd=sshd_keygen
 keyregen_cmd="sshd_keygen force"
+reload_precmd=sshd_reload_precmd
 start_precmd=sshd_precmd
 
 load_rc_config $name



Home | Main Index | Thread Index | Old Index