Moved code for connecting a PPTP tunnel to a separate function, so it can be called by other modules.
---- Changes since 1.190 ----
A PPTP tunnel can now be configured to activate at boot time.
+---- Changes since 1.390 ----
+When connecting a PPTP tunnel, an optional override password can be entered. This allows you to avoid storing the PPTP password in a configuration file. Thanks to Nicolas Ledoux for this patch.
print "<b>",&text('conn_cmd', "<tt>$config{'pptp'} $tunnel->{'server'} ".
"call $in{'tunnel'}</tt>"),"</b><p>\n";
-($ok, @status) = &connect_tunnel($tunnel);
+# If a password is passed, use it to temprarily overwrite the one in
+# the secrets file
+if ($in{'cpass'}) {
+ $login = &find("name", $tunnel->{'opts'});
+ $sn = $login ? $login->{'value'} : &get_system_hostname(1);
+ &lock_file($config{'pap_file'});
+ @secs = &list_secrets();
+ ($sec) = grep { $_->{'client'} eq $sn } @secs;
+ $oldsecret = $sec->{'secret'};
+ $sec->{'secret'} = $in{'cpass'};
+ &change_secret($sec);
+ &flush_file_lines();
+ ($ok, @status) = &connect_tunnel($tunnel);
+ $sec->{'secret'} = $oldsecret;
+ &change_secret($sec);
+ &flush_file_lines();
+ &unlock_file($config{'pap_file'});
+ &lock_file($config{'pap_file'});
+ }
+else {
+ ($ok, @status) = &connect_tunnel($tunnel);
+ }
+
if ($ok) {
# Worked! Tell user
print "<b>",&text('conn_ok', "<tt>$status[0]</tt>",
$config{'tunnel'} eq $t->{'name'} ? "selected" : "",
$t->{'name'};
}
- print "</select></td>\n";
+ print "</select>\n";
+ print $text{'index_pass'}," ",&ui_password("cpass", undef, 10);
+ print "</td>\n";
print "<td>$text{'index_conndesc'}</td> </form></tr>\n";
}
index_tunnel=Tunnel $1
index_add=Add a new PPTP VPN tunnel.
index_conn=Connect to:
+index_pass=with optional password:
index_conndesc=Click this button to connect the selected PPTP VPN tunnel using its current configuration.
index_disc=Disconnect from:
index_discdesc=Click this button to disconnect the selected currently active PPTP VPN tunnel and remove all routes through it.