From 480589f0aec93b5b83d287a221c69d0388f2ec3f Mon Sep 17 00:00:00 2001 From: Tomás Senart Date: Mon, 14 Oct 2013 20:15:51 +0200 Subject: Use passwords from the accounts file This commit makes it so that if the password in an account in the accounts file is present, then use it. Otherwise ask for the password to the user. --- src/config/accounts.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/config/accounts.h') diff --git a/src/config/accounts.h b/src/config/accounts.h index 4c74a523..ba282eac 100644 --- a/src/config/accounts.h +++ b/src/config/accounts.h @@ -28,6 +28,7 @@ typedef struct prof_account_t { gchar *name; gchar *jid; + gchar *password; gchar *resource; gchar *server; gchar *last_presence; -- cgit 1.4.1-2-gfad0 From 99d3322834c337bd6de755665acc08472769b5bd Mon Sep 17 00:00:00 2001 From: James Booth Date: Thu, 7 Nov 2013 22:15:43 +0000 Subject: Added MAX_PASSWORD_SIZE set to 64 fixes #245 --- src/command/command.c | 2 +- src/config/accounts.h | 2 ++ src/ui/inputwin.c | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/config/accounts.h') diff --git a/src/command/command.c b/src/command/command.c index 35bcd4f7..296cf38d 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -3530,7 +3530,7 @@ _cmd_xa(gchar **args, struct cmd_help_t help) static char * _ask_password(void) { - char *passwd = malloc(sizeof(char) * 21); + char *passwd = malloc(sizeof(char) * (MAX_PASSWORD_SIZE + 1)); status_bar_get_password(); status_bar_refresh(); inp_block(); diff --git a/src/config/accounts.h b/src/config/accounts.h index ba282eac..f28067f1 100644 --- a/src/config/accounts.h +++ b/src/config/accounts.h @@ -23,6 +23,8 @@ #ifndef ACCOUNTS_H #define ACCOUNTS_H +#define MAX_PASSWORD_SIZE 64 + #include "common.h" typedef struct prof_account_t { diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c index dfcb533d..d5b882d7 100644 --- a/src/ui/inputwin.c +++ b/src/ui/inputwin.c @@ -35,6 +35,7 @@ #include "command/command.h" #include "common.h" +#include "config/accounts.h" #include "config/preferences.h" #include "config/theme.h" #include "log.h" @@ -207,7 +208,7 @@ inp_get_password(char *passwd) _clear_input(); _inp_win_refresh(); noecho(); - mvwgetnstr(inp_win, 0, 1, passwd, 20); + mvwgetnstr(inp_win, 0, 1, passwd, MAX_PASSWORD_SIZE); wmove(inp_win, 0, 0); echo(); status_bar_clear(); -- cgit 1.4.1-2-gfad0 From be653667e4d250c7ec28f2eab5026e63e95f5453 Mon Sep 17 00:00:00 2001 From: James Booth Date: Thu, 7 Nov 2013 23:36:04 +0000 Subject: Added /account set password --- src/command/command.c | 5 +++++ src/config/accounts.c | 9 +++++++++ src/config/accounts.h | 1 + 3 files changed, 15 insertions(+) (limited to 'src/config/accounts.h') diff --git a/src/command/command.c b/src/command/command.c index 95f16f93..f7737464 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -759,6 +759,7 @@ static struct cmd_t command_defs[] = "online|chat|away", "|xa|dnd : Priority for the specified presence.", "resource : The resource to be used.", + "password : Password for the account, note this is currently stored in plaintext if set.", "muc : The default MUC chat service to use.", "nick : The default nickname to use when joining chat rooms.", "", @@ -1518,6 +1519,10 @@ _cmd_account(gchar **args, struct cmd_help_t help) accounts_set_resource(account_name, value); cons_show("Updated resource for account %s: %s", account_name, value); cons_show(""); + } else if (strcmp(property, "password") == 0) { + accounts_set_password(account_name, value); + cons_show("Updated password for account %s", account_name); + cons_show(""); } else if (strcmp(property, "muc") == 0) { accounts_set_muc_service(account_name, value); cons_show("Updated muc service for account %s: %s", account_name, value); diff --git a/src/config/accounts.c b/src/config/accounts.c index ff140769..6bfc7bef 100644 --- a/src/config/accounts.c +++ b/src/config/accounts.c @@ -434,6 +434,15 @@ accounts_set_resource(const char * const account_name, const char * const value) } } +void +accounts_set_password(const char * const account_name, const char * const value) +{ + if (accounts_account_exists(account_name)) { + g_key_file_set_string(accounts, account_name, "password", value); + _save_accounts(); + } +} + void accounts_set_muc_service(const char * const account_name, const char * const value) { diff --git a/src/config/accounts.h b/src/config/accounts.h index f28067f1..118b5c80 100644 --- a/src/config/accounts.h +++ b/src/config/accounts.h @@ -65,6 +65,7 @@ gboolean accounts_account_exists(const char * const account_name); void accounts_set_jid(const char * const account_name, const char * const value); void accounts_set_server(const char * const account_name, const char * const value); void accounts_set_resource(const char * const account_name, const char * const value); +void accounts_set_password(const char * const account_name, const char * const value); void accounts_set_muc_service(const char * const account_name, const char * const value); void accounts_set_muc_nick(const char * const account_name, const char * const value); void accounts_set_last_presence(const char * const account_name, const char * const value); -- cgit 1.4.1-2-gfad0