Ejemplo n.º 1
0
static void irc_cmd_oper_hack( irc_t *irc, char **cmd )
{
	char *password = g_strjoinv( " ", cmd + 2 );
	
	/* /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 )
	{
		account_t *a;
		
		for( a = irc->b->accounts; a; a = a->next )
			if( strcmp( a->pass, PASSWORD_PENDING ) == 0 )
			{
				set_setstr( &a->set, "password", password );
				irc_rootmsg( irc, "Password added to IM account "
				             "%s", a->tag );
				/* The IRC client may expect this. 491 suggests the OPER
				   password was wrong, so the client won't expect a +o.
				   It may however repeat the password prompt. We'll see. */
				irc_send_num( irc, 491, ":Password added to IM account "
				              "%s", a->tag );
			}
	}
	else if( irc->status & OPER_HACK_IDENTIFY )
	{
		char *send_cmd[] = { "identify", password, NULL, NULL };
		irc->status &= ~OPER_HACK_IDENTIFY;
		if( irc->status & OPER_HACK_IDENTIFY_NOLOAD )
		{
			send_cmd[1] = "-noload";
			send_cmd[2] = password;
		}
		else if( irc->status & OPER_HACK_IDENTIFY_FORCE )
		{
			send_cmd[1] = "-force";
			send_cmd[2] = password;
		}
		irc_send_num( irc, 491, ":Trying to identify" );
		root_command( irc, send_cmd );
	}
	else if( irc->status & OPER_HACK_REGISTER )
	{
		char *send_cmd[] = { "register", password, NULL };
		irc_send_num( irc, 491, ":Trying to identify" );
		root_command( irc, send_cmd );
	}
	
	irc->status &= ~OPER_HACK_ANY;
	g_free( password );
}
Ejemplo n.º 2
0
static void irc_cmd_pass( irc_t *irc, char **cmd )
{
	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. */
		root_command( irc, send_cmd );
		return;
	}
	/* 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 if( global.conf->auth_pass )
	{
		irc_send_num( irc, 464, ":Incorrect password" );
	}
	else
	{
		/* Remember the password and try to identify after USER/NICK. */
		irc_setpass( irc, cmd[1] );
		irc_check_login( irc );
	}
}
Ejemplo n.º 3
0
void root_command_string(irc_t *irc, char *command)
{
	root_command(irc, split_command_parts(command, 0));
}
Ejemplo n.º 4
0
static void irc_cmd_nickserv( irc_t *irc, char **cmd )
{
	/* [SH] This aliases the NickServ command to PRIVMSG root */
	/* [TV] This aliases the NS command to PRIVMSG root as well */
	root_command( irc, cmd + 1 );
}