mirror of
https://github.com/postgres/postgres.git
synced 2025-05-03 22:24:49 +03:00
Add host name resolution information to pg_hba.conf error messages
This is to be able to analyze issues with host names in pg_hba.conf.
This commit is contained in:
parent
a31dc392d6
commit
8a0fa9cad9
@ -439,6 +439,17 @@ ClientAuthentication(Port *port)
|
|||||||
NULL, 0,
|
NULL, 0,
|
||||||
NI_NUMERICHOST);
|
NI_NUMERICHOST);
|
||||||
|
|
||||||
|
#define HOSTNAME_LOOKUP_DETAIL(port) \
|
||||||
|
(port->remote_hostname \
|
||||||
|
? (port->remote_hostname_resolv == +1 \
|
||||||
|
? errdetail_log("Client IP address resolved to \"%s\", forward lookup matches.", port->remote_hostname) \
|
||||||
|
: (port->remote_hostname_resolv == 0 \
|
||||||
|
? errdetail_log("Client IP address resolved to \"%s\", forward lookup not checked.", port->remote_hostname) \
|
||||||
|
: (port->remote_hostname_resolv == -1 \
|
||||||
|
? errdetail_log("Client IP address resolved to \"%s\", forward lookup does not match.", port->remote_hostname) \
|
||||||
|
: 0))) \
|
||||||
|
: 0)
|
||||||
|
|
||||||
if (am_walsender)
|
if (am_walsender)
|
||||||
{
|
{
|
||||||
#ifdef USE_SSL
|
#ifdef USE_SSL
|
||||||
@ -446,12 +457,14 @@ ClientAuthentication(Port *port)
|
|||||||
(errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION),
|
(errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION),
|
||||||
errmsg("no pg_hba.conf entry for replication connection from host \"%s\", user \"%s\", %s",
|
errmsg("no pg_hba.conf entry for replication connection from host \"%s\", user \"%s\", %s",
|
||||||
hostinfo, port->user_name,
|
hostinfo, port->user_name,
|
||||||
port->ssl ? _("SSL on") : _("SSL off"))));
|
port->ssl ? _("SSL on") : _("SSL off")),
|
||||||
|
HOSTNAME_LOOKUP_DETAIL(port)));
|
||||||
#else
|
#else
|
||||||
ereport(FATAL,
|
ereport(FATAL,
|
||||||
(errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION),
|
(errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION),
|
||||||
errmsg("no pg_hba.conf entry for replication connection from host \"%s\", user \"%s\"",
|
errmsg("no pg_hba.conf entry for replication connection from host \"%s\", user \"%s\"",
|
||||||
hostinfo, port->user_name)));
|
hostinfo, port->user_name),
|
||||||
|
HOSTNAME_LOOKUP_DETAIL(port)));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -462,13 +475,15 @@ ClientAuthentication(Port *port)
|
|||||||
errmsg("no pg_hba.conf entry for host \"%s\", user \"%s\", database \"%s\", %s",
|
errmsg("no pg_hba.conf entry for host \"%s\", user \"%s\", database \"%s\", %s",
|
||||||
hostinfo, port->user_name,
|
hostinfo, port->user_name,
|
||||||
port->database_name,
|
port->database_name,
|
||||||
port->ssl ? _("SSL on") : _("SSL off"))));
|
port->ssl ? _("SSL on") : _("SSL off")),
|
||||||
|
HOSTNAME_LOOKUP_DETAIL(port)));
|
||||||
#else
|
#else
|
||||||
ereport(FATAL,
|
ereport(FATAL,
|
||||||
(errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION),
|
(errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION),
|
||||||
errmsg("no pg_hba.conf entry for host \"%s\", user \"%s\", database \"%s\"",
|
errmsg("no pg_hba.conf entry for host \"%s\", user \"%s\", database \"%s\"",
|
||||||
hostinfo, port->user_name,
|
hostinfo, port->user_name,
|
||||||
port->database_name)));
|
port->database_name),
|
||||||
|
HOSTNAME_LOOKUP_DETAIL(port)));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user