Changeset 7cad7b4


Ignore:
Timestamp:
2005-12-08T16:00:08Z (18 years ago)
Author:
Jelmer Vernooij <jelmer@…>
Branches:
master
Children:
87c24ba
Parents:
09adf08
Message:

Clearer seperation between crypting and generic password code

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    r09adf08 r7cad7b4  
    114114        }
    115115
    116         setpassnc( irc, cmd[1] );
     116        irc_setpass( irc, cmd[1] );
    117117        switch( global.storage->save( irc, FALSE )) {
    118118                case STORAGE_ALREADY_EXISTS:
     
    145145                return( 0 );
    146146        case STORAGE_OK:
    147                 setpassnc( irc, NULL );
     147                irc_setpass( irc, NULL );
    148148                irc_usermsg( irc, "Account `%s' removed", irc->nick );
    149149                return( 0 );
  • crypting.c

    r09adf08 r7cad7b4  
    5252#include <stdlib.h>
    5353
    54 #define irc_usermsg
    55 
    5654#endif
    5755
     
    6260\*/
    6361
    64 /* USE WITH CAUTION!
    65    Sets pass without checking */
    66 void setpassnc (irc_t *irc, const char *pass)
    67 {
    68         if (irc->password) g_free (irc->password);
    69        
    70         if (pass) {
    71                 irc->password = g_strdup (pass);
    72                 irc_usermsg (irc, "Password successfully changed");
    73         } else {
    74                 irc->password = NULL;
    75         }
    76 }
    77 
    78 int setpass (irc_t *irc, const char *pass, const char* md5sum)
     62int checkpass (const char *pass, const char *md5sum)
    7963{
    8064        md5_state_t md5state;
     
    9478                if (digits[1] != md5sum[j + 1]) return (-1);
    9579        }
    96        
    97         /* If pass is correct, we end up here and we set the pass */
    98         setpassnc (irc, pass);
    99        
    100         return (0);
    101 }
     80
     81        return( 0 );
     82}
     83
    10284
    10385char *hashpass (irc_t *irc) {
  • crypting.h

    r09adf08 r7cad7b4  
    2424*/
    2525
    26 void setpassnc (irc_t *irc, const char *pass); /* USE WITH CAUTION! */
    27 int setpass (irc_t *irc, const char *pass, const char* md5sum);
     26int checkpass (const char *password, const char *md5sum);
    2827char *hashpass (irc_t *irc);
    2928char *obfucrypt (irc_t *irc, char *line);
  • irc.c

    r09adf08 r7cad7b4  
    3232GSList *irc_connection_list = NULL;
    3333
    34 char *passchange (irc_t *irc, void *set, char *value)
    35 {
    36         setpassnc (irc, value);
     34static char *passchange (irc_t *irc, void *set, char *value)
     35{
     36        irc_setpass (irc, value);
    3737        return (NULL);
    3838}
     
    266266        if( global.conf->runmode == RUNMODE_INETD )
    267267                g_main_quit( global.loop );
     268}
     269
     270/* USE WITH CAUTION!
     271   Sets pass without checking */
     272void irc_setpass (irc_t *irc, const char *pass)
     273{
     274        if (irc->password) g_free (irc->password);
     275       
     276        if (pass) {
     277                irc->password = g_strdup (pass);
     278                irc_usermsg (irc, "Password successfully changed");
     279        } else {
     280                irc->password = NULL;
     281        }
    268282}
    269283
  • irc.h

    r09adf08 r7cad7b4  
    137137void irc_whois( irc_t *irc, char *nick );
    138138int irc_away( irc_t *irc, char *away );
     139void irc_setpass( irc_t *irc, const char *pass ); /* USE WITH CAUTION! */
    139140
    140141int irc_send( irc_t *irc, char *nick, char *s, int flags );
  • storage_text.c

    r09adf08 r7cad7b4  
    5353       
    5454        fscanf( fp, "%32[^\n]s", s );
    55         if( setpass( irc, password, s ) < 0 )
     55
     56        if (checkpass (password, s) != 0)
    5657        {
    5758                fclose( fp );
     
    277278        fclose( fp );
    278279
    279         /*FIXME: Check password */
     280        if (checkpass( password, s) == -1)
     281                return STORAGE_INVALID_PASSWORD;
    280282
    281283        return STORAGE_OK;
Note: See TracChangeset for help on using the changeset viewer.