Review: enroll keeps foreign db keys, configurable paths, on-demand eac-run, launcher ebuild, db dedupe tool

This commit is contained in:
2026-12-04 08:35:52 +01:00
parent dec92adb08
commit 7cf69ae701
18 changed files with 509 additions and 122 deletions
+1
View File
@@ -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.<uid>.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 |
+33 -1
View File
@@ -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}-<guid> 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("<III", b, i + 16)
if lsize < 28:
break
header, keep, j = b[i + 28:i + 28 + hsize], [], i + 28 + hsize
while j + ssize <= i + lsize:
sig = b[j:j + ssize]
if (stype, sig[16:]) not in seen:
seen.add((stype, sig[16:]))
keep.append(sig)
j += ssize
if keep:
out += stype + struct.pack("<III", 28 + hsize + len(keep) * ssize, hsize, ssize) + header + b"".join(keep)
i += lsize
return out
def load(path):
blob = open(path, "rb").read()
return blob if path.endswith(".esl") else blob[4:]
@@ -49,12 +72,21 @@ def selftest():
lst = SHA256 + struct.pack("<III", 28 + 2 * len(sig), 0, len(sig)) + 2 * sig
found = list(entries(lst))
assert len(found) == 2 and len({f[0] for f in found}) == 1
other = SHA256 + struct.pack("<III", 28 + len(sig), 0, len(sig)) + b"\1" * 16 + b"\x22" * 32
once = unique(lst + other + lst)
assert [f[0] for f in entries(once)] == [found[0][0], hashlib.sha256(b"\x22" * 32).hexdigest()[:12]]
assert once == SHA256 + struct.pack("<III", 28 + len(sig), 0, len(sig)) + sig + other
print("selftest ok")
if __name__ == "__main__":
if len(sys.argv) == 1:
selftest()
if sys.argv[1:2] == ["--unique"]:
if len(sys.argv) != 4:
sys.exit("usage: efi-sig-list.py --unique OUT.esl FILE")
open(sys.argv[2], "wb").write(unique(load(sys.argv[3])))
sys.argv[1:] = [sys.argv[2]]
for path in sys.argv[1:]:
found = list(entries(load(path)))
print(f"{path}: {len(found)} entries, {len({f[0] for f in found})} unique")