Allow unsigned local Host Extensions in the pacman install transaction
This commit is contained in:
parent
ed41bbe354
commit
593629f031
4 changed files with 40 additions and 1 deletions
|
|
@ -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`.
|
||||
|
|
|
|||
BIN
adapters/__pycache__/package-transaction.cpython-314.pyc
Normal file
BIN
adapters/__pycache__/package-transaction.cpython-314.pyc
Normal file
Binary file not shown.
|
|
@ -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]],
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue