new --*user and --*password options

Mauro Tortonesi <[email protected]>
Newsgroups gmane.comp.web.wget.patches
Organization University of Ferrara
Message-ID <[email protected]>
This patch adds the --user and --password options for setting username and 
password for both FTP and HTTP retrieval, --ftp-user and --ftp-password for 
setting username and password for FTP retrieval, renames the --ftp-passwd, 
--http-passwd and --proxy-passwd options to --ftp-password, --http-password 
and --proxy-password respectively, and deprecates the login and 
passwd .wgetrc commands.



Index: ChangeLog
===================================================================
RCS file: /pack/anoncvs/wget/ChangeLog,v
retrieving revision 1.249
diff -u -r1.249 ChangeLog
--- ChangeLog	2005/04/22 13:58:38	1.249
+++ ChangeLog	2005/04/27 21:21:24
@@ -1,3 +1,9 @@
+2005-04-27  Mauro Tortonesi  <[email protected]>
+
+	* NEWS: Mention the new --ftp-user, --ftp-password, --user and
+	--password options, the name changes for --http-passwd and
+	--proxy-passwd and the deprecation of login and passwd commands.
+
 2005-04-22  Hrvoje Niksic  <[email protected]>
 
 	* po/eo.po: Added Esperanto translation.
Index: NEWS
===================================================================
RCS file: /pack/anoncvs/wget/NEWS,v
retrieving revision 1.65
diff -u -r1.65 NEWS
--- NEWS	2005/04/26 20:24:43	1.65
+++ NEWS	2005/04/27 21:21:24
@@ -7,6 +7,14 @@
 
 * Changes in Wget 1.10.
 
+** Wget now supports the --ftp-user and --ftp-password command switches to 
set
+username and password for FTP, and the --user and --password command switches
+to set username and password for both FTP and HTTP.  The --http-passwd and
+--proxy-passwd command switches have been renamed to --http-password and
+--proxy-password respectively, and the related http_passwd and proxy_passwd 
+.wgetrc commands to http_password and proxy_password respectively. The 
+login and passwd .wgetrc commands have been deprecated.
+
 ** Downloading files greater than 2GB, also known as "large files",
 now works on systems that support them.  This includes most modern
 Unix variants, as well as Windows.
Index: doc/ChangeLog
===================================================================
RCS file: /pack/anoncvs/wget/doc/ChangeLog,v
retrieving revision 1.134
diff -u -r1.134 ChangeLog
--- doc/ChangeLog	2005/04/27 21:10:30	1.134
+++ doc/ChangeLog	2005/04/27 21:21:24
@@ -1,3 +1,12 @@
+2005-04-27  Mauro Tortonesi  <[email protected]>
+
+	* wget.texi: Document --user, --password, --ftp-user and the
+	corresponding Wgetrc command. Renamed --ftp-passwd to --ftp-password,
+	--http-passwd to --http-passwd and --proxy-passwd to proxy_password.
+	Renamed ftp_passwd to ftp_password, http_passwd to http_passwd and
+	proxy_passwd to proxy_password. Removed documentation for the
+	deprecated login command.
+
 2005-04-27  Hrvoje Niksic  <[email protected]>
 
 	* wget.texi (HTTPS (SSL/TLS) Options): Document --random-file.
Index: doc/wget.texi
===================================================================
RCS file: /pack/anoncvs/wget/doc/wget.texi,v
retrieving revision 1.123
diff -u -r1.123 wget.texi
--- doc/wget.texi	2005/04/27 21:10:30	1.123
+++ doc/wget.texi	2005/04/27 21:21:25
@@ -956,6 +956,17 @@
 not running at all and that retries would not help.  This option is
 for mirroring unreliable sites whose servers tend to disappear for
 short periods of time.
+
+@cindex user
+@cindex password
+@cindex authentication
+@item --user=@var{user}
+@itemx --password=@var{password}
+Specify the username @var{user} and password @var{password} for both
+@sc{ftp} and @sc{http} file retrieval.  These parameters can be overridden
+using the @samp{--ftp-user} and @samp{--ftp-password} options for 
+@sc{ftp} connections and the @samp{--http-user} and @samp{--http-password} 
+options for @sc{http} connections.
 @end table
 
 @node Directory Options
