Changeset 618

Show
Ignore:
Timestamp:
01/07/08 15:19:28 (5 months ago)
Author:
smoku
Message:

Merged MySQL crypt()ed password full implementation. Closes #228

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/storage/authreg_mysql.c

    r541 r618  
    3030enum mysql_pws_crypt { MPC_PLAIN, MPC_CRYPT }; 
    3131 
     32static char salter[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ./"; 
     33 
    3234typedef struct mysqlcontext_st { 
    3335  MYSQL * conn; 
     
    174176    snprintf(irealm, MYSQL_LR+1, "%s", realm); 
    175177 
     178    if (ctx->password_type == MPC_CRYPT) { 
     179       char salt[12] = "$1$"; 
     180       int i; 
     181 
     182       srand(time(0)); 
     183       for(i=0; i<8; i++) 
     184               salt[3+i] = salter[rand()%64]; 
     185       salt[11] = '\0'; 
     186       strcpy(password, crypt(password, salt)); 
     187    } 
     188     
    176189    password[256]= '\0'; 
    177190