public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Thomas Deutschmann" <whissi@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: net-misc/openssh/, net-misc/openssh/files/
Date: Wed,  6 Mar 2019 23:56:14 +0000 (UTC)	[thread overview]
Message-ID: <1551916556.057cc59d64ede3c1b8a4a42ad003fb5cc7ef1d3b.whissi@gentoo> (raw)

commit:     057cc59d64ede3c1b8a4a42ad003fb5cc7ef1d3b
Author:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
AuthorDate: Wed Mar  6 23:55:08 2019 +0000
Commit:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
CommitDate: Wed Mar  6 23:55:56 2019 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=057cc59d

net-misc/openssh: always call checkconfig to trigger key generation

Closes: https://bugs.gentoo.org/675922
Package-Manager: Portage-2.3.62, Repoman-2.3.12
Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>

 net-misc/openssh/files/sshd-r1.initd      | 87 +++++++++++++++++++++++++++++++
 net-misc/openssh/openssh-7.9_p1-r4.ebuild |  2 +-
 2 files changed, 88 insertions(+), 1 deletion(-)

diff --git a/net-misc/openssh/files/sshd-r1.initd b/net-misc/openssh/files/sshd-r1.initd
new file mode 100644
index 00000000000..e91cd0116cd
--- /dev/null
+++ b/net-misc/openssh/files/sshd-r1.initd
@@ -0,0 +1,87 @@
+#!/sbin/openrc-run
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+extra_commands="checkconfig"
+extra_started_commands="reload"
+
+: ${SSHD_CONFDIR:=${RC_PREFIX%/}/etc/ssh}
+: ${SSHD_CONFIG:=${SSHD_CONFDIR}/sshd_config}
+: ${SSHD_PIDFILE:=${RC_PREFIX%/}/run/${SVCNAME}.pid}
+: ${SSHD_BINARY:=${RC_PREFIX%/}/usr/sbin/sshd}
+: ${SSHD_KEYGEN_BINARY:=${RC_PREFIX%/}/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() {
+	# Entropy can be used by ssh-keygen, among other things, but
+	# is not strictly required (bug 470020).
+	use logger dns entropy
+	if [ "${rc_need+set}" = "set" ] ; then
+		: # Do nothing, the user has explicitly set rc_need
+	else
+		local x warn_addr
+		for x in $(awk '/^ListenAddress/{ print $2 }' "$SSHD_CONFIG" 2>/dev/null) ; do
+			case "${x}" in
+				0.0.0.0|0.0.0.0:*) ;;
+				::|\[::\]*) ;;
+				*) warn_addr="${warn_addr} ${x}" ;;
+			esac
+		done
+		if [ -n "${warn_addr}" ] ; then
+			need net
+			ewarn "You are binding an interface in ListenAddress statement in your sshd_config!"
+			ewarn "You must add rc_need=\"net.FOO\" to your ${RC_PREFIX%/}/etc/conf.d/sshd"
+			ewarn "where FOO is the interface(s) providing the following address(es):"
+			ewarn "${warn_addr}"
+		fi
+	fi
+}
+
+checkconfig() {
+	checkpath --mode 0755 --directory "${RC_PREFIX%/}/var/empty"
+
+	if [ ! -e "${SSHD_CONFIG}" ] ; then
+		eerror "You need an ${SSHD_CONFIG} file to run sshd"
+		eerror "There is a sample file in /usr/share/doc/openssh"
+		return 1
+	fi
+
+	${SSHD_KEYGEN_BINARY} -A || return 2
+
+	"${command}" -t ${command_args} || return 3
+}
+
+start_pre() {
+	# 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).
+	#
+	# We always need to call checkconfig because this function will
+	# also generate any missing host key and you can start a
+	# non-running service with "restart" argument.
+	checkconfig || return $?
+}
+
+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 $?
+	fi
+}
+
+reload() {
+	checkconfig || return $?
+	ebegin "Reloading ${SVCNAME}"
+	start-stop-daemon --signal HUP --pidfile "${pidfile}"
+	eend $?
+}

