Skip to content

Commit

Permalink
[IMP] Reorder rules to certaintly apply extra hba rules
Browse files Browse the repository at this point in the history
  • Loading branch information
josep-tecnativa committed Dec 9, 2024
1 parent 6db61e4 commit bc6b537
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions autoconf-entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ local all all trust
local replication all trust
# LAN/WAN autogenerated configurations
{extra_hba}
{extra_conf}
"""
WAN_CIDRS = ("0.0.0.0/0", "::0/0")

# Configuration helpers
hba_conf = []
ssl_conf = []
extra_hba = []


def permissions_fix(filename, client=False):
Expand Down Expand Up @@ -135,12 +137,12 @@ if WAN_CONNECTION != "hostssl" or ssl_conf:
)
)

# Append extra rules to hba_conf
# Append extra rules to extra_hba
for rule in extra_hba_rules:
if not isinstance(rule, str):
print("Each rule in HBA_EXTRA_RULES must be a string", file=sys.stderr)
sys.exit(1)
hba_conf.append(rule)
extra_hba.append(rule)

# Write postgres configuration files
with open(CONF_FILE, "w") as conf_file:
Expand All @@ -151,7 +153,9 @@ with open(CONF_FILE, "w") as conf_file:
)
permissions_fix(CONF_FILE)
with open(HBA_FILE, "w") as conf_file:
conf_file.write(HBA_TPL.format(extra_conf="\n".join(hba_conf)))
conf_file.write(
HBA_TPL.format(extra_hba="\n".join(extra_hba), extra_conf="\n".join(hba_conf))
)
permissions_fix(HBA_FILE)

# Continue normal execution
Expand Down

0 comments on commit bc6b537

Please sign in to comment.