From e815fe81a05f6cec2a684b10567f116e4d721689 Mon Sep 17 00:00:00 2001 From: mtortonesi Date: Wed, 27 Apr 2005 14:30:22 -0700 Subject: [PATCH] [svn] Add the --user, --password, --ftp-user and --ftp-password options. Rename the --ftp-passwd, --http-passwd and --proxy-passwd options to --ftp-password, --http-password and --proxy-password respectively. Deprecate the login and passwd .wgetrc commands. --- ChangeLog | 6 +++++ NEWS | 8 ++++++ doc/ChangeLog | 9 +++++++ doc/wget.texi | 73 ++++++++++++++++++++++++++++++++++++++------------- src/ChangeLog | 19 ++++++++++++++ src/ftp.c | 7 ++--- src/http.c | 4 +-- src/init.c | 22 +++++++++++----- src/main.c | 19 ++++++++++---- src/options.h | 9 ++++--- 10 files changed, 138 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index cb84b531..0411a889 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-04-27 Mauro Tortonesi + + * 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 * po/eo.po: Added Esperanto translation. diff --git a/NEWS b/NEWS index b625a813..ca793717 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,14 @@ Please send GNU Wget bug reports to . * 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. diff --git a/doc/ChangeLog b/doc/ChangeLog index c2fa84c0..4fbfab4a 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,12 @@ +2005-04-27 Mauro Tortonesi + + * 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 * wget.texi (HTTPS (SSL/TLS) Options): Document --random-file. diff --git a/doc/wget.texi b/doc/wget.texi index 671310c0..9c7b1cb8 100644 --- a/doc/wget.texi +++ b/doc/wget.texi @@ -956,6 +956,17 @@ site because failure to connect is taken as a sign that the server is 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 @@ Retrieval Options}). @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 @@ sending of duplicate headers. @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,11 +1437,26 @@ systems that support @file{/dev/random}. @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 @@ -2546,7 +2572,7 @@ just like @samp{--follow-tags=@var{string}}. 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 @@ This command used to be named @code{passwd} prior to Wget 1.10. 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 @@ Add a @samp{.html} extension to @samp{text/html} or 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 @@ Load cookies from @var{file}. See @samp{--load-cookies @var{file}}. @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 @@ module) files download files using @samp{wget --passive-ftp}. If your 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 @@ names. The same as @samp{--protocol-directories}. 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 @@ When set to off, don't use proxy even when proxy-related environment 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 @@ http://hniksic:mypassword@@proxy.company.com:8001/ 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 diff --git a/src/ChangeLog b/src/ChangeLog index 2478ddc8..2b98c3e6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,22 @@ +2005-04-27 Mauro Tortonesi + + * 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 * main.c (print_help): Advertise "DER", not "ASN1". diff --git a/src/ftp.c b/src/ftp.c index 82bc84ae..3542d18e 100644 --- a/src/ftp.c +++ b/src/ftp.c @@ -271,9 +271,10 @@ getftp (struct url *u, wgint *len, wgint restval, ccon *con) 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; diff --git a/src/http.c b/src/http.c index 9162d85e..ed027a99 100644 --- a/src/http.c +++ b/src/http.c @@ -1243,8 +1243,8 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy) 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) { diff --git a/src/init.c b/src/init.c index 5957aa53..c0bbee52 100644 --- a/src/init.c +++ b/src/init.c @@ -157,14 +157,17 @@ static struct { { "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 @@ static struct { { "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 @@ static struct { { "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 @@ static struct { #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 @@ static struct { { "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 @@ defaults (void) 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 @@ cleanup (void) 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 @@ cleanup (void) 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 */ } diff --git a/src/main.c b/src/main.c index 3be046f2..32766365 100644 --- a/src/main.c +++ b/src/main.c @@ -186,7 +186,8 @@ struct cmdline_option option_data[] = { "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 @@ struct cmdline_option option_data[] = { "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 @@ struct cmdline_option option_data[] = { "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 @@ struct cmdline_option option_data[] = { "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 @@ struct cmdline_option option_data[] = { "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 @@ HTTP options:\n"), 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 @@ HTTP options:\n"), 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 @@ HTTPS (SSL/TLS) options:\n"), 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_("\ diff --git a/src/options.h b/src/options.h index 6e968aac..71182c5e 100644 --- a/src/options.h +++ b/src/options.h @@ -80,14 +80,17 @@ struct options 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 */ -- 2.39.2