summaryrefslogtreecommitdiffstats
path: root/security/dropbear/files/dropbear.in
blob: f992c86559d9732ac997514160ebcdb52e3c7a3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/sh

# PROVIDE: dropbear
# REQUIRE: LOGIN cleanvar
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# dropbear_enable (bool):   Set to NO by default.
#               Set it to YES to enable dropbear.
#

. /etc/rc.subr

name="dropbear"
rcvar=dropbear_enable
command="%%PREFIX%%/sbin/${name}"
keygen_cmd="dropbear_keygen"
start_precmd="dropbear_precmd"
pidfile="/var/run/${name}.pid"
extra_commands="keygen"

etcdir="%%PREFIX%%/etc/${name}"

dropbear_keygen()
{
	(
	umask 022

	if [ -f ${etcdir}/dropbear_rsa_host_key ]; then
		echo "You already have an RSA host key" \
		    "in ${etcdir}/dropbear_rsa_host_key"
		echo "Skipping protocol version 2 RSA Key Generation"
	else
		%%PREFIX%%/bin/dropbearkey -t rsa -f ${etcdir}/dropbear_rsa_host_key
	fi

	if [ -f ${etcdir}/dropbear_dss_host_key ]; then
		echo "You already have an DSS host key" \
		    "in ${etcdir}/dropbear_dss_host_key"
		echo "Skipping protocol version 2 DSS Key Generation"
	else
		%%PREFIX%%/bin/dropbearkey -t dss -f ${etcdir}/dropbear_dss_host_key
	fi
	)
}

dropbear_precmd()
{
	if [ ! -f ${etcdir}/dropbear_rsa_host_key -o \
		! -f ${etcdir}/dropbear_dss_host_key ]; then
		run_rc_command keygen
	fi
}

load_rc_config $name

: ${dropbear_enable="NO"}
: ${dropbear_args:=""}

command_args="-P $pidfile $dropbear_args"

run_rc_command "$1"
OpenPOWER on IntegriCloud