@@ -1060,7 +1071,7 @@
 @cindex http password
 @cindex authentication
 @item --http-user=@var{user}
-@itemx --http-passwd=@var{password}
+@itemx --http-password=@var{password}
 Specify the username @var{user} and password @var{password} on an
 @sc{http} server.  According to the type of the challenge, Wget will
 encode them using either the @code{basic} (insecure) or the
@@ -1225,12 +1236,12 @@
 @cindex proxy password
 @cindex proxy authentication
 @item --proxy-user=@var{user}
-@itemx --proxy-passwd=@var{password}
+@itemx --proxy-password=@var{password}
 Specify the username @var{user} and password @var{password} for
 authentication on a proxy server.  Wget will encode them using the
 @code{basic} authentication scheme.
 
-Security considerations similar to those with @samp{--http-passwd}
+Security considerations similar to those with @samp{--http-password}
 pertain here as well.
 
 @cindex http referer
@@ -1426,12 +1437,27 @@
 @section FTP Options
 
 @table @samp
-@cindex password, FTP
-@item --ftp-passwd=@var{string}
-Set the default FTP password to @var{string}.  Without this, or the
-corresponding startup option, the password defaults to @samp{-wget@@},
-normally used for anonymous FTP.
+@cindex ftp user
+@cindex ftp password
+@cindex ftp authentication
+@item --ftp-user=@var{user}
+@itemx --ftp-password=@var{password}
+Specify the username @var{user} and password @var{password} on an
+@sc{ftp} server.  Without this, or the corresponding startup option, 
+the password defaults to @samp{-wget@@}, normally used for anonymous 
+FTP.
 
+Another way to specify username and password is in the @sc{url} itself
+(@pxref{URL Format}).  Either method reveals your password to anyone who
+bothers to run @code{ps}.  To prevent the passwords from being seen,
+store them in @file{.wgetrc} or @file{.netrc}, and make sure to protect
+those files from other users with @code{chmod}.  If the passwords are
+really important, do not leave them lying in those files either---edit
+the files and delete them after Wget has started the download.
+
+For more information about security issues with Wget, @xref{Security
+Considerations}.
+
 @cindex .listing files, removing
 @item --no-remove-listing
 Don't remove the temporary @file{.listing} files generated by @sc{ftp}
@@ -2546,7 +2572,7 @@
 If set to on, force the input filename to be regarded as an @sc{html}
 document---the same as @samp{-F}.
 
-@item ftp_passwd = @var{string}
+@item ftp_password = @var{string}
 Set your @sc{ftp} password to @var{string}.  Without this setting, the
 password defaults to @samp{-wget@@}, which is a useful default for
 anonymous @sc{ftp} access.
@@ -2557,6 +2583,11 @@
 Use @var{string} as @sc{ftp} proxy, instead of the one specified in
 environment.
 
+@item ftp_user = @var{string}
+Set @sc{ftp} user to @var{string}.
+
+This command used to be named @code{login} prior to Wget 1.10.
+
 @item glob = on/off
 Turn globbing on/off---the same as @samp{--glob} and @samp{--no-glob}.
 
@@ -2572,9 +2603,9 @@
 Turn the keep-alive feature on or off (defaults to on).  Turning it
 off is equivalent to @samp{--no-http-keep-alive}.
 
-@item http_passwd = @var{string}
+@item http_password = @var{string}
 Set @sc{http} password, equivalent to
-@samp{--http-passwd=@var{string}}.
+@samp{--http-password=@var{string}}.
 
 @item http_proxy = @var{string}
 Use @var{string} as @sc{http} proxy, instead of the one specified in
@@ -2626,10 +2657,6 @@
 @item logfile = @var{file}
 Set logfile to @var{file}, the same as @samp{-o @var{file}}.
 
-@item login = @var{string}
-Your user name on the remote machine, for @sc{ftp}.  Defaults to
-@samp{anonymous}.
-
 @item mirror = on/off
 Turn mirroring on/off.  The same as @samp{-m}.
 
@@ -2661,6 +2688,11 @@
 firewall does not allow this, you can set @samp{passive_ftp = never}
 to override the command-line.
 
