pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Invent open_auth_file() in hba.c to refactor authentication file
Date: Mon, 14 Nov 2022 01:27:09 +0000
Message-ID: <E1ouOFh-0005Xm-77@gemulon.postgresql.org> (raw)

Invent open_auth_file() in hba.c to refactor authentication file opening

This adds a check on the recursion depth when including authentication
configuration files, something that has never been done when processing
'@' files for database and user name lists in pg_hba.conf.  On HEAD,
this was leading to a rather confusing error, as of:
FATAL:  exceeded maxAllocatedDescs (NN) while trying to open file "/path/blah.conf"

This refactors the code so as the error reported is now the following,
which is the same as for GUCs:
FATAL: could not open file "/path/blah.conf": maximum nesting depth exceeded

This reduces a bit the verbosity of the error message used for files
included in user and database lists, reporting only the file name of
what's failing to load, without mentioning the relative or absolute path
specified after '@' in a HBA file.  The absolute path is built upon what
'@' defines anyway, so there is no actual loss of information.  This
makes the future inclusion logic much simpler.  A follow-up patch will
add an error context to be able to track on which line of which file the
inclusion is failing, to close the loop, providing all the information
needed to know the full chain of events.

This logic has been extracted from a larger patch written by Julien,
rewritten by me to have a unique code path calling AllocateFile() on
authentication files, and is useful on its own.  This new interface
will be used later for authentication files included with
@include[_dir,_if_exists], in a follow-up patch.

Author: Michael Paquier, Julien Rouhaud
Discussion: https://www.postgresql.org/message-id/Y2xUBJ+S+Z0zbxRW@paquier.xyz

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/783e8c69cbcd2b7d6fce1f0c5b568b1c8b686d54

Modified Files
--------------
src/backend/libpq/hba.c          | 100 ++++++++++++++++++++++++++++-----------
src/backend/utils/adt/hbafuncs.c |  22 +++------
src/include/libpq/hba.h          |   4 +-
3 files changed, 81 insertions(+), 45 deletions(-)



Message-ID: <E1ouOFh-0005Xm-77@gemulon.postgresql.org>
Permalink:  ../E1ouOFh-0005Xm-77@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1ouOFh-0005Xm-77@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz
  Subject: Re: pgsql: Invent open_auth_file() in hba.c to refactor authentication file
  In-Reply-To: <E1ouOFh-0005Xm-77@gemulon.postgresql.org>
  References: <E1ouOFh-0005Xm-77@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox