--- backend3.orig/net-pptp 2008-03-02 21:04:00 +0300 +++ backend3/net-pptp 2008-03-02 23:12:25 +0300 @@ -1,7 +1,6 @@ #!/bin/sh -ef PATH=/usr/lib/alterator-net-common:$PATH -chapfile=/etc/ppp/chap-secrets ################### shell file helpers @@ -86,12 +85,14 @@ if [ -n "$in_login" ] ;then sed -r "s,^user[[:space:]].*,user $in_login," -i "$name/pppoptions" - sed -r "s,^$prev_login[[:space:]]*,$in_login ," -i "$chapfile" prev_login="$in_login" fi if [ -n "$in_password" ]; then in_password=$(echo "$in_password"|sed -e 's/["]/\\\\&/g') - sed -r "s,^$prev_login[[:space:]].*,$prev_login * \"$in_password\" *," -i "$chapfile" + sed -r "s,^password[[:space:]].*,password $in_password," -i "$name/pppoptions" + + # deny users from reading the password + chmod o-rw "$name/pppoptions" fi ifdown "$1" && ifup "$1" @@ -99,8 +100,6 @@ new_iface() { - grep -qs "^$in_login[[:space:]]" "$chapfile" && return 1 - local name="/etc/net/ifaces/$1" in_password=$(echo "$in_password"|sed -e 's/["]/\\\\&/g') @@ -111,9 +110,11 @@ shell_add_or_subst "REQUIRES=" "$in_iface" "$name/options" shell_add_or_subst "user " "$in_login" "$name/pppoptions" - - echo "$in_login * \"$in_password\" *" >>"$chapfile" - + shell_add_or_subst "password " "$in_password" "$name/pppoptions" + + # deny users from reading the password + chmod o-rw "$name/pppoptions" + ifup "$1" return 0 } @@ -125,10 +126,9 @@ local name="/etc/net/ifaces/$1" local prev_login="$(grep '^user' "$name/pppoptions"|sed -r 's,user[[:space:]]*,,')" - sed -r "/^$prev_login[[:space:]]/ d" -i "$chapfile" - rm -rf "$name" - - ifdown "$1" + # do ifdown before rm so that ifup-{pre,post} are executed + ifdown "$1" + rm -rf "$name" } _()