Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 831762 | Differences between
and this patch

Collapse All | Expand All

(-)files/sshd-r2.initd (-2 / +28 lines)
Lines 1-5 Link Here
1
#!/sbin/openrc-run
1
#!/sbin/openrc-run
2
# Copyright 1999-2021 Gentoo Authors
2
# Copyright 1999-2022 Gentoo Authors
3
# Distributed under the terms of the GNU General Public License v2
3
# Distributed under the terms of the GNU General Public License v2
4
4
5
extra_commands="checkconfig"
5
extra_commands="checkconfig"
Lines 10-15 extra_started_commands="reload" Link Here
10
: ${SSHD_PIDFILE:=${RC_PREFIX%/}/run/${SVCNAME}.pid}
10
: ${SSHD_PIDFILE:=${RC_PREFIX%/}/run/${SVCNAME}.pid}
11
: ${SSHD_BINARY:=${RC_PREFIX%/}/usr/sbin/sshd}
11
: ${SSHD_BINARY:=${RC_PREFIX%/}/usr/sbin/sshd}
12
: ${SSHD_KEYGEN_BINARY:=${RC_PREFIX%/}/usr/bin/ssh-keygen}
12
: ${SSHD_KEYGEN_BINARY:=${RC_PREFIX%/}/usr/bin/ssh-keygen}
13
: ${SSHD_HOSTKEY_DSA_ENABLE="YES"}
14
: ${SSHD_HOSTKEY_ECDSA_ENABLE="YES"}
15
: ${SSHD_HOSTKEY_ED25519_ENABLE="YES"}
16
: ${SSHD_HOSTKEY_RSA_ENABLE="YES"}
17
: ${SSHD_HOSTKEY_XMSS_ENABLE="YES"}
13
18
14
command="${SSHD_BINARY}"
19
command="${SSHD_BINARY}"
15
pidfile="${SSHD_PIDFILE}"
20
pidfile="${SSHD_PIDFILE}"
Lines 46-62 depend() { Link Here
46
	fi
51
	fi
47
}
52
}
48
53
54
gen_hostkey() {
55
	local hkey_type="${1}"
56
	[ -z ${hkey_type} ] && return 1
57
58
	local hkey_file="${SSHD_CONFDIR}/ssh_host_${hkey_type}_key"
59
	local hkey_type_upper="$(echo ${hkey_type} | tr "[:lower:]" "[:upper:]")"
60
	local hkey_type_var="SSHD_HOSTKEY_${hkey_type_upper}_ENABLE"
61
	local hkey_type_enable="$(eval echo "\$$hkey_type_var")"
62
63
	if yesno ${hkey_type_enable} && [ ! -f ${hkey_file} ] ; then
64
		${SSHD_KEYGEN_BINARY} -t ${hkey_type} -f ${hkey_file} -N '' || return 1
65
	fi
66
}
67
49
checkconfig() {
68
checkconfig() {
50
	checkpath --mode 0755 --directory "${RC_PREFIX%/}/var/empty"
69
	checkpath --mode 0755 --directory "${RC_PREFIX%/}/var/empty"
51
70
71
	# Check for sshd_config.
52
	if [ ! -e "${SSHD_CONFIG}" ] ; then
72
	if [ ! -e "${SSHD_CONFIG}" ] ; then
53
		eerror "You need an ${SSHD_CONFIG} file to run sshd"
73
		eerror "You need an ${SSHD_CONFIG} file to run sshd"
54
		eerror "There is a sample file in /usr/share/doc/openssh"
74
		eerror "There is a sample file in /usr/share/doc/openssh"
55
		return 1
75
		return 1
56
	fi
76
	fi
57
77
58
	${SSHD_KEYGEN_BINARY} -A || return 2
78
	# HostKey generation.
79
	gen_hostkey "dsa" || return 2
80
	gen_hostkey "ecdsa" || return 2
81
	gen_hostkey "ed25519" || return 2
82
	gen_hostkey "rsa" || return 2
83
	gen_hostkey "xmss" || return 2
59
84
85
	# Check sshd config file syntax
60
	"${command}" -t ${command_args} || return 3
86
	"${command}" -t ${command_args} || return 3
61
}
87
}
62
88

Return to bug 831762