2006-10-05 04:05:48 +08:00
|
|
|
#!/bin/sh /etc/rc.common
|
|
|
|
# Copyright (C) 2006 OpenWrt.org
|
2007-05-10 18:38:53 +08:00
|
|
|
START=50
|
2006-10-29 13:53:13 +08:00
|
|
|
# Copyright (C) 2006 Carlos Sobrinho
|
|
|
|
|
|
|
|
config_cb() {
|
|
|
|
local cfg="$CONFIG_SECTION"
|
|
|
|
local nopasswd
|
2007-01-18 04:24:36 +08:00
|
|
|
local cfgt
|
|
|
|
config_get cfgt "$cfg" TYPE
|
2006-10-29 13:53:13 +08:00
|
|
|
|
2007-01-18 04:24:36 +08:00
|
|
|
case "$cfgt" in
|
2006-10-29 13:53:13 +08:00
|
|
|
dropbear)
|
|
|
|
config_get passauth $cfg PasswordAuth
|
|
|
|
config_get port $cfg Port
|
|
|
|
|
|
|
|
case "$passauth" in
|
|
|
|
no|off|disabled|0) nopasswd=1;;
|
|
|
|
esac
|
2007-01-21 01:09:14 +08:00
|
|
|
DROPBEAR_ARGS="${nopasswd:+-s }${port:+-p $port}"
|
2006-10-29 13:53:13 +08:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
2005-03-06 11:53:29 +08:00
|
|
|
|
2006-10-31 18:29:41 +08:00
|
|
|
keygen() {
|
2006-10-29 13:53:13 +08:00
|
|
|
for keytype in rsa dss; do
|
|
|
|
# check for keys
|
2006-10-31 18:29:41 +08:00
|
|
|
key=dropbear/dropbear_${keytype}_host_key
|
2009-02-04 06:28:16 +08:00
|
|
|
[ -f /tmp/$key -o -s /etc/$key ] || {
|
2006-10-29 13:53:13 +08:00
|
|
|
# generate missing keys
|
|
|
|
mkdir -p /tmp/dropbear
|
|
|
|
[ -x /usr/bin/dropbearkey ] && {
|
2006-11-02 02:11:44 +08:00
|
|
|
/usr/bin/dropbearkey -t $keytype -f /tmp/$key 2>&- >&- && exec /etc/rc.common "$initscript" start
|
2006-10-29 13:53:13 +08:00
|
|
|
} &
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
done
|
|
|
|
|
|
|
|
lock /tmp/.switch2jffs
|
|
|
|
mkdir -p /etc/dropbear
|
|
|
|
mv /tmp/dropbear/dropbear_* /etc/dropbear/
|
|
|
|
lock -u /tmp/.switch2jffs
|
|
|
|
chown root /etc/dropbear
|
|
|
|
chmod 0700 /etc/dropbear
|
2006-10-31 18:29:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
start() {
|
2009-02-04 06:28:16 +08:00
|
|
|
[ -s /etc/dropbear/dropbear_rsa_host_key -a \
|
|
|
|
-s /etc/dropbear/dropbear_dss_host_key ] || keygen
|
2006-10-31 18:29:41 +08:00
|
|
|
|
2006-10-29 13:53:13 +08:00
|
|
|
config_load dropbear
|
|
|
|
/usr/sbin/dropbear $DROPBEAR_ARGS
|
2006-10-05 04:05:48 +08:00
|
|
|
}
|
2006-10-08 03:11:19 +08:00
|
|
|
|
|
|
|
stop() {
|
|
|
|
killall dropbear
|
|
|
|
}
|