diff --git a/EXTENSIONS.md b/EXTENSIONS.md index 781464e..20e54c7 100644 --- a/EXTENSIONS.md +++ b/EXTENSIONS.md @@ -157,6 +157,13 @@ explicit finalizer, which failed with duplicate registration. The adapter now uses native `pacman -U` for installation of the exact checksum/signature-verified closure, after libalpm plan validation and releasing its transaction lock. This honors staging hook masks; the outer adapter still rejects failed package actions. +A local Host Extension has no detached signature by design (D-115), while the image +config sets `LocalFileSigLevel = Required`. The service therefore renders a private +`/run/archipelago-package-install.conf` with `LocalFileSigLevel = Optional` for that +one `-U` transaction. Repository `.sig` files remain present and are still verified; +the image's `/etc/pacman.conf` is never changed. Without this, an unsigned local +archive was rejected as "package missing required signature" even though its exact +bytes and `.PKGINFO` identity had already been checked. Retry operation `6245b28b175df563140d6087779d3dff` succeeded and staged `a8b738f3fcb904ad763a2420631db7f4f007b502c649e460c4518e3dcb8b5c66`. diff --git a/adapters/__pycache__/package-transaction.cpython-314.pyc b/adapters/__pycache__/package-transaction.cpython-314.pyc new file mode 100644 index 0000000..79976e5 Binary files /dev/null and b/adapters/__pycache__/package-transaction.cpython-314.pyc differ diff --git a/adapters/package-transaction.py b/adapters/package-transaction.py index 374a978..dc51e6b 100644 --- a/adapters/package-transaction.py +++ b/adapters/package-transaction.py @@ -40,6 +40,23 @@ def package(pkg, local=None): filename=pkg.filename, signature=pkg.base64_sig, size=pkg.size) +def local_file_policy(text): + """Allow one unsigned local Host Extension in the same -U transaction. + + Repository archives keep their detached .sig files, so Optional still verifies + present signatures; a local archive has no signature by design (D-115). The + service has already checked its exact bytes and .PKGINFO identity. + """ + updated, count = re.subn(r'(?m)^\s*LocalFileSigLevel\s*=.*$', + 'LocalFileSigLevel = Optional', text) + if count == 0: + updated = re.sub(r'(?m)^\[options\]\s*$', + '[options]\nLocalFileSigLevel = Optional', updated, count=1) + require('LocalFileSigLevel = Optional' in updated, + 'Could not relax the local package signature policy') + return updated + + def kernel_headers(handle, databases, additions, modules_root=Path('/usr/lib/modules')): """Resolve DKMS build inputs against the target image, never uname or live repos.""" localdb = handle.get_localdb() @@ -192,7 +209,13 @@ def main(): # the staging config and masks, using the exact already-checked files. transaction.release() transaction = None - subprocess.run(['pacman', '--config', '/etc/pacman.conf', + # A single -U transaction applies one local-file policy. Repository + # signatures are present and verified; the local extension is + # intentionally unsigned. Never touch the image's /etc/pacman.conf. + install_config = Path('/run/archipelago-package-install.conf') + install_config.parent.mkdir(parents=True, exist_ok=True) + install_config.write_text(local_file_policy(Path('/etc/pacman.conf').read_text())) + subprocess.run(['pacman', '--config', str(install_config), '--dbpath', '/usr/lib/archipelago/package-db', '--cachedir', '/inputs', '-U', '--noconfirm', '--', *[str(Path('/inputs', item['filename'])) for item in resolved]], diff --git a/tests/dkms_inputs.py b/tests/dkms_inputs.py index b022f7a..efe2f65 100644 --- a/tests/dkms_inputs.py +++ b/tests/dkms_inputs.py @@ -65,6 +65,15 @@ class Inputs(unittest.TestCase): {'.INSTALL': 'unknown non-DKMS action'}): self.assertNotEqual(self.inspect('some-package', payload).returncode, 0) + def test_local_extension_install_keeps_repository_signature_policy(self): + text = '[options]\nSigLevel = Required DatabaseOptional\nLocalFileSigLevel = Required\n[core]\nServer = x\n' + result = packages.local_file_policy(text) + self.assertIn('LocalFileSigLevel = Optional', result) + self.assertNotIn('LocalFileSigLevel = Required', result) + self.assertIn('SigLevel = Required DatabaseOptional', result) + inserted = packages.local_file_policy('[options]\nArchitecture = auto\n') + self.assertIn('[options]\nLocalFileSigLevel = Optional', inserted) + def test_exact_headers_and_missing_snapshot(self): def pkg(name, version): return types.SimpleNamespace(name=name, version=version)