+@itemx password = @var{string}
+Specify password @var{string} for both @sc{ftp} and @sc{http} file retrieval. 
+This command can be overridden using the @samp{ftp_password} and 
+@samp{http_password} command for @sc{ftp} and @sc{http} respectively.
+
 @item post_data = @var{string}
 Use POST as the method for all HTTP requests and send @var{string} in
 the request body.  The same as @samp{--post-data=@var{string}}.
@@ -2697,9 +2729,9 @@
 Set proxy authentication user name to @var{string}, like
 @samp{--proxy-user=@var{string}}.
 
-@item proxy_passwd = @var{string}
+@item proxy_password = @var{string}
 Set proxy authentication password to @var{string}, like
-@samp{--proxy-passwd=@var{string}}.
+@samp{--proxy-password=@var{string}}.
 
 @item quiet = on/off
 Quiet mode---the same as @samp{-q}.
@@ -2793,6 +2825,11 @@
 variables are set.  In that case it is the same as using
 @samp{--no-proxy}.
 
+@item user = @var{string}
+Specify username @var{string} for both @sc{ftp} and @sc{http} file retrieval. 
+This command can be overridden using the @samp{ftp_user} and 
+@samp{http_user} command for @sc{ftp} and @sc{http} respectively.
+
 @item verbose = on/off
 Turn verbose on/off---the same as @samp{-v}/@samp{-nv}.
 
@@ -3167,7 +3204,7 @@
 
 Alternatively, you may use the @samp{proxy-user} and
 @samp{proxy-password} options, and the equivalent @file{.wgetrc}
-settings @code{proxy_user} and @code{proxy_passwd} to set the proxy
+settings @code{proxy_user} and @code{proxy_password} to set the proxy
 username and password.
 
 @node Distribution
Index: src/ChangeLog
===================================================================
RCS file: /pack/anoncvs/wget/src/ChangeLog,v
retrieving revision 1.738
diff -u -r1.738 ChangeLog
--- src/ChangeLog	2005/04/27 21:17:30	1.738
+++ src/ChangeLog	2005/04/27 21:21:26
@@ -1,3 +1,22 @@
+2005-04-27  Mauro Tortonesi  <[email protected]>
+
+	* ftp.c: Add support for --user and --password.
+	
+	* http.c: Add support for --user and --password.
+	
+	* init.c: Deprecated ftppasswd, httppasswd, login, passwd and
+	proxypasswd commands.  Added ftppassword, ftpuser, httppassword,
+	password, proxypassword and user commands.
+
+	* main.c: Renamed --ftp-passwd to --ftp-password.  Added --ftp-user,
+	--http-password, --password, --proxy-password and --user.  Deprecated
+	--http-passwd and --proxy-passwd.  Added documentation for new options
+	and removed documentation for deprecated options in the help string.
+	
+	* options.h (struct options): Added user and passwd members to handle
+	--user and --password respectively.  Renamed ftp_acc and ftp_pass
+	members to ftp_user and ftp_passwd for consistency.
+
 2005-04-27  Hrvoje Niksic  <[email protected]>
 
 	* main.c (print_help): Advertise "DER", not "ASN1".
Index: src/ftp.c
===================================================================
RCS file: /pack/anoncvs/wget/src/ftp.c,v
retrieving revision 1.100
diff -u -r1.100 ftp.c
--- src/ftp.c	2005/04/12 20:32:31	1.100
+++ src/ftp.c	2005/04/27 21:21:26
@@ -271,9 +271,10 @@
   user = u->user;
   passwd = u->passwd;
   search_netrc (u->host, (const char **)&user, (const char **)&passwd, 1);
-  user = user ? user : opt.ftp_acc;
-  passwd = passwd ? passwd : opt.ftp_pass;
-  assert (user && passwd);
+  user = user ? user : (opt.ftp_user ? opt.ftp_user : opt.user);
+  if (!user) user = "anonymous";
+  passwd = passwd ? passwd : (opt.ftp_passwd ? opt.ftp_passwd : opt.passwd);
+  if (!passwd) passwd = "-wget@";
 
   dtsock = -1;
   local_sock = -1;
