From 8b5365f4bc457453ba6234805c776958476b6dc3 Mon Sep 17 00:00:00 2001 From: Kevin Janssen Date: Wed, 18 Nov 2026 17:59:19 +0100 Subject: [PATCH] Verify Linux installer architecture selection and display available targets --- tests/linux_release_bootstrap.py | 27 ++++++++++++++++++++++++++- web/src/agent-updates.ts | 2 +- web/src/main.tsx | 7 ++++--- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/tests/linux_release_bootstrap.py b/tests/linux_release_bootstrap.py index eb133fb..dd4fa3c 100644 --- a/tests/linux_release_bootstrap.py +++ b/tests/linux_release_bootstrap.py @@ -56,9 +56,11 @@ class EnrollmentRetry(unittest.TestCase): lifecycle.device_idle() self.assertEqual(output.getvalue().strip(), expected) - def bootstrap_tenant(self, tenant): + def bootstrap_tenant(self, tenant, expected_platform=None): def answer(source, route, target): self.assertEqual(source, (self.base,'0' * 64)) + if expected_platform: + self.assertEqual(route, '/agent/v1/bootstrap/current?platform=' + expected_platform) target.write_text(json.dumps({'tenant_id': tenant})) return self.stack.enter_context(patch.object(lifecycle,'remote',side_effect=answer)) @@ -80,6 +82,29 @@ class EnrollmentRetry(unittest.TestCase): self.save.assert_called_once() self.healthy.assert_called_once_with('1.0',0) + def test_arm64_install_retry_requests_arm64_release(self): + self.bootstrap_tenant(self.tenant, 'aarch64-unknown-linux-gnu') + with patch.object(lifecycle.platform, 'machine', return_value='aarch64'): + lifecycle.install(self.base, self.token, enable_admin_scripts=True) + self.save.assert_called_once() + self.provision.assert_called_once_with(True) + + def test_unsupported_architecture_stops_before_enrollment(self): + with patch.object(lifecycle.platform, 'machine', return_value='armv7l'), \ + patch.object(lifecycle, 'enrollment_token') as token: + with self.assertRaisesRegex(ValueError, 'Linux x86-64 or ARM64 required'): + lifecycle.install(self.base, self.token) + token.assert_not_called() + self.enable.assert_not_called() + + def test_x64_release_is_rejected_before_downloading_to_arm64(self): + doc = {'manifest': {'release_id': self.tenant, 'platform': 'x86_64-unknown-linux-gnu'}} + with patch.object(lifecycle.platform, 'machine', return_value='aarch64'), \ + patch.object(lifecycle, 'remote') as download: + with self.assertRaisesRegex(ValueError, 'release architecture differs'): + lifecycle.pair(lifecycle.ROOT, doc, (self.base, '0' * 64), lifecycle.ROOT / 'updater') + download.assert_not_called() + def test_timer_starts_only_after_confirmed_first_connection(self): self.bootstrap_tenant(self.tenant) self.healthy.return_value = False diff --git a/web/src/agent-updates.ts b/web/src/agent-updates.ts index bb120c1..7559e80 100644 --- a/web/src/agent-updates.ts +++ b/web/src/agent-updates.ts @@ -55,7 +55,7 @@ export function validateAgentUpdateAction(value: unknown, identity: unknown): Re const action = record(value); exact(action, ['action', 'update']); if (action.action !== 'update_agent') throw new Error('Agentupdate: typisierte Aktion erforderlich'); const u = record(action.update); exact(u, ['schema_version', 'profile', 'release_envelope', 'release_envelope_sha256', 'manifest_sha256', 'predecessor', 'updater', 'peer_pin_transition', 'recovery', 'health_profile', 'health_timeout_seconds', 'no_reboot']); if (u.schema_version !== 1 || u.profile !== 'fixed_code_pair_v1' || u.recovery !== 'restore_exact_predecessor_once' || u.health_profile !== 'mtls_inventory_sync_v1' || u.health_timeout_seconds !== 180 || u.no_reboot !== true) throw new Error('Agentupdate: fester Apply-/Health-/No-Reboot-Vertrag erforderlich'); - const release = releaseEnvelope(u.release_envelope), linux = release.manifest.platform.endsWith('-unknown-linux-gnu'); + const release = releaseEnvelope(u.release_envelope), linux = ['x86_64-unknown-linux-gnu', 'aarch64-unknown-linux-gnu'].includes(String(release.manifest.platform)); if (identity !== (linux ? 'root' : 'system')) throw new Error('Agentupdate: Plattform und Root-/SYSTEM-Identität widersprechen sich'); const old = record(u.predecessor); exact(old, ['release_id', 'release_sequence', 'manifest_sha256', 'installed_record_sha256', 'agent_sha256', 'helper_sha256']); const predecessor = { release_id: uuid(old.release_id), release_sequence: integer(old.release_sequence), manifest_sha256: digest(old.manifest_sha256), installed_record_sha256: digest(old.installed_record_sha256), agent_sha256: digest(old.agent_sha256), helper_sha256: digest(old.helper_sha256) }; diff --git a/web/src/main.tsx b/web/src/main.tsx index 9894012..9c70f83 100644 --- a/web/src/main.tsx +++ b/web/src/main.tsx @@ -203,8 +203,9 @@ function DeviceEnrollment({ tenantId, auth, customerName }: { tenantId: string; const linuxArchitectures = [ ['x86_64-unknown-linux-gnu', 'x86-64'], ['aarch64-unknown-linux-gnu', 'ARM64'], - ].filter(([target]) => enrollment?.platforms.includes(target)).map(([, label]) => label); - const linuxInstaller = origin && linuxArchitectures.length > 0 ? `${origin}/install/linux.sh` : null; + ] as const; + const availableLinuxArchitectures = linuxArchitectures.filter(([target]) => enrollment?.platforms.includes(target)).map(([, label]) => label); + const linuxInstaller = origin && availableLinuxArchitectures.length > 0 ? `${origin}/install/linux.sh` : null; const windowsPlatforms = ['x86_64-pc-windows-gnu', 'x86_64-pc-windows-msvc'].filter(platform => enrollment?.platforms.includes(platform)); const windowsInstaller = origin && windowsPlatforms.length > 0 ? `${origin}/install/windows.ps1` : null; return

Gerät aufnehmen

@@ -245,7 +246,7 @@ function DeviceEnrollment({ tenantId, auth, customerName }: { tenantId: string; {enrollment && !origin &&

Für die Geräteaufnahme ist keine HTTPS-Downloadadresse konfiguriert.

} {origin && !linuxInstaller && !windowsInstaller &&

Für diesen Kunden ist derzeit kein Linux- oder Windows-Installer verfügbar.

} {linuxInstaller && <> -

Linux ({linuxArchitectures.join(' und ')})

+

Linux ({availableLinuxArchitectures.join(' und ')})

Installationsskript linux.sh

{`curl --fail --show-error --silent '${linuxInstaller}' -o linux.sh && sudo sh linux.sh '${origin}'${adminScripts ? ' --enable-admin-scripts' : ''}`}
}