aboutsummaryrefslogtreecommitdiffstats
path: root/irc_commands.c
diff options
context:
space:
mode:
authorulim <a.sporto+bee@gmail.com>2008-04-14 15:10:53 +0200
committerulim <a.sporto+bee@gmail.com>2008-04-14 15:10:53 +0200
commitb79308b943149d729b1daea8c56cff9fc02711a0 (patch)
treea5f80445ed63d864703941474dc6cf8998df3136 /irc_commands.c
parent6cac643f6933e431b90fcb937dec505f989e6a53 (diff)
parentaa311173a85020bcbbbf61135a5451e171d422f5 (diff)
merged in upstream r379 (somewhere after 1.2-3).
Just one trivial conflict in the jabber Makefile, went smoothly.
Diffstat (limited to 'irc_commands.c')
-rw-r--r--irc_commands.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/irc_commands.c b/irc_commands.c
index 68db4617..6a47007a 100644
--- a/irc_commands.c
+++ b/irc_commands.c
@@ -29,15 +29,36 @@
static void irc_cmd_pass( irc_t *irc, char **cmd )
{
- if( global.conf->auth_pass && strcmp( cmd[1], global.conf->auth_pass ) == 0 )
+ 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 ) )
{
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 )
@@ -87,7 +108,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" );
@@ -253,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] );
}
}
@@ -574,7 +597,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 },