summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjc_gargma <jc_gargma@iserlohn-fortress.net>2018-11-01 04:32:33 -0700
committerjc_gargma <jc_gargma@iserlohn-fortress.net>2018-11-01 04:32:33 -0700
commit5fb5606e4c2b5befab93adaa7bae93739c53aa04 (patch)
tree759806ec463d988e24d353b7862d6f17132b375a
parentInitial commit (diff)
downloadopenssh-openrc-5fb5606e4c2b5befab93adaa7bae93739c53aa04.tar.xz
Merged in upstream init | Fixed sshd failing on boot
-rw-r--r--PKGBUILD7
-rw-r--r--[-rwxr-xr-x]sshd.initd66
2 files changed, 40 insertions, 33 deletions
diff --git a/PKGBUILD b/PKGBUILD
index aee31de..40375c4 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -3,9 +3,10 @@
# # I maintain this because:
# Artix version triggers warnings on every other service
# which clutters up the logs
+# Artix version is out-of-date
pkgname=openssh-openrc
-pkgver=20181031
+pkgver=20181101
pkgrel=1
pkgdesc="OpenRC openssh init script"
arch=('any')
@@ -18,8 +19,8 @@ conflicts=('init-openssh')
backup=('etc/conf.d/sshd')
source=("sshd.confd"
"sshd.initd")
-sha256sums=('29c6d57ac3ec6018cadc6ba6cd9b90c9ed46e20049b970fdcc68ee2481a2ee41'
- '43a483014bf177f9238e54a7b8210d5a76830beb67c18999409e543fd744c9e4')
+sha256sums=('f10e1f94414940a8ade2b1bcd60e3623a88f32ccc440d3e687beed231e45aa69'
+ 'f222f5ec452db26102d4631ac455a1fc22e017ed72f6c41e99cebb9ca38518e2')
pkgver() {
date +%Y%m%d
diff --git a/sshd.initd b/sshd.initd
index dd0b146..d0533d2 100755..100644
--- a/sshd.initd
+++ b/sshd.initd
@@ -1,5 +1,5 @@
#!/usr/bin/openrc-run
-# Copyright 1999-2015 Gentoo Foundation
+# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
extra_commands="checkconfig"
@@ -9,15 +9,27 @@ extra_started_commands="reload"
: ${SSHD_CONFIG:=${SSHD_CONFDIR}/sshd_config}
: ${SSHD_PIDFILE:=/run/${SVCNAME}.pid}
: ${SSHD_BINARY:=/usr/bin/sshd}
+: ${SSHD_KEYGEN_BINARY:=/usr/bin/ssh-keygen}
+
+command="${SSHD_BINARY}"
+pidfile="${SSHD_PIDFILE}"
+command_args="${SSHD_OPTS} -o PidFile=${pidfile} -f ${SSHD_CONFIG}"
+
+# Wait one second (length chosen arbitrarily) to see if sshd actually
+# creates a PID file, or if it crashes for some reason like not being
+# able to bind to the address in ListenAddress (bug 617596).
+: ${SSHD_SSD_OPTS:=--wait 1000}
+start_stop_daemon_args="${SSHD_SSD_OPTS}"
depend() {
- use logger dns
+ # Entropy can be used by ssh-keygen, among other things, but
+ # is not strictly required (bug 470020).
+ use logger dns entropy
+ need net
}
checkconfig() {
- if [ ! -d /var/empty ] ; then
- mkdir -p /var/empty || return 1
- fi
+ checkpath --mode 0755 --directory "/var/empty"
if [ ! -e "${SSHD_CONFIG}" ] ; then
eerror "You need an ${SSHD_CONFIG} file to run sshd"
@@ -25,41 +37,35 @@ checkconfig() {
return 1
fi
- ssh-keygen -A || return 1
+ ${SSHD_KEYGEN_BINARY} -A || return 2
- [ "${SSHD_PIDFILE}" != "/run/sshd.pid" ] \
- && SSHD_OPTS="${SSHD_OPTS} -o PidFile=${SSHD_PIDFILE}"
- [ "${SSHD_CONFIG}" != "/etc/ssh/sshd_config" ] \
- && SSHD_OPTS="${SSHD_OPTS} -f ${SSHD_CONFIG}"
-
- "${SSHD_BINARY}" -t ${SSHD_OPTS} || return 1
+ "${command}" -t ${command_args} || return 3
}
-start() {
- checkconfig || return 1
-
- ebegin "Starting ${SVCNAME}"
- start-stop-daemon --start --exec "${SSHD_BINARY}" \
- --pidfile "${SSHD_PIDFILE}" \
- -- ${SSHD_OPTS}
- eend $?
+start_pre() {
+ # If this isn't a restart, make sure that the user's config isn't
+ # busted before we try to start the daemon (this will produce
+ # better error messages than if we just try to start it blindly).
+ #
+ # If, on the other hand, this *is* a restart, then the stop_pre
+ # action will have ensured that the config is usable and we don't
+ # need to do that again.
+ if [ "${RC_CMD}" != "restart" ] ; then
+ checkconfig || return $?
+ fi
}
-stop() {
+stop_pre() {
+ # If this is a restart, check to make sure the user's config
+ # isn't busted before we stop the running daemon.
if [ "${RC_CMD}" = "restart" ] ; then
- checkconfig || return 1
+ checkconfig || return $?
fi
-
- ebegin "Stopping ${SVCNAME}"
- start-stop-daemon --stop --exec "${SSHD_BINARY}" \
- --pidfile "${SSHD_PIDFILE}" --quiet
- eend $?
}
reload() {
- checkconfig || return 1
+ checkconfig || return $?
ebegin "Reloading ${SVCNAME}"
- start-stop-daemon --signal HUP \
- --exec "${SSHD_BINARY}" --pidfile "${SSHD_PIDFILE}"
+ start-stop-daemon --signal HUP --pidfile "${pidfile}"
eend $?
}