Merge pull request 'Keep the BIND catalog accessible under a restrictive umask' (#320) from fix/dns-catalog-directory into main
Coulobre Panel CI / Checks (Python 3.12) (push) Successful in 2m10s
Coulobre Panel CI / Checks (Python 3.14) (push) Successful in 2m26s

Reviewed-on: #320
This commit was merged in pull request #320.
This commit is contained in:
parkel committed 2026-12-05 13:12:14 +01:00
commit cae0a7890a
3 files changed
+29 -2

No files matched your search

+12 -1
View File
@@ -2,6 +2,7 @@ import argparse
import grp
import json
import os
import stat
import subprocess
from contextlib import suppress
from pathlib import Path
@@ -60,7 +61,17 @@ def seed_catalog():
from coulobre.domain_names import canonical_domain
from coulobre.node_files import read_root_file
engine.root_directory(PATH.parent)
directory = PATH.parent
mode = 0o2750
engine.root_directory(directory, mode=mode)
info = directory.lstat()
group = grp.getgrnam("bind").gr_gid
if info.st_gid != group:
os.chown(directory, -1, group, follow_symlinks=False)
# mkdir honors the caller's umask, but BIND must be able to traverse
# this directory even when setup is run with a restrictive umask.
if info.st_gid != group or stat.S_IMODE(info.st_mode) != mode:
directory.chmod(mode)
if PATH.exists():
engine.root_file(PATH, 0o644)
return
+3 -1
View File
@@ -3893,7 +3893,9 @@ On an existing catalog primary, rerun the primary command from the current
release using the same peer address. This grants the DNS apply service
write access to the catalog directory while retaining its filesystem
sandbox. It preserves the catalog, managed zones, and transfer key. The
secondary does not need this permission.
command also repairs the catalog directory's access for BIND if setup
previously ran with a restrictive umask. The secondary does not need the
DNS apply service's write permission.
When upgrading a catalog primary from 1.2.0 or earlier, apply this step
before resuming DNS provisioning. On an APT-managed primary, run
+14
View File
@@ -1,4 +1,5 @@
import os
import stat
import tempfile
import unittest
from functools import partial
@@ -113,16 +114,29 @@ class DNSCatalogSandboxTests(unittest.TestCase):
self.run_command.call_args_list,
)
def test_primary_catalog_is_traversable_with_a_restrictive_umask(self):
previous = os.umask(0o077)
try:
secondary.setup("primary", self.peer)
finally:
os.umask(previous)
self.assertEqual(stat.S_IMODE(self.seed.parent.stat().st_mode), 0o2750)
self.assertEqual(self.seed.parent.stat().st_gid, os.getgid())
self.assertEqual(stat.S_IMODE(self.seed.stat().st_mode), 0o644)
def test_existing_primary_without_override_gets_one(self):
self.config.write_text(secondary.configuration("primary", self.peer))
self.seed.parent.mkdir()
catalog = dns_catalog.render_catalog(17, {"site.test"})
self.seed.write_text(catalog)
self.seed.parent.chmod(0o2700)
secondary.setup("primary", self.peer)
self.assertEqual(self.override.read_text(), self.override_text)
self.assertEqual(self.seed.read_text(), catalog)
self.assertEqual(stat.S_IMODE(self.seed.parent.stat().st_mode), 0o2750)
def test_existing_primary_keeps_zones_key_and_manual_override(self):
self.config.write_text(secondary.configuration("primary", self.peer))