View | Details | Raw Unified | Return to bug 14649
Collapse All | Expand All

(-)backend3.orig/net-pppoe (-12 / +12 lines)
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
5
4
6
################### shell file helpers
5
################### shell file helpers
7
6
Lines 79-90 Link Here
79
	
78
	
80
	if [ -n "$in_login" ] ;then
79
	if [ -n "$in_login" ] ;then
81
		sed -r "s,^user[[:space:]].*,user $in_login," -i "$name/pppoptions"
80
		sed -r "s,^user[[:space:]].*,user $in_login," -i "$name/pppoptions"
82
		sed -r "s,^$prev_login[[:space:]]*,$in_login	," -i "$chapfile"
83
		prev_login="$in_login"
81
		prev_login="$in_login"
84
	fi
82
	fi
85
	if [ -n "$in_password" ]; then
83
	if [ -n "$in_password" ]; then
86
		in_password=$(echo "$in_password"|sed -e 's/["]/\\\\&/g')
84
		in_password=$(echo "$in_password"|sed -e 's/["]/\\\\&/g')
87
		sed -r "s,^$prev_login[[:space:]].*,$prev_login	*	\"$in_password\"	*," -i "$chapfile"
85
		sed -r "s,^password[[:space:]].*,password $in_password," -i "$name/pppoptions"
86
		
87
		# deny users from reading the password
88
		chmod o-rw "$name/pppoptions"
88
	fi
89
	fi
89
90
90
	ifdown "$1" && ifup "$1"
91
	ifdown "$1" && ifup "$1"
Lines 92-99 Link Here
92
93
93
new_iface()
94
new_iface()
94
{
95
{
95
	grep -qs "^$in_login[[:space:]]" "$chapfile" && return 1
96
97
	local name="/etc/net/ifaces/$1"
96
	local name="/etc/net/ifaces/$1"
98
	in_password=$(echo "$in_password"|sed -e 's/["]/\\\\&/g')
97
	in_password=$(echo "$in_password"|sed -e 's/["]/\\\\&/g')
99
98
Lines 105-113 Link Here
105
	shell_add_or_subst "PPPMAXFAIL=" "0" "$name/options"
104
	shell_add_or_subst "PPPMAXFAIL=" "0" "$name/options"
106
	
105
	
107
	shell_add_or_subst "user " "$in_login" "$name/pppoptions"
106
	shell_add_or_subst "user " "$in_login" "$name/pppoptions"
108
107
	shell_add_or_subst "password " "$in_password" "$name/pppoptions"
109
	echo "$in_login	*	\"$in_password\"	*" >>"$chapfile"
108
	
110
109
	# deny users from reading the password
110
	chmod o-rw "$name/pppoptions"
111
	
111
	ifup "$1"
112
	ifup "$1"
112
	return 0
113
	return 0
113
}
114
}
Lines 119-128 Link Here
119
	local name="/etc/net/ifaces/$1"
120
	local name="/etc/net/ifaces/$1"
120
	local prev_login="$(grep '^user' "$name/pppoptions"|sed -r 's,user[[:space:]]*,,')"
121
	local prev_login="$(grep '^user' "$name/pppoptions"|sed -r 's,user[[:space:]]*,,')"
121
122
122
	sed -r "/^$prev_login[[:space:]]/ d" -i "$chapfile"
123
	# do ifdown before rm so that ifup-{pre,post} are executed 
123
	rm -rf "$name"
124
	ifdown "$1" 
124
125
	rm -rf "$name" 
125
	ifdown "$1"
126
}
126
}
127
127
128
_()
128
_()

Return to bug 14649