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