Index: src/http.c
===================================================================
RCS file: /pack/anoncvs/wget/src/http.c,v
retrieving revision 1.169
diff -u -r1.169 http.c
--- src/http.c	2005/04/27 21:08:40	1.169
+++ src/http.c	2005/04/27 21:21:27
@@ -1243,8 +1243,8 @@
   user = u->user;
   passwd = u->passwd;
   search_netrc (u->host, (const char **)&user, (const char **)&passwd, 0);
-  user = user ? user : opt.http_user;
-  passwd = passwd ? passwd : opt.http_passwd;
+  user = user ? user : (opt.http_user ? opt.http_user : opt.user);
+  passwd = passwd ? passwd : (opt.http_passwd ? opt.http_passwd : 
opt.passwd);
 
   if (user && passwd)
     {
Index: src/init.c
===================================================================
RCS file: /pack/anoncvs/wget/src/init.c,v
retrieving revision 1.107
diff -u -r1.107 init.c
--- src/init.c	2005/04/27 21:08:40	1.107
+++ src/init.c	2005/04/27 21:21:27
@@ -157,14 +157,17 @@
   { "followftp",	&opt.follow_ftp,	cmd_boolean },
   { "followtags",	&opt.follow_tags,	cmd_vector },
   { "forcehtml",	&opt.force_html,	cmd_boolean },
-  { "ftppasswd",	&opt.ftp_pass,		cmd_string },
+  { "ftppasswd",	&opt.ftp_passwd,	cmd_string }, /* deprecated */
+  { "ftppassword",	&opt.ftp_passwd,	cmd_string },
+  { "ftpuser",	        &opt.ftp_user,		cmd_string },
   { "ftpproxy",		&opt.ftp_proxy,		cmd_string },
   { "glob",		&opt.ftp_glob,		cmd_boolean },
   { "header",		&opt.user_headers,	cmd_spec_header },
   { "htmlextension",	&opt.html_extension,	cmd_boolean },
   { "htmlify",		NULL,			cmd_spec_htmlify },
   { "httpkeepalive",	&opt.http_keep_alive,	cmd_boolean },
-  { "httppasswd",	&opt.http_passwd,	cmd_string },
+  { "httppasswd",	&opt.http_passwd,	cmd_string }, /* deprecated */
+  { "httppassword",	&opt.http_passwd,	cmd_string },
   { "httpproxy",	&opt.http_proxy,	cmd_string },
   { "httpsproxy",	&opt.https_proxy,	cmd_string },
   { "httpuser",		&opt.http_user,		cmd_string },
@@ -181,7 +184,7 @@
   { "limitrate",	&opt.limit_rate,	cmd_bytes },
   { "loadcookies",	&opt.cookies_input,	cmd_file },
   { "logfile",		&opt.lfilename,		cmd_file },
-  { "login",		&opt.ftp_acc,		cmd_string },
+  { "login",		&opt.ftp_user,		cmd_string },/* deprecated*/
   { "mirror",		NULL,			cmd_spec_mirror },
   { "netrc",		&opt.netrc,		cmd_boolean },
   { "noclobber",	&opt.noclobber,		cmd_boolean },
@@ -191,6 +194,8 @@
   { "outputdocument",	&opt.output_document,	cmd_file },
   { "pagerequisites",	&opt.page_requisites,	cmd_boolean },
   { "passiveftp",	&opt.ftp_pasv,		cmd_lockable_boolean },
+  { "passwd",	        &opt.ftp_passwd,	cmd_string },/* deprecated*/
+  { "password",	        &opt.passwd,		cmd_string },
   { "postdata",		&opt.post_data,		cmd_string },
   { "postfile",		&opt.post_file_name,	cmd_file },
   { "preferfamily",	NULL,			cmd_spec_prefer_family },
@@ -201,7 +206,8 @@
 #endif
   { "progress",		&opt.progress_type,	cmd_spec_progress },
   { "protocoldirectories", &opt.protocol_directories, cmd_boolean },
-  { "proxypasswd",	&opt.proxy_passwd,	cmd_string },
+  { "proxypasswd",	&opt.proxy_passwd,	cmd_string }, /* deprecated */
+  { "proxypassword",	&opt.proxy_passwd,	cmd_string },
   { "proxyuser",	&opt.proxy_user,	cmd_string },
   { "quiet",		&opt.quiet,		cmd_boolean },
   { "quota",		&opt.quota,		cmd_bytes_large },
@@ -231,6 +237,7 @@
   { "timestamping",	&opt.timestamping,	cmd_boolean },
   { "tries",		&opt.ntry,		cmd_number_inf },
   { "useproxy",		&opt.use_proxy,		cmd_boolean },
+  { "user",	        &opt.user,		cmd_string },
   { "useragent",	NULL,			cmd_spec_useragent },
   { "verbose",		&opt.verbose,		cmd_boolean },
   { "wait",		&opt.wait,		cmd_time },
@@ -279,8 +286,6 @@
   opt.ntry = 20;
   opt.reclevel = 5;
   opt.add_hostdir = 1;
-  opt.ftp_acc  = xstrdup ("anonymous");
-  opt.ftp_pass = xstrdup ("-wget@");
   opt.netrc = 1;
   opt.ftp_glob = 1;
   opt.htmlify = 1;
@@ -1449,7 +1454,8 @@
   free_vec (opt.ignore_tags);
   xfree_null (opt.progress_type);
   xfree (opt.ftp_acc);
-  xfree_null (opt.ftp_pass);
+  xfree_null (opt.ftp_user);
+  xfree_null (opt.ftp_passwd);
   xfree_null (opt.ftp_proxy);
   xfree_null (opt.https_proxy);
   xfree_null (opt.http_proxy);
@@ -1466,5 +1472,7 @@
   xfree_null (opt.bind_address);
   xfree_null (opt.cookies_input);
   xfree_null (opt.cookies_output);
+  xfree_null (opt.user);
+  xfree_null (opt.passwd);
 #endif /* DEBUG_MALLOC */
 }
