Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita54b658

Browse files
committed
Add support for file inclusions in HBA and ident configuration files
pg_hba.conf and pg_ident.conf gain support for three record keywords:- "include", to include a file.- "include_if_exists", to include a file, ignoring it if missing.- "include_dir", to include a directory of files. These are classifiedby name (C locale, mostly) and need to be prefixed by ".conf", hencefollowing the same rules as GUCs.This commit relies on the refactoring pieces done inefc9816,ad6c528,783e8c6 and1b73d0b, adding a small wrapper to build a list ofTokenizedAuthLines (tokenize_include_file), and the code is shaped tooffer some symmetry with what is done for GUCs with the same options.pg_hba_file_rules and pg_ident_file_mappings gain a new field calledfile_name, to track from which file a record is located, takingadvantage of the addition of rule_number inc591300 to offer anorganized view of the HBA or ident records loaded.Bump catalog version.Author: Julien RouhaudReviewed-by: Michael PaquierDiscussion:https://postgr.es/m/20220223045959.35ipdsvbxcstrhya@jrouhaud
1 parentd09dbeb commita54b658

File tree

9 files changed

+352
-60
lines changed

9 files changed

+352
-60
lines changed

‎doc/src/sgml/client-auth.sgml

Lines changed: 72 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@
8989
</para>
9090

9191
<para>
92-
Each record specifies a connection type, a client IP address range
93-
(if relevant for the connection type), a database name, a user name,
92+
Eachauthenticationrecord specifies a connection type, a client IP address
93+
range(if relevant for the connection type), a database name, a user name,
9494
and the authentication method to be used for connections matching
9595
these parameters. The first record with a matching connection type,
9696
client address, requested database, and user name is used to perform
@@ -100,20 +100,38 @@
100100
access is denied.
101101
</para>
102102

103+
<para>
104+
Each record can be an include directive or an authentication record.
105+
Include directives specify files that can be included, that contain
106+
additional records. The records will be inserted in place of the
107+
include records. These records only contain two fields:
108+
<literal>include</literal>, <literal>include_if_exists</literal> or
109+
<literal>include_dir</literal> directive and the file or directory to be
110+
included. The file or directory can be a relative of absolute path, and can
111+
be double-quoted. For the <literal>include_dir</literal> form, all files
112+
not starting with a <literal>.</literal> and ending with
113+
<literal>.conf</literal> will be included. Multiple files within an include
114+
directory are processed in file name order (according to C locale rules,
115+
i.e., numbers before letters, and uppercase letters before lowercase ones).
116+
</para>
117+
103118
<para>
104119
A record can have several formats:
105120
<synopsis>
106-
local <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
107-
host <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>address</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
108-
hostssl <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>address</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
109-
hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>address</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
110-
hostgssenc <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>address</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
111-
hostnogssenc <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>address</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
112-
host <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>IP-address</replaceable> <replaceable>IP-mask</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
113-
hostssl <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>IP-address</replaceable> <replaceable>IP-mask</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
114-
hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>IP-address</replaceable> <replaceable>IP-mask</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
115-
hostgssenc <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>IP-address</replaceable> <replaceable>IP-mask</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
116-
hostnogssenc <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>IP-address</replaceable> <replaceable>IP-mask</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
121+
local <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
122+
host <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>address</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
123+
hostssl <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>address</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
124+
hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>address</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
125+
hostgssenc <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>address</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
126+
hostnogssenc <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>address</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
127+
host <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>IP-address</replaceable> <replaceable>IP-mask</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
128+
hostssl <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>IP-address</replaceable> <replaceable>IP-mask</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
129+
hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>IP-address</replaceable> <replaceable>IP-mask</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
130+
hostgssenc <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>IP-address</replaceable> <replaceable>IP-mask</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
131+
hostnogssenc <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>IP-address</replaceable> <replaceable>IP-mask</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
132+
include <replaceable>file</replaceable>
133+
include_if_exists <replaceable>file</replaceable>
134+
include_dir <replaceable>directory</replaceable>
117135
</synopsis>
118136
The meaning of the fields is as follows:
119137

