From 7cf69ae7013562aad163dcfb1b9cc08fbdb81d03 Mon Sep 17 00:00:00 2001 From: fabolous005 Date: Fri, 4 Dec 2026 08:35:52 +0100 Subject: [PATCH] Review: enroll keeps foreign db keys, configurable paths, on-demand eac-run, launcher ebuild, db dedupe tool --- AGENTS.md | 110 +++++++++++------ README.md | 42 ++++--- docs/progress.md | 22 +++- docs/troubleshooting.md | 31 ++++- .../epic-games-launcher-bin/Manifest | 1 + .../epic-games-launcher-bin-0.127.0.ebuild | 54 ++++++++ .../files/EpicGamesLauncher | 7 ++ ...ebuild => eac-openrc-compat-0.1-r2.ebuild} | 18 ++- .../eac-openrc-compat/files/README.md | 27 +++- .../sys-apps/eac-openrc-compat/files/eac-run | 34 +++++ .../files/org.gentoo.eac-openrc-compat.policy | 16 +++ .../files/socket-activate-ctl | 22 ++++ .../eac-openrc-compat/files/systemd-run-agent | 3 +- ...cachyos-eac-kernel-bin-7.3.5_p2-r3.ebuild} | 33 +++-- .../cachyos-eac-kernel-bin/files/README.md | 60 ++++++--- .../cachyos-eac-kernel-bin/files/eac-boot | 116 ++++++++++++++---- tools/README.md | 1 + tools/efi-sig-list.py | 34 ++++- 18 files changed, 509 insertions(+), 122 deletions(-) create mode 100644 overlay/games-util/epic-games-launcher-bin/Manifest create mode 100644 overlay/games-util/epic-games-launcher-bin/epic-games-launcher-bin-0.127.0.ebuild create mode 100755 overlay/games-util/epic-games-launcher-bin/files/EpicGamesLauncher rename overlay/sys-apps/eac-openrc-compat/{eac-openrc-compat-0.1-r1.ebuild => eac-openrc-compat-0.1-r2.ebuild} (66%) create mode 100755 overlay/sys-apps/eac-openrc-compat/files/eac-run create mode 100644 overlay/sys-apps/eac-openrc-compat/files/org.gentoo.eac-openrc-compat.policy create mode 100755 overlay/sys-apps/eac-openrc-compat/files/socket-activate-ctl rename overlay/sys-kernel/cachyos-eac-kernel-bin/{cachyos-eac-kernel-bin-7.3.5_p2-r2.ebuild => cachyos-eac-kernel-bin-7.3.5_p2-r3.ebuild} (62%) mode change 100755 => 100644 diff --git a/AGENTS.md b/AGENTS.md index a901300..0e51bba 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -49,10 +49,11 @@ doas -n sbctl status # Installed, Setup Mode di rc-service elogind status; pgrep -x polkitd df -h /efi # >= 200 MB free efibootmgr # note BootOrder and Boot0201 -emerge -p sys-kernel/cachyos-eac-kernel-bin sys-apps/eac-openrc-compat sys-auth/hyprpolkitagent +emerge -p sys-kernel/cachyos-eac-kernel-bin sys-apps/eac-openrc-compat \ + games-util/epic-games-launcher-bin sys-auth/hyprpolkitagent ``` -`emerge -p` must resolve both packages from `febuild`. If `febuild` lacks them, +`emerge -p` must resolve the three packages from `febuild`. If `febuild` lacks them, add `overlay/` from this repository as a repository in `/etc/portage/repos.conf/eac-gentoo-openrc.conf` (`location` = absolute path of `overlay/`). Missing keywords: `~amd64` in `package.accept_keywords`. @@ -62,9 +63,14 @@ add `overlay/` from this repository as a repository in ```sh doas -n install -m644 host/portage/package.use/intel-microcode /etc/portage/package.use/ doas -n emerge sys-firmware/intel-microcode sys-kernel/cachyos-eac-kernel-bin \ - sys-apps/eac-openrc-compat sys-auth/hyprpolkitagent + sys-apps/eac-openrc-compat games-util/epic-games-launcher-bin sys-auth/hyprpolkitagent ``` +The launcher package replaces a downloaded AppImage; delete +`~/Downloads/EpicGamesLauncher-x86_64.AppImage` once the package works. Both +use the same data directory (`~/.local/share/com.epicgames.eglv2`), so logins +and installed games stay. + On lucifer the USE flag already sits in `/etc/portage/package.use/sys-fimware`; skip the copy there. `intel-microcode` with `dist-kernel` reinstalls the normal kernel, which is harmless. @@ -73,12 +79,14 @@ Check: ```sh ls /lib/modules/*-cachyos-eac/vmlinuz /usr/lib/cachyos-eac/systemd-bootx64.efi.signed -eac-boot esp # /efi -qfile /usr/bin/systemctl /usr/bin/systemd-run /usr/lib64/libsystemd.so.0 +eac-boot esp; eac-boot kernel-dir; eac-boot loader # /efi, /efi//linux-cachyos-eac, /efi/EFI/cachyos-eac/... +qfile /usr/bin/systemctl /usr/bin/systemd-run /usr/bin/eac-run /usr/lib64/libsystemd.so.0 +ldd /opt/epic-games-launcher/bin/EpicGamesLauncher | grep 'not found' # empty ldd /usr/libexec/hyprpolkitagent | grep 'not found' # empty ``` -Libraries reported "not found" for hyprpolkitagent mean a live (`9999`) Hyprland +lucifer uses every `eac-boot` default, so it has no `/etc/eac-boot.conf`; do +not create one. Libraries reported "not found" for hyprpolkitagent mean a live (`9999`) Hyprland library changed its SONAME: rebuild the packages that link the old one (`emerge -1`), see troubleshooting. @@ -98,16 +106,23 @@ doas -n openssl x509 -in /var/lib/sbctl/keys/KEK/KEK.pem -outform DER | sha256su doas -n python3 tools/efi-sig-list.py $V/KEK-8be4df61-93ca-11d2-aa0d-00e098032b8c ``` -The KEK fingerprint must appear in the script's list. Then: +The KEK fingerprint must appear in the script's list (`eac-boot enroll` +checks this as well and refuses otherwise). List db before and after: ```sh +doas -n python3 tools/efi-sig-list.py $V/db-d719b2cb-3d3a-4596-a3bc-dad00e67656f doas -n eac-boot enroll doas -n python3 tools/efi-sig-list.py $V/db-d719b2cb-3d3a-4596-a3bc-dad00e67656f ``` -Expected: `7 entries, 7 unique`: Database Key (sbctl), Windows Production PCA -2011, Windows UEFI CA 2023, Microsoft Corporation UEFI CA 2011, Microsoft UEFI -CA 2023, Microsoft Option ROM UEFI CA 2023, CachyOS EAC CA. +`enroll` only appends the CachyOS EAC CA: every entry from the first listing +must still be there, plus the CA. When the CA is already enrolled it prints +"nothing to do" and writes nothing. On lucifer the CA is enrolled; expected +db: `7 entries, 7 unique`: Database Key (sbctl), Windows Production PCA 2011, +Windows UEFI CA 2023, Microsoft Corporation UEFI CA 2011, Microsoft UEFI CA +2023, Microsoft Option ROM UEFI CA 2023, CachyOS EAC CA. Duplicates in the +first listing are a separate problem: report them to the user, do not fix +them here (see troubleshooting). `sbctl list-enrolled-keys` prints issuers, so two Microsoft names appear twice there; that is correct. @@ -157,24 +172,41 @@ ls -l /dev/dri/igpu In `~/.config/hypr/env.lua`: `hl.env("AQ_DRM_DEVICES", "/dev/dri/igpu")`. -In `~/.config/hypr/autocmds.lua`, inside `hl.on("hyprland.start", function () ... end)`: +The polkit agent is the only addition to the session autostart. In +`~/.config/hypr/autocmds.lua`, inside `hl.on("hyprland.start", function () ... end)`: ```lua hl.exec_cmd("/usr/libexec/hyprpolkitagent") -hl.exec_cmd("/usr/libexec/eac-openrc-compat/systemd-run-agent") ``` -Start both in the running session without a relogin: +Do not autostart `systemd-run-agent` and do not add +`socket-activate.easyanticheat_eos` to a runlevel: `eac-run` starts both when +the launcher starts and stops them when it exits. Remove such lines if an older +setup left them (`grep -n systemd-run-agent ~/.config/hypr/*.lua`, +`rc-update show | grep socket-activate`). + +Start the polkit agent in the running session without a relogin, then test +`eac-run` from the session (Hyprland's exec, not ssh, so polkit sees the active +session): ```sh hyprctl -i 0 dispatch 'hl.dsp.exec_cmd("/usr/libexec/hyprpolkitagent")' -hyprctl -i 0 dispatch 'hl.dsp.exec_cmd("/usr/libexec/eac-openrc-compat/systemd-run-agent")' -ls -l /run/user/1000/systemd-run-agent.sock -systemd-run --user --wait --pipe cat /proc/self/sessionid # must equal the next line +hyprctl -i 0 dispatch 'hl.dsp.exec_cmd("eac-run sleep 20")' +sleep 5 +rc-service socket-activate.easyanticheat_eos status # started (once EAC is installed, step 8) +systemd-run --user --wait --pipe cat /proc/self/sessionid # must equal the next line cat /proc/$(pgrep -x Hyprland)/sessionid +sleep 20 +rc-service socket-activate.easyanticheat_eos status # stopped +pgrep -f systemd-run-agent # nothing ``` -Polkit check: +No password dialog may appear for `eac-run`: the polkit action +`org.gentoo.eac-openrc-compat.socket-activate` is allowed for the active +session (`pkcheck --action-id org.gentoo.eac-openrc-compat.socket-activate +--process $(pgrep -x Hyprland)` exits 0). + +Polkit agent check, during the `eac-run` window: `systemd-run --user --wait --pipe pkexec --disable-internal-agent /usr/bin/true`. **(user)** A password dialog must appear; cancel it. "No authentication agent found" means hyprpolkitagent is not running. @@ -198,7 +230,10 @@ The next normal reboot returns to Gentoo. ## 8. First game launch (user) -1. **(user)** Start the Epic Games Launcher (AppImage) and Fortnite. +1. **(user)** Start the Epic Games Launcher from the application menu or as + `EpicGamesLauncher` (the package's wrapper runs it through `eac-run`), then + Fortnite. A launcher started any other way (an AppImage, a desktop file of + its own) has to be started as `eac-run `. 2. **(user)** Answer "Easy Anti-Cheat service installation required. Install now?" with Yes and enter the password in the polkit dialog. @@ -218,22 +253,16 @@ Operation succeeded. and `/var/lib/easyanticheat_eos/authorizedusers/1000` exists. -## 9. Start the service at boot +## 9. Check a protected game -EAC only runs `systemctl start`; on systemd its `sockets.target.d` drop-in -starts the socket at boot, which OpenRC does not read. Add it to the runlevel: - -```sh -doas -n rc-update add socket-activate.easyanticheat_eos default -rc-service socket-activate.easyanticheat_eos status # started -``` - -## 10. Check a protected game - -After the next launch, `/var/log/socket-activate.easyanticheat_eos.log` shows +**(user)** Close the launcher, start it again the same way, join a match. +`eac-run` starts the listener this time (the setup did it on the first launch). +After the launch, `/var/log/socket-activate.easyanticheat_eos.log` shows `Running service, version ...`, and `.../AppData/Local/FortniteGame/Saved/Logs/FortniteGame.log` in the Proton prefix shows `[AntiCheatClient] [BeginSession-...]` when joining a match. +After the launcher exits, `rc-service socket-activate.easyanticheat_eos status` +is `stopped` again. Nothing EAC-related starts at boot. ## Updates @@ -248,15 +277,19 @@ prefix shows `[AntiCheatClient] [BeginSession-...]` when joining a match. ```sh pkexec /usr/local/bin/easyanticheat_eos uninstall standalone -doas -n rc-update del socket-activate.easyanticheat_eos default doas -n efibootmgr -b 0201 -B -doas -n emerge -C sys-apps/eac-openrc-compat sys-kernel/cachyos-eac-kernel-bin +doas -n emerge -C sys-apps/eac-openrc-compat sys-kernel/cachyos-eac-kernel-bin games-util/epic-games-launcher-bin ``` Then remove `/efi/EFI/cachyos-eac`, `/efi//linux-cachyos-eac` and -`/efi/loader/entries/cachyos-eac.conf`. The unmerge also removed the CA from -`/var/lib/sbctl/keys/custom/db/`; to drop it from the firmware db too, run -`doas -n sbctl enroll-keys --partial db --microsoft --ignore-immutable`. +`/efi/loader/entries/cachyos-eac.conf`. + +The CachyOS EAC CA can stay in db: it only lets CachyOS-signed binaries boot. +Never remove it with `sbctl enroll-keys` (that rewrites db and drops every key +sbctl does not manage). To remove it, ask the user, then write back the db +backup from step 2, which predates the CA: the "Duplicate keys in db" recipe in +troubleshooting, with the backup file as input instead of `efi-readvar`'s +output. Keys enrolled after that backup are lost. ## systemd systems @@ -264,9 +297,10 @@ The compatibility layer exists only because this machine runs OpenRC. On a systemd system it may work without it (untested): - **Gentoo with systemd:** install only `cachyos-eac-kernel-bin` - (`eac-openrc-compat` blocks `sys-apps/systemd`). Follow steps 0-5, 7 and 8, - with any polkit agent in the desktop session. Skip the `systemd-run-agent` - lines in step 6 and all of step 9. + and `epic-games-launcher-bin` (`eac-openrc-compat` blocks `sys-apps/systemd`). + Follow steps 0-5 and 7-9, with any polkit agent in the desktop session; skip + the `eac-run` parts of step 6. EAC's own socket unit then starts at boot and + starts the service on demand. - **Other distributions:** use the distribution's signed kernel if Epic trusts its key, or CachyOS's own packages and instructions (wiki.cachyos.org/configuration/easy_anti_cheat). `eac-boot` and the ebuild diff --git a/README.md b/README.md index f682866..86cd6e2 100644 --- a/README.md +++ b/README.md @@ -9,10 +9,10 @@ Easy Anti-Cheat Linux v2 needs two things Gentoo with OpenRC does not have: installs a socket-activated systemd service with `systemd-run`, `pkexec` and `systemctl`. A small compatibility layer maps those calls to OpenRC. -This repository holds the two ebuilds, the host configuration, the debugging +This repository holds the ebuilds (kernel, compatibility layer, launcher), the host configuration, the debugging tools used to work out the service install, and the documentation. -**Status (2026-12-03): working** on the author's desktop (Gentoo, OpenRC, +**Status (2026-12-04): working** on the author's desktop (Gentoo, OpenRC, elogind, Hyprland, Intel Raptor Lake + AMD eGPU). EAC accepted the boot, the service installed itself, and Fortnite ran creative islands with active anti-cheat sessions. Battle Royale matchmaking is untested. @@ -20,18 +20,20 @@ anti-cheat sessions. Battle Royale matchmaking is untested. ## How the pieces fit ``` -firmware: Secure Boot on, db = own sbctl key + Microsoft certs + CachyOS EAC CA +firmware: Secure Boot on, db = whatever was there + CachyOS EAC CA -> firmware entry "CachyOS EAC": CachyOS-signed systemd-boot (measures into the TPM) -> CachyOS-signed linux-cachyos-eac + host-built dracut initramfs cmdline + lockdown=integrity lsm=...,bpf iommu.passthrough=0 intel_iommu=on module.sig_enforce=1 sysctl.kernel.kexec_load_disabled=1 - -> Hyprland session: hyprpolkitagent + systemd-run-agent (autostarted) - -> Epic Games Launcher -> Proton -> Fortnite + EAC bootstrapper + -> Hyprland session: hyprpolkitagent (autostarted) + -> EpicGamesLauncher = eac-run + launcher; while it runs: + systemd-run-agent (user) + socket-activate.easyanticheat_eos (root, via pkexec + polkit rule) + -> Proton -> Fortnite + EAC bootstrapper first launch: EAC setup -> systemd-run --user -> pkexec -> install -> systemctl start every launch: game connects to @easyanticheat_eos -> service starts, stops after the game ``` -The normal Gentoo boot stays the default. The EAC entry is last in BootOrder +Nothing EAC-related runs at boot or between game sessions. The normal Gentoo boot stays the default. The EAC entry is last in BootOrder and is started once with `eac-boot boot` or from the firmware's boot menu. ## Contents @@ -41,22 +43,25 @@ and is started once with `eac-boot boot` or from the firmware's boot menu. | [`AGENTS.md`](AGENTS.md) | installation runbook for agents, for the author's machine | | [`docs/troubleshooting.md`](docs/troubleshooting.md) | error messages and their causes, log locations, debugging tools | | [`docs/progress.md`](docs/progress.md) | how it got here, decisions, open items | -| `overlay/` | Portage overlay (`repo_name` `eac-gentoo-openrc`) with both packages; snapshot of the author's `febuild` overlay | +| `overlay/` | Portage overlay (`repo_name` `eac-gentoo-openrc`) with the three packages; snapshot of the author's `febuild` overlay | | `overlay/sys-kernel/cachyos-eac-kernel-bin/` | CachyOS's EAC kernel, signed systemd-boot, EAC CA and `eac-status`, repackaged byte for byte, plus the `eac-boot` tool. [README](overlay/sys-kernel/cachyos-eac-kernel-bin/files/README.md) | -| `overlay/sys-apps/eac-openrc-compat/` | the systemd compatibility layer for EAC's service on OpenRC. [README](overlay/sys-apps/eac-openrc-compat/files/README.md) | +| `overlay/sys-apps/eac-openrc-compat/` | the systemd compatibility layer for EAC's service on OpenRC, and `eac-run`. [README](overlay/sys-apps/eac-openrc-compat/files/README.md) | +| `overlay/games-util/epic-games-launcher-bin/` | Epic's official Linux launcher from its `.deb`, self-update off, started through `eac-run` | | `host/udev/61-dri-igpu.rules` | stable `/dev/dri/igpu` name for the iGPU at PCI `0000:00:02.0`; goes to `/etc/udev/rules.d/` | | `host/portage/package.use/intel-microcode` | `initramfs` USE flag, so dracut puts early microcode into the EAC initramfs; goes to `/etc/portage/package.use/` | | `tools/` | debugging tools, not installed by anything. [README](tools/README.md) | -## The two packages +## The packages **`sys-kernel/cachyos-eac-kernel-bin`** installs, unchanged, from `mirror.cachyos.org/repo/x86_64/cachyos/`: `linux-cachyos-eac` (kernel and -signed modules to `/lib/modules/-cachyos-eac/`), +signed modules to kmod's module directory, `/lib/modules/-cachyos-eac/`), `systemd-boot-cachyos-signed`, `cachyos-eac-signing-key` and `eac-status` from `cachyos-settings`. Nothing is stripped or re-signed: a second signature fails -EAC. `eac-boot` enrolls the db, puts kernel, dracut initramfs and systemd-boot on -the ESP, creates the firmware entry and boots it once. +EAC. `eac-boot` appends the CachyOS CA to db (keeping every other key), puts +kernel, dracut initramfs and systemd-boot on the ESP, creates the firmware entry +and boots it once. ESP, directories, entry names, command line and keys are +set in `/etc/eac-boot.conf`. **`sys-apps/eac-openrc-compat`** provides exactly what EAC's setup (`EasyAntiCheat_EOS_Setup` 0.1.7) calls: @@ -67,8 +72,14 @@ the ESP, creates the firmware entry and boots it once. | `/usr/bin/systemd-run` + `/usr/libexec/eac-openrc-compat/systemd-run-agent` | `systemd-run --user`: the agent runs commands in the graphical session, outside Proton's no_new_privs sandbox, so `pkexec` works | | `/usr/bin/systemctl` | `systemctl` for `NAME.socket`/`NAME.service` when the OpenRC service `socket-activate.NAME` exists; other units fail as on a non-systemd host | | `/usr/libexec/eac-openrc-compat/socket-activate`, `/etc/init.d/socket-activate`, `socket-activate.easyanticheat_eos` | systemd socket activation of `@easyanticheat_eos` | +| `/usr/bin/eac-run`, `socket-activate-ctl` + polkit action | the always-on systemd socket: starts agent and listener for the launcher's lifetime only | -It does not pretend that systemd booted the machine: `/run/systemd/system` +**`games-util/epic-games-launcher-bin`** installs Epic's official `.deb` +(versioned download, system webkit-gtk 4.1) to `/opt/epic-games-launcher`, with +a wrapper `EpicGamesLauncher` that turns self-update off and runs it through +`eac-run` when that is installed. + +The compatibility layer does not pretend that systemd booted the machine: `/run/systemd/system` stays absent and `sd_booted()` returns 0. ## systemd distributions @@ -76,7 +87,8 @@ stays absent and `sd_booted()` returns 0. On a systemd system the compatibility layer is not needed, and it blocks `sys-apps/systemd`. EAC's setup uses the real `systemd-run`, `systemctl` and socket activation there. A Gentoo systemd install should work with only -`cachyos-eac-kernel-bin` and a polkit agent in the desktop session (untested). +`cachyos-eac-kernel-bin`, the launcher package and a polkit agent in the +desktop session (untested). Other distributions use their own signed kernel or CachyOS's packages directly; see [AGENTS.md](AGENTS.md#systemd-systems). @@ -84,6 +96,8 @@ see [AGENTS.md](AGENTS.md#systemd-systems). - Never re-sign, strip or `sbctl sign` the CachyOS kernel or systemd-boot. - Never use `sbctl enroll-keys --append`: it enrolls every key a second time. + Never rewrite db with `sbctl enroll-keys` either: it drops keys sbctl does not + manage. `eac-boot enroll` only appends. - In the firmware, only toggle Secure Boot. "Reset to Setup Mode", "Restore Factory Keys" and "Clear All Keys" erase the custom db. - A BitLocker Windows install asks for its recovery key after db or Secure Boot diff --git a/docs/progress.md b/docs/progress.md index 114fd50..d3a32b5 100644 --- a/docs/progress.md +++ b/docs/progress.md @@ -24,6 +24,13 @@ hyprpolkitagent crashed on a stale live-ebuild SONAME (hyprtoolkit). 4. 15:44: install succeeded with `sys-apps/eac-openrc-compat`; Fortnite reached the lobby and ran creative islands with EAC sessions active. +- **12-04:** review. `eac-boot enroll` appends only the CA (keys sbctl does not + manage survive); every path in `eac-boot` and `eac-status` configurable + through `/etc/eac-boot.conf`, modules where kmod looks. `eac-run` starts the + user agent and the root listener per launcher session (polkit rule for the + active session) instead of autostart and runlevel. New package + `games-util/epic-games-launcher-bin` from Epic's `.deb`, wrapped with + `eac-run`. ## Decisions @@ -46,14 +53,23 @@ outside that process tree and in the same elogind session as the polkit agent. An `openrc --user` service would run in a background session where polkit finds no agent. +- **On demand, not at boot.** On systemd the socket listens from boot and + costs nothing until a game connects. Here `eac-run` brackets the launcher: + both pieces exist only while it runs. The polkit action lets the active + local session start and stop only `socket-activate.*` services that exist, + through one root helper. +- **Launcher from the `.deb`, not the AppImage.** Same binary; the `.deb` links + the system's webkit-gtk 4.1 instead of bundling 120 MB of libraries, has a + versioned URL that can go in a Manifest, and installs a desktop file and the + `com.epicgames.launcher://` handler. Self-update is off; updates come as + ebuild bumps. Same approach as AUR's `epic-games-launcher-bin`. - **Captured, not redistributed.** The EAC setup binary is Epic's; this repository only documents what it calls. ## Open items -- `socket-activate.easyanticheat_eos` must be added to the default runlevel by - hand after the first install (AGENTS.md step 9). The `systemctl` shim could - map EAC's `sockets.target.d` drop-in to `rc-update add` on `daemon-reload`. +- `eac-run` covers launchers started through it only. A game started without + the launcher (Heroic, Lutris) needs `eac-run` around that program too. - Battle Royale matchmaking untested. - The layer matches EAC setup 0.1.7; a later setup may call something new. - CachyOS is not on Epic's published key list from October; Epic accepted the diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 606972e..f62986e 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -23,7 +23,7 @@ installation failed with N'`. The setup's `service.log` says why: | --- | --- | --- | --- | | 127 | no new lines | the setup cannot load `libsystemd.so.0` | `sys-apps/eac-openrc-compat` (links it to libelogind) | | 13 | `execvp systemd-run failed with No such file or directory` | no `systemd-run` | `sys-apps/eac-openrc-compat` | -| 13 | `systemd-run exited with code 1` | `systemd-run-agent` not running in the session | start it (AGENTS.md step 6) | +| 13 | `systemd-run exited with code 1` | `systemd-run-agent` not running in the session | start the launcher through `eac-run` (AGENTS.md step 6) | | 2 | `Running install with pkexec.` then `pkexec auth failed.` in the same second | no polkit agent registered for the session | run hyprpolkitagent; `pkttyagent` registers only for its own parent shell and cannot serve the setup | | 2 | `pkexec request dismissed.` | the dialog was cancelled | launch again | @@ -35,7 +35,9 @@ Polkit check from the session without a terminal: | Symptom | Cause | Fix | | --- | --- | --- | -| Works once, fails after a reboot | `socket-activate.easyanticheat_eos` not in the runlevel | `rc-update add socket-activate.easyanticheat_eos default` | +| Game reports EAC not running / cannot connect | launcher not started through `eac-run`, so the listener is stopped | start the launcher as `EpicGamesLauncher` or `eac-run ` | +| `eac-run: could not start socket-activate.easyanticheat_eos`, or a password dialog on every launch | not started from the active graphical session (ssh, another seat) | start it from the desktop session; check with `pkcheck --action-id org.gentoo.eac-openrc-compat.socket-activate --process $$` | +| Listener still running after the launcher closed | the EAC service still serves a game, or the listener is in a runlevel | expected; it stops with the game, or `rc-update del socket-activate.easyanticheat_eos` | | Service log prints the setup's usage text and exits 1 | `EAC_MODE_SERVICE=1` missing | check `socket_env` in `/etc/conf.d/socket-activate.easyanticheat_eos` | | `systemd did not pass exactly the socket '@easyanticheat_eos'` | started without socket activation | start it only through the OpenRC service | | `User 1000 not found in /var/lib/easyanticheat_eos/authorizedusers` | user not authorized | `pkexec /usr/local/bin/easyanticheat_eos authorizeuser --uid=1000` | @@ -53,6 +55,31 @@ Polkit check from the session without a terminal: | `module verification failed` | an out-of-tree module (bcachefs, kvmfr) | not available in the EAC boot | | hyprpolkitagent: `libaquamarine.so.N`, `libhyprtoolkit.so.N: cannot open shared object file` | a live Hyprland library changed its SONAME | find the stale package with `readelf -d` over `ldd`'s libraries, `emerge -1` it and its users | | Entry missing from the F12 menu | entry not in BootOrder | `eac-boot setup 0201` | +| EAC entry boots the other systemd-boot's default | the ESP has a `loader.conf` of another systemd-boot, which `eac-boot update` keeps | boot through `eac-boot boot` (sets `LoaderEntryOneShot`) | +| `eac-boot enroll`: `... is not enrolled in KEK` | the KEK found is not the firmware's | set `KEK_KEY`/`KEK_CERT` in `/etc/eac-boot.conf` to the enrolled KEK's key and certificate | +| `eac-status` cannot find the kernel or loader | `/etc/eac-boot.conf` changed after `eac-boot setup` | `eac-boot setup` again; remove the old files from the ESP | + +## Duplicate keys in db + +`sbctl enroll-keys --append` re-adds keys that are already there, and the +firmware keeps both copies. `tools/efi-sig-list.py` shows `N entries, M unique` +when that happened. Writing back the same list with every key once keeps all +keys, including any that sbctl does not manage. Needs the KEK's key; check that +it is the enrolled one first (AGENTS.md step 2). + +```sh +cd "$(mktemp -d)" +doas efi-readvar -v db -o db.esl +python3 -I /path/to/tools/efi-sig-list.py --unique db-unique.esl db.esl # read the list it prints +doas sign-efi-sig-list -g "$(doas cat /var/lib/sbctl/GUID)" \ + -c /var/lib/sbctl/keys/KEK/KEK.pem -k /var/lib/sbctl/keys/KEK/KEK.key db db-unique.esl db.auth +doas chattr -i /sys/firmware/efi/efivars/db-d719b2cb-3d3a-4596-a3bc-dad00e67656f +doas efi-updatevar -f db.auth db +python3 -I /path/to/tools/efi-sig-list.py /sys/firmware/efi/efivars/db-d719b2cb-3d3a-4596-a3bc-dad00e67656f +``` + +Back up db first (AGENTS.md step 2). Without `-a`, `sign-efi-sig-list` +replaces db, so the input must be the complete list. Lockdown also blocks MSR writes (undervolting), `/dev/mem` and hibernation in the EAC boot. diff --git a/overlay/games-util/epic-games-launcher-bin/Manifest b/overlay/games-util/epic-games-launcher-bin/Manifest new file mode 100644 index 0000000..9e4711c --- /dev/null +++ b/overlay/games-util/epic-games-launcher-bin/Manifest @@ -0,0 +1 @@ +DIST epic-games-launcher-bin-0.127.0.deb 71836680 BLAKE2B 59670ac2f267f155e54988a4d6d5bf013a163b024b97fd26d652fa22a5c5e078cfe2b704bd0e1a4d03d585e34b4c51f3510543b557756e40fe68189267061e49 SHA512 ebaeb89eb677ae92c8e3e559564d0f565f8a3588d6c3eda1bbbe363a9eaed8b776681f59aef62c70df5766f590c2787ca9b8503e7da8e6d8f45aab572a435a4a diff --git a/overlay/games-util/epic-games-launcher-bin/epic-games-launcher-bin-0.127.0.ebuild b/overlay/games-util/epic-games-launcher-bin/epic-games-launcher-bin-0.127.0.ebuild new file mode 100644 index 0000000..1ebdc60 --- /dev/null +++ b/overlay/games-util/epic-games-launcher-bin/epic-games-launcher-bin-0.127.0.ebuild @@ -0,0 +1,54 @@ +# Copyright 2026 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit desktop unpacker xdg + +# Epic's build id; the version alone does not name a download. +EGL_BUILD=gc5cf008 + +DESCRIPTION="Epic Games Launcher (official Linux preview)" +HOMEPAGE="https://store.epicgames.com/" +SRC_URI="https://content-download-egs.distro.on.epicgames.com/Builds/EGLv2/${PV}%2B${EGL_BUILD}/Linux/EpicGamesLauncher-x86_64.deb -> ${P}.deb" +S=${WORKDIR} + +LICENSE="all-rights-reserved" +SLOT="0" +KEYWORDS="-* ~amd64" +RESTRICT="bindist mirror strip" +QA_PREBUILT="*" + +RDEPEND=" + dev-libs/glib:2 + dev-libs/libayatana-appindicator + net-libs/libsoup:3.0 + net-libs/webkit-gtk:4.1 + sys-apps/dbus + x11-libs/cairo + x11-libs/gdk-pixbuf:2 + x11-libs/gtk+:3 + x11-libs/libX11 + x11-misc/xdg-utils +" + +src_install() { + local dir=/opt/epic-games-launcher + + # The binary's RUNPATH is $ORIGIN/../lib/epic-games-launcher: keep the .deb layout. + exeinto ${dir}/bin + doexe usr/bin/EpicGamesLauncher + exeinto ${dir}/lib/epic-games-launcher + doexe usr/lib/epic-games-launcher/libEOSSDK-Linux-Shipping.so + insinto ${dir}/lib/epic-games-launcher/resources + doins usr/lib/epic-games-launcher/resources/ThirdPartyNotices.txt + + dobin "${FILESDIR}"/EpicGamesLauncher + dosym EpicGamesLauncher /usr/bin/epic-games-launcher + + domenu usr/share/applications/epic-games-launcher.desktop + local size + for size in 32 128 256; do + doicon -s ${size} usr/share/icons/hicolor/${size}x${size}/apps/EpicGamesLauncher.png + done +} diff --git a/overlay/games-util/epic-games-launcher-bin/files/EpicGamesLauncher b/overlay/games-util/epic-games-launcher-bin/files/EpicGamesLauncher new file mode 100755 index 0000000..f532974 --- /dev/null +++ b/overlay/games-util/epic-games-launcher-bin/files/EpicGamesLauncher @@ -0,0 +1,7 @@ +#!/bin/sh +# The package manager installs updates, so the launcher's self-update is off. +export EGL_DISABLE_SELF_UPDATE="${EGL_DISABLE_SELF_UPDATE:-1}" +egl=/opt/epic-games-launcher/bin/EpicGamesLauncher +# On OpenRC, eac-run (sys-apps/eac-openrc-compat) provides what Easy Anti-Cheat needs while the launcher runs. +command -v eac-run >/dev/null 2>&1 && exec eac-run "$egl" "$@" +exec "$egl" "$@" diff --git a/overlay/sys-apps/eac-openrc-compat/eac-openrc-compat-0.1-r1.ebuild b/overlay/sys-apps/eac-openrc-compat/eac-openrc-compat-0.1-r2.ebuild similarity index 66% rename from overlay/sys-apps/eac-openrc-compat/eac-openrc-compat-0.1-r1.ebuild rename to overlay/sys-apps/eac-openrc-compat/eac-openrc-compat-0.1-r2.ebuild index 26a9e5e..e7edbeb 100644 --- a/overlay/sys-apps/eac-openrc-compat/eac-openrc-compat-0.1-r1.ebuild +++ b/overlay/sys-apps/eac-openrc-compat/eac-openrc-compat-0.1-r2.ebuild @@ -23,13 +23,19 @@ RDEPEND=" sys-apps/util-linux sys-auth/elogind sys-auth/polkit + sys-process/procps " src_install() { - dobin "${FILESDIR}"/systemctl "${FILESDIR}"/systemd-run - exeinto /usr/libexec/${PN} - doexe "${FILESDIR}"/systemd-run-agent "${FILESDIR}"/socket-activate - python_fix_shebang "${ED}"/usr/bin/systemd-run "${ED}"/usr/libexec/${PN} + local lib=/usr/libexec/${PN} + + dobin "${FILESDIR}"/systemctl "${FILESDIR}"/systemd-run "${FILESDIR}"/eac-run + exeinto ${lib} + doexe "${FILESDIR}"/systemd-run-agent "${FILESDIR}"/socket-activate "${FILESDIR}"/socket-activate-ctl + python_fix_shebang "${ED}"/usr/bin/systemd-run "${ED}"${lib}/systemd-run-agent "${ED}"${lib}/socket-activate + + insinto /usr/share/polkit-1/actions + doins "${FILESDIR}"/org.gentoo.eac-openrc-compat.policy newinitd "${FILESDIR}"/socket-activate.initd socket-activate dosym socket-activate /etc/init.d/socket-activate.easyanticheat_eos @@ -42,7 +48,7 @@ src_install() { } pkg_postinst() { - elog "Start ${EPREFIX}/usr/libexec/${PN}/systemd-run-agent from your compositor's autostart," - elog "and run a session-wide polkit authentication agent there (not pkttyagent)." + elog "Start game launchers through eac-run, e.g. eac-run EpicGamesLauncher," + elog "and run a session-wide polkit authentication agent (not pkttyagent)." elog "Details: ${EROOT}/usr/share/doc/${PF}/README.md*" } diff --git a/overlay/sys-apps/eac-openrc-compat/files/README.md b/overlay/sys-apps/eac-openrc-compat/files/README.md index 439596b..9d105b1 100644 --- a/overlay/sys-apps/eac-openrc-compat/files/README.md +++ b/overlay/sys-apps/eac-openrc-compat/files/README.md @@ -30,6 +30,9 @@ Logs: `~/.cache/com.epicgames.easyanticheat/service.log` (setup), | File | Role | | --- | --- | +| `/usr/bin/eac-run` | `eac-run COMMAND [ARGS...]`: runs a game launcher with the two pieces below, which run only as long as it does | +| `/usr/libexec/eac-openrc-compat/socket-activate-ctl` | `{start\|stop} NAME` for `socket-activate.NAME`, as root through pkexec; `stop` does nothing while the service it started still runs | +| `/usr/share/polkit-1/actions/org.gentoo.eac-openrc-compat.policy` | lets the active local session run `socket-activate-ctl` without a password; anyone else needs an admin password | | `/usr/lib64/libsystemd.so.0` | link to elogind's library, which exports the same `LIBSYSTEMD_*` symbols the setup uses (`sd_listen_fds`, `sd_is_socket_unix`, `sd_notify`) | | `/usr/bin/systemd-run` | the `--user` form only, forwarded to `systemd-run-agent`; anything else fails as on a host without a user manager | | `/usr/libexec/eac-openrc-compat/systemd-run-agent` | runs those commands in the graphical session, with the session's environment, outside the caller's process tree | @@ -64,8 +67,20 @@ Logs: `~/.cache/com.epicgames.easyanticheat/service.log` (setup), ## Setup -1. Start the agent in the graphical session, e.g. Hyprland: - `hl.exec_cmd("/usr/libexec/eac-openrc-compat/systemd-run-agent")`. +1. Start the launcher through `eac-run`, e.g. `eac-run EpicGamesLauncher` + (`games-util/epic-games-launcher-bin`'s `EpicGamesLauncher` does this + itself). From the graphical session, so the agent gets its environment and + polkit sees the active session. `eac-run`: + - starts `systemd-run-agent` unless one already runs for the user; + - starts `socket-activate.easyanticheat_eos` through pkexec once EAC is + installed (before that, the setup starts it itself); + - when the launcher exits, stops both, unless the listener was already + running before or is in the default runlevel. The listener stays + while the EAC service still serves a game. + + Nothing runs at boot or in the background between game sessions. To keep + the listener running instead: `rc-update add socket-activate.easyanticheat_eos default` + (or `systemctl enable easyanticheat_eos.socket`); `eac-run` leaves it alone then. 2. Run a session-wide polkit authentication agent in that session (hyprpolkitagent, polkit-gnome, lxqt-policykit, ...). `pkttyagent` does not work: without `--process` it registers only for its parent shell, so polkit @@ -73,8 +88,10 @@ Logs: `~/.cache/com.epicgames.easyanticheat/service.log` (setup), in the setup's log). Check with `systemd-run --user --wait --pipe pkexec --disable-internal-agent /usr/bin/true`: "No authentication agent found" means none is registered for the session. -3. Launch the game and accept the service installation. The setup enables - `socket-activate.easyanticheat_eos` in the default runlevel itself. +3. Launch the game and accept the service installation. The setup runs + `systemctl start`; it never runs `enable`, since systemd would start the + socket at boot through EAC's `sockets.target.d` drop-in, which OpenRC does + not read. Remove EAC's files again with `pkexec /usr/local/bin/easyanticheat_eos -uninstall standalone`, then `rc-update del socket-activate.easyanticheat_eos`. +uninstall standalone`. diff --git a/overlay/sys-apps/eac-openrc-compat/files/eac-run b/overlay/sys-apps/eac-openrc-compat/files/eac-run new file mode 100755 index 0000000..42982f0 --- /dev/null +++ b/overlay/sys-apps/eac-openrc-compat/files/eac-run @@ -0,0 +1,34 @@ +#!/bin/sh +# Usage: eac-run COMMAND [ARGS...] +# Runs COMMAND (a game launcher) with what Easy Anti-Cheat needs on OpenRC, and only for as long +# as it runs: systemd-run-agent for the user, and the socket-activate.easyanticheat_eos listener, +# started through pkexec (no password for the active local session, see the polkit action). +[ $# -gt 0 ] || { echo "usage: eac-run COMMAND [ARGS...]" >&2; exit 2; } + +lib=/usr/libexec/eac-openrc-compat +name=easyanticheat_eos +svc=socket-activate.$name + +running() { rc-service "$svc" status >/dev/null 2>&1; } +at_boot() { rc-update show default 2>/dev/null | grep -qwF "$svc"; } + +"$lib/systemd-run-agent" 2>/dev/null & +agent=$! + +was_running= +running && was_running=1 +# Before EAC's first install the binary is missing; its setup then starts the listener itself. +if [ -z "$was_running" ] && [ -x /usr/local/bin/easyanticheat_eos ]; then + pkexec "$lib/socket-activate-ctl" start "$name" >/dev/null || echo "eac-run: could not start $svc" >&2 +fi + +cleanup() { + if [ -z "$was_running" ] && running && ! at_boot; then + pkexec "$lib/socket-activate-ctl" stop "$name" >/dev/null + fi + kill "$agent" 2>/dev/null +} +trap cleanup EXIT +trap 'exit 130' INT TERM HUP + +"$@" diff --git a/overlay/sys-apps/eac-openrc-compat/files/org.gentoo.eac-openrc-compat.policy b/overlay/sys-apps/eac-openrc-compat/files/org.gentoo.eac-openrc-compat.policy new file mode 100644 index 0000000..c75781c --- /dev/null +++ b/overlay/sys-apps/eac-openrc-compat/files/org.gentoo.eac-openrc-compat.policy @@ -0,0 +1,16 @@ + + + + eac-openrc-compat + + Start or stop a socket-activated service + Authentication is required to start or stop a socket-activated service + + auth_admin + auth_admin + yes + + /usr/libexec/eac-openrc-compat/socket-activate-ctl + + diff --git a/overlay/sys-apps/eac-openrc-compat/files/socket-activate-ctl b/overlay/sys-apps/eac-openrc-compat/files/socket-activate-ctl new file mode 100755 index 0000000..1c035ad --- /dev/null +++ b/overlay/sys-apps/eac-openrc-compat/files/socket-activate-ctl @@ -0,0 +1,22 @@ +#!/bin/sh +# Usage (as root, normally through pkexec): socket-activate-ctl {start|stop} NAME +# Starts or stops the OpenRC service socket-activate.NAME. stop leaves it running while the +# service it started is still serving a client (for EAC: a game that is still running). +set -eu +action=${1:-} +name=${2:-} +case $action in start|stop) ;; *) echo "usage: socket-activate-ctl {start|stop} NAME" >&2; exit 2 ;; esac +case $name in ''|*[!A-Za-z0-9_.-]*) echo "socket-activate-ctl: invalid name '$name'" >&2; exit 2 ;; esac +svc=socket-activate.$name +[ -e "/etc/init.d/$svc" ] || { echo "socket-activate-ctl: $svc does not exist" >&2; exit 1; } + +if [ "$action" = start ]; then + exec rc-service -N "$svc" start +fi +socket_command= +. "/etc/conf.d/$svc" +if [ -n "$socket_command" ] && pgrep -xf -- "$socket_command" >/dev/null; then + echo "socket-activate-ctl: ${socket_command%% *} still runs, $svc stays started" >&2 + exit 0 +fi +exec rc-service -s "$svc" stop diff --git a/overlay/sys-apps/eac-openrc-compat/files/systemd-run-agent b/overlay/sys-apps/eac-openrc-compat/files/systemd-run-agent index 897d3da..4fd2280 100755 --- a/overlay/sys-apps/eac-openrc-compat/files/systemd-run-agent +++ b/overlay/sys-apps/eac-openrc-compat/files/systemd-run-agent @@ -1,7 +1,8 @@ #!/usr/bin/python3 -I """Runs commands for systemd-run (eac-openrc-compat) in the graphical session. -Start it once per session, from the compositor's autostart. Each request comes from the +eac-run starts it from the graphical session (or start it from the compositor's autostart); a +second instance exits while the first one answers. Each request comes from the systemd-run in /usr/bin over $XDG_RUNTIME_DIR/systemd-run-agent.sock; only the agent's own user may connect. The command gets the agent's environment plus the request's --setenv values and, with --pipe, the caller's stdin/stdout/stderr. Every run is logged to syslog. diff --git a/overlay/sys-kernel/cachyos-eac-kernel-bin/cachyos-eac-kernel-bin-7.3.5_p2-r2.ebuild b/overlay/sys-kernel/cachyos-eac-kernel-bin/cachyos-eac-kernel-bin-7.3.5_p2-r3.ebuild old mode 100755 new mode 100644 similarity index 62% rename from overlay/sys-kernel/cachyos-eac-kernel-bin/cachyos-eac-kernel-bin-7.3.5_p2-r2.ebuild rename to overlay/sys-kernel/cachyos-eac-kernel-bin/cachyos-eac-kernel-bin-7.3.5_p2-r3.ebuild index b7d335d..84e0c3f --- a/overlay/sys-kernel/cachyos-eac-kernel-bin/cachyos-eac-kernel-bin-7.3.5_p2-r2.ebuild +++ b/overlay/sys-kernel/cachyos-eac-kernel-bin/cachyos-eac-kernel-bin-7.3.5_p2-r3.ebuild @@ -3,6 +3,8 @@ EAPI=8 +inherit toolchain-funcs + MY_PV=${PV/_p/-} MY_KV=${MY_PV}-cachyos-eac SDBOOT_PV=262.2_1-1 @@ -28,6 +30,7 @@ KEYWORDS="~amd64" RESTRICT="mirror strip" RDEPEND=" + app-crypt/efitools app-crypt/sbctl app-crypt/sbsigntools app-crypt/tpm2-tools @@ -36,7 +39,11 @@ RDEPEND=" sys-boot/efibootmgr sys-kernel/dracut " -BDEPEND="app-arch/zstd" +BDEPEND=" + app-arch/zstd + sys-apps/kmod + virtual/pkgconfig +" src_unpack() { local f @@ -47,21 +54,32 @@ src_unpack() { src_prepare() { default - sed -i 's#esp=$(bootctl --print-esp-path 2>/dev/null || echo /boot)#esp=$(eac-boot esp)#' \ + # eac-status takes the ESP, kernel and boot loader locations from eac-boot. + sed -i \ + -e 's#esp=$(bootctl --print-esp-path 2>/dev/null || echo /boot)#esp=$(eac-boot esp)#' \ + -e 's#"$esp/$(cat /etc/machine-id)/linux-cachyos-eac#"$(eac-boot kernel-dir)#' \ + -e 's#"$esp/EFI/cachyos-eac/systemd-bootx64.efi"#"$(eac-boot loader)"#' \ usr/bin/eac-status || die grep -q 'esp=$(eac-boot esp)' usr/bin/eac-status || die "eac-status: ESP patch did not apply" + [[ $(grep -c '$(eac-boot kernel-dir)' usr/bin/eac-status) == 2 ]] || die "eac-status: kernel-dir patch did not apply" + grep -q '"$(eac-boot loader)"' usr/bin/eac-status || die "eac-status: loader patch did not apply" } src_install() { - dodir /lib/modules - cp -a "usr/lib/modules/${MY_KV}" "${ED}/lib/modules/" || die - fowners -R root:root "/lib/modules/${MY_KV}" + # Wherever this system's kmod looks for modules (/lib/modules on Gentoo). + MODULES_DIR=$($(tc-getPKG_CONFIG) --variable=module_directory kmod) + : "${MODULES_DIR:=/lib/modules}" + + dodir "${MODULES_DIR}" + cp -a "usr/lib/modules/${MY_KV}" "${ED}${MODULES_DIR}/" || die + fowners -R root:root "${MODULES_DIR}/${MY_KV}" insinto /usr/lib/cachyos-eac doins usr/lib/systemd/boot/efi/systemd-bootx64.efi.signed insinto /usr/share/cachyos-eac doins usr/share/cachyos-eac/cachyos-eac-ca.{crt,der} + # Only used by `sbctl enroll-keys --custom` with sbctl's default keydir; eac-boot enroll reads the copy above. insinto /var/lib/sbctl/keys/custom/db doins var/lib/sbctl/keys/custom/db/cachyos-eac-ca.der @@ -72,7 +90,7 @@ src_install() { pkg_postinst() { depmod -b "${EROOT:-/}" "${MY_KV}" || die - if [[ -z ${ROOT} && -d $(eac-boot esp 2>/dev/null)/EFI/cachyos-eac ]]; then + if [[ -z ${ROOT} && -f $(eac-boot loader 2>/dev/null) ]]; then eac-boot update || ewarn "eac-boot update failed, run it by hand" else elog "First-time setup: eac-boot enroll, eac-boot setup, then enable Secure Boot." @@ -83,5 +101,6 @@ pkg_postinst() { pkg_postrm() { # depmod output is not owned by the package - [[ -d ${EROOT}/lib/modules/${MY_KV}/kernel ]] || rm -rf "${EROOT}/lib/modules/${MY_KV}" + [[ -n ${MODULES_DIR} && ! -d ${EROOT}${MODULES_DIR}/${MY_KV}/kernel ]] || return 0 + rm -rf "${EROOT}${MODULES_DIR}/${MY_KV}" } diff --git a/overlay/sys-kernel/cachyos-eac-kernel-bin/files/README.md b/overlay/sys-kernel/cachyos-eac-kernel-bin/files/README.md index 62c544a..00206e0 100644 --- a/overlay/sys-kernel/cachyos-eac-kernel-bin/files/README.md +++ b/overlay/sys-kernel/cachyos-eac-kernel-bin/files/README.md @@ -4,10 +4,10 @@ Repackages the CachyOS Easy Anti-Cheat Linux v2 boot chain unchanged: | From CachyOS | Installed to | |---|---| -| `linux-cachyos-eac` (kernel + signed modules) | `/lib/modules/-cachyos-eac/` (kernel at `vmlinuz`) | +| `linux-cachyos-eac` (kernel + signed modules) | `/-cachyos-eac/` (kernel at `vmlinuz`); `` is kmod's `module_directory`, `/lib/modules` on Gentoo | | `systemd-boot-cachyos-signed` | `/usr/lib/cachyos-eac/systemd-bootx64.efi.signed` | | `cachyos-eac-signing-key` (CachyOS EAC CA) | `/usr/share/cachyos-eac/`, `/var/lib/sbctl/keys/custom/db/` | -| `eac-status` from `cachyos-settings` | `/usr/sbin/eac-status` (ESP lookup patched to `eac-boot esp`) | +| `eac-status` from `cachyos-settings` | `/usr/sbin/eac-status` (ESP, kernel and loader paths patched to ask `eac-boot`) | The kernel is not handled by installkernel or uefi-mkconfig, and nothing is re-signed. A second signature, or a kernel started without the CachyOS-signed @@ -17,37 +17,57 @@ systemd-boot, fails the EAC checks. | Command | Does | |---|---| -| `eac-boot enroll` | rewrites the Secure Boot db as: your sbctl db key, the Microsoft certificates, the CachyOS EAC CA | -| `eac-boot setup [bootnum]` | `update`, then creates the `CachyOS EAC` firmware entry and puts it at the end of BootOrder; `bootnum` (4 hex digits) replaces the entry with that number | +| `eac-boot enroll` | appends the CachyOS EAC CA to the Secure Boot db, signed with your KEK; every other entry stays | +| `eac-boot setup [bootnum]` | `update`, then creates the firmware entry and puts it at the end of BootOrder; `bootnum` (4 hex digits) replaces the entry with that number | | `eac-boot update` | dracut initramfs, kernel and systemd-boot to the ESP, writes the loader entry | -| `eac-boot boot` | sets BootNext to the EAC entry and reboots | -| `eac-boot cmdline` | prints the EAC entry's kernel command line | -| `eac-boot esp` | prints the ESP mount point | +| `eac-boot boot` | starts the EAC entry once (BootNext, and systemd-boot's one-shot entry) and reboots | +| `eac-boot cmdline`, `esp`, `kernel-dir`, `loader` | print the command line and the paths in use | -ESP layout (same as CachyOS with Limine, which `eac-status` checks): +ESP layout with the defaults: ``` -//linux-cachyos-eac/{vmlinuz,initramfs} -/EFI/cachyos-eac/systemd-bootx64.efi +//linux-cachyos-eac/{vmlinuz,initramfs} KERNEL_DIR +/EFI/cachyos-eac/systemd-bootx64.efi LOADER_DIR +/loader/entries/cachyos-eac.conf ENTRY /loader/loader.conf -/loader/entries/cachyos-eac.conf ``` -Settings: +`/loader/` is where every systemd-boot looks, whatever its own directory. +If the ESP already has a `loader.conf` from another systemd-boot, it is kept; +`eac-boot boot` then picks the EAC entry through `LoaderEntryOneShot`. -- `EAC_ESP`: ESP mount point. Default: the first vfat mount of `/efi`, `/boot/efi`, `/boot`. -- `/etc/kernel/cmdline`: base kernel command line. Default: `/proc/cmdline`. - The EAC options are appended. +## Settings: `/etc/eac-boot.conf` + +Shell `KEY=value` lines, all optional: + +| Key | Default | +| --- | --- | +| `ESP` | first vfat mount of `/efi`, `/boot/efi`, `/boot` | +| `KERNEL_DIR` | `/linux-cachyos-eac` (relative to the ESP) | +| `LOADER_DIR` | `EFI/cachyos-eac` (relative to the ESP) | +| `ENTRY` | `cachyos-eac.conf` | +| `LABEL` | `CachyOS EAC` (firmware entry name) | +| `CMDLINE` | `/etc/kernel/cmdline`, else `/proc/cmdline`; the EAC options are appended | +| `MODULES_DIR` | kmod's `module_directory` | +| `KEK_KEY`, `KEK_CERT` | `KEK/KEK.key`, `KEK/KEK.pem` in sbctl's `keydir` (`/etc/sbctl/sbctl.conf`, default `/var/lib/sbctl/keys`) | +| `OWNER_GUID` | sbctl's GUID file, else random | + +`eac-status` checks the kernel only under `KERNEL_DIR` and the loader only +under `LOADER_DIR`, and expects the kernel modules where kmod looks for them. After the first `setup`, every package update runs `eac-boot update` from -`pkg_postinst`. +`pkg_postinst`. Changing `KERNEL_DIR`, `LOADER_DIR`, `ENTRY` or `LABEL` after +`setup` leaves the old files and firmware entry behind: remove them by hand. ## One-time setup -1. `eac-boot enroll`: the db needs your own `Database Key`, the Microsoft - certificates and `CachyOS EAC CA`. It is written with your sbctl KEK, so - Setup Mode is not needed. Do not use `sbctl enroll-keys --append`: it adds - every key again, and the firmware keeps the duplicates. +1. `eac-boot enroll`: appends `CachyOS EAC CA` to db with an authenticated + write signed by your KEK, so Setup Mode is not needed and nothing else in + db changes: your own keys, Microsoft's and any other vendor's stay. Run it + again and it sees the CA and does nothing. Do not use + `sbctl enroll-keys --append`: it re-adds sbctl's keys and the Microsoft + certificates, and the firmware keeps the duplicates. To remove duplicates + that are already there, see the troubleshooting doc. `sbctl list-enrolled-keys` prints the issuer of each certificate, so some names appear twice in a correct db. 2. Your normal kernels must be signed with the sbctl db key. With `USE=secureboot` diff --git a/overlay/sys-kernel/cachyos-eac-kernel-bin/files/eac-boot b/overlay/sys-kernel/cachyos-eac-kernel-bin/files/eac-boot index 79022a3..0eaf9ab 100755 --- a/overlay/sys-kernel/cachyos-eac-kernel-bin/files/eac-boot +++ b/overlay/sys-kernel/cachyos-eac-kernel-bin/files/eac-boot @@ -1,34 +1,55 @@ #!/usr/bin/env bash # Boot chain for linux-cachyos-eac: CachyOS-signed systemd-boot on the ESP, # started once through its own firmware entry (BootNext). +# Settings: /etc/eac-boot.conf (KEY=value), documented in the README. set -euo pipefail EAC_OPTS="lockdown=integrity lsm=landlock,lockdown,yama,integrity,bpf iommu.passthrough=0 intel_iommu=on module.sig_enforce=1 sysctl.kernel.kexec_load_disabled=1" -LABEL="CachyOS EAC" SDBOOT=/usr/lib/cachyos-eac/systemd-bootx64.efi.signed +CA=/usr/share/cachyos-eac/cachyos-eac-ca +LOADER_GUID=4a67b082-0a4c-41cf-b6c7-440b29bb8c4f +EFIVARS=/sys/firmware/efi/efivars die() { echo "eac-boot: $*" >&2; exit 1; } +sbctl_conf() { sed -n "s/^$1: *//p" /etc/sbctl/sbctl.conf 2>/dev/null | head -n1; } + +ESP= KERNEL_DIR= LOADER_DIR=EFI/cachyos-eac ENTRY=cachyos-eac.conf LABEL="CachyOS EAC" CMDLINE= +MODULES_DIR=$(pkg-config --variable=module_directory kmod 2>/dev/null || true) +KEYDIR=$(sbctl_conf keydir) +KEK_KEY=${KEYDIR:-/var/lib/sbctl/keys}/KEK/KEK.key +KEK_CERT=${KEYDIR:-/var/lib/sbctl/keys}/KEK/KEK.pem +OWNER_GUID= +[[ -r /etc/eac-boot.conf ]] && . /etc/eac-boot.conf +MODULES_DIR=${MODULES_DIR:-/lib/modules} +KERNEL_DIR=${KERNEL_DIR:-$(/dev/null) == vfat ]] && { echo "$d"; return; } done - die "no mounted vfat ESP found, set EAC_ESP" + die "no mounted vfat ESP found, set ESP in /etc/eac-boot.conf" } +kernel_dir() { echo "$(esp)/$KERNEL_DIR"; } +loader() { echo "$(esp)/$LOADER_DIR/systemd-bootx64.efi"; } + kver() { local k - k=$(ls -d /lib/modules/*-cachyos-eac 2>/dev/null | sort -V | tail -n1) || true - [[ -f $k/vmlinuz ]] || die "no linux-cachyos-eac kernel in /lib/modules" + k=$(ls -d "$MODULES_DIR"/*-cachyos-eac 2>/dev/null | sort -V | tail -n1) || true + [[ -f $k/vmlinuz ]] || die "no linux-cachyos-eac kernel in $MODULES_DIR" echo "${k##*/}" } -# Base command line from /etc/kernel/cmdline or the running system, plus the EAC options. +# Base command line (CMDLINE, /etc/kernel/cmdline or the running system), plus the EAC options. cmdline() { - local src=/proc/cmdline opt out=() - [[ -f /etc/kernel/cmdline ]] && src=/etc/kernel/cmdline - for opt in $(<"$src"); do + local base=$CMDLINE opt out=() + if [[ -z $base ]]; then + if [[ -f /etc/kernel/cmdline ]]; then base=$( "$esp/loader/entries/cachyos-eac.conf" - printf 'default cachyos-eac.conf\ntimeout 0\n' > "$esp/loader/loader.conf" + printf 'title CachyOS (EAC)\nlinux /%s/vmlinuz\ninitrd /%s/initramfs\noptions %s\n' \ + "$KERNEL_DIR" "$KERNEL_DIR" "$(cmdline)" > "$esp/loader/entries/$ENTRY" + + # loader.conf is shared by every systemd-boot on this ESP: only write our own. + conf=$(printf 'default %s\ntimeout 0\n' "$ENTRY") + if [[ ! -e $esp/loader/loader.conf || $(<"$esp/loader/loader.conf") == "$conf" ]]; then + printf '%s\n' "$conf" > "$esp/loader/loader.conf" + else + echo "eac-boot: kept the existing $esp/loader/loader.conf; eac-boot boot selects $ENTRY once" + fi echo "eac-boot: $kv installed to $dir" } -# The whole db is rewritten: sbctl --append adds every key again, and firmware keeps duplicates. +# Same file contents as a certificate in a signature database variable? +in_sigdb() { + local var=$1 der=$2 f + efi-readvar -v "$var" -o "$tmp/$var.esl" >/dev/null + (cd "$tmp" && sig-list-to-certs "$var.esl" "$var" >/dev/null 2>&1) || true + for f in "$tmp/$var"-*.der; do + [[ -f $f ]] && cmp -s "$f" "$der" && return 0 + done + return 1 +} + +# Appends only the CachyOS EAC CA. Every other db entry stays, and nothing is added twice. enroll() { - sbctl enroll-keys --partial db --microsoft --custom --ignore-immutable + tmp=$(mktemp -d) + trap 'rm -rf "$tmp"' EXIT + if in_sigdb db "$CA.der"; then + echo "eac-boot: the CachyOS EAC CA is already in db, nothing to do" + return + fi + [[ -r $KEK_KEY && -r $KEK_CERT ]] || die "KEK key or certificate not found ($KEK_KEY, $KEK_CERT); set KEK_KEY and KEK_CERT in /etc/eac-boot.conf" + openssl x509 -in "$KEK_CERT" -outform DER -out "$tmp/kek.der" + in_sigdb KEK "$tmp/kek.der" || die "$KEK_CERT is not enrolled in KEK, so the firmware would reject the update" + local guid=${OWNER_GUID:-$(cat "$(sbctl_conf guid)" 2>/dev/null || cat /proc/sys/kernel/random/uuid)} + cert-to-efi-sig-list -g "$guid" "$CA.crt" "$tmp/ca.esl" >/dev/null + sign-efi-sig-list -a -g "$guid" -c "$KEK_CERT" -k "$KEK_KEY" db "$tmp/ca.esl" "$tmp/ca.auth" >/dev/null + chattr -i "$EFIVARS/db-d719b2cb-3d3a-4596-a3bc-dad00e67656f" 2>/dev/null || true + efi-updatevar -a -f "$tmp/ca.auth" db + in_sigdb db "$CA.der" || die "the firmware did not take the CachyOS EAC CA" + echo "eac-boot: appended the CachyOS EAC CA to db; existing entries were kept" } # With a boot number, the entry is created there and replaces the entry that has it. @@ -93,7 +146,7 @@ create() { local have=$1 want=$2 old esp src [[ -n $have ]] && efibootmgr -b "$have" -B >/dev/null if [[ -n $want ]]; then - old=$(efibootmgr | sed -n "s/^Boot$want\*\{0,1\} \([^ ]*\).*/\1/p") + old=$(efibootmgr | sed -n "s/^Boot$want\*\{0,1\} \([^\t]*\).*/\1/p") if [[ -n $old ]]; then efibootmgr -b "$want" -B >/dev/null echo "eac-boot: removed Boot$want \"$old\"" @@ -103,24 +156,37 @@ create() { src=$(findmnt -no SOURCE --mountpoint "$esp") efibootmgr --create-only ${want:+--bootnum "$want"} --disk "/dev/$(lsblk -no PKNAME "$src")" \ --part "$(<"/sys/class/block/${src##*/}/partition")" \ - --label "$LABEL" --loader '\EFI\cachyos-eac\systemd-bootx64.efi' >/dev/null + --label "$LABEL" --loader "\\${LOADER_DIR//\//\\}\\systemd-bootx64.efi" >/dev/null echo "eac-boot: created firmware entry Boot$(bootnum) \"$LABEL\"" } +# systemd-boot reads LoaderEntryOneShot (UTF-16LE, NUL-terminated) and deletes it. +oneshot() { + local var=$EFIVARS/LoaderEntryOneShot-$LOADER_GUID tmp i data='\x07\x00\x00\x00' + for ((i = 0; i < ${#ENTRY}; i++)); do data+="${ENTRY:i:1}\\x00"; done + tmp=$(mktemp) + printf "$data"'\x00\x00' > "$tmp" + [[ -e $var ]] && chattr -i "$var" 2>/dev/null + cat "$tmp" > "$var" + rm -f "$tmp" +} + boot() { local n n=$(bootnum) [[ -n $n ]] || die "no \"$LABEL\" firmware entry, run: eac-boot setup" + oneshot efibootmgr --bootnext "$n" >/dev/null reboot } case ${1:-} in - esp|cmdline) "$1"; exit ;; + esp|cmdline|loader) "$1"; exit ;; + kernel-dir) kernel_dir; exit ;; esac [[ $(id -u) == 0 ]] || die "run as root" case ${1:-} in - enroll|update|boot) "$1" ;; + enroll|update|boot|oneshot) "$1" ;; setup) setup "${2:-}" ;; - *) echo "usage: eac-boot {enroll|setup [bootnum]|update|boot|cmdline|esp}" >&2; exit 2 ;; + *) echo "usage: eac-boot {enroll|setup [bootnum]|update|boot|cmdline|esp|kernel-dir|loader}" >&2; exit 2 ;; esac diff --git a/tools/README.md b/tools/README.md index 42c5c02..1140275 100644 --- a/tools/README.md +++ b/tools/README.md @@ -9,6 +9,7 @@ the packages; run them from this directory. | `exec-trace [seconds]` | as root: JSON lines for every exec on the system (pid, parent, uid, command) and the exit status of each exec'd process (kernel proc connector) | | `eac-catch [seconds] [prefix] [dir]` | as the game's user: hardlinks every file created below `/tmp/EasyAntiCheat_EOS_Setup.*` into `/tmp/.eac-catch/` before EAC deletes it | | `efi-sig-list.py FILE...` | lists the certificates in efivarfs dumps or `.esl` files (sha256 prefix, subject, issuer) and counts duplicates | +| `efi-sig-list.py --unique OUT.esl FILE` | writes FILE's signature lists with every signature once; used to remove duplicate db keys without losing any other key (docs/troubleshooting.md) | | `systemctl-trace` | logs argv, uid and parent to `$SYSTEMD_TRACE_DIR/systemd-trace..log` (default `/tmp`) and exits with `$SYSTEMD_TRACE_RC` (default 0) | | `systemd1-trace [--session]` | owns `org.freedesktop.systemd1` on the system (or session) bus, prints every method call as a JSON line with the caller, replies `NotSupported` | | `systemd1-trace.conf` | D-Bus policy that lets root own `org.freedesktop.systemd1` on the system bus | diff --git a/tools/efi-sig-list.py b/tools/efi-sig-list.py index e4caf83..161797a 100755 --- a/tools/efi-sig-list.py +++ b/tools/efi-sig-list.py @@ -2,10 +2,13 @@ """List the entries of UEFI signature lists and count duplicates. Usage: efi-sig-list.py FILE... + efi-sig-list.py --unique OUT.esl FILE FILE = an efivarfs dump (/sys/firmware/efi/efivars/{PK,KEK,db,dbx}- or a `cat` copy; the 4-byte attribute prefix is skipped) or a plain `.esl` file - (e.g. from `sbctl enroll-keys --export esl`). + (e.g. from `efi-readvar -v db -o db.esl`). Prints per entry: sha256 prefix, subject CN, issuer CN; then entries vs unique. +--unique writes FILE's signature lists to OUT.esl with every signature once (first +occurrence, original order and owner); nothing else is dropped. No arguments runs a self-check. """ import hashlib @@ -39,6 +42,26 @@ def entries(b): i += lsize +def unique(b): + seen, out, i = set(), b"", 0 + while i + 28 <= len(b): + stype = b[i:i + 16] + lsize, hsize, ssize = struct.unpack_from("