Index: src/main.c
===================================================================
RCS file: /pack/anoncvs/wget/src/main.c,v
retrieving revision 1.132
diff -u -r1.132 main.c
--- src/main.c	2005/04/27 21:17:30	1.132
+++ src/main.c	2005/04/27 21:21:27
@@ -186,7 +186,8 @@
     { "follow-tags", 0, OPT_VALUE, "followtags", -1 },
     { "force-directories", 'x', OPT_BOOLEAN, "dirstruct", -1 },
     { "force-html", 'F', OPT_BOOLEAN, "forcehtml", -1 },
-    { "ftp-passwd", 0, OPT_VALUE, "ftppasswd", -1 },
+    { "ftp-password", 0, OPT_VALUE, "ftppasswd", -1 },
+    { "ftp-user", 0, OPT_VALUE, "ftpuser", -1 },
     { "glob", 0, OPT_BOOLEAN, "glob", -1 },
     { "header", 0, OPT_VALUE, "header", -1 },
     { "help", 'h', OPT_FUNCALL, (void *)print_help, no_argument },
@@ -194,7 +195,8 @@
     { "html-extension", 'E', OPT_BOOLEAN, "htmlextension", -1 },
     { "htmlify", 0, OPT_BOOLEAN, "htmlify", -1 },
     { "http-keep-alive", 0, OPT_BOOLEAN, "httpkeepalive", -1 },
-    { "http-passwd", 0, OPT_VALUE, "httppasswd", -1 },
+    { "http-passwd", 0, OPT_VALUE, "httppasswd", -1 }, /* deprecated */
+    { "http-password", 0, OPT_VALUE, "httppasswd", -1 },
     { "http-user", 0, OPT_VALUE, "httpuser", -1 },
     { "ignore-length", 0, OPT_BOOLEAN, "ignorelength", -1 },
     { "ignore-tags", 0, OPT_VALUE, "ignoretags", -1 },
@@ -217,6 +219,7 @@
     { "page-requisites", 'p', OPT_BOOLEAN, "pagerequisites", -1 },
     { "parent", 0, OPT__PARENT, NULL, optional_argument },
     { "passive-ftp", 0, OPT_BOOLEAN, "passiveftp", -1 },
+    { "password", 0, OPT_VALUE, "password", -1 },
     { "post-data", 0, OPT_VALUE, "postdata", -1 },
     { "post-file", 0, OPT_VALUE, "postfile", -1 },
     { "prefer-family", 0, OPT_VALUE, "preferfamily", -1 },
