The following changes were made:

* Corrected PrivSep home directory (/var/lib/sshd -l /var/run/sshd)
  * Minor cleanup of duplication in usher
  * Cleaned up init script
This commit is contained in:
2017-05-16 18:30:53 -05:00
parent 563812345d
commit fbb00bd666
3 changed files with 40 additions and 40 deletions

View File

@@ -1,9 +1,10 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: sshd
# Required-Start: $network $syslog
# Required-Stop: $network $syslog
# Should-Start:
# Should-Stop:
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: OpenBSD Secure Shell server
@@ -12,38 +13,45 @@
. /lib/lsb/init-functions
DAEMON=/usr/sbin/sshd
check_privsep_dir() {
# Create the PrivSep empty dir if necessary
if [ ! -d /var/run/sshd ]; then
mkdir /var/run/sshd
chmod 0755 /var/run/sshd
fi
}
PIDFILE=/var/run/sshd.pid
PRIVSEPDIR=/var/run/sshd
case "$1" in
start)
check_privsep_dir
log_info_msg "Starting OpenBSD Secure Shell server"
$DAEMON && log_success_msg || log_failure_msg
log_init_msg "Starting OpenBSD Secure Shell server"
if [ ! -d "$PRIVSEPDIR" ]; then
mkdir "$PRIVSEPDIR" || error=1
fi
chmod 0755 "$PRIVSEPDIR" || error=1
start_daemon "$DAEMON" || error=1
[ -z "$error" ] && log_success_msg || log_failure_msg
exit $error
;;
stop)
log_info_msg "Stopping OpenBSD Secure Shell server"
log_init_msg "Stopping OpenBSD Secure Shell server"
if ! test -f /var/run/sshd.pid; then
echo -n " - No sshd running"
log_warning_msg
killproc "$DAEMON" -TERM && log_success_msg || log_failure_msg
;;
reload|restart)
log_init_msg "Restarting OpenBSD Secure Shell server"
killproc -p "$PIDFILE" "$DAEMON" -HUP && log_success_msg || log_failure_msg
;;
status)
pid=$(pidofproc -p "$PIDFILE" "$DAEMON")
if [ "$?" -ne 0 ]; then
echo "OpenBSD Secure Shell server not running"
else
kill -TERM $(cat /var/run/sshd.pid) && log_success_msg || log_failure_msg
echo "OpenBSD Secure Shell server running with PID: $pid"
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 [start|stop|restart]"
echo "Usage: $0 [start|stop|reload|restart|status]"
exit 1
;;
esac