I work at a company that uses authenticated proxy to access the web. In
order not to let my password exposed in clear text, I wrote this patch that
implement this function.

Regards,

Ronan

Changelog:

2010-02-05 Ronan Resende <[email protected]>

        * main.c (main): New code that handles prompting for proxy
        passwords when specified explicitly via command-line option

        * init.c: Add "ask-proxy-password" to the list of recognised
commands.

        * options.h: Add an according boolean member to the options
        struct.
--- /var/tmp/wget-1.12-original/src/main.c      2009-09-22 00:03:11.000000000 
-0300
+++ main.c      2010-02-05 09:35:00.000000000 -0200
@@ -151,6 +151,7 @@
     { "adjust-extension", 'E', OPT_BOOLEAN, "adjustextension", -1 },
     { "append-output", 'a', OPT__APPEND_OUTPUT, NULL, required_argument },
     { "ask-password", 0, OPT_BOOLEAN, "askpassword", -1 },
+    { "ask-proxy-password", 0, OPT_BOOLEAN, "askproxypassword", -1 },
     { "auth-no-challenge", 0, OPT_BOOLEAN, "authnochallenge", -1 },
     { "background", 'b', OPT_BOOLEAN, "background", -1 },
     { "backup-converted", 'K', OPT_BOOLEAN, "backupconverted", -1 },
@@ -547,6 +548,8 @@
     N_("\
        --max-redirect          maximum redirections allowed per page.\n"),
     N_("\
+       --ask-proxy-password    prompt for proxy password.\n"),
+    N_("\
        --proxy-user=USER       set USER as proxy username.\n"),
     N_("\
        --proxy-password=PASS   set PASS as proxy password.\n"),
@@ -1129,6 +1132,14 @@
         exit (1);
     }
 
+  if (opt.ask_proxy_passwd)
+    {
+      opt.proxy_passwd = prompt_for_password ();
+
+      if (opt.proxy_passwd == NULL || opt.proxy_passwd[0] == '\0')
+        exit (1);
+    }
+
 #ifdef USE_WATT32
   if (opt.wdebug)
      dbug_init();
--- /var/tmp/wget-1.12-original/src/init.c      2009-09-22 00:02:41.000000000 
-0300
+++ init.c      2010-02-04 18:58:30.000000000 -0200
@@ -110,6 +110,7 @@
   { "adjustextension",  &opt.adjust_extension,  cmd_boolean },
   { "alwaysrest",       &opt.always_rest,       cmd_boolean }, /* deprecated */
   { "askpassword",      &opt.ask_passwd,        cmd_boolean },
+  { "askproxypassword", &opt.ask_proxy_passwd,  cmd_boolean },
   { "authnochallenge",  &opt.auth_without_challenge,
                                                 cmd_boolean },
   { "background",       &opt.background,        cmd_boolean },
--- /var/tmp/wget-1.12-original/src/options.h   2009-09-22 00:03:47.000000000 
-0300
+++ options.h   2010-02-05 09:33:49.000000000 -0200
@@ -103,6 +103,7 @@
 
   bool use_proxy;              /* Do we use proxy? */
   bool allow_cache;            /* Do we allow server-side caching? */
+  bool ask_proxy_passwd;        /* Ask for proxy password? */
   char *http_proxy, *ftp_proxy, *https_proxy;
   char **no_proxy;
   char *base_href;

Reply via email to