Lines 1-7
Link Here
|
1 |
#!/bin/sh -ef |
1 |
#!/bin/sh -ef |
2 |
|
2 |
|
3 |
PATH=/usr/lib/alterator-net-common:$PATH |
3 |
PATH=/usr/lib/alterator-net-common:$PATH |
4 |
chapfile=/etc/ppp/chap-secrets |
4 |
# chapfile=/etc/ppp/chap-secrets |
5 |
|
5 |
|
6 |
################### shell file helpers |
6 |
################### shell file helpers |
7 |
|
7 |
|
Lines 86-97
Link Here
|
86 |
|
86 |
|
87 |
if [ -n "$in_login" ] ;then |
87 |
if [ -n "$in_login" ] ;then |
88 |
sed -r "s,^user[[:space:]].*,user $in_login," -i "$name/pppoptions" |
88 |
sed -r "s,^user[[:space:]].*,user $in_login," -i "$name/pppoptions" |
89 |
sed -r "s,^$prev_login[[:space:]]*,$in_login ," -i "$chapfile" |
89 |
# sed -r "s,^$prev_login[[:space:]]*,$in_login ," -i "$chapfile" |
90 |
prev_login="$in_login" |
90 |
prev_login="$in_login" |
91 |
fi |
91 |
fi |
92 |
if [ -n "$in_password" ]; then |
92 |
if [ -n "$in_password" ]; then |
93 |
in_password=$(echo "$in_password"|sed -e 's/["]/\\\\&/g') |
93 |
in_password=$(echo "$in_password"|sed -e 's/["]/\\\\&/g') |
94 |
sed -r "s,^$prev_login[[:space:]].*,$prev_login * \"$in_password\" *," -i "$chapfile" |
94 |
sed -r "s,^password[[:space:]].*,password $in_password," -i "$name/pppoptions" |
|
|
95 |
### WARNING deny users from reading the password |
96 |
chmod o-rw "$name/pppoptions" |
97 |
# sed -r "s,^$prev_login[[:space:]].*,$prev_login * \"$in_password\" *," -i "$chapfile" |
95 |
fi |
98 |
fi |
96 |
|
99 |
|
97 |
ifdown "$1" && ifup "$1" |
100 |
ifdown "$1" && ifup "$1" |
Lines 99-105
Link Here
|
99 |
|
102 |
|
100 |
new_iface() |
103 |
new_iface() |
101 |
{ |
104 |
{ |
102 |
grep -qs "^$in_login[[:space:]]" "$chapfile" && return 1 |
105 |
# grep -qs "^$in_login[[:space:]]" "$chapfile" && return 1 |
103 |
|
106 |
|
104 |
local name="/etc/net/ifaces/$1" |
107 |
local name="/etc/net/ifaces/$1" |
105 |
in_password=$(echo "$in_password"|sed -e 's/["]/\\\\&/g') |
108 |
in_password=$(echo "$in_password"|sed -e 's/["]/\\\\&/g') |
Lines 111-118
Link Here
|
111 |
shell_add_or_subst "REQUIRES=" "$in_iface" "$name/options" |
114 |
shell_add_or_subst "REQUIRES=" "$in_iface" "$name/options" |
112 |
|
115 |
|
113 |
shell_add_or_subst "user " "$in_login" "$name/pppoptions" |
116 |
shell_add_or_subst "user " "$in_login" "$name/pppoptions" |
|
|
117 |
shell_add_or_subst "password " "$in_password" "$name/pppoptions" |
118 |
### WARNING deny users from reading the password |
119 |
chmod o-rw "$name/pppoptions" |
120 |
|
114 |
|
121 |
|
115 |
echo "$in_login * \"$in_password\" *" >>"$chapfile" |
122 |
# echo "$in_login * \"$in_password\" *" >>"$chapfile" |
116 |
|
123 |
|
117 |
ifup "$1" |
124 |
ifup "$1" |
118 |
return 0 |
125 |
return 0 |
Lines 125-131
Link Here
|
125 |
local name="/etc/net/ifaces/$1" |
132 |
local name="/etc/net/ifaces/$1" |
126 |
local prev_login="$(grep '^user' "$name/pppoptions"|sed -r 's,user[[:space:]]*,,')" |
133 |
local prev_login="$(grep '^user' "$name/pppoptions"|sed -r 's,user[[:space:]]*,,')" |
127 |
|
134 |
|
128 |
sed -r "/^$prev_login[[:space:]]/ d" -i "$chapfile" |
135 |
# sed -r "/^$prev_login[[:space:]]/ d" -i "$chapfile" |
129 |
rm -rf "$name" |
136 |
rm -rf "$name" |
130 |
|
137 |
|
131 |
ifdown "$1" |
138 |
ifdown "$1" |