From 046461c3cde0800d745f5a086a7b324ca8777df6 Mon Sep 17 00:00:00 2001 From: harkl <89045610+h4rkl@users.noreply.github.com> Date: Wed, 28 Oct 2026 10:36:52 +1300 Subject: [PATCH 1/3] omamobile-firstboot 0.1.3: seed the clock before key setup Phones without an RTC can start before the installed signing keys were created. Use the newest public keyring timestamp in the verified root image as a clock floor before GnuPG creates or imports keys, without moving an accurate clock backwards. The Linux firstboot tests cover an old clock, an accurate clock, absent keyrings, and ordering before pacman-key. Move this shared policy out of the tegu package. Co-Authored-By: Codex --- .../bin/omamobile-firstboot | 14 +++++++++++ packages/omamobile-firstboot/test/all | 23 +++++++++++++++++++ packages/omamobile-firstboot/version | 2 +- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/packages/omamobile-firstboot/bin/omamobile-firstboot b/packages/omamobile-firstboot/bin/omamobile-firstboot index f951476b1..597bac603 100755 --- a/packages/omamobile-firstboot/bin/omamobile-firstboot +++ b/packages/omamobile-firstboot/bin/omamobile-firstboot @@ -211,6 +211,20 @@ step() { } s_keyring() { + # A phone without a working RTC can boot before its signing keys existed. + # Installed public keyrings are part of the verified root image; use their + # newest mtime as a floor before GnuPG creates or imports keys offline. + # Never move a valid clock backwards, and do nothing without a keyring. + local keyring stamp floor=0 now + for keyring in "$ROOT"/usr/share/pacman/keyrings/*.gpg; do + [[ -f $keyring ]] || continue + stamp=$(stat -c %Y "$keyring") + ((stamp <= floor)) || floor=$stamp + done + now=$(date -u +%s) + if ((now < floor)); then + date -u -s "@$floor" >/dev/null + fi if [[ ! -f $ROOT/etc/pacman.d/gnupg/trustdb.gpg ]]; then pacman-key --init fi diff --git a/packages/omamobile-firstboot/test/all b/packages/omamobile-firstboot/test/all index 429925390..403030cf7 100755 --- a/packages/omamobile-firstboot/test/all +++ b/packages/omamobile-firstboot/test/all @@ -121,6 +121,15 @@ pass "values are data, never executed" # --- a whole run against fakes ------------------------------------------------ F=$t/fakes; mkdir -p "$F"; CALLS=$t/calls; : > "$CALLS" fake() { printf '#!/bin/bash\n%s\n' "$2" > "$F/$1"; chmod +x "$F/$1"; } +export REAL_DATE=$(command -v date) TEST_NOW=1 +fake date 'case "$*" in + "-u +%s") echo "$TEST_NOW" ;; + "-u -s "*) echo "clock-set ${3#@}" >> "$CALLS" ;; + *) "$REAL_DATE" "$@" ;; +esac' +mkdir -p "$R/usr/share/pacman/keyrings" +touch -d @2000000000 "$R/usr/share/pacman/keyrings/archlinuxarm.gpg" +touch -d @2000000060 "$R/usr/share/pacman/keyrings/omamobile.gpg" for cmd in pacman-key systemctl ufw chown hostname nmcli usermod omamobile-setup-system; do fake "$cmd" 'echo "$(basename "$0") $*" >> "$CALLS"' done @@ -146,6 +155,9 @@ run() { OMAMOBILE_FIRSTBOOT_ROOT=$R OMARCHY_PATH=$O OMAMOBILE_LOCK_PAM=$F/lock-p good > "$R/etc/omamobile/firstboot.conf" run || { cat "$t/run.out"; fail "a run with a good conf succeeds"; } +grep -qx 'clock-set 2000000060' "$CALLS" || fail "clock advances to the newest installed keyring" +[[ $(head -1 "$CALLS") == 'clock-set 2000000060' ]] || fail "clock is seeded before pacman-key" +pass "an offline clock is seeded before creating and importing keys" [[ ! -e $R/etc/omamobile/firstboot.conf ]] || fail "the conf is deleted after a run" [[ -f $R/var/lib/omamobile/firstboot/done ]] || fail "the run is recorded" grep -q '^useradd -m -G wheel,audio,video,input -s /bin/bash -c Alice Example alice$' "$CALLS" || fail "the user gets the groups and name" @@ -181,11 +193,22 @@ pass "the lock's PAM file comes from lock-pam, not omarchy-apply-lock" run || fail "without a conf, nothing to do" [[ ! -s $CALLS ]] || fail "without a conf, nothing runs" good | sed '/^WIFI_/d' > "$R/etc/omamobile/firstboot.conf" +export TEST_NOW=2000000100 run || { cat "$t/run.out"; fail "a second run succeeds"; } +grep -q '^clock-set' "$CALLS" && fail "an accurate clock is never moved backwards" grep -q '^usermod -aG wheel,audio,video,input' "$CALLS" || fail "a second run updates the user it made" [[ $(grep -cxF "$KEY" "$R/home/alice/.ssh/authorized_keys") == 1 ]] || fail "a second run doesn't duplicate the key" pass "running again is safe" +: > "$CALLS" +rm "$R/usr/share/pacman/keyrings/"*.gpg +export TEST_NOW=1 +good > "$R/etc/omamobile/firstboot.conf" +run || { cat "$t/run.out"; fail "a root without keyrings still runs"; } +grep -q '^clock-set' "$CALLS" && fail "no keyrings means no clock adjustment" +grep -q '^pacman-key --populate' "$CALLS" || fail "key setup still runs without a floor" +pass "missing keyrings leave the clock alone" + # An essential step failing keeps the conf (minus the Wi-Fi secret) for the next boot rm -f "$R/var/lib/omamobile/firstboot/user" sed -i '/^alice:/d' "$R/etc/passwd" diff --git a/packages/omamobile-firstboot/version b/packages/omamobile-firstboot/version index d917d3e26..b1e80bb24 100644 --- a/packages/omamobile-firstboot/version +++ b/packages/omamobile-firstboot/version @@ -1 +1 @@ -0.1.2 +0.1.3 From f76d7ae4c139dae8549f4d84bbd41b9a576817a1 Mon Sep 17 00:00:00 2001 From: harkl <89045610+h4rkl@users.noreply.github.com> Date: Wed, 28 Oct 2026 11:00:38 +1300 Subject: [PATCH 2/3] omamobile-firstboot 0.1.3: declare native test dependency The package check uses cmp, which is absent from the minimal phone root. Declare diffutils as a check dependency so makepkg can run the full tests in a fresh build environment. Built with checks enabled on aarch64 tegu, installed 0.1.3-2, and ran the installed keyring setup against an isolated keyring root. Clock seeding and real pacman-key initialization and population passed. Co-Authored-By: Codex --- packages/omamobile-firstboot/PKGBUILD | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/omamobile-firstboot/PKGBUILD b/packages/omamobile-firstboot/PKGBUILD index 73453d21d..f87949f17 100644 --- a/packages/omamobile-firstboot/PKGBUILD +++ b/packages/omamobile-firstboot/PKGBUILD @@ -2,12 +2,13 @@ # Maintainer: Derek Ross pkgname=omamobile-firstboot pkgver=$(cat "${startdir:-.}/version") -pkgrel=1 +pkgrel=2 pkgdesc="Omarchy Mobile first boot: the user, SSH key, firewall and Omarchy's setup from the installer's answers" arch=(any) url="https://github.com/derekross/omarchy-mobile" license=(MIT) depends=(bash coreutils grep sed gawk shadow sudo systemd openssh ufw networkmanager pacman util-linux) +checkdepends=(diffutils) backup=(etc/ssh/sshd_config.d/10-omamobile.conf) install=omamobile-firstboot.install From 496f2e8c8bf7cb1de0fed4cb06f89463d5c886fe Mon Sep 17 00:00:00 2001 From: harkl <89045610+h4rkl@users.noreply.github.com> Date: Sun, 1 Nov 2026 14:24:20 +1300 Subject: [PATCH 3/3] omamobile-firstboot 0.1.3: reset pkgrel and fix the root image wording A new version starts at pkgrel=1; the -2 was a local rebuild. Nothing verifies the root image (there is no dm-verity), so the comment no longer calls it verified. Co-Authored-By: Claude Opus 5.5 --- packages/omamobile-firstboot/PKGBUILD | 2 +- packages/omamobile-firstboot/bin/omamobile-firstboot | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/omamobile-firstboot/PKGBUILD b/packages/omamobile-firstboot/PKGBUILD index f87949f17..a9a5c281c 100644 --- a/packages/omamobile-firstboot/PKGBUILD +++ b/packages/omamobile-firstboot/PKGBUILD @@ -2,7 +2,7 @@ # Maintainer: Derek Ross pkgname=omamobile-firstboot pkgver=$(cat "${startdir:-.}/version") -pkgrel=2 +pkgrel=1 pkgdesc="Omarchy Mobile first boot: the user, SSH key, firewall and Omarchy's setup from the installer's answers" arch=(any) url="https://github.com/derekross/omarchy-mobile" diff --git a/packages/omamobile-firstboot/bin/omamobile-firstboot b/packages/omamobile-firstboot/bin/omamobile-firstboot index 597bac603..39f4ea018 100755 --- a/packages/omamobile-firstboot/bin/omamobile-firstboot +++ b/packages/omamobile-firstboot/bin/omamobile-firstboot @@ -212,7 +212,7 @@ step() { s_keyring() { # A phone without a working RTC can boot before its signing keys existed. - # Installed public keyrings are part of the verified root image; use their + # Installed public keyrings are part of the root image; use their # newest mtime as a floor before GnuPG creates or imports keys offline. # Never move a valid clock backwards, and do nothing without a keyring. local keyring stamp floor=0 now