Files
w3cjandClaude Opus 5.5 2b68a2347c feat(gitprotect): .git protection on Linux without root, through a user namespace around QEMU
On Linux, a start of a VM whose protection is on pins .git, its git dirs
and every lock path read-only in a user and mount namespace that devvm
_qemu pinned makes around QEMU. It keeps the pins while QEMU runs, records
each re-pin, refuses hard links and fails closed on watches and records;
doctor says why a host can't lock, and such hosts watch .git instead. The
pins' events file is read through safefile, and the command-line check
takes "devvm lock" in prose as English.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 10:06:17 -07:00

34 lines
1.1 KiB
Go

package cli
import (
"errors"
"testing"
)
// doctor's warning names why this host can't lock .git: the kernel's
// setting, else the probe's error; none where it can, or off Linux.
func TestPinsWarning(t *testing.T) {
refused := errors.New("operation not permitted")
for _, tc := range []struct {
probe func() error
limit string
want string
}{
{nil, "", ""},
{func() error { return nil }, "apparmor", ""},
{func() error { return refused }, "apparmor", "doctor_pins_apparmor"},
{func() error { return refused }, "sysctl", "doctor_pins_sysctl"},
{func() error { return refused }, "max", "doctor_pins_max"},
{func() error { return refused }, "", "doctor_pins_failed reason=operation not permitted"},
} {
c := pinsCheck{Probe: tc.probe, Limit: func() string { return tc.limit }}
m, ok := c.warning()
if got := m.Names(); ok != (tc.want != "") || ok && got != tc.want {
t.Errorf("limit %q: %q (%t), want %q", tc.limit, got, ok, tc.want)
}
}
if c := newPinsCheck(nil); c.Probe != nil || c.Limit == nil {
t.Error("a check without a registry probes")
}
}