Crypted PLAIN passwords. --- cyrus-sasl-2.1.19/lib/checkpw.c.orig 2005-04-07 18:01:33.190205440 +0400 +++ cyrus-sasl-2.1.19/lib/checkpw.c 2005-04-07 18:28:15.274651584 +0400 @@ -143,6 +143,10 @@ "*cmusaslsecretPLAIN", NULL }; struct propval auxprop_values[3]; + + /* added by lopaka */ + char salt[31]; + char *crypt_passwd = NULL; if (!conn || !userstr) return SASL_BADPARAM; @@ -180,12 +184,35 @@ 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