mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
- [email protected], a template: devvm-cosign@run for the timer, and @check and @init for setting up. The keys are root's, mode 0600, and reach the service only as systemd's credentials (LoadCredential=), in a folder of its own while it runs; the base's key comes from a drop-in, devvm-cosign-base.conf, which install.sh installs once there is one, as a credential that isn't there fails the service. Its processes are in a PID namespace of their own (PrivatePIDs=), and any failure starts devvm-cosign-failed.service (OnFailure=). - devvm-cosign-podman.service, where a process that escapes a build's container lands: a PID namespace of its own, so no other process's /proc/<pid>/root; the config, the keys, every service's credentials and the whole state folder inaccessible; its HOME, with podman's config and storage, and its only writable folder, the build folder, /var/lib/devvm-cosign-build; StopWhenUnneeded=, so it runs only while a run needs it; each start deletes the whole build folder, podman's config first, then its images and containers (podman system reset), then the rest, so nothing a build left, a link or a config pointing podman at another runtime, reaches the next; and OnFailure=, as a run whose podman fails to start doesn't fail itself. - devvm-cosign-failed.service runs devvm-cosign failed, which tells the maintainer through the config's notify command, reading no key. - devvm-cosign.timer starts devvm-cosign@run hourly. - install.sh: 65536 subordinate IDs from the first multiple of 65536 above every range another user has in /etc/subuid or /etc/subgid, so no two users' containers share an ID; the state folder and the build folder, with the folders the units need; the config readable by the co-signer's group, for retry and ack; the old devvm-cosign.service removed. - Docs: contributing/cosigner.md for the new flow: what CI hands over, what a run does (the old step 8 split into the draft, the publish and the check after), refusals and alerts, retry, ack and notify through OnFailure (HTTPS, not a local sendmail, under NoNewPrivileges), the base's snapshot bound and why, its files, the config's new keys and the credentials' names and modes, the setup with the Go the tag's mise.lock pins (mise exec), the units, what a build's container can reach and what's still shared (the user and the machine: an escape can slow or change the build it's in, which then doesn't match, and use the network while that run lasts; a kernel escape gets past it all), the GitHub App's Actions: read and the tap ruleset's bypass, that the units name the folders, and moving machines by copying /var/lib/devvm-cosign but stage/, src/ and cache/. maintaining.md's Release keys say who publishes, as it is; structure.md's package row; the 0.2.0 page and the changelog line. Validated on Fedora 43 (SELinux enforcing, podman 5.6, systemd 258), in a throwaway Lima VM: install.sh, then check, init and a run under these units with rootless podman, against the fake GitHub over TLS with a throwaway v9.9.9 and throwaway keys. CI's build was release.sh --tag under rootless podman, handed over as an artifact; the co-signer cloned its root-owned checkout, rebuilt, matched, signed, made the release, published it and wrote both formulas, the same bytes as CI's build's. Both signatures verified with minisign, every file with SHA256SUMS, the podman unit stopped after the run, and a second run did nothing. During the build, from the podman service's namespaces as the co-signer's user: only the build's own processes were there, so release.sh's and the run's /proc/<pid>/root weren't; the state folder, the clone release.sh ran from and CI's staged files were refused; and only the build folder was writable; only SHA256SUMS and CI's signature were staged; and the build's finished files and the download cache were in the state folder. A second start of the podman service reset the last build's images and containers and left an empty build folder. A run failed with GitHub gone started devvm-cosign-failed, whose notify got the recorded failure, and a podman start that failed started it too. The first runs found three things the fake can't, fixed in the earlier commits: podman needs ~/.config, which install.sh now makes; system credentials are mode 0440 with an ACL; and the clone needs the checkout's .git named safe. The podman service's first ExecStartPre deletes the co-signer's user's /dev/shm/libpod* files, podman's locks, which outlive the service and no folder it empties holds (TestPodmanUnitStartsClean). cosigner.md also covers a build that keeps failing and GitHub's latest release. Co-Authored-By: Claude Opus 5.5 <[email protected]>
52 lines
2.2 KiB
Desktop File
52 lines
2.2 KiB
Desktop File
# devvm's co-signer, one devvm-cosign command per instance: [email protected], which
|
|
# devvm-cosign.timer starts hourly, and [email protected] and [email protected], which
|
|
# the maintainer starts once. docs/content/docs/contributing/cosigner.md sets it up.
|
|
[Unit]
|
|
Description=devvm's co-signer: %i
|
|
Documentation=https://devvm.dev/docs/contributing/cosigner/
|
|
Wants=network-online.target
|
|
After=network-online.target devvm-cosign-podman.service
|
|
Requires=devvm-cosign-podman.service
|
|
# Any failure, a killed or timed-out run's too, tells the maintainer, through the config's notify.
|
|
OnFailure=devvm-cosign-failed.service
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
User=devvm-cosign
|
|
Group=devvm-cosign
|
|
ExecStart=/usr/local/bin/devvm-cosign -config /etc/devvm-cosign/config.toml %i
|
|
# The keys are root's, mode 0600, so the co-signer's user can't read them: systemd copies each into
|
|
# this service's own credentials folder for as long as it runs, by its file's name, which
|
|
# devvm-cosign reads them from ($CREDENTIALS_DIRECTORY). The base's key, once there is one, comes
|
|
# from devvm-cosign-base.conf, a drop-in, as a credential that isn't there fails the service.
|
|
LoadCredential=release.key:/etc/devvm-cosign/release.key
|
|
LoadCredential=app.pem:/etc/devvm-cosign/app.pem
|
|
# release.sh's containers run in the rootless podman service of devvm-cosign-podman.service, as
|
|
# this service's NoNewPrivileges stops podman mapping a user namespace itself (newuidmap).
|
|
Environment=CONTAINER_HOST=unix:///run/devvm-cosign/podman.sock
|
|
# A release builds in well under an hour; release.sh stops its own containers after two.
|
|
TimeoutStartSec=3h
|
|
KillMode=mixed
|
|
UMask=0077
|
|
NoNewPrivileges=yes
|
|
ProtectSystem=strict
|
|
# The state folder, which no build can reach, and the build folder, which the builds write.
|
|
ReadWritePaths=/var/lib/devvm-cosign /var/lib/devvm-cosign-build
|
|
ProtectHome=yes
|
|
PrivateTmp=yes
|
|
# Its processes, release.sh and git among them, which are dumpable, can't be seen from outside it.
|
|
PrivatePIDs=yes
|
|
PrivateDevices=yes
|
|
ProtectKernelTunables=yes
|
|
ProtectKernelModules=yes
|
|
ProtectKernelLogs=yes
|
|
ProtectControlGroups=yes
|
|
ProtectClock=yes
|
|
ProtectHostname=yes
|
|
RestrictSUIDSGID=yes
|
|
RestrictRealtime=yes
|
|
LockPersonality=yes
|
|
CapabilityBoundingSet=
|
|
AmbientCapabilities=
|
|
SystemCallArchitectures=native
|