@@ -655,6 +673,39 @@ openssl x509 -in myclient.crt -noout --subject -nameopt RFC2253 | sed "s/^subjec
655673
</para>
656674
</listitem>
657675
</varlistentry>
676+
677+
<varlistentry>
678+
<term><literal>include</literal></term>
679+
<listitem>
680+
<para>
681+
This line will be replaced by the contents of the given file.
682+
</para>
683+
</listitem>
684+
</varlistentry>
685+
686+
<varlistentry>
687+
<term><literal>include_if_exists</literal></term>
688+
<listitem>
689+
<para>
690+
This line will be replaced by the content of the given file if the
691+
file exists. Otherwise, a message is logged to indicate that the file
692+
has been skipped.
693+
</para>
694+
</listitem>
695+
</varlistentry>
696+
697+
<varlistentry>
698+
<term><literal>include_dir</literal></term>
699+
<listitem>
700+
<para>
701+
This line will be replaced by the contents of all the files found in
702+
the directory, if they don't start with a <literal>.</literal> and end
703+
with <literal>.conf</literal>, processed in file name order (according
704+
to C locale rules, i.e., numbers before letters, and uppercase letters
705+
before lowercase ones).
706+
</para>
707+
</listitem>
708+
</varlistentry>
658709
</variablelist>
659710
</para>
660711

@@ -863,9 +914,12 @@ local db1,db2,@demodbs all md5
863914
cluster's data directory. (It is possible to place the map file
864915
elsewhere, however; see the <xref linkend="guc-ident-file"/>
865916
configuration parameter.)
866-
The ident map file contains lines of the generalform:
917+
The ident map file contains lines of the generalforms:
867918
<synopsis>
868919
<replaceable>map-name</replaceable> <replaceable>system-username</replaceable> <replaceable>database-username</replaceable>
920+
<replaceable>include</replaceable> <replaceable>file</replaceable>
921+
<replaceable>include_if_exists</replaceable> <replaceable>file</replaceable>
922+
<replaceable>include_dir</replaceable> <replaceable>directory</replaceable>
869923
</synopsis>
870924
Comments, whitespace and line continuations are handled in the same way as in
871925
<filename>pg_hba.conf</filename>. The
@@ -875,6 +929,10 @@ local db1,db2,@demodbs all md5
875929
database user name. The same <replaceable>map-name</replaceable> can be
876930
used repeatedly to specify multiple user-mappings within a single map.
877931
</para>
932+
<para>
933+
As for <filename>pg_hba.conf</filename>, the lines in this file can
934+
be include directives, following the same rules.
935+
</para>
878936
<para>
879937
There is no restriction regarding how many database users a given
880938
operating system user can correspond to, nor vice versa. Thus, entries

‎doc/src/sgml/system-views.sgml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,12 +1002,21 @@
10021002
</para></entry>
10031003
</row>
10041004

1005+
<row>
1006+
<entry role="catalog_table_entry"><para role="column_definition">
1007+
<structfield>file_name</structfield> <type>text</type>
1008+
</para>
1009+
<para>
1010+
Name of the file containing this rule
1011+
</para></entry>
1012+
</row>
1013+
10051014
<row>
10061015
<entry role="catalog_table_entry"><para role="column_definition">
10071016
<structfield>line_number</structfield> <type>int4</type>
10081017
</para>
10091018
<para>
1010-
Line number of this rule in <filename>pg_hba.conf</filename>
1019+
Line number of this rule in <literal>file_name</literal>
10111020
</para></entry>
10121021
</row>
10131022

@@ -1152,12 +1161,21 @@
11521161
</para></entry>
11531162
</row>
11541163

1164+
<row>
1165+
<entry role="catalog_table_entry"><para role="column_definition">
1166+
<structfield>file_name</structfield> <type>text</type>
1167+
</para>
1168+
<para>
1169+
Name of the file containing this map
1170+
</para></entry>
1171+
</row>
1172+
11551173
<row>
11561174
<entry role="catalog_table_entry"><para role="column_definition">
11571175
<structfield>line_number</structfield> <type>int4</type>
11581176
</para>
11591177
<para>
1160-
Line number of this map in <filename>pg_ident.conf</filename>
1178+
Line number of this map in <literal>file_name</literal>
11611179
</para></entry>
11621180
</row>
11631181

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp