wok rev 18042
ppp/ppp.cgi: misc fixes
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Mon May 11 16:08:11 2015 +0200 (2015-05-11) |
parents | 2ac3320b31e9 |
children | 96a79b0c83ee |
files | dropbear/stuff/sshx ppp/stuff/ppp.cgi ppp/stuff/pppnc-server |
line diff
1.1 --- a/dropbear/stuff/sshx Mon May 11 08:03:12 2015 +0200 1.2 +++ b/dropbear/stuff/sshx Mon May 11 16:08:11 2015 +0200 1.3 @@ -30,12 +30,13 @@ 1.4 read -s -t 30 DROPBEAR_PASSWORD && export DROPBEAR_PASSWORD 1.5 $ssh $1 true || exit 1 1.6 } 1.7 - extra="$(route -n | awk -vd=${1#*@} \ 1.8 + extra="$(route -n | awk -vd=$(nslookup ${1#*@} | \ 1.9 + sed '$!d;s/.*: \([^ ]*\).*/\1/') \ 1.10 '$1=="0.0.0.0"{ print d " gw " $2 " dev " $8 }')" 1.11 for i in ${4/default/128.0.0.0/1 0.0.0.0/1} ; do 1.12 echo "route add -net $i dev \$1" 1.13 done > /etc/ppp/ip-up.d/pppssh$$ 1.14 - [ "$4" ] && echo "route add $extra" >> /etc/ppp/ip-up.d/pppssh$ 1.15 + [ "$4" ] && echo "route add $extra" >> /etc/ppp/ip-up.d/pppssh$$ 1.16 chmod +x /etc/ppp/ip-up.d/pppssh$$ 1.17 n=10.$(($$%256)).$(($$/256)) 1.18 ppp="/usr/sbin/pppd local noauth nodetach"
2.1 --- a/ppp/stuff/ppp.cgi Mon May 11 08:03:12 2015 +0200 2.2 +++ b/ppp/stuff/ppp.cgi Mon May 11 16:08:11 2015 +0200 2.3 @@ -82,10 +82,10 @@ 2.4 *\ setpppnc\ *) 2.5 [ "$(GET stop_pppncs)" ] && killall pppnc-server 2.6 [ "$(GET start_pppncs)" ] && 2.7 - pppnc-server $(GET port) "$(GET localip):$(GET remoteip)" & 2.8 + pppnc-server "$(GET port)" "$(GET localip):$(GET remoteip)" & 2.9 [ "$(GET stop_pppncc)" ] && killall pppnc-client 2.10 [ "$(GET start_pppncc)" ] && 2.11 - pppnc-client $(GET serverip) $(GET port) "$(GET routes)" & 2.12 + pppnc-client "$(GET serverip)" "$(GET port)" "$(GET routes)" & 2.13 ;; 2.14 *\ setpppssh\ *) 2.15 cat > /etc/ppp/pppssh <<EOT 2.16 @@ -98,7 +98,8 @@ 2.17 ROUTES="$(GET routes)" 2.18 EOT 2.19 [ "$(GET pass)" ] && export DROPBEAR_PASSWORD="$(GET pass)" 2.20 - if [ "$(GET send_key)" ]; then 2.21 + case " $(GET) " in 2.22 + *\ send_key\ *) 2.23 ( dropbearkey -y -f /etc/dropbear/dropbear_rsa_host_key ; 2.24 cat /etc/ssh/ssh_host_rsa_key.pub ) 2> /dev/null | \ 2.25 grep ^ssh | dbclient $(echo $(GET send_key) | sed \ 2.26 @@ -106,16 +107,18 @@ 2.27 while read key; do for i in authorized_keys authorized_keys2; do \ 2.28 grep -qs '\$key' .ssh/\$i || echo '\$key' >> .ssh/\$i ; done ; done ; \ 2.29 chmod 700 .ssh ; chmod 600 .ssh/authorized_keys*" 2.30 - fi 2.31 - if [ "$(GET stop_pppssh)" ]; then 2.32 + ;; 2.33 + *\ stop_pppssh\ *) 2.34 ppp="$(sed '/pppd/!d;s/.*="\([^"]*\).*/\1/' /usr/bin/pppssh)" 2.35 - kill $(busybox ps x | grep "$ppp" | awk '/dbclient/{print $1}') 2.36 - fi 2.37 - if [ "$(GET start_pppssh)" ]; then 2.38 + kill $(busybox ps x | grep "$ppp" | awk '/pty/{next}/dbclient/{print $1}') 2.39 + ;; 2.40 + *\ start_pppssh\ *) 2.41 +EOT 2.42 pppssh "$(GET ssharg) $(GET peer)" \ 2.43 "$(GET localip):$(GET remoteip) $(GET localpppopt)" \ 2.44 - "$(GET remotepppopt)" & 2.45 - fi 2.46 + "$(GET remotepppopt)" "$(GET routes)" & 2.47 + ;; 2.48 + esac 2.49 ;; 2.50 esac 2.51 2.52 @@ -196,7 +199,8 @@ 2.53 $(_ 'Manage PSTN Internet connections')</span> 2.54 </header> 2.55 <form action="index.cgi" id="indexform"></form> 2.56 -<form method="get" action="?setppppstn"> 2.57 +<form method="get"> 2.58 + <input type="hidden" name="setppppstn" /> 2.59 <table> 2.60 <tr> 2.61 <td>$(_ 'Username')</td> 2.62 @@ -211,11 +215,11 @@ 2.63 <td><input type="text" name="phone" size="40" value="$PHONE" /></td> 2.64 </tr> 2.65 </table> 2.66 + <footer><!-- 2.67 + --><button type="submit" name="start_pstn" data-icon="start" $start_disabled>$(_ 'Start' )</button><!-- 2.68 + --><button type="submit" name="stop_pstn" data-icon="stop" $stop_disabled >$(_ 'Stop' )</button><!-- 2.69 + --></footer> 2.70 </form> 2.71 - <footer><!-- 2.72 - --><button form="conf" type="submit" name="start_pstn" data-icon="start" $start_disabled>$(_ 'Start' )</button><!-- 2.73 - --><button form="conf" type="submit" name="stop_pstn" data-icon="stop" $stop_disabled >$(_ 'Stop' )</button><!-- 2.74 - --></footer> 2.75 </section> 2.76 2.77 <a name="pppoe"></a> 2.78 @@ -224,7 +228,8 @@ 2.79 <span data-icon="eth">$(_ 'Cable Modem') - 2.80 $(_ 'Manage PPPoE Internet connections')</span> 2.81 </header> 2.82 -<form method="get" action="?setpppoe"> 2.83 +<form method="get"> 2.84 + <input type="hidden" name="setpppoe" /> 2.85 <table> 2.86 <tr> 2.87 <td>$(_ 'Username')</td> 2.88 @@ -235,11 +240,11 @@ 2.89 <td><input type="text" name="pass" size="40" value="$PASSWORD" /></td> 2.90 </tr> 2.91 </table> 2.92 + <footer><!-- 2.93 + --><button type="submit" name="start_pppoe" data-icon="start" $startoe_disabled>$(_ 'Start' )</button><!-- 2.94 + --><button type="submit" name="stop_pppoe" data-icon="stop" $stopoe_disabled >$(_ 'Stop' )</button><!-- 2.95 + --></footer> 2.96 </form> 2.97 - <footer><!-- 2.98 - --><button form="conf" type="submit" name="start_pppoe" data-icon="start" $startoe_disabled>$(_ 'Start' )</button><!-- 2.99 - --><button form="conf" type="submit" name="stop_pppoe" data-icon="stop" $stopoe_disabled >$(_ 'Stop' )</button><!-- 2.100 - --></footer> 2.101 </section> 2.102 2.103 <a name="pppnc"></a> 2.104 @@ -248,7 +253,8 @@ 2.105 <span data-icon="upgrade">$(_ 'Route shortcut') - 2.106 $(_ 'Reach unreachable networks')</span> 2.107 </header> 2.108 -<form method="get" action="?setppprc"> 2.109 +<form method="get"> 2.110 + <input type="hidden" name="setppprc" /> 2.111 <table> 2.112 <tr> 2.113 <td>$(_ 'TCP port')</td> 2.114 @@ -272,22 +278,22 @@ 2.115 <td><input type="text" name="routes" size="50" value="${ROUTES:-192.168.10.0/24 192.168.20.0/28}" title="$(_ "Routes on peer network to import or 'default' to redirect the default route")"/></td> 2.116 </tr> 2.117 </table> 2.118 + <footer><!-- 2.119 + --><button type="submit" name="start_pppncs" data-icon="start" >$(_ 'Start server' )</button><!-- 2.120 + --><button type="submit" name="stop_pppncs" data-icon="stop" $stops_disabled>$(_ 'Stop server' )</button><!-- 2.121 + --><button type="submit" name="start_pppncc" data-icon="start" >$(_ 'Start client' )</button><!-- 2.122 + --><button type="submit" name="stop_pppncc" data-icon="stop" $stopc_disabled>$(_ 'Stop client' )</button><!-- 2.123 + --></footer> 2.124 </form> 2.125 - <footer><!-- 2.126 - --><button form="conf" type="submit" name="start_pppncs" data-icon="start" >$(_ 'Start server' )</button><!-- 2.127 - --><button form="conf" type="submit" name="stop_pppncs" data-icon="stop" $stops_disabled>$(_ 'Stop server' )</button><!-- 2.128 - --><button form="conf" type="submit" name="start_pppncc" data-icon="start" >$(_ 'Start client' )</button><!-- 2.129 - --><button form="conf" type="submit" name="stop_pppncc" data-icon="stop" $stopc_disabled>$(_ 'Stop client' )</button><!-- 2.130 - --></footer> 2.131 </section> 2.132 EOT 2.133 if [ "$(which pppssh 2>/dev/null)" ]; then 2.134 [ -s /etc/ppp/pppssh ] && . /etc/ppp/pppssh 2.135 ppp="$(sed '/pppd/!d;s/.*="\([^"]*\).*/\1/' /usr/bin/pppssh)" 2.136 if [ "$(busybox ps x | grep "$ppp" | awk '/dbclient/{print $1}')" ]; then 2.137 - start_disabled='disabled' 2.138 + startssh_disabled='disabled' 2.139 else 2.140 - stop_disabled='disabled' 2.141 + stopssh_disabled='disabled' 2.142 fi 2.143 cat <<EOT 2.144 <a name="pppssh"></a> 2.145 @@ -296,7 +302,8 @@ 2.146 <span data-icon="eth">$(_ 'Virtual Private Network') - 2.147 $(_ 'Manage private TCP/IP connections')</span> 2.148 </header> 2.149 -<form method="get" action="?setpppssh"> 2.150 +<form method="get"> 2.151 + <input type="hidden" name="setpppssh" /> 2.152 <table> 2.153 <tr> 2.154 <td>$(_ 'Peer')</td> 2.155 @@ -331,12 +338,12 @@ 2.156 <td><input type="text" name="routes" size="50" value="${ROUTES:-192.168.10.0/24 192.168.20.0/28}" title="$(_ "Routes on peer network to import or 'default' to redirect the default route")"/></td> 2.157 </tr> 2.158 </table> 2.159 + <footer><!-- 2.160 + --><button type="submit" name="start_pppssh" data-icon="start" $startssh_disabled>$(_ 'Start' )</button><!-- 2.161 + --><button type="submit" name="stop_pppssh" data-icon="stop" $stopssh_disabled>$(_ 'Stop' )</button><!-- 2.162 + --><button type="submit" name="send_key" data-icon="sync" >$(_ 'Send SSH key' )</button><!-- 2.163 + --></footer> 2.164 </form> 2.165 - <footer><!-- 2.166 - --><button form="conf" type="submit" name="start_pppssh" data-icon="start" $start_disabled>$(_ 'Start' )</button><!-- 2.167 - --><button form="conf" type="submit" name="stop_pppssh" data-icon="stop" $stop_disabled>$(_ 'Stop' )</button><!-- 2.168 - --><button form="conf" type="submit" name="send_key" data-icon="sync" >$(_ 'Send SSH key' )</button><!-- 2.169 - --></footer> 2.170 </section> 2.171 EOT 2.172 fi
3.1 --- a/ppp/stuff/pppnc-server Mon May 11 08:03:12 2015 +0200 3.2 +++ b/ppp/stuff/pppnc-server Mon May 11 16:08:11 2015 +0200 3.3 @@ -11,11 +11,12 @@ 3.4 esac 3.5 3.6 [ -z "$1" ] && echo "Usage: $0 serverip [port] [routes]" && exit 1 3.7 -extra="$(route -n | awk -vd=$1 '$1=="0.0.0.0"{ print d " gw " $2 " dev " $8 }')" 3.8 +extra="$(route -n | awk -vd=$(nslookup ${1#*@} | sed \ 3.9 + '$!d;s/.*: \([^ ]*\).*/\1/') '$1=="0.0.0.0"{ print d " gw " $2 " dev " $8 }')" 3.10 for i in ${3/default/128.0.0.0/1 0.0.0.0/1} ; do 3.11 echo "route add -net $i dev \$1" 3.12 done > $ipupd/pppnc$$ 3.13 -[ "$3" ] && echo "route add $extra" >> $ipupd/pppnc$ 3.14 +[ "$3" ] && echo "route add $extra" >> $ipupd/pppnc$$ 3.15 chmod +x $ipupd/pppnc$$ 3.16 $ppp noipdefault pty "nc $1 ${2:-$port}" ipparam pppnc$$ 3.17 [ "$3" ] && route del $extra