Skip to content

Commit e665865

Browse files
Merge pull request #24 from Tecnativa/reorder-rules
[IMP] Reorder rules to certaintly apply extra hba rules
2 parents 6db61e4 + bc6b537 commit e665865

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

autoconf-entrypoint

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,15 @@ local all all trust
5151
local replication all trust
5252
5353
# LAN/WAN autogenerated configurations
54+
{extra_hba}
5455
{extra_conf}
5556
"""
5657
WAN_CIDRS = ("0.0.0.0/0", "::0/0")
5758

5859
# Configuration helpers
5960
hba_conf = []
6061
ssl_conf = []
62+
extra_hba = []
6163

6264

6365
def permissions_fix(filename, client=False):
@@ -135,12 +137,12 @@ if WAN_CONNECTION != "hostssl" or ssl_conf:
135137
)
136138
)
137139

138-
# Append extra rules to hba_conf
140+
# Append extra rules to extra_hba
139141
for rule in extra_hba_rules:
140142
if not isinstance(rule, str):
141143
print("Each rule in HBA_EXTRA_RULES must be a string", file=sys.stderr)
142144
sys.exit(1)
143-
hba_conf.append(rule)
145+
extra_hba.append(rule)
144146

145147
# Write postgres configuration files
146148
with open(CONF_FILE, "w") as conf_file:
@@ -151,7 +153,9 @@ with open(CONF_FILE, "w") as conf_file:
151153
)
152154
permissions_fix(CONF_FILE)
153155
with open(HBA_FILE, "w") as conf_file:
154-
conf_file.write(HBA_TPL.format(extra_conf="\n".join(hba_conf)))
156+
conf_file.write(
157+
HBA_TPL.format(extra_hba="\n".join(extra_hba), extra_conf="\n".join(hba_conf))
158+
)
155159
permissions_fix(HBA_FILE)
156160

157161
# Continue normal execution

0 commit comments

Comments
 (0)