From 9564e55a35ebffaad644c13827ec2b795fb21154 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 22 Nov 2010 13:17:45 +0000 Subject: Allow omitting the password argument to "account add", to then separately enter the password using the /OPER command (which will not echo to the screen and/or logs). It's a fairly ugly hack but the improved password security is worth it IMHO. --- root_commands.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index db29d088..01313b1c 100644 --- a/root_commands.c +++ b/root_commands.c @@ -393,7 +393,16 @@ static void cmd_account( irc_t *irc, char **cmd ) { struct prpl *prpl; - MIN_ARGS( 4 ); + MIN_ARGS( 3 ); + + if( cmd[4] == NULL ) + for( a = irc->b->accounts; a; a = a->next ) + if( strcmp( a->pass, PASSWORD_PENDING ) == 0 ) + { + irc_usermsg( irc, "Enter password for account %s(%s) " + "first (use /OPER)", a->prpl->name, a->user ); + return; + } prpl = find_protocol( cmd[2] ); @@ -409,7 +418,7 @@ static void cmd_account( irc_t *irc, char **cmd ) "protocol `%s' and username `%s'. Are you accidentally " "trying to add it twice?", prpl->name, cmd[3] ); - a = account_add( irc->b, prpl, cmd[3], cmd[4] ); + a = account_add( irc->b, prpl, cmd[3], cmd[4] ? cmd[4] : PASSWORD_PENDING ); if( cmd[5] ) { irc_usermsg( irc, "Warning: Passing a servername/other flags to `account add' " @@ -419,6 +428,9 @@ static void cmd_account( irc_t *irc, char **cmd ) irc_usermsg( irc, "Account successfully added" ); + if( cmd[4] == NULL ) + irc_usermsg( irc, "Now, use /OPER to enter your password for this account" ); + return; } else if( len >= 1 && g_strncasecmp( cmd[1], "list", len ) == 0 ) @@ -461,7 +473,13 @@ static void cmd_account( irc_t *irc, char **cmd ) for( a = irc->b->accounts; a; a = a->next ) if( !a->ic && a->auto_connect ) - account_on( irc->b, a ); + { + if( strcmp( a->pass, PASSWORD_PENDING ) == 0 ) + irc_usermsg( irc, "Enter password for account %s(%s) " + "first (use /OPER)", a->prpl->name, a->user ); + else + account_on( irc->b, a ); + } } else { @@ -519,6 +537,9 @@ static void cmd_account( irc_t *irc, char **cmd ) { if( a->ic ) irc_usermsg( irc, "Account already online" ); + else if( strcmp( a->pass, PASSWORD_PENDING ) == 0 ) + irc_usermsg( irc, "Enter password for account %s(%s) " + "first (use /OPER)", a->prpl->name, a->user ); else account_on( irc->b, a ); } -- cgit v1.2.3