ci: boot the published layer without root on keel-lxc-1 #16
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Keel-Linux/.github!16
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "ci/unprivileged-boot-test"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
The runner
keel-lxc-1reached root through sudo:apt-get, thelxc-*commands and the two root helperskeel-ci-boot-testandkeel-ci-cleanup. Each of those is root-equivalent (install any .deb, a custom LXC config mounting host paths,lxc-attach), so any job on the runner could become root on the public services VM that also serves keellinux.org, archive, mirror and releases.What changes
bin/unprivileged-lxc run SCRATCH -- tests/boot-test.sh ...runs the repository's own boot test, unchanged, as root in a user namespace (lxc-usernsexec) mapped onto the runner's subordinate ids (runner:165536:65536), which are also the ids the container runs as. The assembled rootfs therefore has the owners the container sees. The runner's uid is mapped in at 65536, so the workspace and scratch tree stay writable.lxcbr0or enter a container's cgroup. The test'slxc-*commands are links to the same script that forward to a broker outside the namespace, running as the runner:lxc-startgetsuserns.conf, thelxc.idmapand the AppArmor profilelxc-container-default-with-nestingon top of the config the test wrote, insidesystemd-run --user --scope -p Delegate=yes;lxc-attachruns in a scope of the same user manager and gets the stdin the test piped to it (keel-mariadb pipes SQL).taris a link too, because a user namespace may not create device nodes. It forgives exactly that refusal, and fails if anything else is mixed in. LXC mounts its own/devover the rootfs anyway.unprivileged-lxc cleanupremoves the subuid-owned scratch tree through the same namespace. The cleanup step no longer uses sudo.tests/boot-test.shin the appliance repositories needs to change. The job id and the check nameappliance / boot-published-layerare unchanged.build-deb.ymlstill callssudo apt-get. Nothing calls it, andprofile/WORKFLOWS.mdnow says it has to move into an unprivileged container first.The host side (subuid,
lxc-usernet, the runner's LXC default config, linger, removal of/etc/sudoers.d/runnerand the root helpers) is recorded in docs/ci-cd.md section 6 of the keel repository.Evidence
tests/unprivileged-lxc.bats, 22 cases.tests/coverage.shlocally: 100 percent ofbin/unprivileged-lxc(124/124), total 100.runner, without sudo: keel-core'stests/boot-test.shagainst the publishedcorelayer passed in 27 s. The assemble skipped 9 device nodes, the container had a ULA address in 6 s, first boot finished 5 s later,keel diffreported 6 same and 0 drift, and cleanup removed the tree.appliance / boot-published-layeragainst this branch (tooling_refset to it, temporary caller branch since deleted), on keel-lxc-1:/etc/sudoers.d/runnerand both root helpers were removed: https://github.com/Keel-Linux/keel-core/actions/runs/36814955977, green in 44 s, the container up with an address in 6 s, first boot finished 5 s later,keel diff6 same 0 drift, 0 monitors left.Test plan
lint / actionlintandtests / coveragegreenappliance / boot-published-layergreen from main