Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oshv1-00043r-7h for pgsql-general@arkaria.postgresql.org; Wed, 09 Nov 2022 10:02:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oshv0-0003s9-52 for pgsql-general@arkaria.postgresql.org; Wed, 09 Nov 2022 10:02:50 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oshuz-0003nt-K6 for pgsql-general@lists.postgresql.org; Wed, 09 Nov 2022 10:02:49 +0000 Received: from mail-oa1-x30.google.com ([2001:4860:4864:20::30]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oshuw-0005rp-J2 for pgsql-general@lists.postgresql.org; Wed, 09 Nov 2022 10:02:48 +0000 Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-13c569e5ff5so19116756fac.6 for ; Wed, 09 Nov 2022 02:02:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=SNypDb1qD4fHicrm/IMHTpco7cwcz9rIaOD6QSjUky8=; b=nFQzGrhroxXa28mGMsPvZGPYGYRI39oqfP7V8EnJpuAQPZsFL415mGgArlDZ5fqTc8 6CwZo3shf1tAeXWqRFi3Z16E3isAjgMkZqNj9C5sNPPc0pTcgyhjW9/20wxt0UOb8JtS ObQrXvCpwwGSUQ+3iurutsGL/6Bd68XDWU3Wk2aqWhDwET2X79z/4NGlCh09WVrSvX/Z 80gglHGmmt+A86GUoPybWwnFj7XJKX1hUn+AYF3sADUPpYPFTyhBSUWlAA4aEKH26EQW D5o6UcUZWCM13Awpa/Cl5Zyyq7PA+FtRwqg+1/fxSTpmTOyKGRjMUyoeiVurNuLe15Vg d9Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=SNypDb1qD4fHicrm/IMHTpco7cwcz9rIaOD6QSjUky8=; b=FIsQamr0O/aKDs5ZjjHIOormzeRoFWyvnDqtzE6jW0YJFFKm70H5yinsZUV0b6i3PD cbRgcGmls2coXqxtCLB0fXr5VrCDgoiIC1X9BfNRA0LZBJgID3eHj84c8M734juRGCOH QmHrJN4MmYUlO3CJSxaos1PgAEDc4Icgzoz4wa4RG4uVIhcbHlvoSXb6OPP49pmvjW+r Nr/BLrpzc7hz+0rLqhs8L1myQOSJ9asEewmyuA0Ly20qSbQ1kxPcynRlEUEvEwaS/TWd PzjWcR9v3HgoIQAw9OyNKf85ev40ycorUgY+qklJ7M+I7YV6pvV5kCeunmxAGtsc6Fei vEBQ== X-Gm-Message-State: ACrzQf0X3B1ijOA7Z6xwvgAhj+Hjzm+33xj7k6F5rCN6yWHAW7cf+Ho1 6ponrBkepGE/VPDqyhxDgzlXGON2hls= X-Google-Smtp-Source: AMsMyM7crsVgeX6PLnYDRyxtre6KSiyePCpFd+1+Kv1sr+pw02MPg0I5jWeMcEBl5cTmijBB8JannA== X-Received: by 2002:a05:6870:a449:b0:13c:7d1c:5116 with SMTP id n9-20020a056870a44900b0013c7d1c5116mr34991672oal.27.1667988165199; Wed, 09 Nov 2022 02:02:45 -0800 (PST) Received: from [192.168.88.10] (ip68-11-68-85.no.no.cox.net. [68.11.68.85]) by smtp.googlemail.com with ESMTPSA id w189-20020a4a5dc6000000b004807de5c302sm4000158ooa.17.2022.11.09.02.02.44 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 09 Nov 2022 02:02:44 -0800 (PST) Content-Type: multipart/alternative; boundary="------------16cXwDvQseLW0AprtrAvCDPf" Message-ID: <14a96ca8-cba4-ec09-4420-b71c0719e8c8@gmail.com> Date: Wed, 9 Nov 2022 04:02:43 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: Q: pg_hba.conf separate database names file format Content-Language: en-US To: pgsql-general@lists.postgresql.org References: From: Ron In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------16cXwDvQseLW0AprtrAvCDPf Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 11/8/22 23:19, Michael Paquier wrote: > On Tue, Nov 08, 2022 at 02:16:03PM +0100, Albrecht Dreß wrote: >> However, I could not find a specification of the format for this >> file… It appears as if simply giving each database name on a >> separate line does the job. Is this correct? May the file contain >> comments (i.e. lines starting with “#”) or empty lines? May the >> file be specified including a path (e.g. “@/some/path/databases”)? > I have been playing with this code for the last couple of days, and > the answer is that you can use an absolute path or a relative path. > In the case of a relative path, the code considers the base directory > as the parent directory of the file this is included in. For example, > /data/pg/pg_hba.conf including a @databases.conf resolves as > /data/pg/databases.conf, and a @conf/databases.conf resolves as > /data/pg/conf/databases.conf. > > The parsing of these files uses the same rules as what's done for > pg_hba.conf and pg_ident.conf, so you can specify a list of > user names separated by commas or even spaces, or put one name per > line. Comments beginning with '#' are ignored. > > If you want to play with your file and see the results, I would > recommend to tweak the files, and then look at the contents generated > in the system view pg_hba_file_rules. Querying pg_hba_file_rules > loads directly the configuration files from disk, so there is no need > to reload or restart the server to see the effects any modifications > would have. > > The documentation has already some descriptions, that you've missed, > perhaps: > https://www.postgresql.org/docs/15/auth-pg-hba-conf.html > "Files included by @ constructs are read as lists of names, which can > be separated by either whitespace or commas. Comments are introduced > by #, just as in pg_hba.conf, and nested @ constructs are > allowed. Unless the file name following @ is an absolute path, it is > taken to be relative to the directory containing the referencing > file." Are these "include" files supposed to solve the problem of having a *lot* of databases (or users) that you want to allow access to? -- Angular momentum makes the world go 'round. --------------16cXwDvQseLW0AprtrAvCDPf Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit On 11/8/22 23:19, Michael Paquier wrote:
On Tue, Nov 08, 2022 at 02:16:03PM +0100, Albrecht Dreß wrote:
However, I could not find a specification of the format for this
file…  It appears as if simply giving each database name on a
separate line does the job.  Is this correct?  May the file contain
comments (i.e. lines starting with “#”) or empty lines?  May the
file be specified including a path (e.g. “@/some/path/databases”)?
I have been playing with this code for the last couple of days, and
the answer is that you can use an absolute path or a relative path.
In the case of a relative path, the code considers the base directory
as the parent directory of the file this is included in.  For example,
/data/pg/pg_hba.conf including a @databases.conf resolves as
/data/pg/databases.conf, and a @conf/databases.conf resolves as
/data/pg/conf/databases.conf.

The parsing of these files uses the same rules as what's done for
pg_hba.conf and pg_ident.conf, so you can specify a list of
user names separated by commas or even spaces, or put one name per
line.  Comments beginning with '#' are ignored.

If you want to play with your file and see the results, I would
recommend to tweak the files, and then look at the contents generated
in the system view pg_hba_file_rules.  Querying pg_hba_file_rules
loads directly the configuration files from disk, so there is no need
to reload or restart the server to see the effects any modifications
would have.

The documentation has already some descriptions, that you've missed,
perhaps:
https://www.postgresql.org/docs/15/auth-pg-hba-conf.html
"Files included by @ constructs are read as lists of names, which can
be separated by either whitespace or commas. Comments are introduced
by #, just as in pg_hba.conf, and nested @ constructs are
allowed. Unless the file name following @ is an absolute path, it is
taken to be relative to the directory containing the referencing
file."

Are these "include" files supposed to solve the problem of having a lot of databases (or users) that you want to allow access to?

--
Angular momentum makes the world go 'round.
--------------16cXwDvQseLW0AprtrAvCDPf--