@@ -227,7 +230,8 @@
     { "protocol-directories", 0, OPT_BOOLEAN, "protocoldirectories", -1 },
     { "proxy", 0, OPT_BOOLEAN, "useproxy", -1 },
     { "proxy__compat", 'Y', OPT_VALUE, "useproxy", -1 }, /* back-compatible 
*/
-    { "proxy-passwd", 0, OPT_VALUE, "proxypasswd", -1 },
+    { "proxy-passwd", 0, OPT_VALUE, "proxypasswd", -1 }, /* deprecated */
+    { "proxy-password", 0, OPT_VALUE, "proxypasswd", -1 },
     { "proxy-user", 0, OPT_VALUE, "proxyuser", -1 },
     { "quiet", 'q', OPT_BOOLEAN, "quiet", -1 },
     { "quota", 'Q', OPT_VALUE, "quota", -1 },
@@ -252,6 +256,7 @@
     { "timeout", 'T', OPT_VALUE, "timeout", -1 },
     { "timestamping", 'N', OPT_BOOLEAN, "timestamping", -1 },
     { "tries", 't', OPT_VALUE, "tries", -1 },
+    { "user", 0, OPT_VALUE, "user", -1 },
     { "user-agent", 'U', OPT_VALUE, "useragent", -1 },
     { "verbose", 'v', OPT_BOOLEAN, "verbose", -1 },
     { "verbose", 0, OPT_BOOLEAN, "verbose", -1 },
@@ -497,7 +502,7 @@
     N_("\
        --http-user=USER        set http user to USER.\n"),
     N_("\
-       --http-passwd=PASS      set http password to PASS.\n"),
+       --http-password=PASS    set http password to PASS.\n"),
     N_("\
        --no-cache              disallow server-cached data.\n"),
     N_("\
@@ -509,7 +514,7 @@
     N_("\
        --proxy-user=USER       set USER as proxy username.\n"),
     N_("\
-       --proxy-passwd=PASS     set PASS as proxy password.\n"),
+       --proxy-password=PASS   set PASS as proxy password.\n"),
     N_("\
        --referer=URL           include `Referer: URL' header in HTTP request.
\n"),
     N_("\
@@ -561,6 +566,10 @@
 
     N_("\
 FTP options:\n"),
+    N_("\
+       --ftp-user=USER         set ftp user to USER.\n"),
+    N_("\
+       --ftp-password=PASS     set ftp password to PASS.\n"),
     N_("\
        --no-remove-listing     don't remove `.listing' files.\n"),
     N_("\
Index: src/options.h
===================================================================
RCS file: /pack/anoncvs/wget/src/options.h,v
retrieving revision 1.51
diff -u -r1.51 options.h
--- src/options.h	2005/04/27 21:08:40	1.51
+++ src/options.h	2005/04/27 21:21:27
@@ -80,14 +80,17 @@
   char *output_document;	/* The output file to which the
 				   documents will be printed.  */
 
+  char *user;			/* Generic username */
+  char *passwd;			/* Generic password */
+  
   int always_rest;		/* Always use REST. */
-  char *ftp_acc;		/* FTP username */
-  char *ftp_pass;		/* FTP password */
+  char *ftp_user;		/* FTP username */
+  char *ftp_passwd;		/* FTP password */
   int netrc;			/* Whether to read .netrc. */
   int ftp_glob;			/* FTP globbing */
   int ftp_pasv;			/* Passive FTP. */
 
-  char *http_user;		/* HTTP user. */
+  char *http_user;		/* HTTP username. */
   char *http_passwd;		/* HTTP password. */
   char **user_headers;		/* User-defined header(s). */
   int http_keep_alive;		/* whether we use keep-alive */

-- 
Aequam memento rebus in arduis servare mentem...

Mauro Tortonesi                          http://www.tortonesi.com

University of Ferrara - Dept. of Eng.    http://www.ing.unife.it
Institute of Human & Machine Cognition   http://www.ihmc.us
GNU Wget - HTTP/FTP file retrieval tool  http://www.gnu.org/software/wget
Deep Space 6 - IPv6 for Linux            http://www.deepspace6.net
Ferrara Linux User Group                 http://www.ferrara.linux.it
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.