Changeset edf9657


Ignore:
Timestamp:
2006-01-14T18:25:00Z (18 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
b23c5c7
Parents:
c22c210
Message:

Fixed the PASS-command, added error messages for invalid commands to irc_exec().

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • irc.c

    rc22c210 redf9657  
    573573       
    574574        irc_reply( irc, 366, "%s :End of /NAMES list", channel );
     575}
     576
     577int irc_check_login( irc_t *irc )
     578{
     579        if( irc->user && irc->nick )
     580        {
     581                if( global.conf->authmode == AUTHMODE_CLOSED && irc->status < USTATUS_AUTHORIZED )
     582                {
     583                        irc_reply( irc, 464, ":This server is password-protected." );
     584                        return 0;
     585                }
     586                else
     587                {
     588                        irc_login( irc );
     589                        return 1;
     590                }
     591        }
     592        else
     593        {
     594                /* More information needed. */
     595                return 0;
     596        }
    575597}
    576598
  • irc.h

    rc22c210 redf9657  
    118118
    119119void irc_login( irc_t *irc );
     120int irc_check_login( irc_t *irc );
    120121void irc_motd( irc_t *irc );
    121122void irc_names( irc_t *irc, char *channel );
  • irc_commands.c

    rc22c210 redf9657  
    2929static int irc_cmd_pass( irc_t *irc, char **cmd )
    3030{
    31         if( strcmp( cmd[1], (global.conf)->auth_pass ) == 0 )
     31        if( global.conf->auth_pass && strcmp( cmd[1], global.conf->auth_pass ) == 0 )
    3232        {
    3333                irc->status = USTATUS_AUTHORIZED;
     34                irc_check_login();
    3435        }
    3536        else
    3637        {
    37                 irc_reply( irc, 464, ":Nope, maybe you should try it again..." );
     38                irc_reply( irc, 464, ":Incorrect password." );
    3839        }
    3940       
     
    4344static int irc_cmd_user( irc_t *irc, char **cmd )
    4445{
    45         if( irc->user )
    46         {
    47                 irc_reply( irc, 462, ":You can't change your nick/userinfo" );
    48         }
    49         else
    50         {
    51                 irc->user = g_strdup( cmd[1] );
    52                 irc->realname = g_strdup( cmd[4] );
    53                 if( irc->nick ) irc_login( irc );
    54         }
     46        irc->user = g_strdup( cmd[1] );
     47        irc->realname = g_strdup( cmd[4] );
     48       
     49        irc_check_login( irc );
    5550       
    5651        return( 1 );
     
    7671        {
    7772                irc->nick = g_strdup( cmd[1] );
    78                 if( irc->user ) irc_login( irc );
     73               
     74                irc_check_login( irc );
    7975        }
    8076       
     
    8985        return( 0 );
    9086}
    91 
    92 /*
    93         if( !irc->user || !irc->nick )
    94         {
    95                 irc_reply( irc, 451, ":Register first" );
    96                 return( 1 );
    97         }
    98 */
    9987
    10088static int irc_cmd_ping( irc_t *irc, char **cmd )
     
    626614                if( g_strcasecmp( irc_commands[i].command, cmd[0] ) == 0 )
    627615                {
    628                         if( irc_commands[i].flags & IRC_CMD_PRE_LOGIN && irc->status > USTATUS_AUTHORIZED )
    629                                 continue;
     616                        if( irc_commands[i].flags & IRC_CMD_PRE_LOGIN && irc->status >= USTATUS_LOGGED_IN )
     617                        {
     618                                irc_reply( irc, 462, ":Only allowed before logging in" );
     619                                return( 1 );
     620                        }
    630621                        if( irc_commands[i].flags & IRC_CMD_LOGGED_IN && irc->status < USTATUS_LOGGED_IN )
    631                                 continue;
     622                        {
     623                                irc_reply( irc, 451, ":Register first" );
     624                                return( 1 );
     625                        }
    632626                        if( irc_commands[i].flags & IRC_CMD_OPER_ONLY && !strchr( irc->umode, 'o' ) )
    633                                 continue;
     627                        {
     628                                irc_reply( irc, 481, ":Permission denied - You're not an IRC operator" );
     629                                return( 1 );
     630                        }
    634631                       
    635632                        for( j = 1; j <= irc_commands[i].required_parameters; j ++ )
Note: See TracChangeset for help on using the changeset viewer.