diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-08-01 18:58:42 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-08-01 18:59:06 +0900 |
| commit | 547a2adaa488556f0504e186c5c1dfb0e679c935 (patch) | |
| tree | 8c2f0fd5190d3e460672f5f7be50024baac15372 /container/container_test.go | |
| parent | c02948e1557551a94b5366bf186148b8275598c1 (diff) | |
container/mount: pass tmpfs flags
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/container_test.go')
| -rw-r--r-- | container/container_test.go | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/container/container_test.go b/container/container_test.go index 190fa5b5..bc4999e5 100644 --- a/container/container_test.go +++ b/container/container_test.go @@ -28,7 +28,9 @@ const ( ignore = "\x00" ignoreV = -1 - pathWantMnt = "/etc/hakurei/want-mnt" + pathPrefix = "/etc/hakurei/" + pathWantMnt = pathPrefix + "want-mnt" + pathReadonly = pathPrefix + "readonly" ) var containerTestCases = []struct { @@ -62,7 +64,7 @@ var containerTestCases = []struct { new(container.Ops). Tmpfs(hst.Tmp, 0, 0755), []*vfs.MountInfoEntry{ - ent("/", hst.Tmp, "rw,nosuid,nodev,relatime", "tmpfs", "tmpfs", ignore), + ent("/", hst.Tmp, "rw,nosuid,nodev,relatime", "tmpfs", "ephemeral", ignore), }, 9, 9, nil, 0, seccomp.PresetStrict}, {"dev", true, true /* go test output is not a tty */, false, @@ -140,6 +142,7 @@ func TestContainer(t *testing.T) { c.HostNet = tc.net c. + Readonly(pathReadonly, 0755). Tmpfs("/tmp", 0, 0755). Place("/etc/hostname", []byte(c.Hostname)) // needs /proc to check mountinfo @@ -158,8 +161,10 @@ func TestContainer(t *testing.T) { } mnt = append(mnt, tc.mnt...) mnt = append(mnt, + // Readonly(pathReadonly, 0755) + ent("/", pathReadonly, "ro,nosuid,nodev", "tmpfs", "readonly", ignore), // Tmpfs("/tmp", 0, 0755) - ent("/", "/tmp", "rw,nosuid,nodev,relatime", "tmpfs", "tmpfs", ignore), + ent("/", "/tmp", "rw,nosuid,nodev,relatime", "tmpfs", "ephemeral", ignore), // Place("/etc/hostname", []byte(hostname)) ent(ignore, "/etc/hostname", "ro,nosuid,nodev,relatime", "tmpfs", "rootfs", ignore), // Proc("/proc") @@ -309,6 +314,10 @@ func init() { return fmt.Errorf("/etc/hostname: %q, want %q", string(p), wantHost) } + if _, err := os.Create(pathReadonly + "/nonexistent"); !errors.Is(err, syscall.EROFS) { + return err + } + { var fail bool |
