From 6c9efb27c7df0089518ea23db93301397177f338 Mon Sep 17 00:00:00 2001 From: Derek Ross Date: Mon, 9 Nov 2026 00:52:17 -0500 Subject: [PATCH 1/2] omamobile-omarchy 0.1.38: omarchy update without a session environment Omarchy's update scripts read OMARCHY_PATH under set -u, and a session gets it from Omarchy's env-bootstrap. A root login over SSH or a TTY has none, so `omarchy update` there stopped after updating, in omarchy-update-dev ("OMARCHY_PATH: unbound variable"; the 2026.11.08 test install on the Pixel 7 Pro, over tools/phone-ssh). omamobile-update already knew the default, /usr/share/omarchy, but passed it only to the migrations it runs; it now sets it for Omarchy's update too when the environment has none. test/update.sh runs the sheet's update once more with OMARCHY_PATH removed from the environment and checks that omarchy-update receives Omarchy's path; against the previous omamobile-update that check fails. test/all: 233 ok. Co-Authored-By: Claude Opus 5.5 --- packages/omamobile-omarchy/bin/omamobile-update | 4 ++++ packages/omamobile-omarchy/test/update.sh | 9 +++++++++ packages/omamobile-omarchy/version | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/omamobile-omarchy/bin/omamobile-update b/packages/omamobile-omarchy/bin/omamobile-update index 3e2023b29..ad8d21903 100755 --- a/packages/omamobile-omarchy/bin/omamobile-update +++ b/packages/omamobile-omarchy/bin/omamobile-update @@ -770,6 +770,10 @@ def inner(args): omarchy_line = next((l for l in lines if l.split()[0] in ("omarchy", "omarchy-dev")), "") print("%d package(s) to update%s" % (len(targets) or len(lines), "; " + omarchy_line if omarchy_line else ""), flush=True) + # Omarchy's scripts read OMARCHY_PATH under set -u (omarchy-update-dev: + # "unbound variable"). A session gets it from Omarchy's env-bootstrap; + # a root login over SSH or a TTY doesn't, so pass the default on. + env.setdefault("OMARCHY_PATH", OMARCHY_PATH) env.update(PATH=SHIMS + ":" + env.get("PATH", "/usr/bin"), OMARCHY_UPDATE_LOGGED="1", OMAMOBILE_UPDATE="1", OMAMOBILE_UPDATE_DIR=RUNTIME, OMAMOBILE_SUDO=SUDO, OMAMOBILE_UPDATE_STARTED=str(int(time.time()))) return subprocess.run([OMARCHY_UPDATE, "-y"], env=env).returncode diff --git a/packages/omamobile-omarchy/test/update.sh b/packages/omamobile-omarchy/test/update.sh index 98d8efe0f..3760c4a0b 100755 --- a/packages/omamobile-omarchy/test/update.sh +++ b/packages/omamobile-omarchy/test/update.sh @@ -66,6 +66,7 @@ EOF cat >"$fake/omarchy-update" <>"$calls" +echo "omarchy-update OMARCHY_PATH=\${OMARCHY_PATH-unset}" >>"$calls" for c in omarchy-snapshot omarchy-update-aur-pkgs omarchy-update-orphan-pkgs omarchy-migrate omarchy-update-restart sudo; do echo "resolve \$c \$(command -v \$c)" >>"$calls" done @@ -408,4 +409,12 @@ echo "omarchy 4.0.4-2 -> 4.0.5-1" >"$t/available" python3 -I "$U" notify-check >/dev/null; python3 -I "$U" notify-check >/dev/null ok "notify-check: one toast per release, opening the sheet" '[[ $(grep -c "^notify" "$calls") == 1 ]] && grep -c "summon omamobile.update" "$calls" >/dev/null' +# A root login over SSH (or a TTY) has no Omarchy session environment, and +# Omarchy's update scripts read OMARCHY_PATH under set -u: it still arrives +: >"$calls" +rc=0; out=$(printf '1234\n' | env -u OMARCHY_PATH python3 -I "$U" start) || rc=$? +ok "no OMARCHY_PATH in the environment: the update starts (exit 0, '$out')" '[[ $rc == 0 && $out == started ]]' +wait_done +ok "no OMARCHY_PATH in the environment: omarchy-update still gets Omarchy's (omarchy-update-dev)" 'grep -c "^omarchy-update OMARCHY_PATH=/usr/share/omarchy$" "$calls" >/dev/null' + exit $((failures > 0)) diff --git a/packages/omamobile-omarchy/version b/packages/omamobile-omarchy/version index 9f42295fc..5786113b6 100644 --- a/packages/omamobile-omarchy/version +++ b/packages/omamobile-omarchy/version @@ -1 +1 @@ -0.1.37 +0.1.38 From 537905255534b36d617491319b37d336ef24d1a0 Mon Sep 17 00:00:00 2001 From: Derek Ross Date: Mon, 9 Nov 2026 10:23:03 -0500 Subject: [PATCH 2/2] omamobile-omarchy 0.1.38: omamobile-update refuses to run as root Omarchy records the migrations it has run in the caller's home (~/.local/state/omarchy/migrations). On 2026-11-09 the release test phone was updated from a root login over SSH: root's record was empty, so Omarchy ran 59 migrations again as root. One swapped quickshell for an older quickshell-git (Omarchy's own later migration swaps it back, but that one counted as done too), others wrote configs into /root and restarted systemd-oomd. Before the OMARCHY_PATH default in the previous commit, the same run stopped early on "unbound variable"; the default alone made the root path reachable. run, start, __inner and run-migration now refuse as root with exit 5 and say why; check, status and channel still answer. The tests stand in for root with OMAMOBILE_UPDATE_TEST_EUID. Co-Authored-By: Claude Opus 5.5 --- packages/omamobile-omarchy/bin/omamobile-update | 16 +++++++++++++++- packages/omamobile-omarchy/test/update.sh | 11 +++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/packages/omamobile-omarchy/bin/omamobile-update b/packages/omamobile-omarchy/bin/omamobile-update index ad8d21903..890660547 100755 --- a/packages/omamobile-omarchy/bin/omamobile-update +++ b/packages/omamobile-omarchy/bin/omamobile-update @@ -37,7 +37,9 @@ directory of stand-ins first on PATH (/usr/lib/omamobile-omarchy/update-bin): omarchy-migrate (boot-related migrations held), sudo (non-interactive from the sheet) -Before anything is downloaded it refuses: below 30% battery unless charging, +It never runs as root (Omarchy records its migrations per user, and root's +record is empty). Before anything is downloaded it refuses: below 30% +battery unless charging, when /etc/pacman.conf doesn't list [omamobile] first and [omarchy] before Arch Linux ARM's repositories, when [omarchy] isn't Omarchy's stable channel, and when the update would install another distribution's kernel, @@ -106,6 +108,8 @@ PATCH_STATUS = os.environ.get("OMAMOBILE_PATCH_STATUS", "/var/lib/omamobile/omar NOTIFY = os.environ.get("OMAMOBILE_NOTIFY", "omarchy-notification-send") OMARCHY_PATH = os.environ.get("OMARCHY_PATH") or "/usr/share/omarchy" MIN_BATTERY = int(os.environ.get("OMAMOBILE_MIN_BATTERY", "30")) +# Tests stand in for root here; nothing else should set it. +EUID = int(os.environ.get("OMAMOBILE_UPDATE_TEST_EUID") or os.geteuid()) MIN_FREE = 10 * 1024 ** 3 # omarchy-update-requires-free-space's limit UNIT = "omamobile-update" RELEASE_NOTES = "https://github.com/basecamp/omarchy/releases/latest" @@ -930,6 +934,16 @@ def main(argv): for b in result["blockers"]: print("Blocked: " + b) return 0 if result["ok"] else 1 + if cmd in ("run", "start", "__inner", "run-migration") and EUID == 0: + # Omarchy keeps the migrations it has run in the caller's home + # (~/.local/state/omarchy/migrations). Root's list is empty, so an + # update as root (a root login over SSH, as on 2026-11-09) ran every + # migration again as root: one swapped quickshell for an older + # quickshell-git, others wrote root's own configs. + print("omamobile-update: not as root. Run \"omarchy update\" as the phone's user, in a terminal on " + "the phone or from Settings: Omarchy records its migrations per user, and root's record is " + "empty, so every migration would run again as root.", file=sys.stderr) + return 5 if cmd == "run": return run(args) if cmd == "__inner": diff --git a/packages/omamobile-omarchy/test/update.sh b/packages/omamobile-omarchy/test/update.sh index 3760c4a0b..58b8e5a2c 100755 --- a/packages/omamobile-omarchy/test/update.sh +++ b/packages/omamobile-omarchy/test/update.sh @@ -417,4 +417,15 @@ ok "no OMARCHY_PATH in the environment: the update starts (exit 0, '$out')" '[[ wait_done ok "no OMARCHY_PATH in the environment: omarchy-update still gets Omarchy's (omarchy-update-dev)" 'grep -c "^omarchy-update OMARCHY_PATH=/usr/share/omarchy$" "$calls" >/dev/null' +# As root (a root login over SSH, 2026-11-09) Omarchy's per-user migration +# record is empty and every migration ran again as root: refused, nothing runs +: >"$calls" +for c in run start run-migration; do + rc=0; out=$(printf '1234\n' | OMAMOBILE_UPDATE_TEST_EUID=0 python3 -I "$U" $c 2>&1) || rc=$? + ok "as root: $c refused (exit 5) and says why" '[[ $rc == 5 && $out == *"not as root"* ]]' +done +ok "as root: nothing reached omarchy-update or sudo" '[[ ! -s $calls ]]' +rc=0; OMAMOBILE_UPDATE_TEST_EUID=0 python3 -I "$U" check --json >/dev/null || rc=$? +ok "as root: check still answers (read-only, exit $rc)" '[[ $rc == 0 || $rc == 1 ]]' + exit $((failures > 0))