EAC Linux v2 on Gentoo with OpenRC: ebuilds, host config, tools, docs
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
masters = gentoo
|
||||
thin-manifests = true
|
||||
sign-manifests = false
|
||||
@@ -0,0 +1 @@
|
||||
eac-gentoo-openrc
|
||||
@@ -0,0 +1,48 @@
|
||||
# Copyright 2026 Gentoo Authors
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
EAPI=8
|
||||
|
||||
PYTHON_COMPAT=( python3_{13..14} )
|
||||
|
||||
inherit python-single-r1
|
||||
|
||||
DESCRIPTION="systemctl, systemd-run and socket activation for the EAC Linux v2 service on OpenRC"
|
||||
HOMEPAGE="https://easy.ac"
|
||||
S="${WORKDIR}"
|
||||
|
||||
LICENSE="MIT"
|
||||
SLOT="0"
|
||||
KEYWORDS="~amd64"
|
||||
REQUIRED_USE="${PYTHON_REQUIRED_USE}"
|
||||
|
||||
RDEPEND="
|
||||
${PYTHON_DEPS}
|
||||
!sys-apps/systemd
|
||||
sys-apps/openrc
|
||||
sys-apps/util-linux
|
||||
sys-auth/elogind
|
||||
sys-auth/polkit
|
||||
"
|
||||
|
||||
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}
|
||||
|
||||
newinitd "${FILESDIR}"/socket-activate.initd socket-activate
|
||||
dosym socket-activate /etc/init.d/socket-activate.easyanticheat_eos
|
||||
newconfd "${FILESDIR}"/easyanticheat_eos.confd socket-activate.easyanticheat_eos
|
||||
|
||||
# EAC's helper links libsystemd.so.0; elogind exports the same LIBSYSTEMD_* symbol versions.
|
||||
dosym libelogind.so.0 /usr/$(get_libdir)/libsystemd.so.0
|
||||
|
||||
dodoc "${FILESDIR}"/README.md
|
||||
}
|
||||
|
||||
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 "Details: ${EROOT}/usr/share/doc/${PF}/README.md*"
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
# eac-openrc-compat
|
||||
|
||||
Lets the Easy Anti-Cheat Linux v2 setup install and run its service on an
|
||||
OpenRC host. It provides only what the setup (`EasyAntiCheat_EOS_Setup`, 0.1.7)
|
||||
calls; nothing here talks to systemd or pretends a systemd boot to other
|
||||
software (`/run/systemd/system` stays absent, `sd_booted()` returns 0).
|
||||
|
||||
## What the EAC setup does
|
||||
|
||||
On the first protected launch the game writes the setup to
|
||||
`/tmp/EasyAntiCheat_EOS_Setup.XXXXXX/` and runs `verify-and-install <product>`:
|
||||
|
||||
1. Proton has set no_new_privs, so the setup re-runs itself with
|
||||
`systemd-run --user --wait --pipe --collect --quiet --setenv=... <setup> ...`.
|
||||
2. Outside Proton it runs `pkexec <setup> install <product>` (polkit prompt).
|
||||
3. As root it writes `/usr/local/bin/easyanticheat_eos`,
|
||||
`/usr/lib/systemd/system/easyanticheat_eos.{socket,service}`,
|
||||
`/var/lib/easyanticheat_eos/` (state, `authorizedusers/<uid>`), then runs
|
||||
`systemctl --version` (needs systemd >= 249), `daemon-reload`,
|
||||
`enable --quiet easyanticheat_eos.socket` and `start`.
|
||||
4. The game connects to the abstract socket `@easyanticheat_eos`; the service
|
||||
starts with that socket (`LISTEN_FDS`) and `EAC_MODE_SERVICE=1`, and stops
|
||||
when the game exits.
|
||||
|
||||
Logs: `~/.cache/com.epicgames.easyanticheat/service.log` (setup),
|
||||
`/var/log/socket-activate.easyanticheat_eos.log` (service), syslog tags
|
||||
`systemctl-compat` and `systemd-run-agent`.
|
||||
|
||||
## Files
|
||||
|
||||
| File | Role |
|
||||
| --- | --- |
|
||||
| `/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 |
|
||||
| `/usr/bin/systemctl` | units `NAME.socket`/`NAME.service` map to the OpenRC service `socket-activate.NAME` when it exists; other units fail as on a host not booted with systemd |
|
||||
| `/usr/libexec/eac-openrc-compat/socket-activate` | `socket-activate [-n] {stream\|seqpacket} ADDRESS COMMAND [ARGS...]`: listens on ADDRESS (`@NAME` = abstract) and starts COMMAND with the socket as fd 3 for each burst of connections, like `Accept=no` |
|
||||
| `/etc/init.d/socket-activate` | OpenRC service family; instances are links `socket-activate.NAME` |
|
||||
| `/etc/conf.d/socket-activate.easyanticheat_eos` | the EAC instance |
|
||||
|
||||
## Instance settings (`/etc/conf.d/socket-activate.NAME`)
|
||||
|
||||
| Variable | Meaning |
|
||||
| --- | --- |
|
||||
| `socket_type` | `stream` (default) or `seqpacket` |
|
||||
| `socket_address` | `@NAME` for an abstract socket, else a path |
|
||||
| `socket_nonblocking` | `yes`: O_NONBLOCK on the socket (systemd `NonBlocking=yes`) |
|
||||
| `socket_command` | the service binary and its arguments |
|
||||
| `socket_env` | space-separated `KEY=VALUE` pairs for the service |
|
||||
|
||||
## systemctl mapping
|
||||
|
||||
| systemctl | OpenRC |
|
||||
| --- | --- |
|
||||
| `--version` | prints `systemd 257` |
|
||||
| `daemon-reload`, `reset-failed` | nothing |
|
||||
| `start` | `rc-service -N socket-activate.NAME start` |
|
||||
| `stop NAME.service` | restarts the listener, which ends the running service; the socket keeps listening |
|
||||
| `stop NAME.socket`, `stop NAME.*` | `rc-service -s ... stop` |
|
||||
| `restart` | `rc-service ... restart` |
|
||||
| `enable [--now]`, `disable [--now]` | `rc-update add/del ... default` |
|
||||
| `is-enabled` | `enabled`/`disabled` from the default runlevel; `static` for a `.service` |
|
||||
| `is-active`, `status` | `rc-service ... status` |
|
||||
|
||||
## Setup
|
||||
|
||||
1. Start the agent in the graphical session, e.g. Hyprland:
|
||||
`hl.exec_cmd("/usr/libexec/eac-openrc-compat/systemd-run-agent")`.
|
||||
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
|
||||
finds no agent for the setup and pkexec fails at once ("pkexec auth failed"
|
||||
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.
|
||||
|
||||
Remove EAC's files again with `pkexec /usr/local/bin/easyanticheat_eos
|
||||
uninstall standalone`, then `rc-update del socket-activate.easyanticheat_eos`.
|
||||
@@ -0,0 +1,5 @@
|
||||
socket_type="seqpacket"
|
||||
socket_address="@easyanticheat_eos"
|
||||
socket_nonblocking="yes"
|
||||
socket_command="/usr/local/bin/easyanticheat_eos"
|
||||
socket_env="EAC_MODE_SERVICE=1"
|
||||
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/python3 -I
|
||||
"""Socket activation without systemd, like a .socket unit with Accept=no.
|
||||
|
||||
Usage: socket-activate [-n] {stream|seqpacket} ADDRESS COMMAND [ARGS...]
|
||||
ADDRESS is @NAME for an abstract Unix socket, else a filesystem path. When a client connects,
|
||||
COMMAND starts with the listening socket as fd 3, LISTEN_FDS=1 and LISTEN_PID; after it exits
|
||||
the next connection starts it again. -n sets O_NONBLOCK on the socket (NonBlocking=yes).
|
||||
SIGTERM is passed on to a running COMMAND.
|
||||
"""
|
||||
import os
|
||||
import select
|
||||
import signal
|
||||
import socket
|
||||
import sys
|
||||
import time
|
||||
|
||||
args = sys.argv[1:]
|
||||
nonblocking = args[:1] == ["-n"]
|
||||
if nonblocking:
|
||||
args = args[1:]
|
||||
kind, address, cmd = args[0], args[1], args[2:]
|
||||
sock = socket.socket(socket.AF_UNIX, {"stream": socket.SOCK_STREAM, "seqpacket": socket.SOCK_SEQPACKET}[kind])
|
||||
if address.startswith("@"):
|
||||
sock.bind("\0" + address[1:])
|
||||
else:
|
||||
if os.path.exists(address):
|
||||
os.unlink(address)
|
||||
sock.bind(address)
|
||||
sock.listen(128)
|
||||
sock.setblocking(not nonblocking)
|
||||
child = 0
|
||||
|
||||
|
||||
def stop(signum, _):
|
||||
if child:
|
||||
os.kill(child, signal.SIGTERM)
|
||||
os.waitpid(child, 0)
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
signal.signal(signal.SIGTERM, stop)
|
||||
signal.signal(signal.SIGINT, stop)
|
||||
print(f"listening on {address}", file=sys.stderr, flush=True)
|
||||
while True:
|
||||
select.select([sock], [], [])
|
||||
child = os.fork()
|
||||
if child == 0:
|
||||
os.dup2(sock.fileno(), 3)
|
||||
os.set_inheritable(3, True)
|
||||
os.environ.update(LISTEN_FDS="1", LISTEN_PID=str(os.getpid()))
|
||||
os.environ.pop("LISTEN_FDNAMES", None)
|
||||
try:
|
||||
os.execvp(cmd[0], cmd)
|
||||
finally:
|
||||
os._exit(127)
|
||||
started = time.monotonic()
|
||||
print(f"started {cmd[0]} as pid {child}", file=sys.stderr, flush=True)
|
||||
_, status = os.waitpid(child, 0)
|
||||
child = 0
|
||||
print(f"{cmd[0]} exited with {os.waitstatus_to_exitcode(status)}", file=sys.stderr, flush=True)
|
||||
# ponytail: fixed 1 s pause after a quick exit instead of systemd's StartLimitBurst accounting
|
||||
if time.monotonic() - started < 1:
|
||||
time.sleep(1)
|
||||
@@ -0,0 +1,32 @@
|
||||
#!/sbin/openrc-run
|
||||
# Instances: socket-activate.NAME -> socket-activate, settings in conf.d/socket-activate.NAME.
|
||||
|
||||
description="Starts a service when a client connects to its socket (systemd socket activation)"
|
||||
supervisor=supervise-daemon
|
||||
command=/usr/libexec/eac-openrc-compat/socket-activate
|
||||
command_args="${socket_type:-stream} ${socket_address} ${socket_command}"
|
||||
[ "${socket_nonblocking}" = yes ] && command_args="-n ${command_args}"
|
||||
output_log="/var/log/${RC_SVCNAME}.log"
|
||||
error_log="/var/log/${RC_SVCNAME}.log"
|
||||
retry="TERM/15/KILL/5"
|
||||
respawn_max=5
|
||||
respawn_period=60
|
||||
|
||||
depend() {
|
||||
need localmount
|
||||
after bootmisc
|
||||
}
|
||||
|
||||
start_pre() {
|
||||
if [ "${RC_SVCNAME}" = socket-activate ]; then
|
||||
eerror "Start an instance: socket-activate.NAME"
|
||||
return 1
|
||||
fi
|
||||
if [ ! -x "${socket_command%% *}" ]; then
|
||||
eerror "${socket_command%% *} is not installed"
|
||||
return 1
|
||||
fi
|
||||
for kv in ${socket_env}; do
|
||||
export "${kv}"
|
||||
done
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
#!/bin/bash
|
||||
# systemctl for OpenRC hosts (eac-openrc-compat). A unit NAME.socket or NAME.service is handled
|
||||
# when the OpenRC service socket-activate.NAME exists; everything else fails as on a host that
|
||||
# was not booted with systemd. Every call is logged to syslog.
|
||||
|
||||
logger -t systemctl-compat -- "uid=$EUID: $*" 2>/dev/null
|
||||
|
||||
nosystemd() {
|
||||
echo "System has not been booted with systemd as init system (PID 1). Can't operate." >&2
|
||||
echo "Failed to connect to system scope bus via local transport: Host is down" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
cmd= now= quiet= units=()
|
||||
for a; do
|
||||
case $a in
|
||||
--version) echo "systemd 257 (257-eac-openrc-compat)"; exit 0 ;;
|
||||
--now) now=1 ;;
|
||||
-q|--quiet) quiet=1 ;;
|
||||
--system|--no-block|--no-pager|--no-reload|--no-ask-password|--full|-l) ;;
|
||||
-*) nosystemd ;;
|
||||
*) if [[ -z $cmd ]]; then cmd=$a; else units+=("$a"); fi ;;
|
||||
esac
|
||||
done
|
||||
|
||||
case $cmd in
|
||||
daemon-reload|daemon-reexec) exit 0 ;;
|
||||
'') nosystemd ;;
|
||||
esac
|
||||
|
||||
svc= kinds=()
|
||||
for u in "${units[@]}"; do
|
||||
[[ $u == *.* ]] || u+=.service
|
||||
s=socket-activate.${u%.*}
|
||||
[[ -e /etc/init.d/$s && ( -z $svc || $svc == "$s" ) ]] || nosystemd
|
||||
svc=$s
|
||||
kinds+=("${u##*.}")
|
||||
done
|
||||
[[ -n $svc ]] || nosystemd
|
||||
only_service=1
|
||||
for k in "${kinds[@]}"; do [[ $k == service ]] || only_service=; done
|
||||
|
||||
out() { [[ -n $quiet ]] || echo "$@"; }
|
||||
rc() { if [[ -n $quiet ]]; then rc-service "$@" >/dev/null; else rc-service "$@"; fi; }
|
||||
|
||||
case $cmd in
|
||||
start) rc -N "$svc" start ;;
|
||||
restart|try-restart|reload-or-restart) rc "$svc" restart ;;
|
||||
# Stopping only the service keeps the socket listening: restart the listener, which ends its child.
|
||||
stop) if [[ -n $only_service ]]; then rc -s "$svc" restart; else rc -s "$svc" stop; fi ;;
|
||||
reset-failed) exit 0 ;;
|
||||
enable)
|
||||
rc-update add "$svc" default >/dev/null || exit
|
||||
[[ -z $now ]] || rc -N "$svc" start ;;
|
||||
disable)
|
||||
rc-update del "$svc" default >/dev/null 2>&1
|
||||
[[ -z $now ]] || rc -s "$svc" stop ;;
|
||||
is-enabled)
|
||||
if [[ -n $only_service ]]; then out static; exit 0; fi
|
||||
if rc-update show default | grep -qwF "$svc"; then out enabled; else out disabled; exit 1; fi ;;
|
||||
is-active)
|
||||
if rc-service "$svc" status >/dev/null 2>&1; then out active; else out inactive; exit 3; fi ;;
|
||||
status) rc-service "$svc" status ;;
|
||||
*) echo "systemctl (eac-openrc-compat): '$cmd' is not supported." >&2; exit 1 ;;
|
||||
esac
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
#!/usr/bin/python3 -I
|
||||
"""systemd-run for OpenRC hosts: the `--user` form, forwarded to systemd-run-agent.
|
||||
|
||||
The agent runs in the graphical session and takes the place of the systemd user manager: the
|
||||
command runs with the agent's environment plus --setenv values, outside the caller's process
|
||||
tree, so a caller's no_new_privs (Proton) does not apply to it.
|
||||
|
||||
Supported: --user, --wait, --pipe/-P, --setenv/-E, --same-dir/-d, --working-directory; accepted
|
||||
and ignored: --collect/-G, --quiet/-q, --unit/-u, --description, --property/-p. Anything else
|
||||
fails as systemd-run does on a host without a user manager.
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import socket
|
||||
import sys
|
||||
|
||||
VALUE = {"-E", "--setenv", "-u", "--unit", "--description", "-p", "--property", "--working-directory"}
|
||||
IGNORED = {"-G", "--collect", "-q", "--quiet", "-u", "--unit", "--description", "-p", "--property"}
|
||||
|
||||
|
||||
def fail(msg):
|
||||
print(msg, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
args = sys.argv[1:]
|
||||
user = wait = pipe = False
|
||||
env, cwd, i = {}, None, 0
|
||||
while i < len(args) and args[i].startswith("-"):
|
||||
arg = args[i]
|
||||
i += 1
|
||||
if arg == "--":
|
||||
break
|
||||
opt, eq, val = arg.partition("=")
|
||||
if opt in VALUE and not eq:
|
||||
if i == len(args):
|
||||
fail(f"Option '{opt}' requires an argument.")
|
||||
val, i = args[i], i + 1
|
||||
if opt == "--user":
|
||||
user = True
|
||||
elif opt == "--wait":
|
||||
wait = True
|
||||
elif opt in ("-P", "--pipe"):
|
||||
pipe = True
|
||||
elif opt in ("-E", "--setenv"):
|
||||
key, has, value = val.partition("=")
|
||||
env[key] = value if has else os.environ.get(key, "")
|
||||
elif opt in ("-d", "--same-dir"):
|
||||
cwd = os.getcwd()
|
||||
elif opt == "--working-directory":
|
||||
cwd = val
|
||||
elif opt not in IGNORED:
|
||||
fail(f"systemd-run (eac-openrc-compat): unsupported option '{arg}'.")
|
||||
cmd = args[i:]
|
||||
if not user:
|
||||
fail("System has not been booted with systemd as init system (PID 1). Can't operate.")
|
||||
if not cmd:
|
||||
fail("Command line to execute required.")
|
||||
|
||||
runtime = os.environ.get("XDG_RUNTIME_DIR") or f"/run/user/{os.getuid()}"
|
||||
sock = socket.socket(socket.AF_UNIX, socket.SOCK_SEQPACKET)
|
||||
try:
|
||||
sock.connect(os.path.join(runtime, "systemd-run-agent.sock"))
|
||||
except OSError as e:
|
||||
fail(f"Failed to connect to user scope bus: systemd-run-agent is not running ({e.strerror}).")
|
||||
request = json.dumps({"argv": cmd, "env": env, "cwd": cwd, "wait": wait}).encode()
|
||||
socket.send_fds(sock, [request], [0, 1, 2] if pipe else [])
|
||||
reply = sock.recv(65536)
|
||||
sys.exit(json.loads(reply)["status"] if reply else 1)
|
||||
@@ -0,0 +1,67 @@
|
||||
#!/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
|
||||
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.
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import socket
|
||||
import struct
|
||||
import subprocess
|
||||
import syslog
|
||||
import threading
|
||||
|
||||
runtime = os.environ.get("XDG_RUNTIME_DIR") or f"/run/user/{os.getuid()}"
|
||||
path = os.path.join(runtime, "systemd-run-agent.sock")
|
||||
syslog.openlog("systemd-run-agent")
|
||||
|
||||
|
||||
def exit_status(code):
|
||||
return code if code >= 0 else 128 - code
|
||||
|
||||
|
||||
def serve(conn):
|
||||
with conn:
|
||||
uid = struct.unpack("3i", conn.getsockopt(socket.SOL_SOCKET, socket.SO_PEERCRED, 12))[1]
|
||||
if uid != os.getuid():
|
||||
return
|
||||
data, fds, _, _ = socket.recv_fds(conn, 1 << 20, 3)
|
||||
if not data:
|
||||
return
|
||||
req = json.loads(data)
|
||||
stdio = fds if len(fds) == 3 else [subprocess.DEVNULL, None, None]
|
||||
try:
|
||||
proc = subprocess.Popen(req["argv"], stdin=stdio[0], stdout=stdio[1], stderr=stdio[2],
|
||||
env=dict(os.environ, **req["env"]), start_new_session=True,
|
||||
cwd=req["cwd"] or os.path.expanduser("~"))
|
||||
except OSError as e:
|
||||
syslog.syslog(f"{req['argv'][0]}: {e.strerror}")
|
||||
conn.send(json.dumps({"status": 127}).encode())
|
||||
return
|
||||
finally:
|
||||
for fd in fds:
|
||||
os.close(fd)
|
||||
syslog.syslog(f"pid {proc.pid}: {' '.join(req['argv'])}")
|
||||
if not req["wait"]:
|
||||
conn.send(json.dumps({"status": 0}).encode())
|
||||
status = exit_status(proc.wait())
|
||||
syslog.syslog(f"pid {proc.pid} exited with {status}")
|
||||
if req["wait"]:
|
||||
conn.send(json.dumps({"status": status}).encode())
|
||||
|
||||
|
||||
probe = socket.socket(socket.AF_UNIX, socket.SOCK_SEQPACKET)
|
||||
if probe.connect_ex(path) == 0:
|
||||
raise SystemExit("systemd-run-agent is already running")
|
||||
if os.path.exists(path):
|
||||
os.unlink(path)
|
||||
server = socket.socket(socket.AF_UNIX, socket.SOCK_SEQPACKET)
|
||||
server.bind(path)
|
||||
server.listen(16)
|
||||
syslog.syslog(f"listening on {path}")
|
||||
while True:
|
||||
conn, _ = server.accept()
|
||||
threading.Thread(target=serve, args=(conn,), daemon=True).start()
|
||||
@@ -0,0 +1,4 @@
|
||||
DIST cachyos-eac-signing-key-1-2-any.pkg.tar.zst 25931 BLAKE2B 7a333eb9b1988b334fcf7f14a7ef089fd81ae71f09a0954290ff63e8ff443c65ee21f1f3a8355d449aa1c92cdc4d8522bc24bc58c68962e0209f0e31493078b7 SHA512 061964faa8bb41b489a77bfa3b38ab56484d4e34578ecbfe8d184f3ee84acf0de5ffb59423f06fe02a55f4fc85ab08b368e32843186432f36a19426197ee993e
|
||||
DIST cachyos-settings-1.4.5-1-any.pkg.tar.zst 34054 BLAKE2B 1dd6b77c8367c2813fa8b946cba19f0ebba4f9597d629e46b3cbfffbc86cb92ea08ec0ad058a92422818e2cdbf919276e97b8edd211a5132d679e71d0653131d SHA512 d6cbfac39f3b4648e8a3bca5eda3311db8600d9118ab2a6099d3a5da11168d285963797ff1cbb6a8f9b35b2d7f3c8970502c276454c5ab40214de7894f229c0b
|
||||
DIST linux-cachyos-eac-7.3.5-2-x86_64.pkg.tar.zst 160513377 BLAKE2B bc19c6888b913c0175131dd5cb67029e36ad5016b13679b7f3d3c2ffd5f40c5a1f2ebf51916595baa530e6e48c92e693966ba759fe9b4e35b7a89e367e806575 SHA512 8819db16f28301f9a1908e2a53383fa512e93f1b799485c0e9650562e9fd6be4988a9d90a9a3581a06c159990aef694d8264594927fbea071cb835f99fb6c794
|
||||
DIST systemd-boot-cachyos-signed-262.2_1-1-x86_64.pkg.tar.zst 103982 BLAKE2B 132ec57dd05133a24f306f33728f61cb283bf3fb26d1b0e6fad6e8b10cabb2eefdf695a9bbcdaf4ca7dcfd07193582c9fb874401e85adfb2161cfe5eed0b1dda SHA512 7d56f609e5b7d17d8560c047041a7b347a040f5632ad99e136ebd78b5098b5f9083c2c39dc13ef420c853c23f50a6aa2a54dceb9ad69c38fc99fdbce4a2b2534
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
# Copyright 2026 Gentoo Authors
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
EAPI=8
|
||||
|
||||
MY_PV=${PV/_p/-}
|
||||
MY_KV=${MY_PV}-cachyos-eac
|
||||
SDBOOT_PV=262.2_1-1
|
||||
KEY_PV=1-2
|
||||
SETTINGS_PV=1.4.5-1
|
||||
MIRROR=https://mirror.cachyos.org/repo/x86_64/cachyos
|
||||
|
||||
DESCRIPTION="CachyOS-signed kernel and systemd-boot for Easy Anti-Cheat Linux v2"
|
||||
HOMEPAGE="https://wiki.cachyos.org/configuration/easy_anti_cheat/"
|
||||
SRC_URI="
|
||||
${MIRROR}/linux-cachyos-eac-${MY_PV}-x86_64.pkg.tar.zst
|
||||
${MIRROR}/systemd-boot-cachyos-signed-${SDBOOT_PV}-x86_64.pkg.tar.zst
|
||||
${MIRROR}/cachyos-eac-signing-key-${KEY_PV}-any.pkg.tar.zst
|
||||
${MIRROR}/cachyos-settings-1%3A${SETTINGS_PV}-any.pkg.tar.zst
|
||||
-> cachyos-settings-${SETTINGS_PV}-any.pkg.tar.zst
|
||||
"
|
||||
S=${WORKDIR}
|
||||
|
||||
LICENSE="GPL-2 LGPL-2.1+ GPL-3+ GPL-1"
|
||||
SLOT="0"
|
||||
KEYWORDS="~amd64"
|
||||
# Stripping or re-signing anything here breaks the CachyOS signatures EAC checks.
|
||||
RESTRICT="mirror strip"
|
||||
|
||||
RDEPEND="
|
||||
app-crypt/sbctl
|
||||
app-crypt/sbsigntools
|
||||
app-crypt/tpm2-tools
|
||||
dev-libs/openssl
|
||||
sys-apps/kmod[zstd]
|
||||
sys-boot/efibootmgr
|
||||
sys-kernel/dracut
|
||||
"
|
||||
BDEPEND="app-arch/zstd"
|
||||
|
||||
src_unpack() {
|
||||
local f
|
||||
for f in ${A}; do
|
||||
tar -xf "${DISTDIR}/${f}" || die "unpacking ${f} failed"
|
||||
done
|
||||
}
|
||||
|
||||
src_prepare() {
|
||||
default
|
||||
sed -i 's#esp=$(bootctl --print-esp-path 2>/dev/null || echo /boot)#esp=$(eac-boot esp)#' \
|
||||
usr/bin/eac-status || die
|
||||
grep -q 'esp=$(eac-boot esp)' usr/bin/eac-status || die "eac-status: ESP 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}"
|
||||
|
||||
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}
|
||||
insinto /var/lib/sbctl/keys/custom/db
|
||||
doins var/lib/sbctl/keys/custom/db/cachyos-eac-ca.der
|
||||
|
||||
dosbin usr/bin/eac-status "${FILESDIR}"/eac-boot
|
||||
dodoc "${FILESDIR}"/README.md
|
||||
}
|
||||
|
||||
pkg_postinst() {
|
||||
depmod -b "${EROOT:-/}" "${MY_KV}" || die
|
||||
|
||||
if [[ -z ${ROOT} && -d $(eac-boot esp 2>/dev/null)/EFI/cachyos-eac ]]; 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."
|
||||
elog "Boot it with eac-boot boot and check it with eac-status."
|
||||
elog "Details: README in ${EROOT}/usr/share/doc/${PF}/"
|
||||
fi
|
||||
}
|
||||
|
||||
pkg_postrm() {
|
||||
# depmod output is not owned by the package
|
||||
[[ -d ${EROOT}/lib/modules/${MY_KV}/kernel ]] || rm -rf "${EROOT}/lib/modules/${MY_KV}"
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
# cachyos-eac-kernel-bin
|
||||
|
||||
Repackages the CachyOS Easy Anti-Cheat Linux v2 boot chain unchanged:
|
||||
|
||||
| From CachyOS | Installed to |
|
||||
|---|---|
|
||||
| `linux-cachyos-eac` (kernel + signed modules) | `/lib/modules/<ver>-cachyos-eac/` (kernel at `vmlinuz`) |
|
||||
| `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`) |
|
||||
|
||||
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
|
||||
systemd-boot, fails the EAC checks.
|
||||
|
||||
## eac-boot
|
||||
|
||||
| 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 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 |
|
||||
|
||||
ESP layout (same as CachyOS with Limine, which `eac-status` checks):
|
||||
|
||||
```
|
||||
<esp>/<machine-id>/linux-cachyos-eac/{vmlinuz,initramfs}
|
||||
<esp>/EFI/cachyos-eac/systemd-bootx64.efi
|
||||
<esp>/loader/loader.conf
|
||||
<esp>/loader/entries/cachyos-eac.conf
|
||||
```
|
||||
|
||||
Settings:
|
||||
|
||||
- `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.
|
||||
|
||||
After the first `setup`, every package update runs `eac-boot update` from
|
||||
`pkg_postinst`.
|
||||
|
||||
## 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.
|
||||
`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`
|
||||
and no `SECUREBOOT_SIGN_KEY`, secureboot.eclass already uses
|
||||
`/var/lib/sbctl/keys/db/db.key`. Check with `sbverify --list <esp>/EFI/Gentoo/<kernel>.efi`.
|
||||
3. `eac-boot setup [bootnum]`. The entry goes to the end of BootOrder:
|
||||
firmware boot menus (F12) only list BootOrder entries, and at the end it
|
||||
never boots by default. `eac-boot boot` starts it once through BootNext.
|
||||
4. Have the BitLocker recovery key of the Windows disk ready, then enable Secure Boot in the firmware.
|
||||
5. `eac-boot boot`, then `eac-status` inside the EAC boot. Every check has to be `[ OK ]`.
|
||||
|
||||
The next normal reboot starts the default entry again.
|
||||
|
||||
## Not available in the EAC boot
|
||||
|
||||
- Modules not built by CachyOS: bcachefs, kvmfr and anything built by linux-mod-r1.
|
||||
- Lockdown integrity blocks MSR writes, `/dev/mem` and hibernation.
|
||||
|
||||
## Bumping
|
||||
|
||||
CachyOS removes old packages from the mirror. Rename the ebuild to the new kernel
|
||||
`<pkgver>_p<pkgrel>`, update `SDBOOT_PV`, `KEY_PV` and `SETTINGS_PV` from
|
||||
<https://mirror.cachyos.org/repo/x86_64/cachyos/>, then run `ebuild <file> manifest`.
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
#!/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).
|
||||
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
|
||||
|
||||
die() { echo "eac-boot: $*" >&2; exit 1; }
|
||||
|
||||
esp() {
|
||||
local d
|
||||
for d in ${EAC_ESP:-} /efi /boot/efi /boot; do
|
||||
[[ $(findmnt -no FSTYPE --mountpoint "$d" 2>/dev/null) == vfat ]] && { echo "$d"; return; }
|
||||
done
|
||||
die "no mounted vfat ESP found, set EAC_ESP"
|
||||
}
|
||||
|
||||
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"
|
||||
echo "${k##*/}"
|
||||
}
|
||||
|
||||
# Base command line from /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
|
||||
case $opt in BOOT_IMAGE=*|initrd=*) continue ;; esac
|
||||
[[ " $EAC_OPTS " == *" $opt "* ]] && continue
|
||||
out+=("$opt")
|
||||
done
|
||||
echo "${out[*]} $EAC_OPTS"
|
||||
}
|
||||
|
||||
bootnum() {
|
||||
efibootmgr | sed -n "s/^Boot\([0-9A-F]\{4\}\)\*\{0,1\} $LABEL\t.*/\1/p" | head -n1
|
||||
}
|
||||
|
||||
update() {
|
||||
local esp kv mid dir
|
||||
esp=$(esp)
|
||||
kv=$(kver)
|
||||
mid=$(</etc/machine-id)
|
||||
dir=$esp/$mid/linux-cachyos-eac
|
||||
mkdir -p "$dir" "$esp/EFI/cachyos-eac" "$esp/loader/entries"
|
||||
|
||||
dracut --force --hostonly --kver "$kv" "$dir/initramfs.new"
|
||||
install -m644 "/lib/modules/$kv/vmlinuz" "$dir/vmlinuz.new"
|
||||
mv -f "$dir/initramfs.new" "$dir/initramfs"
|
||||
mv -f "$dir/vmlinuz.new" "$dir/vmlinuz"
|
||||
install -m644 "$SDBOOT" "$esp/EFI/cachyos-eac/systemd-bootx64.efi"
|
||||
|
||||
printf 'title CachyOS (EAC)\nlinux /%s/linux-cachyos-eac/vmlinuz\ninitrd /%s/linux-cachyos-eac/initramfs\noptions %s\n' \
|
||||
"$mid" "$mid" "$(cmdline)" > "$esp/loader/entries/cachyos-eac.conf"
|
||||
printf 'default cachyos-eac.conf\ntimeout 0\n' > "$esp/loader/loader.conf"
|
||||
echo "eac-boot: $kv installed to $dir"
|
||||
}
|
||||
|
||||
# The whole db is rewritten: sbctl --append adds every key again, and firmware keeps duplicates.
|
||||
enroll() {
|
||||
sbctl enroll-keys --partial db --microsoft --custom --ignore-immutable
|
||||
}
|
||||
|
||||
# With a boot number, the entry is created there and replaces the entry that has it.
|
||||
setup() {
|
||||
local want=${1^^} have
|
||||
[[ -z $want || $want =~ ^[0-9A-F]{4}$ ]] || die "boot number must be 4 hex digits: $1"
|
||||
update
|
||||
have=$(bootnum)
|
||||
if [[ -n $have && ( -z $want || $have == "$want" ) ]]; then
|
||||
echo "eac-boot: firmware entry Boot$have \"$LABEL\" exists"
|
||||
else
|
||||
create "$have" "$want"
|
||||
fi
|
||||
bootorder_last
|
||||
}
|
||||
|
||||
# Firmware boot menus only list BootOrder entries; at the end it never boots by default.
|
||||
bootorder_last() {
|
||||
local n order
|
||||
n=$(bootnum)
|
||||
order=$(efibootmgr | sed -n 's/^BootOrder: //p')
|
||||
[[ ,$order, == *,$n,* ]] && return
|
||||
efibootmgr --bootorder "${order:+$order,}$n" >/dev/null
|
||||
echo "eac-boot: added Boot$n to the end of BootOrder"
|
||||
}
|
||||
|
||||
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")
|
||||
if [[ -n $old ]]; then
|
||||
efibootmgr -b "$want" -B >/dev/null
|
||||
echo "eac-boot: removed Boot$want \"$old\""
|
||||
fi
|
||||
fi
|
||||
esp=$(esp)
|
||||
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
|
||||
echo "eac-boot: created firmware entry Boot$(bootnum) \"$LABEL\""
|
||||
}
|
||||
|
||||
boot() {
|
||||
local n
|
||||
n=$(bootnum)
|
||||
[[ -n $n ]] || die "no \"$LABEL\" firmware entry, run: eac-boot setup"
|
||||
efibootmgr --bootnext "$n" >/dev/null
|
||||
reboot
|
||||
}
|
||||
|
||||
case ${1:-} in
|
||||
esp|cmdline) "$1"; exit ;;
|
||||
esac
|
||||
[[ $(id -u) == 0 ]] || die "run as root"
|
||||
case ${1:-} in
|
||||
enroll|update|boot) "$1" ;;
|
||||
setup) setup "${2:-}" ;;
|
||||
*) echo "usage: eac-boot {enroll|setup [bootnum]|update|boot|cmdline|esp}" >&2; exit 2 ;;
|
||||
esac
|
||||
Reference in New Issue
Block a user