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: Refactor regular expression handling in hba.c
Date: Wed, 19 Oct 2022 01:13:57 +0000
Message-ID: <E1okxef-002zdq-36@gemulon.postgresql.org> (raw)

Refactor regular expression handling in hba.c

AuthToken gains a regular expression, and IdentLine is changed so as it
uses an AuthToken rather than tracking separately the ident user string
used for the regex compilation and its generated regex_t.  In the case
of pg_ident.conf, a set of AuthTokens is built in the pre-parsing phase
of the file, and an extra regular expression is compiled when building
the list of IdentLines, after checking the sanity of the fields in a
pre-parsed entry.

The logic in charge of computing and executing regular expressions is
now done in a new set of routines called respectively
regcomp_auth_token() and regexec_auth_token() that are wrappers around
pg_regcomp() and pg_regexec(), working on AuthTokens.  While on it, this
patch adds a routine able to free an AuthToken, free_auth_token(), to
simplify a bit the logic around the requirement of using a specific free
routine for computed regular expressions.  Note that there are no
functional or behavior changes introduced by this commit.

The goal of this patch is to ease the use of regular expressions with
more items of pg_hba.conf (user list, database list, potentially
hostnames) where AuthTokens are used extensively.  This will be tackled
later in a separate patch.

Author: Bertrand Drouvot, Michael Paquier
Discussion: https://postgr.es/m/fff0d7c1-8ad4-76a1-9db3-0ab6ec338bf7@amazon.com

Branch
------
master

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

Modified Files
--------------
src/backend/libpq/hba.c          | 160 +++++++++++++++++++++++++--------------
src/backend/utils/adt/hbafuncs.c |   2 +-
src/include/libpq/hba.h          |  28 +++----
3 files changed, 119 insertions(+), 71 deletions(-)



Message-ID: <E1okxef-002zdq-36@gemulon.postgresql.org>
Permalink:  ../E1okxef-002zdq-36@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1okxef-002zdq-36@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: Refactor regular expression handling in hba.c
  In-Reply-To: <E1okxef-002zdq-36@gemulon.postgresql.org>
  References: <E1okxef-002zdq-36@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