Re: Allow continuations in "pg_hba.conf" files - Mailing list pgsql-hackers

From Justin Pryzby
Subject Re: Allow continuations in "pg_hba.conf" files
Date
Msg-id 20200325193923.GD21443@telsasoft.com
Whole thread Raw
In response to Allow continuations in "pg_hba.conf" files  (Fabien COELHO <coelho@cri.ensmp.fr>)
Responses Re: Allow continuations in "pg_hba.conf" files  (Fabien COELHO <coelho@cri.ensmp.fr>)
List pgsql-hackers
Hi,

On Wed, Mar 25, 2020 at 07:09:38PM +0100, Fabien COELHO wrote:
> 
> Hello,
> 
> After writing an unreadable and stupidly long line for ldap authentification
> in a "pg_hba.conf" file, I figured out that allowing continuations looked
> simple enough and should just be done.

I tried this briefly.

> -   Records cannot be continued across lines.
> +   Records can be backslash-continued across lines.

Maybe say: "lines ending with a backslash are logically continued on the next
line", or similar.

> +            /* else we have a continuation, just blank it and loop */
> +            continuations++;
> +            *curend++ = ' ';

Since it puts a blank there, it creates a "word" boundary, which I gather
worked for your use case.  But I wonder whether it's needed to add a space (or
otherwise, document that lines cannot be split beween words?).

You might compare this behavior with that of makefiles (or find a better
example) which I happen to recall *don't* add a space; if you want that, you
have to end the line with: " \" not just "\".

Anyway, I checked that the current patch handles users split across lines, like:
alice,\
bob,\
carol

As written, that depends on the parser's behavior of ignoring commas and
blanks, since it sees:
"alice,[SPACE]bob,[SPACE]carol"

Maybe it'd be nice to avoid depending on that.

I tried with a username called "alice,bob", split across lines:

"alice,\
bob",\

But then your patch makes it look for a user called "alice, bob" (with a
space).  I realize that's not a compelling argument :)

Note, that also appears to affect the "username maps" file.  So mention in that
chapter, too.
https://www.postgresql.org/docs/current/auth-username-maps.html

Cheers,
-- 
Justin



pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: [DOC] Document concurrent index builds waiting on each other
Next
From: Andres Freund
Date:
Subject: Re: AllocSetEstimateChunkSpace()