X-Git-Url: http://sjero.net/git/?p=wget;a=blobdiff_plain;f=src%2Fmain.c;h=5fb91664ca65e63ec728550e7caa92c385248dc9;hp=421a5501b6e34e4795a9a62e779289e42aff1a2f;hb=ec84142901fc685d7a08267fc0be8962e468968d;hpb=e72b57629bf49cdfd663002a8bb336a67b958979 diff --git a/src/main.c b/src/main.c index 421a5501..5fb91664 100644 --- a/src/main.c +++ b/src/main.c @@ -56,6 +56,7 @@ as that of the covered work. */ #include "http.h" /* for save_cookies */ #include +#include "getpass.h" #ifndef PATH_SEPARATOR # define PATH_SEPARATOR '/' @@ -130,6 +131,7 @@ static struct cmdline_option option_data[] = { { "accept", 'A', OPT_VALUE, "accept", -1 }, { "append-output", 'a', OPT__APPEND_OUTPUT, NULL, required_argument }, + { "ask-password", 0, OPT_BOOLEAN, "askpassword", -1 }, { "auth-no-challenge", 0, OPT_BOOLEAN, "authnochallenge", -1 }, { "background", 'b', OPT_BOOLEAN, "background", -1 }, { "backup-converted", 'K', OPT_BOOLEAN, "backupconverted", -1 }, @@ -472,6 +474,8 @@ Download:\n"), --user=USER set both ftp and http user to USER.\n"), N_("\ --password=PASS set both ftp and http password to PASS.\n"), + N_("\ + --ask-password prompt for passwords.\n"), "\n", N_("\ @@ -673,6 +677,16 @@ secs_to_human_time (double interval) return buf; } +static char * +prompt_for_password (void) +{ + if (opt.user) + printf (_("Password for user \"%s\": "), opt.user); + else + printf (_("Password: ")); + return getpass(""); +} + static void print_version (void) { @@ -907,6 +921,13 @@ for details.\n\n")); } } + if (opt.ask_passwd && opt.passwd) + { + printf (_("Cannot specify both --ask-password and --password.\n")); + print_usage (); + exit (1); + } + if (!nurl && !opt.input_filename) { /* No URL specified. */ @@ -1002,6 +1023,9 @@ for details.\n\n")); char *filename = NULL, *redirected_URL = NULL; int dt; + if (opt.ask_passwd) + opt.passwd = prompt_for_password (); + if ((opt.recursive || opt.page_requisites) && (url_scheme (*t) != SCHEME_FTP || url_uses_proxy (*t))) {