Compare commits

..
1 Commits
Author SHA1 Message Date
parkel 491c5900cb Keep the BIND catalog accessible under a restrictive umask
Coulobre Panel CI / Checks (Python 3.12) (pull_request) Successful in 2m3s
Coulobre Panel CI / Checks (Python 3.14) (pull_request) Successful in 2m16s
2026-12-05 01:28:05 +01:00
3 changed files with 29 additions and 2 deletions

No files matched your search

+12 -1
View File
@@ -2,6 +2,7 @@ import argparse
import grp import grp
import json import json
import os import os
import stat
import subprocess import subprocess
from contextlib import suppress from contextlib import suppress
from pathlib import Path from pathlib import Path
@@ -60,7 +61,17 @@ def seed_catalog():
from coulobre.domain_names import canonical_domain from coulobre.domain_names import canonical_domain
from coulobre.node_files import read_root_file 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(): if PATH.exists():
engine.root_file(PATH, 0o644) engine.root_file(PATH, 0o644)
return 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 release using the same peer address. This grants the DNS apply service
write access to the catalog directory while retaining its filesystem write access to the catalog directory while retaining its filesystem
sandbox. It preserves the catalog, managed zones, and transfer key. The 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 When upgrading a catalog primary from 1.2.0 or earlier, apply this step
before resuming DNS provisioning. On an APT-managed primary, run before resuming DNS provisioning. On an APT-managed primary, run
+14
View File
@@ -1,4 +1,5 @@
import os import os
import stat
import tempfile import tempfile
import unittest import unittest
from functools import partial from functools import partial
@@ -113,16 +114,29 @@ class DNSCatalogSandboxTests(unittest.TestCase):
self.run_command.call_args_list, 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): def test_existing_primary_without_override_gets_one(self):
self.config.write_text(secondary.configuration("primary", self.peer)) self.config.write_text(secondary.configuration("primary", self.peer))
self.seed.parent.mkdir() self.seed.parent.mkdir()
catalog = dns_catalog.render_catalog(17, {"site.test"}) catalog = dns_catalog.render_catalog(17, {"site.test"})
self.seed.write_text(catalog) self.seed.write_text(catalog)
self.seed.parent.chmod(0o2700)
secondary.setup("primary", self.peer) secondary.setup("primary", self.peer)
self.assertEqual(self.override.read_text(), self.override_text) self.assertEqual(self.override.read_text(), self.override_text)
self.assertEqual(self.seed.read_text(), catalog) 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): def test_existing_primary_keeps_zones_key_and_manual_override(self):
self.config.write_text(secondary.configuration("primary", self.peer)) self.config.write_text(secondary.configuration("primary", self.peer))