Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1b73d0b

Browse filesBrowse files
committed
Refactor code handling the names of files loaded in hba.c
This has the advantage to limit the presence of the GUC values hba_file and ident_file to the code paths where these files are loaded, easing the introduction of an upcoming feature aimed at adding inclusion logic for files and directories in HBA and ident files. Note that this needs the addition of the source file name to HbaLine, in addition to the line number, which is something needed by the backend in two places of auth.c (authentication failure details and auth_id log when log_connections is enabled). While on it, adjust a log generated on authentication failure to report the name of the actual HBA file on which the connection attempt matched, where the line number and the raw line written in the HBA file were already included. This was previously hardcoded as pg_hba.conf, which would be incorrect when a custom value is used at postmaster startup for the GUC hba_file. Extracted from a larger patch by the same author. Author: Julien Rouhaud Discussion: https://postgr.es/m/20220223045959.35ipdsvbxcstrhya@jrouhaud
1 parent 13d53aa commit 1b73d0b
Copy full SHA for 1b73d0b

File tree

3 files changed

+65
-57
lines changed
Filter options

3 files changed

+65
-57
lines changed

‎src/backend/libpq/auth.c

Copy file name to clipboardExpand all lines: src/backend/libpq/auth.c
+4-3
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,9 @@ auth_failed(Port *port, int status, const char *logdetail)
307307
break;
308308
}
309309

310-
cdetail = psprintf(_("Connection matched pg_hba.conf line %d: \"%s\""),
311-
port->hba->linenumber, port->hba->rawline);
310+
cdetail = psprintf(_("Connection matched %s line %d: \"%s\""),
311+
port->hba->sourcefile, port->hba->linenumber,
312+
port->hba->rawline);
312313
if (logdetail)
313314
logdetail = psprintf("%s\n%s", logdetail, cdetail);
314315
else
@@ -365,7 +366,7 @@ set_authn_id(Port *port, const char *id)
365366
"(%s:%d)",
366367
MyClientConnectionInfo.authn_id,
367368
hba_authname(MyClientConnectionInfo.auth_method),
368-
HbaFileName, port->hba->linenumber));
369+
port->hba->sourcefile, port->hba->linenumber));
369370
}
370371
}
371372

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.