diff --git a/net-misc/openssh/openssh-7.9_p1-r4.ebuild b/net-misc/openssh/openssh-7.9_p1-r4.ebuild
index 1c475e825c0..deb47d530d3 100644
--- a/net-misc/openssh/openssh-7.9_p1-r4.ebuild
+++ b/net-misc/openssh/openssh-7.9_p1-r4.ebuild
@@ -390,7 +390,7 @@ src_install() {
 	emake install-nokeys DESTDIR="${D}"
 	fperms 600 /etc/ssh/sshd_config
 	dobin contrib/ssh-copy-id
-	newinitd "${FILESDIR}"/sshd.initd sshd
+	newinitd "${FILESDIR}"/sshd-r1.initd sshd
 	newconfd "${FILESDIR}"/sshd-r1.confd sshd
 
 	newpamd "${FILESDIR}"/sshd.pam_include.2 sshd


             reply	other threads:[~2019-03-06 23:56 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-06 23:56 Thomas Deutschmann [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-07-01  8:55 [gentoo-commits] repo/gentoo:master commit in: net-misc/openssh/, net-misc/openssh/files/ Sam James
2024-05-21 11:48 Sam James
2024-05-17 14:53 David Seifert
2024-01-20 12:51 Sam James
2024-01-03  9:22 David Seifert
2023-05-12 11:54 David Seifert
2023-05-12 11:01 David Seifert
2023-03-23  6:00 Sam James
2023-02-05  0:10 Mike Gilbert
2022-09-08  1:54 Sam James
2022-02-25  5:58 Patrick McLean
2021-10-25 23:38 Patrick McLean
2021-10-06  1:22 Sam James
2021-09-01 18:23 Patrick McLean
2021-06-17 20:32 Thomas Deutschmann
2021-05-23 13:05 Lars Wendler
2021-04-23 23:14 Patrick McLean
2021-04-22  3:23 Patrick McLean
2021-03-16 19:10 Patrick McLean
2020-10-05 19:05 Patrick McLean
2020-07-31 18:41 Patrick McLean
2020-05-28 22:09 Patrick McLean
2020-03-21 20:55 Patrick McLean
2020-02-23 21:25 Patrick McLean
2020-02-18 22:34 Patrick McLean
2020-02-15 22:31 Patrick McLean
2020-02-05  1:55 Patrick McLean
2019-10-14 19:58 Patrick McLean
2019-10-11 23:05 Patrick McLean
2019-10-09 16:18 Thomas Deutschmann
2019-10-08 16:06 Thomas Deutschmann
2019-06-17 20:14 Patrick McLean
2019-04-19  3:56 Patrick McLean
2019-01-31 23:36 Lars Wendler
2019-01-31 22:55 Lars Wendler
2019-01-15 17:42 Thomas Deutschmann
2018-12-08  1:28 Patrick McLean
2018-10-25  0:07 Patrick McLean
2018-08-22 15:00 Thomas Deutschmann
2018-03-12 15:51 Lars Wendler
2018-02-13  1:09 Patrick McLean
2018-01-31 18:49 Patrick McLean
2018-01-10  8:35 Mike Frysinger
2017-06-09 21:38 Patrick McLean
2017-05-25  3:28 Mike Frysinger
2017-03-27 22:20 Patrick McLean
2017-03-20 19:05 Mike Frysinger
2016-09-28  8:40 Lars Wendler
2016-09-13  3:28 Patrick McLean
2016-09-09  1:38 Patrick McLean
2016-09-02 20:50 Patrick McLean
2016-08-04  0:36 Mike Frysinger
2016-06-11 12:29 Lars Wendler
2016-03-02 20:29 Mike Frysinger
2016-01-14 20:59 Mike Frysinger
2016-01-14 15:31 Lars Wendler
2015-08-12 23:27 Patrick McLean

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1551916556.057cc59d64ede3c1b8a4a42ad003fb5cc7ef1d3b.whissi@gentoo \
    --to=whissi@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox