#include "http.h" /* for save_cookies */
#include <getopt.h>
+#include <getpass.h>
+#include <quote.h>
#ifndef PATH_SEPARATOR
# define PATH_SEPARATOR '/'
{
{ "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 },
--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_("\
return buf;
}
+static char *
+prompt_for_password (void)
+{
+ if (opt.user)
+ printf (_("Password for user %s: "), quote (opt.user));
+ else
+ printf (_("Password: "));
+ return getpass("");
+}
+
static void
print_version (void)
{
}
}
+ 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. */
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)))
{