diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-06-17 02:59:48 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-06-17 02:59:48 +0900 |
| commit | 08112f0b906947bbaf82e450b19c5e0ea8b3fb4d (patch) | |
| tree | dc14cb72cd6d77cf91fdd73fef19dea9356edded /hst | |
| parent | e1a1e1e3996b4a7669de6b3c70fb0750d1841311 (diff) | |
hst: optionally cover /run/ early
This works around awkward root permissions.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'hst')
| -rw-r--r-- | hst/container.go | 10 | ||||
| -rw-r--r-- | hst/container_test.go | 6 | ||||
| -rw-r--r-- | hst/hst_test.go | 1 |
3 files changed, 14 insertions, 3 deletions
diff --git a/hst/container.go b/hst/container.go index f985f393..a34efc32 100644 --- a/hst/container.go +++ b/hst/container.go @@ -69,6 +69,8 @@ const ( // FDevice mount /dev/ from the init mount namespace as is in the container // mount namespace. FDevice + // FCoverRun covers /run/ in the container mount namespace early. + FCoverRun // FShareRuntime shares XDG_RUNTIME_DIR between containers under the same identity. FShareRuntime @@ -101,6 +103,8 @@ func (flags Flags) String() string { return "mapuid" case FDevice: return "device" + case FCoverRun: + return "cover_run" case FShareRuntime: return "runtime" case FShareTmpdir: @@ -196,6 +200,8 @@ type containerConfigJSON = struct { // Corresponds to [FDevice]. Device bool `json:"device,omitempty"` + // Corresponds to [FCoverRun]. + CoverRun bool `json:"cover_run,omitempty"` // Corresponds to [FShareRuntime]. ShareRuntime bool `json:"share_runtime,omitempty"` @@ -219,6 +225,7 @@ func (c *ContainerConfig) MarshalJSON() ([]byte, error) { Multiarch: c.Flags&FMultiarch != 0, MapRealUID: c.Flags&FMapRealUID != 0, Device: c.Flags&FDevice != 0, + CoverRun: c.Flags&FCoverRun != 0, ShareRuntime: c.Flags&FShareRuntime != 0, ShareTmpdir: c.Flags&FShareTmpdir != 0, }) @@ -262,6 +269,9 @@ func (c *ContainerConfig) UnmarshalJSON(data []byte) error { if v.Device { c.Flags |= FDevice } + if v.CoverRun { + c.Flags |= FCoverRun + } if v.ShareRuntime { c.Flags |= FShareRuntime } diff --git a/hst/container_test.go b/hst/container_test.go index df84827e..309c0a63 100644 --- a/hst/container_test.go +++ b/hst/container_test.go @@ -21,8 +21,8 @@ func TestFlagsString(t *testing.T) { }{ {"none", 0, "none"}, {"none high", hst.FAll + 1, "none"}, - {"all", hst.FAll, "multiarch, compat, devel, userns, net, abstract, tty, mapuid, device, runtime, tmpdir"}, - {"all high", math.MaxUint, "multiarch, compat, devel, userns, net, abstract, tty, mapuid, device, runtime, tmpdir"}, + {"all", hst.FAll, "multiarch, compat, devel, userns, net, abstract, tty, mapuid, device, cover_run, runtime, tmpdir"}, + {"all high", math.MaxUint, "multiarch, compat, devel, userns, net, abstract, tty, mapuid, device, cover_run, runtime, tmpdir"}, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { @@ -53,7 +53,7 @@ func TestContainerConfig(t *testing.T) { {"hostnet hostabstract mapuid", &hst.ContainerConfig{Flags: hst.FHostNet | hst.FHostAbstract | hst.FMapRealUID}, `{"env":null,"filesystem":null,"shell":null,"home":null,"args":null,"host_net":true,"host_abstract":true,"map_real_uid":true}`}, {"all", &hst.ContainerConfig{Flags: hst.FAll}, - `{"env":null,"filesystem":null,"shell":null,"home":null,"args":null,"seccomp_compat":true,"devel":true,"userns":true,"host_net":true,"host_abstract":true,"tty":true,"multiarch":true,"map_real_uid":true,"device":true,"share_runtime":true,"share_tmpdir":true}`}, + `{"env":null,"filesystem":null,"shell":null,"home":null,"args":null,"seccomp_compat":true,"devel":true,"userns":true,"host_net":true,"host_abstract":true,"tty":true,"multiarch":true,"map_real_uid":true,"device":true,"cover_run":true,"share_runtime":true,"share_tmpdir":true}`}, } for _, tc := range testCases { diff --git a/hst/hst_test.go b/hst/hst_test.go index 54a81284..c5e2cb12 100644 --- a/hst/hst_test.go +++ b/hst/hst_test.go @@ -245,6 +245,7 @@ func TestTemplate(t *testing.T) { "multiarch": true, "map_real_uid": true, "device": true, + "cover_run": true, "share_runtime": true, "share_tmpdir": true } |
