From 8e168b49fa4dddc5f3330c3bf116e472ca51dc50 Mon Sep 17 00:00:00 2001 From: Alyx-ML <256263590+Alyx-ML@users.noreply.github.com> Date: Sun, 22 Nov 2026 01:10:52 +0000 Subject: [PATCH] tools/aurora-sep: ask for a yes before the SEP writes The install warns that the SEP driver creates an identity keybag and writes to the enclave's anti-replay store, and says "press Ctrl-C now". It then goes straight on. Run as documented, from curl into bash, the warning scrolls past and there is no moment to stop. sep_write_notice now asks for "yes" on /dev/tty, since stdin is the script when piped. With no terminal, the install stops before anything is installed, unless --yes is given (bash -s -- --yes). The agent prompt says to pass --yes only once the owner has agreed in writing. A Mac whose owner blocks apple_sep is still asked nothing. This changes how non-interactive installs behave: a script or agent that ran the installer with no terminal and no --yes now stops with nothing installed, and has to add --yes. --yes may come anywhere on the command line. With --reset-touchid or --m3max-kit it is that command's own --yes, before or after the command name; the kit's own --yes also counts as the yes to the SEP writes. With any other command it is refused. The handling of the file an earlier --read-only install wrote is not changed (aurora-silicon/linux#2591). Tests in test_sep_writes_always_on.py: a run with no terminal and no --yes stops with nothing done; --yes with --uninstall is refused in either order; --yes before and after --reset-touchid or --m3max-kit ends the same way and reaches that command; the write notice test passes --yes. Not run here: the tests need bash 4.4 or newer and this Mac has bash 3.2. sep-source.yml runs this file in CI. The answer typed on a real terminal was not tested: the sandbox refuses a pseudo-terminal. Signed-off-by: Alyx-ML <256263590+Alyx-ML@users.noreply.github.com> --- tools/aurora-sep/install-aurora-sep.sh | 33 ++++++++++++- .../tests/test_sep_writes_always_on.py | 49 ++++++++++++++++++- 2 files changed, 78 insertions(+), 4 deletions(-) diff --git a/tools/aurora-sep/install-aurora-sep.sh b/tools/aurora-sep/install-aurora-sep.sh index b27cad73b1aea..6bb1a40c77960 100755 --- a/tools/aurora-sep/install-aurora-sep.sh +++ b/tools/aurora-sep/install-aurora-sep.sh @@ -25,6 +25,8 @@ # ... | bash -s -- --esp-history Read-only EFI history inventory # ... | bash -s -- --desktop-fixes Optional matched stable desktop fixes; unsupported versions are preserved. # ... | bash -s -- --no-m3-mesa M3 Pro: leave out the M3 Pro's Mesa (installed by default) +# ... | bash -s -- --yes agree to the SEP writes on the command line, where +# there is no terminal to ask on (an install only) # # Kernel: iconidentify/aurora-linux custom/sep (dbbfb92908ba), aurora-silicon/linux aurora-wip plus the # Secure Enclave (Touch ID) driver, Thunderbolt (#8), the Apple video @@ -307,6 +309,8 @@ MODPROBE_CONF=/etc/modprobe.d/aurora-sep.conf # What --read-only wrote there: this first line, comments and the options line. READ_ONLY_CONF_HEADER="# aurora-sep --read-only:" READ_ONLY_CONF_OPTIONS="options apple_sep xart_writes=0 provision_keybag=0" +# --yes with an install: the owner agrees to the SEP writes on the command line. +SEP_WRITES_YES=0 DESKTOP_FIXES=0 DESKTOP_FIXES_DATA="" DESKTOP_FIXES_PACKAGES="" @@ -3744,11 +3748,22 @@ sep_policy() { } sep_write_notice() { + local answer="" [[ -n $(sep_block_line) ]] && return 0 warn "on the first boot of a Mac with a Touch ID profile, the SEP driver creates an identity keybag and writes to the enclave's anti-replay store (xART). SEP writes are always on. Use a Mac you can DFU-restore; if you cannot, - press Ctrl-C now." + do not go on." + if ((SEP_WRITES_YES || M3MAX_KIT_YES)); then + say "--yes: going on" + return 0 + fi + # Piped from curl, stdin is the script; ask on the terminal, if there is one. + { : /dev/null || + die "no terminal to confirm the SEP writes on. Nothing was installed. Run the command in a terminal, or add --yes (bash -s -- --yes) to agree on the command line." + printf 'Type yes to go on (anything else stops, with nothing installed): ' >/dev/tty + read -r answer &2; prompt_notice; agent_prompt ;; - *) die "unknown option $1 (--uninstall, --reset-touchid, --agent-prompt, --m3-report, --m3-power-survey, --neo-gpu, --m3-handoff, --m3-gpu, --m3-gpu-check, --m3-gpu-experiment, --m3-gpu-persistent, --m3-profile=j613-25g83, --m3-profile=j615-25g83, --no-m3-mesa, --archive-esp-history, --esp-history, --desktop-fixes, --m3max-kit or --m3max-kit-status, -stop, -restore)" ;; + *) die "unknown option $1 (--uninstall, --reset-touchid, --agent-prompt, --m3-report, --m3-power-survey, --neo-gpu, --m3-handoff, --m3-gpu, --m3-gpu-check, --m3-gpu-experiment, --m3-gpu-persistent, --m3-profile=j613-25g83, --m3-profile=j615-25g83, --no-m3-mesa, --archive-esp-history, --esp-history, --desktop-fixes, --yes, --m3max-kit or --m3max-kit-status, -stop, -restore)" ;; esac diff --git a/tools/aurora-sep/tests/test_sep_writes_always_on.py b/tools/aurora-sep/tests/test_sep_writes_always_on.py index daf3a3f3b0fe7..5101119dd289c 100644 --- a/tools/aurora-sep/tests/test_sep_writes_always_on.py +++ b/tools/aurora-sep/tests/test_sep_writes_always_on.py @@ -6,7 +6,8 @@ ships one: load-driver runs a plain `modprobe apple_sep`, no modprobe.d file the packages install sets either, and the installer refuses --read-only. An install, a re-run and --reset-touchid delete the file an earlier --read-only install wrote, and keep any other file at that path, with -a warning. Nothing here touches the host: the installer's commands are stubbed. +a warning. An install asks for a yes on the terminal, or takes --yes. Nothing here touches the +host: the installer's commands are stubbed. """ import os import re @@ -26,6 +27,7 @@ "options apple_sep xart_writes=0 provision_keybag=0\n") WRITE_PARAMS = re.compile(r"\b(xart_writes|provision_keybag)\b") KEPT = "is not the file an earlier --read-only install wrote, so it stays as it is" +NO_TTY = "no terminal to confirm the SEP writes on. Nothing was installed." IGNORED = "Kernels from aurora-silicon/linux#2591 on ignore xart_writes and provision_keybag" @@ -250,17 +252,60 @@ def test_uninstall_removes_only_the_read_only_file(self): def test_the_write_notice_offers_no_read_only_install(self): self.conf.write_text(OLD_READ_ONLY_CONF) - proc = self.sh("sep_write_notice") + proc = self.sh("SEP_WRITES_YES=1\nsep_write_notice") self.assertEqual(proc.returncode, 0, proc.stderr) err = flat(proc.stderr) self.assertIn("the SEP driver creates an identity keybag and writes to the enclave's anti-replay " "store (xART). SEP writes are always on. Use a Mac you can DFU-restore", err) self.assertNotIn("read-only", err) + self.assertNotIn("Ctrl-C", err) + self.assertIn("--yes: going on", proc.stdout) # An owner's block: the driver is not loaded, so there is nothing to warn about. proc = self.sh("sep_block_line() { echo '/etc/modprobe.d/mine.conf:1:blacklist apple_sep'; }\n" "sep_write_notice") self.assertEqual((proc.returncode, proc.stderr), (0, "")) + def test_the_write_notice_needs_a_yes(self): + # No terminal (a session of its own) and no --yes: the install stops before anything changes. + proc = self.sh("sep_write_notice\necho AFTER") + self.assertEqual(proc.returncode, 1) + self.assertIn(NO_TTY, flat(proc.stderr)) + self.assertIn("add --yes (bash -s -- --yes)", flat(proc.stderr)) + self.assertNotIn("AFTER", proc.stdout) + self.assertEqual(self.log(), "") + # The kit's own --yes is a yes on the command line as well. + proc = self.sh("M3MAX_KIT_YES=1\nsep_write_notice\necho AFTER") + self.assertEqual(proc.returncode, 0, proc.stderr) + self.assertIn("AFTER", proc.stdout) + + def test_yes_is_for_an_install(self): + for args, err in ((["--yes", "--uninstall"], "--yes goes with an install"), + (["--uninstall", "--yes"], "--yes goes with an install")): + with self.subTest(args=args): + proc = subprocess.run(["bash", str(INSTALLER), *args], capture_output=True, text=True, + env=self.env, start_new_session=True, stdin=subprocess.DEVNULL) + self.assertEqual(proc.returncode, 1, proc.stderr) + self.assertIn(err, proc.stderr) + self.assertEqual(self.log(), "") + + def test_yes_works_before_or_after_the_command(self): + # --yes is that command's own, wherever it is on the line: both orders end the same way, + # and neither is refused as an install's --yes. + for cmd in ("--reset-touchid", "--m3max-kit"): + with self.subTest(cmd=cmd): + runs = [subprocess.run(["bash", str(INSTALLER), *args], capture_output=True, text=True, + env=self.env, start_new_session=True, stdin=subprocess.DEVNULL) + for args in (["--yes", cmd], [cmd, "--yes"])] + for proc in runs: + self.assertNotIn("--yes goes with", proc.stderr) + self.assertEqual([(p.returncode, p.stdout, p.stderr) for p in runs][0], + [(p.returncode, p.stdout, p.stderr) for p in runs][1]) + # The command still sees it: an option it does not know is reported as its own. + proc = subprocess.run(["bash", str(INSTALLER), "--yes", "--reset-touchid", "--nope"], + capture_output=True, text=True, env=self.env, start_new_session=True, + stdin=subprocess.DEVNULL) + self.assertIn("unknown option --nope for --reset-touchid", proc.stderr) + def test_the_agent_prompt_offers_no_read_only_install(self): start = SRC.index("SAFETY, NON-NEGOTIABLE") safety = flat(SRC[start:SRC.index("\nPROMPT\n", start)])