From 8f726ab5e536f24b2875690c13c94ec9efff585e Mon Sep 17 00:00:00 2001 From: josch Date: Tue, 23 Sep 2014 09:26:28 +0200 Subject: [PATCH] allow to pass username and password by commandline arguments --- mfshell/main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mfshell/main.c b/mfshell/main.c index fccf445..ee0c6ef 100644 --- a/mfshell/main.c +++ b/mfshell/main.c @@ -25,6 +25,7 @@ #include #include +#include "../utils/strings.h" #include "mfshell.h" static void mfshell_run(mfshell * shell); @@ -124,6 +125,7 @@ int main(int argc, char *const argv[]) char *username = NULL; char *password = NULL; char *command = NULL; + char *auth_cmd; SSL_library_init(); @@ -132,6 +134,16 @@ int main(int argc, char *const argv[]) shell = mfshell_create(35860, "2c6dq0gb2sr8rgsue5a347lzpjnaay46yjazjcjg", server); + if (username != NULL) { + if (password != NULL) { + auth_cmd = strdup_printf("auth %s %s", username, password); + } else { + auth_cmd = strdup_printf("auth %s", username); + } + mfshell_parse_commands(shell, auth_cmd); + free(auth_cmd); + } + if (command == NULL) { // begin shell mode mfshell_run(shell);