Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions tools/aurora-sep/install-aurora-sep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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=""
Expand Down Expand Up @@ -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/tty; } 2>/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 </dev/tty || answer=""
[[ $answer == yes ]] || die "stopped: nothing was installed."
return 0
}

Expand Down Expand Up @@ -6518,6 +6533,10 @@ fingerprint.

curl -fsSL https://github.com/omacom/linux-aurora/releases/latest/download/install-aurora-sep.sh | bash

The install asks for a "yes" to the SEP writes on the terminal. Where you
have no terminal, add --yes (| bash -s -- --yes), and only once the owner
has agreed to them in writing.

State the tag you installed in your report. If you were given a specific
older tag on purpose, say so and say why.

Expand Down Expand Up @@ -10939,9 +10958,19 @@ for a in "$@"; do
--m3-profile=j615-25g83) M3_GPU_EXPLICIT_PROFILE=1; M3_GPU_PROFILE=j613-25g83; M3_GPU_PERSISTENT=1; M3_TRY=1; M3_25_J615=1 ;;
--no-m3-mesa) M3_PRO_MESA=0 ;;
--desktop-fixes) DESKTOP_FIXES=1 ;;
--yes) SEP_WRITES_YES=1 ;;
*) args+=("$a") ;;
esac
done
# --yes anywhere on the line: with --reset-touchid or --m3max-kit it is that
# command's own, and with an install it agrees to the SEP writes.
if ((SEP_WRITES_YES)); then
case ${args[0]:-} in
--reset-touchid | --m3max-kit) args+=(--yes); SEP_WRITES_YES=0 ;;
"") ;;
*) die "--yes goes with an install, --reset-touchid or --m3max-kit; not with ${args[0]}" ;;
esac
fi
set -- "${args[@]}"
if ((ESP_ARCHIVE_HISTORY)) && [[ -n ${1:-} ]]; then
die "--archive-esp-history goes with an install; use --esp-history for a read-only inventory"
Expand Down Expand Up @@ -10984,5 +11013,5 @@ case ${1:-} in
--m3max-kit-stop) m3max_kit_from_release --stop ;;
--m3max-kit-restore) m3max_kit_from_release --restore ;;
--agent-prompt) release_source >&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
49 changes: 47 additions & 2 deletions tools/aurora-sep/tests/test_sep_writes_always_on.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"


Expand Down Expand Up @@ -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)])
Expand Down
Loading