Optional connect-time password
authorJamie Cameron <jcameron@webmin.com>
Sat, 19 Jan 2008 01:32:58 +0000 (01:32 +0000)
committerJamie Cameron <jcameron@webmin.com>
Sat, 19 Jan 2008 01:32:58 +0000 (01:32 +0000)
pptp-client/CHANGELOG
pptp-client/conn.cgi
pptp-client/index.cgi
pptp-client/lang/en

index 2e2767b..59d22b6 100644 (file)
@@ -2,3 +2,5 @@
 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.
index b08d99c..684dc51 100755 (executable)
@@ -25,7 +25,29 @@ $| = 1;
 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>",
index ea343ae..f827eb5 100755 (executable)
@@ -62,7 +62,9 @@ else {
                          $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 5e3544a..4debcab 100644 (file)
@@ -7,6 +7,7 @@ index_none=No PPTP tunnels have been defined yet.
 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.