@@ -439,19 +439,32 @@ ClientAuthentication(Port *port)
439439 NULL , 0 ,
440440 NI_NUMERICHOST );
441441
442+ #define HOSTNAME_LOOKUP_DETAIL (port ) \
443+ (port->remote_hostname \
444+ ? (port->remote_hostname_resolv == +1 \
445+ ? errdetail_log("Client IP address resolved to \"%s\", forward lookup matches.", port->remote_hostname) \
446+ : (port->remote_hostname_resolv == 0 \
447+ ? errdetail_log("Client IP address resolved to \"%s\", forward lookup not checked.", port->remote_hostname) \
448+ : (port->remote_hostname_resolv == -1 \
449+ ? errdetail_log("Client IP address resolved to \"%s\", forward lookup does not match.", port->remote_hostname) \
450+ : 0))) \
451+ : 0)
452+
442453 if (am_walsender )
443454 {
444455#ifdef USE_SSL
445456 ereport (FATAL ,
446457 (errcode (ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION ),
447458 errmsg ("no pg_hba.conf entry for replication connection from host \"%s\", user \"%s\", %s" ,
448459 hostinfo , port -> user_name ,
449- port -> ssl ? _ ("SSL on" ) : _ ("SSL off" ))));
460+ port -> ssl ? _ ("SSL on" ) : _ ("SSL off" )),
461+ HOSTNAME_LOOKUP_DETAIL (port )));
450462#else
451463 ereport (FATAL ,
452464 (errcode (ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION ),
453465 errmsg ("no pg_hba.conf entry for replication connection from host \"%s\", user \"%s\"" ,
454- hostinfo , port -> user_name )));
466+ hostinfo , port -> user_name ),
467+ HOSTNAME_LOOKUP_DETAIL (port )));
455468#endif
456469 }
457470 else
@@ -462,13 +475,15 @@ ClientAuthentication(Port *port)
462475 errmsg ("no pg_hba.conf entry for host \"%s\", user \"%s\", database \"%s\", %s" ,
463476 hostinfo , port -> user_name ,
464477 port -> database_name ,
465- port -> ssl ? _ ("SSL on" ) : _ ("SSL off" ))));
478+ port -> ssl ? _ ("SSL on" ) : _ ("SSL off" )),
479+ HOSTNAME_LOOKUP_DETAIL (port )));
466480#else
467481 ereport (FATAL ,
468482 (errcode (ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION ),
469483 errmsg ("no pg_hba.conf entry for host \"%s\", user \"%s\", database \"%s\"" ,
470484 hostinfo , port -> user_name ,
471- port -> database_name )));
485+ port -> database_name ),
486+ HOSTNAME_LOOKUP_DETAIL (port )));
472487#endif
473488 }
474489 break ;
0 commit comments