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

(-)backend3.orig/net-pptp (-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 86-97 Link Here
86
	
85
	
87
	if [ -n "$in_login" ] ;then
86
	if [ -n "$in_login" ] ;then
88
		sed -r "s,^user[[:space:]].*,user $in_login," -i "$name/pppoptions"
87
		sed -r "s,^user[[:space:]].*,user $in_login," -i "$name/pppoptions"
89
		sed -r "s,^$prev_login[[:space:]]*,$in_login	," -i "$chapfile"
90
		prev_login="$in_login"
88
		prev_login="$in_login"
91
	fi
89
	fi
92
	if [ -n "$in_password" ]; then
90
	if [ -n "$in_password" ]; then
93
		in_password=$(echo "$in_password"|sed -e 's/["]/\\\\&/g')
91
		in_password=$(echo "$in_password"|sed -e 's/["]/\\\\&/g')
94
		sed -r "s,^$prev_login[[:space:]].*,$prev_login	*	\"$in_password\"	*," -i "$chapfile"
92
		sed -r "s,^password[[:space:]].*,password $in_password," -i "$name/pppoptions"
93
		
94
		# deny users from reading the password
95
		chmod o-rw "$name/pppoptions"
95
	fi
96
	fi
96
97
97
	ifdown "$1" && ifup "$1"
98
	ifdown "$1" && ifup "$1"
Lines 99-106 Link Here
99
100
100
new_iface()
101
new_iface()
101
{
102
{
102
	grep -qs "^$in_login[[:space:]]" "$chapfile" && return 1
103
104
	local name="/etc/net/ifaces/$1"
103
	local name="/etc/net/ifaces/$1"
105
	in_password=$(echo "$in_password"|sed -e 's/["]/\\\\&/g')
104
	in_password=$(echo "$in_password"|sed -e 's/["]/\\\\&/g')
106
105
Lines 111-119 Link Here
111
	shell_add_or_subst "REQUIRES=" "$in_iface" "$name/options"
110
	shell_add_or_subst "REQUIRES=" "$in_iface" "$name/options"
112
111
113
	shell_add_or_subst "user " "$in_login" "$name/pppoptions"
112
	shell_add_or_subst "user " "$in_login" "$name/pppoptions"
114
113
	shell_add_or_subst "password " "$in_password" "$name/pppoptions"
115
	echo "$in_login	*	\"$in_password\"	*" >>"$chapfile"
114
	
116
115
	# deny users from reading the password
116
	chmod o-rw "$name/pppoptions"
117
	
117
	ifup "$1"
118
	ifup "$1"
118
	return 0
119
	return 0
119
}
120
}
Lines 125-134 Link Here
125
	local name="/etc/net/ifaces/$1"
126
	local name="/etc/net/ifaces/$1"
126
	local prev_login="$(grep '^user' "$name/pppoptions"|sed -r 's,user[[:space:]]*,,')"
127
	local prev_login="$(grep '^user' "$name/pppoptions"|sed -r 's,user[[:space:]]*,,')"
127
128
128
	sed -r "/^$prev_login[[:space:]]/ d" -i "$chapfile"
129
	# do ifdown before rm so that ifup-{pre,post} are executed 
129
	rm -rf "$name"
130
	ifdown "$1" 
130
131
	rm -rf "$name" 
131
	ifdown "$1"
132
}
132
}
133
133
134
_()
134
_()

Return to bug 14649