Index: src/backend/libpq/crypt.c =================================================================== RCS file: /cvsroot/pgsql-server/src/backend/libpq/crypt.c,v retrieving revision 1.49 diff -c -c -r1.49 crypt.c *** src/backend/libpq/crypt.c 4 Sep 2002 20:31:19 -0000 1.49 --- src/backend/libpq/crypt.c 5 Dec 2002 07:07:37 -0000 *************** *** 54,64 **** if (passwd == NULL || *passwd == '\0') return STATUS_ERROR; ! /* If they encrypt their password, force MD5 */ ! if (isMD5(passwd) && port->auth_method != uaMD5) { elog(LOG, "Password is stored MD5 encrypted. " ! "'password' and 'crypt' auth methods cannot be used."); return STATUS_ERROR; } --- 54,64 ---- if (passwd == NULL || *passwd == '\0') return STATUS_ERROR; ! /* We can't do crypt with pg_shadow MD5 passwords */ ! if (isMD5(passwd) && port->auth_method == uaCrypt) { elog(LOG, "Password is stored MD5 encrypted. " ! "'crypt' auth method cannot be used."); return STATUS_ERROR; } *************** *** 110,115 **** --- 110,126 ---- break; } default: + if (isMD5(passwd)) + { + char *crypt_pwd2 = palloc(MD5_PASSWD_LEN + 1); + if (!EncryptMD5(pgpass, port->user, strlen(port->user), + crypt_pwd2)) + { + pfree(crypt_pwd2); + return STATUS_ERROR; + } + pgpass = crypt_pwd2; + } crypt_pwd = passwd; break; } *************** *** 136,141 **** --- 147,155 ---- if (port->auth_method == uaMD5) pfree(crypt_pwd); + if (port->auth_method != uaMD5 && port->auth_method != uaCrypt && + isMD5(passwd)) + pfree((char *)pgpass); return retval; }