fuse: allow entering username and password via stdin

- when either username or password are not specified via commandline
   arguments or configuration file, ask them on standard input
 - unify function to read username and password
 - move function to read username and password from mfshell to
   utils/strings.c
 - remove commented cruft from utils/strings.c
This commit is contained in:
josch
2014-12-01 21:59:59 +01:00
parent ffc933cf10
commit 9c4195ebdd
4 changed files with 54 additions and 151 deletions

View File

@@ -536,11 +536,6 @@ static void connect_mf(struct mediafirefs_user_options *options,
options->server = "www.mediafire.com";
}
if (options->username == NULL || options->password == NULL) {
fprintf(stderr, "You must specify username and password\n");
exit(1);
}
ctx->conn = mfconn_create(options->server, options->username,
options->password, options->app_id,
options->api_key);
@@ -657,6 +652,15 @@ int main(int argc, char *argv[])
parse_arguments(&argc, &argv, &options, ctx->configfile);
if (options.username == NULL) {
printf("login: ");
options.username = string_line_from_stdin(false);
}
if (options.password == NULL) {
printf("passwd: ");
options.password = string_line_from_stdin(true);
}
connect_mf(&options, ctx);
ret = fuse_main(argc, argv, &mediafirefs_oper, ctx);