Stacked on #138 (feature/host-logins, now 4.51.0 on main's 4.50.0): this branch starts at its head. Merge #138 first; then this PR's diff is the live patch change alone.
get_kernel_facts() adds a live_patches key (NetOrk/netork#2701, decided 2026-11-28: A, then B for Canonical Livepatch first). Its parts:
loaded: every patch under /sys/kernel/livepatch, with enabled and transition. Generic, no package needed. None on a kernel built without live patching.
kpatch: kpatch list, the loaded modules with their state and the installed ones with their kernel. None without kpatch.
canonical: Canonical Livepatch's status for the running kernel, from canonical-livepatch status --format json. It has the kernel as Canonical names it, state, check_state, version, and the CVEs with whether each is patched. Both client formats are parsed: the 10.x list of fixes and the 9.x text, with keys in either case. None when the client is not installed or its status was not read. canonical_installed tells the two apart.
No network call: only status is run, which returns the daemon's last state. refresh (what contacts Canonical) is never run. Note: this is from the client's documented behaviour and the Ubuntu Pro client's use of the same command; it was not verified on a live Livepatch host.
Root: where the client is installed and its status does not read without root, a driver that supplies _run_livepatch_status_command(command) has LIVEPATCH_STATUS_COMMAND read again as root. This is one fixed, read-only command. A refusal leaves the status unread.
Exported: parse_canonical_status, canonical_release (Canonical's 5.15.0-91.101-generic as uname -r names it), LIVEPATCH_STATUS_COMMAND, LivePatchesDict, CanonicalLivepatchDict. KernelFactsDict.live_patches is NotRequired.
Tests: tests/test_live_patches.py with fixtures for sysfs, kpatch list, the 10.x and 9.x Canonical JSON, and the root fallback. tests/test_kernel_facts.py is unchanged and green. ruff and mypy are clean.
Version: 4.52.0, the next after this stack's 4.51.0 (v4.50.0 is #140's, merged into the stack).
**Stacked on #138** (`feature/host-logins`, now 4.51.0 on main's 4.50.0): this branch starts at its head. Merge #138 first; then this PR's diff is the live patch change alone.
`get_kernel_facts()` adds a `live_patches` key (NetOrk/netork#2701, decided 2026-11-28: A, then B for Canonical Livepatch first). Its parts:
- `loaded`: every patch under `/sys/kernel/livepatch`, with `enabled` and `transition`. Generic, no package needed. `None` on a kernel built without live patching.
- `kpatch`: `kpatch list`, the loaded modules with their state and the installed ones with their kernel. `None` without kpatch.
- `canonical`: Canonical Livepatch's status for the running kernel, from `canonical-livepatch status --format json`. It has the kernel as Canonical names it, `state`, `check_state`, `version`, and the CVEs with whether each is patched. Both client formats are parsed: the 10.x list of fixes and the 9.x text, with keys in either case. `None` when the client is not installed or its status was not read. `canonical_installed` tells the two apart.
- **No network call:** only `status` is run, which returns the daemon's last state. `refresh` (what contacts Canonical) is never run. Note: this is from the client's documented behaviour and the Ubuntu Pro client's use of the same command; it was not verified on a live Livepatch host.
- **Root:** where the client is installed and its status does not read without root, a driver that supplies `_run_livepatch_status_command(command)` has `LIVEPATCH_STATUS_COMMAND` read again as root. This is one fixed, read-only command. A refusal leaves the status unread.
- Exported: `parse_canonical_status`, `canonical_release` (Canonical's `5.15.0-91.101-generic` as `uname -r` names it), `LIVEPATCH_STATUS_COMMAND`, `LivePatchesDict`, `CanonicalLivepatchDict`. `KernelFactsDict.live_patches` is `NotRequired`.
Tests: `tests/test_live_patches.py` with fixtures for sysfs, `kpatch list`, the 10.x and 9.x Canonical JSON, and the root fallback. `tests/test_kernel_facts.py` is unchanged and green. ruff and mypy are clean.
Version: 4.52.0, the next after this stack's 4.51.0 (v4.50.0 is #140's, merged into the stack).
LoginAccountsMixin.get_login_accounts: root and UID 1000 on with a login
shell, from /etc/passwd without the comment field; the newest last login of
lastlog2, lastlog, wtmpdb last and last, with where it came from; the
password state and expiry from passwd -S and chage -l; the failed attempts
since the last login from lastb, else faillock. Root first, the login user
where root is refused, when what needs root is None.
/sys/kernel/livepatch with each patch's enabled and transition, kpatch
list, and Canonical Livepatch's status for the running kernel with the
CVEs it names. status reads the daemon's last state; refresh is never run.
Where the client is installed and its status needs root, a driver that
supplies _run_livepatch_status_command reads it again as root.
christianmanivong
changed title from feat(kernel): the live patches the running kernel carries, in the kernel facts, 4.51.0 (NetOrk/netork#2701) to feat(kernel): the live patches the running kernel carries, in the kernel facts, 4.52.0 (NetOrk/netork#2701)2026-11-28 07:28:13 +00:00
models.py had grown past its recorded size with the live patches;
KernelFactsDict moves to kernel_models, re-exported by models, and the
record shrinks to what is left (1336). The root read of Canonical's status
returns on a refusal instead of passing (bandit B110).
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Stacked on #138 (
feature/host-logins, now 4.51.0 on main's 4.50.0): this branch starts at its head. Merge #138 first; then this PR's diff is the live patch change alone.get_kernel_facts()adds alive_patcheskey (NetOrk/netork#2701, decided 2026-11-28: A, then B for Canonical Livepatch first). Its parts:loaded: every patch under/sys/kernel/livepatch, withenabledandtransition. Generic, no package needed.Noneon a kernel built without live patching.kpatch:kpatch list, the loaded modules with their state and the installed ones with their kernel.Nonewithout kpatch.canonical: Canonical Livepatch's status for the running kernel, fromcanonical-livepatch status --format json. It has the kernel as Canonical names it,state,check_state,version, and the CVEs with whether each is patched. Both client formats are parsed: the 10.x list of fixes and the 9.x text, with keys in either case.Nonewhen the client is not installed or its status was not read.canonical_installedtells the two apart.statusis run, which returns the daemon's last state.refresh(what contacts Canonical) is never run. Note: this is from the client's documented behaviour and the Ubuntu Pro client's use of the same command; it was not verified on a live Livepatch host._run_livepatch_status_command(command)hasLIVEPATCH_STATUS_COMMANDread again as root. This is one fixed, read-only command. A refusal leaves the status unread.parse_canonical_status,canonical_release(Canonical's5.15.0-91.101-genericasuname -rnames it),LIVEPATCH_STATUS_COMMAND,LivePatchesDict,CanonicalLivepatchDict.KernelFactsDict.live_patchesisNotRequired.Tests:
tests/test_live_patches.pywith fixtures for sysfs,kpatch list, the 10.x and 9.x Canonical JSON, and the root fallback.tests/test_kernel_facts.pyis unchanged and green. ruff and mypy are clean.Version: 4.52.0, the next after this stack's 4.51.0 (v4.50.0 is #140's, merged into the stack).
feat(kernel): the live patches the running kernel carries, in the kernel facts, 4.51.0 (NetOrk/netork#2701)to feat(kernel): the live patches the running kernel carries, in the kernel facts, 4.52.0 (NetOrk/netork#2701)