The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
os: bring fresh Asahi accounts into the graphical Harness session (#926)
Dee66806c6385d1
diff --git a/os/fedora_session.py b/os/fedora_session.pyindex 3ea4d1d89..c1fab23ae 100644--- a/os/fedora_session.py+++ b/os/fedora_session.py@@ -168,10 +168,14 @@ class Setup:shadows = [line.split(':') for line in self.path('etc/shadow').read_text().splitlines()]shadow = next((row for row in shadows if len(row) == 9 and row[0] == user), None)today = (datetime.date.today() - datetime.date(1970, 1, 1)).days- if (not shadow or not shadow[1] or shadow[1][0] in '!*' or not shadow[2] or int(shadow[2]) == 0 or+ # shadow(5): an empty last-change field disables password aging. Asahi's+ # initial-setup creates these valid accounts; only zero forces a change.+ if (not shadow or not shadow[1] or shadow[1][0] in '!*' or+ (shadow[2] and int(shadow[2]) == 0) ornot re.fullmatch(r'\$[^$\s:]+\$[^:\s]{10,}|[./0-9A-Za-z]{13}', shadow[1]) or(shadow[7] and int(shadow[7]) >= 0 and int(shadow[7]) <= today) or- (shadow[4] and int(shadow[4]) >= 0 and int(shadow[2]) + int(shadow[4]) <= today)):+ (shadow[2] and int(shadow[2]) > 0 and shadow[4] and int(shadow[4]) >= 0 and+ int(shadow[2]) + int(shadow[4]) <= today)):raise SetupError('The selected account needs a usable, unexpired password for recovery login.')# Query existing policy as root; do not authenticate or grant administrative access.self.run('/usr/bin/sudo', '-n', '-l', '-U', user, '--', '/usr/bin/harness-session-setup', 'disable')@@ -179,7 +183,10 @@ class Setup:def preflight(self, user):release = self.path('etc/os-release').read_text()- if (platform.machine() != 'aarch64' or not re.search(r'^ID=[\"\']?fedora[\"\']?$', release, re.MULTILINE) or+ # The maintained Asahi image identifies itself as fedora-asahi-remix.+ # Accept these two explicit identities, not every ID_LIKE=fedora system.+ fedora = re.search(r'''^ID=(["']?)(fedora|fedora-asahi-remix)\1$''', release, re.MULTILINE)+ if (platform.machine() != 'aarch64' or not fedora orjson.loads(self.path('usr/share/harness-os/runtime.json').read_text()).get('system_profile') != 'fedora'):raise SetupError('This setup is only for the native Fedora ARM session package.')for binary in ('usr/bin/greetd', 'usr/bin/agreety', 'usr/bin/harness-session', 'usr/sbin/visudo'):diff --git a/os/packaging/fedora/harness-os-session.spec b/os/packaging/fedora/harness-os-session.specindex ab7786e8b..85ac70b14 100644--- a/os/packaging/fedora/harness-os-session.spec+++ b/os/packaging/fedora/harness-os-session.spec@@ -14,6 +14,9 @@ Source0: payload.tar.gzSource1: files.listRequires: python3, nodejs22, nodejs22-bin, tmux, foot, labwc+# Fedora's labwc exits during startup when this executable is absent, even+# for native Wayland clients. Keep its on-demand server available.+Requires: /usr/bin/XwaylandRequires: systemd, dbus-tools, NetworkManager, sudo, util-linux, procps-ng, kmod, iprouteRequires: pipewire, pipewire-pulseaudio, wireplumber, swayidle, gtklock, brightnessctlRequires: wl-clipboard, grim, slurp, xdg-utils, xdg-desktop-portal-wlr, dejavu-sans-mono-fontsdiff --git a/os/tests/fedora_package_lifecycle.py b/os/tests/fedora_package_lifecycle.pyindex 39f873a1b..9dbab004f 100644--- a/os/tests/fedora_package_lifecycle.py+++ b/os/tests/fedora_package_lifecycle.py@@ -259,6 +259,13 @@ def main():for kind in ['config', 'data', 'cache', 'state']]]assert run('runuser', '-u', 'harness-rpm-probe', '--', 'env', *environment,'/usr/bin/opencode', '--version', timeout=30).stdout.strip() == agent['version']+ # Exercise the distribution compositor with only the RPM's+ # declared dependencies. Merely resolving labwc's libraries+ # misses its mandatory Xwayland executable at startup.+ run('runuser', '-u', 'harness-rpm-probe', '--', 'env', *environment,+ 'XDG_RUNTIME_DIR=' + temporary, 'WLR_BACKENDS=headless',+ 'WLR_RENDERER=pixman', 'labwc', '-C', temporary,+ '-S', '/usr/bin/true', timeout=30)assert run('rpm', '-qf', '--qf', '%{NAME}', '/usr/bin/opencode').stdout == 'harness-os-session'assert run('rpm', '-qf', '--qf', '%{NAME}', '/usr/lib/harness-opencode/opencode').stdout == 'harness-os-session'assert '/usr/share/licenses/harness-opencode/LICENSE' in installed@@ -269,6 +276,7 @@ def main():assert run('getent', 'passwd', 'harness-rpm-probe').stdout == accountassert run('getent', 'passwd', 'me', check=False).returncode != 0, 'Package created a default OS account'receipt['checks'].append(f'Native {label}: declared payload owned/verified, existing user and host configuration unchanged')+ receipt['checks'].append(f'Native {label}: packaged dependencies start the distribution compositor on a headless Wayland backend')# A plain RPM erase is intentional: dependency autoremoval is a separate# DNF policy and must not disguise removal of this package's own files.run('rpm', '-e', 'harness-os-session')diff --git a/os/tests/test_fedora_session.py b/os/tests/test_fedora_session.pyindex 1e81cf97a..b9756c62c 100644--- a/os/tests/test_fedora_session.py+++ b/os/tests/test_fedora_session.py@@ -116,6 +116,38 @@ class FedoraSession(unittest.TestCase):self.setup.disable()self.assert_original()+ def test_asahi_remix_identity_can_enable_and_restore_the_existing_login(self):+ for identity in ('fedora-asahi-remix', '"fedora-asahi-remix"', "'fedora-asahi-remix'"):+ with self.subTest(identity=identity):+ self.put('etc/os-release', f'NAME="Fedora Asahi Remix"\nID={identity}\nID_LIKE=fedora\nVERSION_ID=44\n')+ self.setup.enable('owner')+ self.assertEqual(self.setup.load()['phase'], 'enabled')+ self.assertEqual(self.snapshot_protected(), self.protected)+ self.setup.disable()+ self.assert_original()++ def test_foreign_or_malformed_distribution_cannot_change_login_policy(self):+ for release in ('ID=arch\nID_LIKE=fedora\n', 'ID=another-fedora-remix\nID_LIKE=fedora\n',+ 'ID=fedora-asahi-remix-extra\n', 'ID="fedora-asahi-remix\n',+ "ID='fedora-asahi-remix\"\n"):+ with self.subTest(release=release):+ self.put('etc/os-release', release)+ with self.assertRaisesRegex(session.SetupError, 'native Fedora ARM'):+ self.setup.enable('owner')+ self.assert_original()+ self.assertEqual(self.setup.commands, [])++ def test_asahi_identity_still_requires_the_native_fedora_runtime(self):+ self.put('etc/os-release', 'ID=fedora-asahi-remix\nID_LIKE=fedora\n')+ with patch.object(session.platform, 'machine', return_value='x86_64'):+ with self.assertRaisesRegex(session.SetupError, 'native Fedora ARM'):+ self.setup.enable('owner')+ self.put('usr/share/harness-os/runtime.json', '{"system_profile":"arch"}\n')+ with self.assertRaisesRegex(session.SetupError, 'native Fedora ARM'):+ self.setup.enable('owner')+ self.assert_original()+ self.assertEqual(self.setup.commands, [])+def test_idempotent_enable_checks_identity_and_does_not_rewrite(self):self.setup.enable('owner')before = {name: self.setup.path(name).lstat().st_mtime_ns for name in session.PATHS}@@ -167,6 +199,27 @@ class FedoraSession(unittest.TestCase):self.setup.enable('owner')self.assert_original()+ def test_valid_password_with_aging_disabled_is_preserved(self):+ for last_change in ('', '-1'):+ for maximum in ('', '1', '99999'):+ with self.subTest(last_change=last_change, maximum=maximum):+ self.put('etc/shadow', f'owner:$y$j9T$existing-password-hash:{last_change}:0:{maximum}:7:::\n', 0o600)+ self.protected = self.snapshot_protected()+ self.setup.enable('owner')+ self.assertEqual(self.snapshot_protected(), self.protected)+ self.setup.disable()+ self.assert_original()++ def test_forced_password_change_and_expired_accounts_are_still_rejected(self):+ for last_change, maximum, expires in (('0', '99999', ''), ('1', '1', ''),+ ('', '99999', '1'), ('-1', '', '1')):+ with self.subTest(last_change=last_change, maximum=maximum, expires=expires):+ self.put('etc/shadow', f'owner:$y$j9T$existing-password-hash:{last_change}:0:{maximum}:7::{expires}:\n', 0o600)+ self.protected = self.snapshot_protected()+ with self.assertRaisesRegex(session.SetupError, 'usable, unexpired password'):+ self.setup.enable('owner')+ self.assert_original()+def test_conflicting_configuration_is_never_overwritten(self):for name in (session.CONFIG, session.DROPIN, session.SUDOERS, session.ALIAS):self.put(name, 'existing admin configuration\n')