fix: retain exact APT configure action without pending package repair
Rust development slice / linux (push) Failing after 6s

This commit is contained in:
2026-11-13 16:09:03 +01:00
parent 12557394fa
commit a430de7bf0
6 changed files with 205 additions and 2 deletions
+30
View File
@@ -1,5 +1,35 @@
# Tatsächlicher Implementierungsstand
## APT-Unpack-only-Ursache lokal korrigiert, Cloud weiter gesperrt — 2026-11-13
Feste APT-Konfiguration ergänzt um
`dpkg::selection::remove::approved=false`. Damit bleibt die explizite
Konfiguration des im Plan gebundenen Pakets erhalten. `ConfigurePending=false`
und `TriggersPending=false` bleiben bestehen; Hook verlangt alle drei Werte
eindeutig, fehlende/abweichende Werte führen zum Veto. Kein allgemeines
`--configure --pending`, keine Fremdpaketkonfiguration oder stiller Reparaturpfad.
**67 Python-Tests bestanden**, einschließlich echtem APT-Argumentvergleich im
isolierten readonly/offline-Container als UID 1000. Dort **APT 2.6.2**, nicht die
Cloudversion 2.7.14: Original nur `--unpack` des exakten Fixturearchivs; Korrektur
zusätzlich ausschließlich `--configure rmm-mvp-test:all`. Unabhängiger
dpkg-Wrapper delegiert nur einzeln erlaubte Readonly-Queries, simuliert sämtliche
Wirkungsaufrufe und zeichnet argv auf. Keine Pending-/Trigger-/Remove-/Purge-
oder Fremdpaketaufrufe; echte und kopierte Statusdatei bytegleich. Test ist
ausdrücklich opt-in `RMM_APT_ARGUMENT_REGRESSION=1`. Erster Containerlauf hatte
eine veraltete Unit eingebunden und scheiterte korrekt am Clock-Pin; mit
aktueller readonly-Unit alle Tests bestanden, kein Guard abgeschwächt.
Sourceprovider `3977c2c0ad68823a372cf8e66d050642ff8e15162260d5809b7e46e58999f455`,
Sourceconfig `18ba7b2fe65ff557a86acdf87a0cc0f004d56202a104e0fb0d416c998d413b95`.
**Nicht auf Cloud installiert, kein neuer Helper-/Agentbuild und keine native
Cloudabnahme dieser Konfiguration.** VM weiterhin Provider `465ac5ed…`, alter
Runtimepin unverändert. APT-Versuch weiterhin unknown/teilweise ausgeführt,
kein Paketretry oder Configure-Reparaturaufruf. Vor weiterer Wirkung sind ein
signierter, rein prüfender Abgleich der gespeicherten Teilwirkung und ein neuer
fest gebundener UI-Plan für eine begrenzte Wiederherstellung erforderlich.
Bestehende Unknown-/Restore-/Rootfences bleiben aktiv.
## Neuer APT-Versuch: Hook/APT bestanden, Nachprüfung unknown — 2026-11-13
**Kein Paketerfolg und keine Linux-MVP-Abnahme.** Neuer fest gebundener
@@ -5,6 +5,8 @@ DPkg::Tools::Options::/usr/lib/rmm-apt-transaction/hook::InfoFD=0
Dir::Bin::dpkg=/usr/bin/dpkg
Dir::State::status=/var/lib/dpkg/status
DPkg::ConfigurePending=false
DPkg::TriggersPending=false
dpkg::selection::remove::approved=false
rmm-mvp-test - - none < 1.1 all none /var/lib/rmm-apt-transaction/archives/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.deb
rmm-mvp-test - - none < 1.1 all none **CONFIGURE**
@@ -0,0 +1,133 @@
"""Real local APT argument regression; dpkg effects are independently replaced.
Opt in only inside the documented offline, read-only, unprivileged container:
RMM_APT_ARGUMENT_REGRESSION=1 python3 -m unittest discover ...
This is neither a native Cloud-VM test nor a package installation proof.
"""
import hashlib
import json
import os
from pathlib import Path
import subprocess
import tempfile
import unittest
from test_guard import apt
def digest(path):
return hashlib.sha256(path.read_bytes()).hexdigest()
def guarded_dpkg(path, calls):
# No arbitrary argv is ever delegated to real dpkg. Read-only, one-argument
# architecture/version/feature queries are the entire delegation allowlist.
path.write_text('''#!/usr/bin/python3 -I
import json, os, re, sys
from pathlib import Path
args = sys.argv[1:]
query = [arg for arg in args if not arg.startswith('--log=')]
if len(query) == 1 and (query[0] in (
'--version', '--print-architecture', '--print-foreign-architectures')
or re.fullmatch(r'--assert-[a-z0-9-]+', query[0])):
os.execve('/usr/bin/dpkg', ['/usr/bin/dpkg', query[0]], dict(os.environ))
data = sys.stdin.buffer.read() if '--set-selections' in args else b''
with Path(''' + repr(str(calls)) + ''').open('a', encoding='utf-8') as out:
out.write(json.dumps({'argv': args, 'stdin': data.decode('ascii')}) + '\\n')
# Effect calls are recorded and simulated; real dpkg is NEVER invoked here.
if any(op in args for op in ('--unpack', '--configure', '--set-selections')):
sys.exit(0)
sys.exit(91)
''', encoding='utf-8')
path.chmod(0o700)
def run_case(work, fixed):
for name in ('empty', 'lists', 'cache', 'log', 'state', 'dpkg'):
(work / name).mkdir(mode=0o700)
status = work / 'dpkg/status'
status.write_bytes(Path('/var/lib/dpkg/status').read_bytes())
fixture = work / 'rmm-mvp-test_1.0_all.deb'
fixture.write_bytes(apt.fixture_archive('1.0'))
calls = work / 'dpkg-calls.jsonl'
guard = work / 'dpkg-guard'
guarded_dpkg(guard, calls)
config = apt.apt_config().decode('ascii')
# This test reaches actual dpkg command generation. The production hook is
# removed only in this copied-state harness, whose dpkg cannot have effects.
config = '\n'.join(line for line in config.splitlines()
if not line.startswith(('DPkg::Pre-Install-Pkgs',
'DPkg::Tools::Options'))) + '\n'
if not fixed:
config = config.replace('dpkg::selection::remove::approved "false";\n', '')
config = config.replace(str(apt.ACTIVE), str(work))
config = config.replace(str(apt.BASE / 'log'), str(work / 'log'))
config = config.replace(str(apt.BASE / 'state'), str(work / 'state'))
config = config.replace('/var/lib/dpkg/status', str(status))
config = config.replace('Dir::Bin::dpkg "/usr/bin/dpkg";',
'Dir::Bin::dpkg "' + str(guard) + '";')
config += 'Dir::State "' + str(work / 'state') + '";\n'
config += 'Dir::Cache "' + str(work / 'cache') + '";\n'
config_path = work / 'apt.conf'
config_path.write_text(config, encoding='ascii')
before = digest(status)
result = subprocess.run(
['/usr/bin/apt-get', '--yes', '--no-remove', '--no-install-recommends',
'install', '--', str(fixture)],
env={'PATH': '/usr/sbin:/usr/bin:/sbin:/bin', 'LC_ALL': 'C',
'DEBIAN_FRONTEND': 'noninteractive', 'HOME': str(work),
'APT_CONFIG': str(config_path)},
stdin=subprocess.DEVNULL, capture_output=True, timeout=25,
)
records = [json.loads(line) for line in calls.read_text().splitlines()] if calls.exists() else []
return {'exit_code': result.returncode, 'calls': records,
'status_unchanged': digest(status) == before,
'fixture': str(fixture), 'stderr': result.stderr.decode('ascii', errors='replace')}
@unittest.skipUnless(os.environ.get('RMM_APT_ARGUMENT_REGRESSION') == '1',
'explicit offline read-only container regression only')
class RealAptConfigureArguments(unittest.TestCase):
def test_exact_fixture_configure_survives_without_any_pending_command(self):
self.assertNotEqual(os.geteuid(), 0, 'must run unprivileged')
host_status = Path('/var/lib/dpkg/status')
original = digest(host_status)
summaries = {}
with tempfile.TemporaryDirectory(prefix='rmm-apt-arguments-') as temp:
for fixed in (False, True):
name = 'fixed' if fixed else 'original'
work = Path(temp) / name
work.mkdir(mode=0o700)
result = run_case(work, fixed)
self.assertEqual(result['exit_code'], 0, result['stderr'])
self.assertTrue(result['status_unchanged'])
effects = []
for call in result['calls']:
args = call['argv']
self.assertNotIn('--pending', args)
self.assertNotIn('--triggers-only', args)
self.assertNotIn('--remove', args)
self.assertNotIn('--purge', args)
if '--unpack' in args:
self.assertEqual(args[args.index('--unpack') + 1:],
['--auto-deconfigure', result['fixture']])
effects.append('unpack:exact-fixture-archive')
elif '--configure' in args:
self.assertEqual(args[args.index('--configure') + 1:],
['rmm-mvp-test:all'])
effects.append('configure:rmm-mvp-test:all')
else:
self.assertIn('--set-selections', args)
for line in call['stdin'].splitlines():
self.assertEqual(line.split()[0].split(':')[0], 'rmm-mvp-test')
self.assertEqual(effects, ['unpack:exact-fixture-archive'] +
(['configure:rmm-mvp-test:all'] if fixed else []))
summaries[name] = effects
self.assertEqual(digest(host_status), original)
version = subprocess.check_output(['/usr/bin/apt-get', '--version']).decode().splitlines()[0]
print(json.dumps({'apt_version': version, 'dpkg_effects_simulated': True,
'host_and_copied_status_unchanged': True, 'cases': summaries}))
if __name__ == '__main__':
unittest.main()
+15 -1
View File
@@ -38,7 +38,8 @@ def protocol(old=None):
'DPkg::Tools::Options::' + apt.HOOK + '::Version=3\n'
'DPkg::Tools::Options::' + apt.HOOK + '::InfoFD=0\n'
'Dir::Bin::dpkg=/usr/bin/dpkg\nDir::State::status=/var/lib/dpkg/status\n'
'DPkg::ConfigurePending=false\n\n' + action + transaction()['packages'][0]['archive_path'] +
'DPkg::ConfigurePending=false\nDPkg::TriggersPending=false\n'
'dpkg::selection::remove::approved=false\n\n' + action + transaction()['packages'][0]['archive_path'] +
'\n' + action + '**CONFIGURE**\n').encode('ascii')
@@ -84,6 +85,16 @@ class ProtocolTests(unittest.TestCase):
with self.assertRaises(apt.Veto):
apt.check_hook_config(config)
def test_explicit_configure_and_no_pending_settings_are_required_in_actual_hook(self):
original = protocol()
for setting in (b'DPkg::ConfigurePending', b'DPkg::TriggersPending',
b'dpkg::selection::remove::approved'):
for changed in (original.replace(setting + b'=false\n', b''),
original.replace(setting + b'=false', setting + b'=true')):
config, _ = apt.parse_protocol3(changed)
with self.subTest(setting=setting), self.assertRaises(apt.Veto):
apt.check_hook_config(config)
def test_entire_action_set_dependency_change_remove_configure(self):
tx = apt.ResolvedAptTransaction.parse(transaction())
original = protocol()
@@ -277,6 +288,9 @@ print('FILTER_LOADED')
self.assertEqual((ROOT / 'tools/apt-transaction/hook').read_bytes(), apt.hook_script())
self.assertIn(b'Dir::Etc::parts', apt.apt_config())
self.assertIn(b'APT::Get::Download "true";', apt.apt_config())
self.assertIn(b'dpkg::selection::remove::approved "false";', apt.apt_config())
self.assertIn(b'DPkg::ConfigurePending "false";', apt.apt_config())
self.assertIn(b'DPkg::TriggersPending "false";', apt.apt_config())
def test_ip_socket_denials_are_required_for_both_families(self):
with patch.object(apt.socket, 'socket', side_effect=OSError(errno.EAFNOSUPPORT, 'synthetic')) as make:
+18
View File
@@ -1,5 +1,23 @@
# Root-helper APT transaction provider / explicit first native acceptance
**Current 2026-11-13:** Cloud fixture retry reached armed hook and APT exit 0,
but independent verification found an unpacked/unconfigured package; outcome
remains **unknown**, with all original/retry tombstones and ledger preserved.
No native acceptance record, package repair or further retry. Root test policy
closed. Detailed real evidence: `../../docs/implementation-status.md`.
Source configuration now disables APT's `dpkg::selection::remove::approved`
rewrite, retaining the exact package's Configure operation while both pending
modes remain disabled and hook-pinned. Upstream explanation:
[APT 2.7.14 dpkgpm.cc](https://github.com/Debian/apt/blob/2.7.14/apt-pkg/deb/dpkgpm.cc#L1626-L1657).
Local actual APT 2.6.2 regression in an offline readonly unprivileged container
proved unpack + exact `--configure rmm-mvp-test:all`, no `--pending` or foreign
target; independent dpkg guard simulated effects, real/copied status unchanged.
67 Python tests passed with this opt-in regression. **This source correction
is not deployed or natively accepted on the Cloud VM.** No automatic repair,
marker reset or implicit unknown-resolution is introduced. Older sections below
describe historical increments; current operational status is the linked log.
Current dedicated runner/probe/profile/agent integration and executed local
checks: [`../../deploy/linux/apt-helper-README.md`](../../deploy/linux/apt-helper-README.md).
The general helper unit remains unchanged; actual native VM measurements are
+7 -1
View File
@@ -890,6 +890,9 @@ def check_preconditions(transaction, baseline):
def apt_config():
"""Constant bytes: no job string, URL, shell interpolation, global hooks."""
# APT's default selection rewrite erases explicit Configure operations and
# substitutes --configure --pending. Keep the exact target Configure instead
# while both pending modes remain disabled (upstream dpkgpm.cc, APT 2.7.14).
return ('''Dir::Etc::parts "/var/lib/rmm-apt-transaction/active/empty";
Dir::Etc::main "/dev/null";
Dir::Etc::sourcelist "/dev/null";
@@ -920,6 +923,7 @@ APT::Get::allow-Remove-Essential "false";
DPkg::Lock::Timeout "10";
DPkg::ConfigurePending "false";
DPkg::TriggersPending "false";
dpkg::selection::remove::approved "false";
DPkg::Inhibit-Shutdown "false";
DPkg::Use-Pty "false";
DPkg::Pre-Install-Pkgs { "/usr/lib/rmm-apt-transaction/hook"; };
@@ -946,7 +950,9 @@ def check_hook_config(config):
('dpkg::tools::options::' + HOOK + '::infofd', '0'),
('dir::bin::dpkg', '/usr/bin/dpkg'),
('dir::state::status', '/var/lib/dpkg/status'),
('dpkg::configurepending', 'false')):
('dpkg::configurepending', 'false'),
('dpkg::triggerspending', 'false'),
('dpkg::selection::remove::approved', 'false')):
require([value for name, value in config if name.lower() == key] == [expected],
'APT_CONFIG_BINDING')