From 35987a1c74b708cd9ba2dc351400edd4d4046a6f Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 28 Feb 2014 23:17:28 +0000 Subject: Allow use of "ac x set -del password" to use /oper to change the password "securely". Patch from Flexo, bug #1117. --- irc.h | 2 +- irc_commands.c | 2 +- protocols/account.c | 16 ++++++++++++---- root_commands.c | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/irc.h b/irc.h index 866e85c3..39cf178c 100644 --- a/irc.h +++ b/irc.h @@ -59,7 +59,7 @@ typedef enum OPER_HACK_IDENTIFY_NOLOAD = 0x01100, OPER_HACK_IDENTIFY_FORCE = 0x02100, OPER_HACK_REGISTER = 0x200, - OPER_HACK_ACCOUNT_ADD = 0x400, + OPER_HACK_ACCOUNT_PASSWORD = 0x400, OPER_HACK_ANY = 0x3700, /* To check for them all at once. */ IRC_UTF8_NICKS = 0x10000, /* Disable ASCII restrictions on buddy nicks. */ diff --git a/irc_commands.c b/irc_commands.c index 3db243bf..19930121 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -432,7 +432,7 @@ static void irc_cmd_oper_hack( irc_t *irc, char **cmd ) /* /OPER can now also be used to enter IM/identify passwords without echoing. It's a hack but the extra password security is worth it. */ - if( irc->status & OPER_HACK_ACCOUNT_ADD ) + if( irc->status & OPER_HACK_ACCOUNT_PASSWORD ) { account_t *a; diff --git a/protocols/account.c b/protocols/account.c index dec9c3ea..b90a60ee 100644 --- a/protocols/account.c +++ b/protocols/account.c @@ -153,10 +153,18 @@ char *set_eval_account( set_t *set, char *value ) } else if( strcmp( set->key, "password" ) == 0 ) { - /* set -del should be allowed now, but I don't want to have any - NULL pointers to have to deal with. */ - if( !value ) - value = ""; + /* set -del allows /oper to be used to change the password or, + iff oauth is enabled, reset the oauth credential magic. + */ + if( !value ) { + if ( set_getbool( &(acc->set), "oauth" ) ) { + value = ""; + } else { + value = PASSWORD_PENDING; + ((irc_t *)acc->bee->ui_data)->status |= OPER_HACK_ACCOUNT_PASSWORD; + irc_rootmsg((irc_t *)acc->bee->ui_data, "You may now use /OPER to set the password"); + } + } g_free( acc->pass ); acc->pass = g_strdup( value ); diff --git a/root_commands.c b/root_commands.c index 0bd16163..2c153f0e 100644 --- a/root_commands.c +++ b/root_commands.c @@ -421,7 +421,7 @@ static void cmd_account( irc_t *irc, char **cmd ) return; } - irc->status |= OPER_HACK_ACCOUNT_ADD; + irc->status |= OPER_HACK_ACCOUNT_PASSWORD; } prpl = find_protocol( cmd[2] ); -- cgit v1.2.3