diff options
author | David Sommerseth <dazo@users.sourceforge.net> | 2008-12-12 23:30:41 +0100 |
---|---|---|
committer | David Sommerseth <dazo@users.sourceforge.net> | 2008-12-12 23:30:41 +0100 |
commit | e937945a5697a594747475c610789436b2c4fa28 (patch) | |
tree | b36b13844858b23c8c3e43dc431d7f32ab0efa2e /eurephiadm | |
parent | 3e9f99119b6ce0b151f3396b7c28eed860a1286a (diff) | |
download | eurephia-e937945a5697a594747475c610789436b2c4fa28.tar.gz eurephia-e937945a5697a594747475c610789436b2c4fa28.tar.xz eurephia-e937945a5697a594747475c610789436b2c4fa28.zip |
Added username in config file
By adding username=<eurephiadm username>, the program will not ask about
username when logging in, only password
Diffstat (limited to 'eurephiadm')
-rw-r--r-- | eurephiadm/eurephiadm.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/eurephiadm/eurephiadm.c b/eurephiadm/eurephiadm.c index 43ae999..3cc1fa2 100644 --- a/eurephiadm/eurephiadm.c +++ b/eurephiadm/eurephiadm.c @@ -170,14 +170,19 @@ int eurephia_ConnectDB(eurephiaCTX *ctx, const char *argstr) { return 1; } -eurephiaSESSION *do_login(eurephiaCTX *ctx, const char *req_access) { +eurephiaSESSION *do_login(eurephiaCTX *ctx, eurephiaVALUES *cfg, const char *req_access) { eurephiaSESSION *session = NULL; - char username[33], password[33]; + char username[33], password[33], *tmp = NULL; int uid = 0; memset(&username, 0, 33); memset(&password, 0, 33); - get_console_input(username, 32, "User:", 0); + if( (tmp = eGet_value(cfg, "username")) == NULL ) { + memset(username, 0, 34); + get_console_input(username, 32, "User:", 0); + } else { + strncpy(username, tmp, 32); + } get_console_input(password, 32, "Password:", 1); if( (uid = eDBadminAuth(ctx, req_access, username, password)) < 1 ) { @@ -350,7 +355,7 @@ int main(int argc, char **argv) { rc = 0; goto exit; } - session = do_login(ctx, call_fnc->accesslvl); + session = do_login(ctx, cfg, call_fnc->accesslvl); if( session == NULL ) { fprintf(stderr, "Login failed\n"); } @@ -370,7 +375,7 @@ int main(int argc, char **argv) { } else { // If not valid, remove session file and go to login remove_session_file(ctx); - session = do_login(ctx, call_fnc->accesslvl); + session = do_login(ctx, cfg, call_fnc->accesslvl); if( session == NULL ) { fprintf(stderr, "Login failed\n"); } |