From ec0355f6998eb5dee254e4bc60a3207bb661c854 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 16 Mar 2008 16:31:27 +0000 Subject: Passwords in bitlbee.conf can now be (properly salted) MD5 hashes, for just that little bit extra security. --- irc_commands.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'irc_commands.c') diff --git a/irc_commands.c b/irc_commands.c index 68db4617..14209732 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -29,7 +29,10 @@ static void irc_cmd_pass( irc_t *irc, char **cmd ) { - if( global.conf->auth_pass && strcmp( cmd[1], global.conf->auth_pass ) == 0 ) + if( global.conf->auth_pass && + strncmp( global.conf->auth_pass, "md5:", 4 ) == 0 ? + md5_verify_password( cmd[1], global.conf->auth_pass + 4 ) == 0 : + strcmp( cmd[1], global.conf->auth_pass ) == 0 ) { irc->status |= USTATUS_AUTHORIZED; irc_check_login( irc ); @@ -87,7 +90,10 @@ static void irc_cmd_ping( irc_t *irc, char **cmd ) static void irc_cmd_oper( irc_t *irc, char **cmd ) { - if( global.conf->oper_pass && strcmp( cmd[2], global.conf->oper_pass ) == 0 ) + if( global.conf->oper_pass && + strncmp( global.conf->oper_pass, "md5:", 4 ) == 0 ? + md5_verify_password( cmd[2], global.conf->oper_pass + 4 ) == 0 : + strcmp( cmd[2], global.conf->oper_pass ) == 0 ) { irc_umode_set( irc, "+o", 1 ); irc_reply( irc, 381, ":Password accepted" ); -- cgit v1.2.3 From c029350d962d95c2d5e9854ca4d82e597addf76d Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 16 Mar 2008 17:17:23 +0000 Subject: Added some brackets in irc_cmd_(pass|oper) to prevent crashes when no passwords were set. --- irc_commands.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'irc_commands.c') diff --git a/irc_commands.c b/irc_commands.c index 14209732..b8bae541 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -30,9 +30,9 @@ static void irc_cmd_pass( irc_t *irc, char **cmd ) { if( global.conf->auth_pass && - strncmp( global.conf->auth_pass, "md5:", 4 ) == 0 ? - md5_verify_password( cmd[1], global.conf->auth_pass + 4 ) == 0 : - strcmp( cmd[1], global.conf->auth_pass ) == 0 ) + ( strncmp( global.conf->auth_pass, "md5:", 4 ) == 0 ? + md5_verify_password( cmd[1], global.conf->auth_pass + 4 ) == 0 : + strcmp( cmd[1], global.conf->auth_pass ) == 0 ) ) { irc->status |= USTATUS_AUTHORIZED; irc_check_login( irc ); @@ -91,9 +91,9 @@ static void irc_cmd_ping( irc_t *irc, char **cmd ) static void irc_cmd_oper( irc_t *irc, char **cmd ) { if( global.conf->oper_pass && - strncmp( global.conf->oper_pass, "md5:", 4 ) == 0 ? - md5_verify_password( cmd[2], global.conf->oper_pass + 4 ) == 0 : - strcmp( cmd[2], global.conf->oper_pass ) == 0 ) + ( strncmp( global.conf->oper_pass, "md5:", 4 ) == 0 ? + md5_verify_password( cmd[2], global.conf->oper_pass + 4 ) == 0 : + strcmp( cmd[2], global.conf->oper_pass ) == 0 ) ) { irc_umode_set( irc, "+o", 1 ); irc_reply( irc, 381, ":Password accepted" ); -- cgit v1.2.3 From a199d33ed818820ffba328f718799bbd77392f6a Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 29 Mar 2008 22:19:17 +0000 Subject: Closing bug #209: The PASS command can now be used to identify yourself to BitlBee. The advantage: No more messing with NickServ hooks. Just set a server password. --- irc_commands.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'irc_commands.c') diff --git a/irc_commands.c b/irc_commands.c index b8bae541..61517614 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -29,7 +29,19 @@ static void irc_cmd_pass( irc_t *irc, char **cmd ) { - if( global.conf->auth_pass && + if( irc->status & USTATUS_LOGGED_IN ) + { + char *send_cmd[] = { "identify", cmd[1], NULL }; + + /* We're already logged in, this client seems to send the PASS + command last. (Possibly it won't send it at all if it turns + out we don't require it, which will break this feature.) + Try to identify using the given password. */ + return root_command( irc, send_cmd ); + } + /* Handling in pre-logged-in state, first see if this server is + password-protected: */ + else if( global.conf->auth_pass && ( strncmp( global.conf->auth_pass, "md5:", 4 ) == 0 ? md5_verify_password( cmd[1], global.conf->auth_pass + 4 ) == 0 : strcmp( cmd[1], global.conf->auth_pass ) == 0 ) ) @@ -37,10 +49,16 @@ static void irc_cmd_pass( irc_t *irc, char **cmd ) irc->status |= USTATUS_AUTHORIZED; irc_check_login( irc ); } - else + else if( global.conf->auth_pass ) { irc_reply( irc, 464, ":Incorrect password" ); } + else + { + /* Remember the password and try to identify after USER/NICK. */ + irc_setpass( irc, cmd[1] ); + irc_check_login( irc ); + } } static void irc_cmd_user( irc_t *irc, char **cmd ) @@ -580,7 +598,7 @@ static void irc_cmd_rehash( irc_t *irc, char **cmd ) } static const command_t irc_commands[] = { - { "pass", 1, irc_cmd_pass, IRC_CMD_PRE_LOGIN }, + { "pass", 1, irc_cmd_pass, 0 }, { "user", 4, irc_cmd_user, IRC_CMD_PRE_LOGIN }, { "nick", 1, irc_cmd_nick, 0 }, { "quit", 0, irc_cmd_quit, 0 }, -- cgit v1.2.3 From f9756bd2e2711d58e06ad2a33ad3292ff10fc6da Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 30 Mar 2008 22:26:16 +0100 Subject: Changed charset handling: irc_t keeps two iconv structures, which are just used for every line sent and received, so now there's no need to use g_iconv_open() every time a message comes in/out. Also, fixed a small memory leak that was there for a long time but somehow never caught my attention. --- irc_commands.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'irc_commands.c') diff --git a/irc_commands.c b/irc_commands.c index 61517614..6a47007a 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -277,8 +277,7 @@ static void irc_cmd_privmsg( irc_t *irc, char **cmd ) if( cmd[1] != irc->last_target ) { - if( irc->last_target ) - g_free( irc->last_target ); + g_free( irc->last_target ); irc->last_target = g_strdup( cmd[1] ); } } -- cgit v1.2.3