/* Get role info from pg_authid */
roleTup = SearchSysCache1(AUTHNAME, PointerGetDatum(role)); if (!HeapTupleIsValid(roleTup))
{
*logdetail = psprintf(_("Role \"%s\" does not exist."),
role); return NULL; /* no such user */
}
datum = SysCacheGetAttr(AUTHNAME, roleTup,
Anum_pg_authid_rolpassword, &isnull); if (isnull)
{
ReleaseSysCache(roleTup);
*logdetail = psprintf(_("User \"%s\" has no password assigned."),
role); return NULL; /* user has no password */
}
shadow_pass = TextDatumGetCString(datum);
datum = SysCacheGetAttr(AUTHNAME, roleTup,
Anum_pg_authid_rolvaliduntil, &isnull); if (!isnull)
vuntil = DatumGetTimestampTz(datum);
ReleaseSysCache(roleTup);
/* *PasswordOK,butchecktobesurewearenotpastrolvaliduntil
*/ if (!isnull && vuntil < GetCurrentTimestamp())
{
*logdetail = psprintf(_("User \"%s\" has an expired password."),
role); return NULL;
}
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("encrypted password is too long"),
errdetail("Encrypted passwords must be no longer than %d bytes.",
MAX_ENCRYPTED_PASSWORD_LEN)));
}
if (md5_password_warnings &&
get_password_type(encrypted_password) == PASSWORD_TYPE_MD5)
ereport(WARNING,
(errcode(ERRCODE_WARNING_DEPRECATED_FEATURE),
errmsg("setting an MD5-encrypted password"),
errdetail("MD5 password support is deprecated and will be removed in a future release of PostgreSQL."),
errhint("Refer to the PostgreSQL documentation for details about migrating to another password type.")));
if (get_password_type(shadow_pass) != PASSWORD_TYPE_MD5)
{ /* incompatible password hash format. */
*logdetail = psprintf(_("User \"%s\" has a password that cannot be used with MD5 authentication."),
role); return STATUS_ERROR;
}
/* *ComputethecorrectanswerfortheMD5challenge.
*/ /* stored password already encrypted, only do salt */ if (!pg_md5_encrypt(shadow_pass + strlen("md5"),
md5_salt, md5_salt_len,
crypt_pwd, &errstr))
{
*logdetail = errstr; return STATUS_ERROR;
}
if (strlen(client_pass) == strlen(crypt_pwd) &&
timingsafe_bcmp(client_pass, crypt_pwd, strlen(crypt_pwd)) == 0)
retval = STATUS_OK; else
{
*logdetail = psprintf(_("Password does not match for user \"%s\"."),
role);
retval = STATUS_ERROR;
}
/* *Clientsentpasswordinplaintext.IfwehaveanMD5hashstored,hash *thepasswordtheclientsent,andcomparethehashes.Otherwise *comparetheplaintextpasswordsdirectly.
*/ switch (get_password_type(shadow_pass))
{ case PASSWORD_TYPE_SCRAM_SHA_256: if (scram_verify_plain_password(role,
client_pass,
shadow_pass))
{ return STATUS_OK;
} else
{
*logdetail = psprintf(_("Password does not match for user \"%s\"."),
role); return STATUS_ERROR;
} break;
case PASSWORD_TYPE_MD5: if (!pg_md5_encrypt(client_pass,
(uint8 *) role,
strlen(role),
crypt_client_pass,
&errstr))
{
*logdetail = errstr; return STATUS_ERROR;
} if (strlen(crypt_client_pass) == strlen(shadow_pass) &&
timingsafe_bcmp(crypt_client_pass, shadow_pass, strlen(shadow_pass)) == 0) return STATUS_OK; else
{
*logdetail = psprintf(_("Password does not match for user \"%s\"."),
role); return STATUS_ERROR;
} break;
/* *Thisshouldn'thappen.Plain"password"authenticationispossible *withanykindofstoredpasswordhash.
*/
*logdetail = psprintf(_("Password of user \"%s\" is in unrecognized format."),
role); return STATUS_ERROR;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-08-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.