Ignore sudoers/fwupd.conf/polkit rules.d: system rewrites their modes, git cannot store 440/640/750 #43

Open
william wants to merge 10 commits from william/igor-etc-capture into main AGit
Member
No description provided.
william force-pushed william/igor-etc-capture from 9d6f5ab199 to 9de68b914e 2026-11-22 23:04:46 -08:00 Compare
@ -15,2 +16,4 @@
LimitMEMLOCK=infinity
# Run only on socket 0's cores (both hyperthreads), the socket the GPUs are attached to
AllowedCPUs=0-17,36-53
Owner

Wrap this in a toml condition matching host igor, we only want it for igor

Wrap this in a toml condition matching host igor, we only want it for igor
Author
Member

Already igor-only: llama-swap.container.tmpl is wrapped file-wide — {{- if eq .chezmoi.hostname "igor" -}} on L1, {{ end -}} at L67, so AllowedCPUs/NUMA render nowhere else. The diff hunk can't show the guard.

Already igor-only: llama-swap.container.tmpl is wrapped file-wide — {{- if eq .chezmoi.hostname "igor" -}} on L1, {{ end -}} at L67, so AllowedCPUs/NUMA render nowhere else. The diff hunk can't show the guard.
william-admin marked this conversation as resolved
@ -24,6 +27,9 @@ table inet filter {
tcp dport 10001-10009 accept
socket cgroupv2 level 2 @cg_llama_swap accept
}
chain input_william_ai {
Owner

This should be wrapped in an if check for igor

This should be wrapped in an if check for `igor`
Author
Member

Already guarded: chain input_william_ai (L30) is inside the igor block starting L25 (ends L40) with the pi-dev chain; its input_lo vmap entry 1001 also has its own igor guard (L44-47).

Already guarded: chain input_william_ai (L30) is inside the igor block starting L25 (ends L40) with the pi-dev chain; its input_lo vmap entry 1001 also has its own igor guard (L44-47).
william-admin marked this conversation as resolved
@ -11,6 +11,9 @@ table inet filter {
set cg_llama_swap {
type cgroupsv2
}
set cg_william_ai {
Owner

This should be wrapped in an if check for igor

This should be wrapped in an if check for `igor`
Author
Member

Already guarded: set cg_william_ai (L14) sits inside the existing {{- if eq .chezmoi.hostname "igor" }} block (L10-L17), same block as set cg_llama_swap. Diff hunk doesn't render the guard lines.

Already guarded: set cg_william_ai (L14) sits inside the existing {{- if eq .chezmoi.hostname "igor" }} block (L10-L17), same block as set cg_llama_swap. Diff hunk doesn't render the guard lines.
william-admin marked this conversation as resolved
william force-pushed william/igor-etc-capture from 9de68b914e to dd1c12c8e9 2026-11-22 23:11:24 -08:00 Compare
william force-pushed william/igor-etc-capture from dd1c12c8e9 to e71d56c147 2026-11-22 23:11:57 -08:00 Compare
william force-pushed william/igor-etc-capture from e71d56c147 to fe85de27f3 2026-11-22 23:12:12 -08:00 Compare
@ -143,2 +159,4 @@
oifname "lo" tcp dport 8800 accept comment "Allow bifrost locally"
oifname nlan tcp dport {3232,6053} accept comment "Allow esphome operation"
oifname nlan meta l4proto { icmp, icmpv6 } accept comment "allow icmp to nlan"
oifname lo socket cgroupv2 level 2 @cg_william_ai meta mark set 1001 accept
Owner

This should be wrapped in an if check for igor

This should be wrapped in an if check for `igor`
Author
Member

Already guarded: both lines (L161-162) are inside chain output_william_ai within the igor block {{ if eq .chezmoi.hostname "igor" -}} L147 ... {{- end }} L164.

Already guarded: both lines (L161-162) are inside chain output_william_ai within the igor block {{ if eq .chezmoi.hostname "igor" -}} L147 ... {{- end }} L164.
william-admin marked this conversation as resolved
run_ scripts re-execute on every apply and always show in diff, so they
cannot hide. An onchange_ script that writes /etc/sudoers itself lands
0440, passes diff/verify silently, and re-runs (content + chmod) only
when the content changes; visudo gates the result.

fwupd.conf carries no local content (identical to the package default)
and polkit's rules.d mode/group are re-enforced every boot by
/usr/lib/tmpfiles.d/polkit-tmpfiles.conf (0750 root:polkitd), a fight
chezmoi cannot win for a directory holding no rules. Both are
package-owned: untracked entirely.
william force-pushed william/igor-etc-capture from b5c1284cb3 to cc51f80858 2026-11-22 23:26:28 -08:00 Compare
Untracking them relied on the packages being installed with intact
files. An onchange_ script creates /etc/fwupd/fwupd.conf with our
content at 0640 and /etc/polkit-1/rules.d at 0750 root:polkitd, and
stays out of diff/verify once recorded (polkit's own tmpfiles re-locks
that dir every boot, which is why it must not be a plain tracked dir:
apply's 755 would fight tmpfiles forever).

tmpfiles.d z-lines re-heal sudoers/fwupd.conf modes at boot if they
ever fall back to stock 0644.
@ -0,0 +8,4 @@
# tmpfiles re-enforces that every boot, so we must not track it as a
# plain chezmoi dir (755) or apply would fight tmpfiles forever.
mkdir -p /etc/fwupd
printf '[fwupd]\n# use `man 5 fwupd.conf` for documentation\n' > /etc/fwupd/fwupd.conf
Owner

This won't fix the file contents if they change on disk after running. We need the change sanity at least for contents

This won't fix the file contents if they change on disk after running. We need the change sanity at least for contents
Owner

or are the contents still preserved? Won't this not run if we change the fwupd.conf file in chezetc or on disk?

or are the contents still preserved? Won't this not run if we change the fwupd.conf file in chezetc or on disk?
Author
Member

Done: fwupd.conf is a plain tracked file again, so on-disk content drift is detected and healed by apply. Ack the tradeoff: apply re-stores 644 (git cannot record 640); nothing enforces 640 and the root-run daemon does not care.

Done: fwupd.conf is a plain tracked file again, so on-disk content drift is detected and healed by apply. Ack the tradeoff: apply re-stores 644 (git cannot record 640); nothing enforces 640 and the root-run daemon does not care.
Author
Member

Answer to both questions: onchange_ re-runs when the script content changes, so editing fwupd.conf required editing the script (bad), and yes, drift on disk was never noticed (worse). Fixed: fwupd.conf is now a plain tracked file with normal apply-time content checking; the onchange_ script only guarantees polkit rules.d existence/mode now.

Answer to both questions: onchange_ re-runs when the *script* content changes, so editing fwupd.conf required editing the script (bad), and yes, drift on disk was never noticed (worse). Fixed: fwupd.conf is now a plain tracked file with normal apply-time content checking; the onchange_ script only guarantees polkit rules.d existence/mode now.
@ -40,2 +46,4 @@
1001 : jump input_william_ai,
{{- end }}
}
{{- if eq .chezmoi.hostname "igor" }}
Owner

This is not igor specific, all nodes should have this

This is not igor specific, all nodes should have this
Author
Member

Done (315d5c9): set cg_william_ai, chain input_william_ai and the 1001 vmap entry are now unguarded (all nodes). Kept igor-only: llama-swap/DNS/pi-dev rules and the output-side rules (output_william_ai + mark-set), which reference igor-only chains/sets; on other hosts the input-side mark never gets set, so the accept chain is inert without the igor-only output path. Renders verified nft -c as igor and as a hypothetical non-igor host.

Done (315d5c9): set cg_william_ai, chain input_william_ai and the 1001 vmap entry are now unguarded (all nodes). Kept igor-only: llama-swap/DNS/pi-dev rules and the output-side rules (output_william_ai + mark-set), which reference igor-only chains/sets; on other hosts the input-side mark never gets set, so the accept chain is inert without the igor-only output path. Renders verified nft -c as igor and as a hypothetical non-igor host.
@ -0,0 +1,4 @@
# Daemons require stricter modes than git can store in chezmoi.
Owner

Just drop this, it's okay to not set these at boot

Just drop this, it's okay to not set these at boot
Author
Member

Done: tmpfiles.d/99-wak-modes.conf dropped (and removed from this host).

Done: tmpfiles.d/99-wak-modes.conf dropped (and removed from this host).
william force-pushed william/igor-etc-capture from 9cf08ffe07 to 315d5c9bc7 2026-11-23 00:03:20 -08:00 Compare
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/43/head:william/igor-etc-capture'
git switch 'william/igor-etc-capture'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'william/igor-etc-capture'
git switch 'william/igor-etc-capture'
git rebase 'main'
git switch 'main'
git merge --ff-only 'william/igor-etc-capture'
git switch 'william/igor-etc-capture'
git rebase 'main'
git switch 'main'
git merge --no-ff 'william/igor-etc-capture'
git switch 'main'
git merge --squash 'william/igor-etc-capture'
git switch 'main'
git merge --ff-only 'william/igor-etc-capture'
git switch 'main'
git merge 'william/igor-etc-capture'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
wak/chezetc-wak!43
No description provided.