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: Add error context callback when tokenizing authentication files
Date: Mon, 14 Nov 2022 02:59:41 +0000
Message-ID: <E1ouPhE-00065i-9K@gemulon.postgresql.org> (raw)

Add error context callback when tokenizing authentication files

The parsing of the authentication files for HBA and ident entries
happens in two phases:
- Tokenization of the files, creating a list of TokenizedAuthLines.
- Validation of the HBA and ident entries, building a set of HbaLines or
IdentLines.

The second phase doing the validation provides already some error
context about the configuration file and the line where a problem
happens, but there is no such information in the first phase when
tokenizing the files.  This commit adds an ErrorContextCallback in
tokenize_auth_file(), with a context made of the line number and the
configuration file name involved in a problem.  This is useful for files
included in an HBA file for user and database lists, and it will become
much more handy to track problems for files included via a potential
@include[_dir,_if_exists].

The error context is registered so as the full chain of events is
reported when using cascaded inclusions when for example
tokenize_auth_file() recurses over itself on new files, displaying one
context line for each file gone through when tokenizing things.

Author: Michael Paquier
Reviewed-by: Julien Rouhaud
Discussion: https://postgr.es/m/Y2xUBJ+S+Z0zbxRW@paquier.xyz

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ad6c52846f13e4e86daa247c1369ed85558830e7

Modified Files
--------------
src/backend/libpq/hba.c          | 31 +++++++++++++++++++++++++++++++
src/tools/pgindent/typedefs.list |  1 +
2 files changed, 32 insertions(+)



Message-ID: <E1ouPhE-00065i-9K@gemulon.postgresql.org>
Permalink:  ../E1ouPhE-00065i-9K@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1ouPhE-00065i-9K@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: Add error context callback when tokenizing authentication files
  In-Reply-To: <E1ouPhE-00065i-9K@gemulon.postgresql.org>
  References: <E1ouPhE-00065i-9K@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