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

(-)net-pptp.orig (-5 / +31 lines)
Lines 67-72 Link Here
67
read_iface()
67
read_iface()
68
{
68
{
69
	local name="/etc/net/ifaces/$1" && shift
69
	local name="/etc/net/ifaces/$1" && shift
70
	local MPPE="#f"	# mppe is off by default with pppd
71
	grep -q '^require-mppe' "$name/pppoptions" && MPPE="#t"
70
	
72
	
71
	( PPTP_SERVER=
73
	( PPTP_SERVER=
72
	  REQUIRES=
74
	  REQUIRES=
Lines 76-95 Link Here
76
	printf 'server "%s"' "$PPTP_SERVER"
78
	printf 'server "%s"' "$PPTP_SERVER"
77
	printf 'iface "%s"' "$REQUIRES"
79
	printf 'iface "%s"' "$REQUIRES"
78
	printf 'login "%s"' "$(grep '^user' "$name/pppoptions"|sed -r 's,user[[:space:]]*,,')"
80
	printf 'login "%s"' "$(grep '^user' "$name/pppoptions"|sed -r 's,user[[:space:]]*,,')"
81
	printf 'mppe %s' "$MPPE"
79
	echo ')'
82
	echo ')'
80
	
83
	
81
	)
84
	)
82
}
85
}
83
86
87
set_mppe()
88
{
89
	if [ -n "$in_mppe" ]; then
90
		if [ "$in_mppe" = "#t" ]; then
91
			MPPE_ADD="require-mppe"
92
			MPPE_DEL="nomppe"
93
		else
94
			MPPE_ADD="nomppe"
95
			MPPE_DEL="require-mppe"
96
		fi
97
		sed "/^$MPPE_ADD/d" -i "$name/pppoptions" ||:
98
		if grep -q "^$MPPE_DEL" "$name/pppoptions"; then
99
			sed "s,^$MPPE_DEL,$MPPE_ADD," -i "$name/pppoptions" ||:
100
		else
101
			echo "$MPPE_ADD" >> "$name/pppoptions"
102
		fi
103
	fi
104
}
105
84
write_iface()
106
write_iface()
85
{
107
{
86
	[ "$1" = "/" ] && return
108
	[ "$1" = "/" ] && return
87
	local name="/etc/net/ifaces/$1"
109
	local name="/etc/net/ifaces/$1"
88
	prev_login="$(grep '^user' "$name/pppoptions"|sed -r 's,user[[:space:]]*,,')"
110
	local prev_login="$(grep '^user' "$name/pppoptions"|sed -r 's,user[[:space:]]*,,')"
89
	[ -d "$name" ] || mkdir "$name"
111
	[ -d "$name" ] || mkdir "$name"
90
	[ -n "$in_server" ] && shell_add_or_subst "PPTP_SERVER=" "$in_server" "$name/options"
112
	[ -n "$in_server" ] && shell_add_or_subst "PPTP_SERVER=" "$in_server" "$name/options"
91
	[ -n "$in_iface" ] && shell_add_or_subst "REQUIRES=" "$in_iface" "$name/options"
113
	[ -n "$in_iface" ] && shell_add_or_subst "REQUIRES=" "$in_iface" "$name/options"
92
	
93
	if [ -n "$in_login" ] ;then
114
	if [ -n "$in_login" ] ;then
94
		sed -r "s,^user[[:space:]].*,user $in_login," -i "$name/pppoptions"
115
		sed -r "s,^user[[:space:]].*,user $in_login," -i "$name/pppoptions"
95
		sed -r "s,^$prev_login[[:space:]]*,$in_login	," -i "$chapfile"
116
		sed -r "s,^$prev_login[[:space:]]*,$in_login	," -i "$chapfile"
Lines 100-107 Link Here
100
		sed -r "s,^$prev_login[[:space:]].*,$prev_login	*	\"$in_password\"	*," -i "$chapfile"
121
		sed -r "s,^$prev_login[[:space:]].*,$prev_login	*	\"$in_password\"	*," -i "$chapfile"
101
	fi
122
	fi
102
123
103
	"$ifdown" "$1"
124
	set_mppe
104
	"$ifup" "$1"
125
126
	# NB: ifup (etcnet-0.9.4-alt1) would complain like this:
127
	# ERROR: /sbin/ifup: Could not ifup dependency for interface 'ppp0'
128
	# while eth0 would be perfectly up and working -- mike on 20071205
129
	ifdown "$1" && ifup "$1"
105
}
130
}
106
131
107
new_iface()
132
new_iface()
Lines 118-123 Link Here
118
	shell_add_or_subst "REQUIRES=" "$in_iface" "$name/options"
143
	shell_add_or_subst "REQUIRES=" "$in_iface" "$name/options"
119
144
120
	shell_add_or_subst "user " "$in_login" "$name/pppoptions"
145
	shell_add_or_subst "user " "$in_login" "$name/pppoptions"
146
	set_mppe
121
147
122
	echo "$in_login	*	\"$in_password\"	*" >>"$chapfile"
148
	echo "$in_login	*	\"$in_password\"	*" >>"$chapfile"
123
149
Lines 130-136 Link Here
130
{
156
{
131
	[ "$1" = "/" ] && return
157
	[ "$1" = "/" ] && return
132
	local name="/etc/net/ifaces/$1"
158
	local name="/etc/net/ifaces/$1"
133
	prev_login="$(grep '^user' "$name/pppoptions"|sed -r 's,user[[:space:]]*,,')"
159
	local prev_login="$(grep '^user' "$name/pppoptions"|sed -r 's,user[[:space:]]*,,')"
134
160
135
	sed -r "/^$prev_login[[:space:]]/ d" -i "$chapfile"
161
	sed -r "/^$prev_login[[:space:]]/ d" -i "$chapfile"
136
	rm -rf "$name"
162
	rm -rf "$name"

Return to bug 11988