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