Crypted PLAIN passwords. --- cyrus-sasl-2.1.22/lib/checkpw.c.orig 2006-03-13 21:30:41.000000000 +0300 +++ cyrus-sasl-2.1.22/lib/checkpw.c 2008-02-05 13:44:28.000000000 +0300 @@ -55,6 +55,7 @@ #include #ifdef HAVE_UNISTD_H +#define __USE_XOPEN #include #endif #include @@ -143,6 +144,10 @@ static int auxprop_verify_password(sasl_ "*cmusaslsecretPLAIN", NULL }; struct propval auxprop_values[3]; + + /* added by lopaka */ + char salt[32]; + char *crypt_passwd = NULL; if (!conn || !userstr) return SASL_BADPARAM; @@ -180,12 +185,35 @@ static int auxprop_verify_password(sasl_ goto done; } + /* 20041008 added by lopaka */ + /* 20050407 cuted by bog for linux */ + /* encrypt the passwd and then compare it with the encrypted passwd */ + if(!strncmp(auxprop_values[0].values[0],"$1",2)) + { + /* MD5 */ + /* obtain salt = first 12 chars */ + strncpy(salt,auxprop_values[0].values[0],13); + } + else if(!strncmp(auxprop_values[0].values[0],"$2",2)) + { + /* BLF (blowfish) */ + /* obtain salt = first 30 chars */ + strncpy(salt,auxprop_values[0].values[0],31); + } + else + { + /* DES */ + /* obtain salt = first 2 chars */ + strncpy(salt,auxprop_values[0].values[0],3); + } + crypt_passwd = crypt(passwd,salt); + /* At the point this has been called, the username has been canonified * and we've done the auxprop lookup. This should be easy. */ if(auxprop_values[0].name && auxprop_values[0].values && auxprop_values[0].values[0] - && !strcmp(auxprop_values[0].values[0], passwd)) { + && !strcmp(auxprop_values[0].values[0], crypt_passwd)) { /* We have a plaintext version and it matched! */ return SASL_OK; } else if(auxprop_values[1].name