internal/env: cleaner runtime dir fallback
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m16s
Test / Hakurei (push) Successful in 3m10s
Test / Hpkg (push) Successful in 4m1s
Test / Sandbox (race detector) (push) Successful in 4m14s
Test / Hakurei (race detector) (push) Successful in 4m57s
Test / Flake checks (push) Successful in 1m28s
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m16s
Test / Hakurei (push) Successful in 3m10s
Test / Hpkg (push) Successful in 4m1s
Test / Sandbox (race detector) (push) Successful in 4m14s
Test / Hakurei (race detector) (push) Successful in 4m57s
Test / Flake checks (push) Successful in 1m28s
This now places rundir inside the fallback runtime dir, so special case in internal/outcome is avoided. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
parent
e7fc311d0b
commit
f33aea9ff9
5
internal/env/env.go
vendored
5
internal/env/env.go
vendored
@ -29,12 +29,11 @@ func (env *Paths) Copy(v *hst.Paths, userid int) {
|
|||||||
|
|
||||||
if env.RuntimePath == nil {
|
if env.RuntimePath == nil {
|
||||||
// fall back to path in share since hakurei has no hard XDG dependency
|
// fall back to path in share since hakurei has no hard XDG dependency
|
||||||
v.RunDirPath = v.SharePath.Append("run")
|
v.RuntimePath = v.SharePath.Append("compat")
|
||||||
v.RuntimePath = v.RunDirPath.Append("compat")
|
|
||||||
} else {
|
} else {
|
||||||
v.RuntimePath = env.RuntimePath
|
v.RuntimePath = env.RuntimePath
|
||||||
v.RunDirPath = env.RuntimePath.Append("hakurei")
|
|
||||||
}
|
}
|
||||||
|
v.RunDirPath = v.RuntimePath.Append("hakurei")
|
||||||
}
|
}
|
||||||
|
|
||||||
// CopyPaths returns a populated [Paths].
|
// CopyPaths returns a populated [Paths].
|
||||||
|
|||||||
4
internal/env/env_test.go
vendored
4
internal/env/env_test.go
vendored
@ -35,8 +35,8 @@ func TestPaths(t *testing.T) {
|
|||||||
}, hst.Paths{
|
}, hst.Paths{
|
||||||
TempDir: fhs.AbsTmp,
|
TempDir: fhs.AbsTmp,
|
||||||
SharePath: fhs.AbsTmp.Append("hakurei.3735928559"),
|
SharePath: fhs.AbsTmp.Append("hakurei.3735928559"),
|
||||||
RuntimePath: fhs.AbsTmp.Append("hakurei.3735928559/run/compat"),
|
RuntimePath: fhs.AbsTmp.Append("hakurei.3735928559/compat"),
|
||||||
RunDirPath: fhs.AbsTmp.Append("hakurei.3735928559/run"),
|
RunDirPath: fhs.AbsTmp.Append("hakurei.3735928559/compat/hakurei"),
|
||||||
}, ""},
|
}, ""},
|
||||||
|
|
||||||
{"full", &env.Paths{
|
{"full", &env.Paths{
|
||||||
|
|||||||
@ -68,10 +68,10 @@ func TestOutcomeMain(t *testing.T) {
|
|||||||
).
|
).
|
||||||
|
|
||||||
// ensureRuntimeDir
|
// ensureRuntimeDir
|
||||||
Ensure(m("/run/user/1971/hakurei"), 0700).
|
|
||||||
UpdatePermType(system.User, m("/run/user/1971/hakurei"), acl.Execute).
|
|
||||||
Ensure(m("/run/user/1971"), 0700).
|
Ensure(m("/run/user/1971"), 0700).
|
||||||
UpdatePermType(system.User, m("/run/user/1971"), acl.Execute).
|
UpdatePermType(system.User, m("/run/user/1971"), acl.Execute).
|
||||||
|
Ensure(m("/run/user/1971/hakurei"), 0700).
|
||||||
|
UpdatePermType(system.User, m("/run/user/1971/hakurei"), acl.Execute).
|
||||||
|
|
||||||
// runtime
|
// runtime
|
||||||
Ephemeral(system.Process, m("/run/user/1971/hakurei/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), 0700).
|
Ephemeral(system.Process, m("/run/user/1971/hakurei/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), 0700).
|
||||||
@ -347,8 +347,8 @@ func TestOutcomeMain(t *testing.T) {
|
|||||||
Ensure(m("/tmp/hakurei.0/tmpdir/9"), 01700).UpdatePermType(system.User, m("/tmp/hakurei.0/tmpdir/9"), acl.Read, acl.Write, acl.Execute).
|
Ensure(m("/tmp/hakurei.0/tmpdir/9"), 01700).UpdatePermType(system.User, m("/tmp/hakurei.0/tmpdir/9"), acl.Read, acl.Write, acl.Execute).
|
||||||
Ephemeral(system.Process, m("/tmp/hakurei.0/ebf083d1b175911782d413369b64ce7c"), 0711).
|
Ephemeral(system.Process, m("/tmp/hakurei.0/ebf083d1b175911782d413369b64ce7c"), 0711).
|
||||||
Wayland(m("/tmp/hakurei.0/ebf083d1b175911782d413369b64ce7c/wayland"), m("/run/user/1971/wayland-0"), "org.chromium.Chromium", "ebf083d1b175911782d413369b64ce7c").
|
Wayland(m("/tmp/hakurei.0/ebf083d1b175911782d413369b64ce7c/wayland"), m("/run/user/1971/wayland-0"), "org.chromium.Chromium", "ebf083d1b175911782d413369b64ce7c").
|
||||||
Ensure(m("/run/user/1971/hakurei"), 0700).UpdatePermType(system.User, m("/run/user/1971/hakurei"), acl.Execute).
|
|
||||||
Ensure(m("/run/user/1971"), 0700).UpdatePermType(system.User, m("/run/user/1971"), acl.Execute). // this is ordered as is because the previous Ensure only calls mkdir if XDG_RUNTIME_DIR is unset
|
Ensure(m("/run/user/1971"), 0700).UpdatePermType(system.User, m("/run/user/1971"), acl.Execute). // this is ordered as is because the previous Ensure only calls mkdir if XDG_RUNTIME_DIR is unset
|
||||||
|
Ensure(m("/run/user/1971/hakurei"), 0700).UpdatePermType(system.User, m("/run/user/1971/hakurei"), acl.Execute).
|
||||||
Ephemeral(system.Process, m("/run/user/1971/hakurei/ebf083d1b175911782d413369b64ce7c"), 0700).UpdatePermType(system.Process, m("/run/user/1971/hakurei/ebf083d1b175911782d413369b64ce7c"), acl.Execute).
|
Ephemeral(system.Process, m("/run/user/1971/hakurei/ebf083d1b175911782d413369b64ce7c"), 0700).UpdatePermType(system.Process, m("/run/user/1971/hakurei/ebf083d1b175911782d413369b64ce7c"), acl.Execute).
|
||||||
Link(m("/run/user/1971/pulse/native"), m("/run/user/1971/hakurei/ebf083d1b175911782d413369b64ce7c/pulse")).
|
Link(m("/run/user/1971/pulse/native"), m("/run/user/1971/hakurei/ebf083d1b175911782d413369b64ce7c/pulse")).
|
||||||
MustProxyDBus(&hst.BusConfig{
|
MustProxyDBus(&hst.BusConfig{
|
||||||
@ -499,8 +499,8 @@ func TestOutcomeMain(t *testing.T) {
|
|||||||
Ensure(m("/tmp/hakurei.0/runtime/1"), 0700).UpdatePermType(system.User, m("/tmp/hakurei.0/runtime/1"), acl.Read, acl.Write, acl.Execute).
|
Ensure(m("/tmp/hakurei.0/runtime/1"), 0700).UpdatePermType(system.User, m("/tmp/hakurei.0/runtime/1"), acl.Read, acl.Write, acl.Execute).
|
||||||
Ensure(m("/tmp/hakurei.0/tmpdir"), 0700).UpdatePermType(system.User, m("/tmp/hakurei.0/tmpdir"), acl.Execute).
|
Ensure(m("/tmp/hakurei.0/tmpdir"), 0700).UpdatePermType(system.User, m("/tmp/hakurei.0/tmpdir"), acl.Execute).
|
||||||
Ensure(m("/tmp/hakurei.0/tmpdir/1"), 01700).UpdatePermType(system.User, m("/tmp/hakurei.0/tmpdir/1"), acl.Read, acl.Write, acl.Execute).
|
Ensure(m("/tmp/hakurei.0/tmpdir/1"), 01700).UpdatePermType(system.User, m("/tmp/hakurei.0/tmpdir/1"), acl.Read, acl.Write, acl.Execute).
|
||||||
Ensure(m("/run/user/1971/hakurei"), 0700).UpdatePermType(system.User, m("/run/user/1971/hakurei"), acl.Execute).
|
|
||||||
Ensure(m("/run/user/1971"), 0700).UpdatePermType(system.User, m("/run/user/1971"), acl.Execute). // this is ordered as is because the previous Ensure only calls mkdir if XDG_RUNTIME_DIR is unset
|
Ensure(m("/run/user/1971"), 0700).UpdatePermType(system.User, m("/run/user/1971"), acl.Execute). // this is ordered as is because the previous Ensure only calls mkdir if XDG_RUNTIME_DIR is unset
|
||||||
|
Ensure(m("/run/user/1971/hakurei"), 0700).UpdatePermType(system.User, m("/run/user/1971/hakurei"), acl.Execute).
|
||||||
UpdatePermType(hst.EWayland, m("/run/user/1971/wayland-0"), acl.Read, acl.Write, acl.Execute).
|
UpdatePermType(hst.EWayland, m("/run/user/1971/wayland-0"), acl.Read, acl.Write, acl.Execute).
|
||||||
Ephemeral(system.Process, m("/run/user/1971/hakurei/8e2c76b066dabe574cf073bdb46eb5c1"), 0700).UpdatePermType(system.Process, m("/run/user/1971/hakurei/8e2c76b066dabe574cf073bdb46eb5c1"), acl.Execute).
|
Ephemeral(system.Process, m("/run/user/1971/hakurei/8e2c76b066dabe574cf073bdb46eb5c1"), 0700).UpdatePermType(system.Process, m("/run/user/1971/hakurei/8e2c76b066dabe574cf073bdb46eb5c1"), acl.Execute).
|
||||||
Link(m("/run/user/1971/pulse/native"), m("/run/user/1971/hakurei/8e2c76b066dabe574cf073bdb46eb5c1/pulse")).
|
Link(m("/run/user/1971/pulse/native"), m("/run/user/1971/hakurei/8e2c76b066dabe574cf073bdb46eb5c1/pulse")).
|
||||||
|
|||||||
@ -196,10 +196,10 @@ func (state *outcomeStateSys) ensureRuntimeDir() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
state.useRuntimeDir = true
|
state.useRuntimeDir = true
|
||||||
state.sys.Ensure(state.sc.RunDirPath, 0700)
|
state.sys.
|
||||||
state.sys.UpdatePermType(system.User, state.sc.RunDirPath, acl.Execute)
|
// ensure this dir in case XDG_RUNTIME_DIR is unset
|
||||||
state.sys.Ensure(state.sc.RuntimePath, 0700) // ensure this dir in case XDG_RUNTIME_DIR is unset
|
Ensure(state.sc.RuntimePath, 0700).UpdatePermType(system.User, state.sc.RuntimePath, acl.Execute).
|
||||||
state.sys.UpdatePermType(system.User, state.sc.RuntimePath, acl.Execute)
|
Ensure(state.sc.RunDirPath, 0700).UpdatePermType(system.User, state.sc.RunDirPath, acl.Execute)
|
||||||
}
|
}
|
||||||
|
|
||||||
// instance returns the pathname to a process-specific directory within TMPDIR.
|
// instance returns the pathname to a process-specific directory within TMPDIR.
|
||||||
|
|||||||
@ -127,10 +127,10 @@ func TestSpPulseOp(t *testing.T) {
|
|||||||
call("open", stub.ExpectArgs{"/proc/nonexistent/cookie"}, &stubOsFile{Reader: bytes.NewReader(sampleCookie)}, nil),
|
call("open", stub.ExpectArgs{"/proc/nonexistent/cookie"}, &stubOsFile{Reader: bytes.NewReader(sampleCookie)}, nil),
|
||||||
}, newI().
|
}, newI().
|
||||||
// state.ensureRuntimeDir
|
// state.ensureRuntimeDir
|
||||||
Ensure(m(wantRunDirPath), 0700).
|
|
||||||
UpdatePermType(system.User, m(wantRunDirPath), acl.Execute).
|
|
||||||
Ensure(m(wantRuntimePath), 0700).
|
Ensure(m(wantRuntimePath), 0700).
|
||||||
UpdatePermType(system.User, m(wantRuntimePath), acl.Execute).
|
UpdatePermType(system.User, m(wantRuntimePath), acl.Execute).
|
||||||
|
Ensure(m(wantRunDirPath), 0700).
|
||||||
|
UpdatePermType(system.User, m(wantRunDirPath), acl.Execute).
|
||||||
// state.runtime
|
// state.runtime
|
||||||
Ephemeral(system.Process, m(wantRuntimeSharePath), 0700).
|
Ephemeral(system.Process, m(wantRuntimeSharePath), 0700).
|
||||||
UpdatePerm(m(wantRuntimeSharePath), acl.Execute).
|
UpdatePerm(m(wantRuntimeSharePath), acl.Execute).
|
||||||
@ -159,10 +159,10 @@ func TestSpPulseOp(t *testing.T) {
|
|||||||
call("open", stub.ExpectArgs{"/proc/nonexistent/cookie"}, &stubOsFile{Reader: bytes.NewReader(sampleCookie[:len(sampleCookie)-0xe])}, nil),
|
call("open", stub.ExpectArgs{"/proc/nonexistent/cookie"}, &stubOsFile{Reader: bytes.NewReader(sampleCookie[:len(sampleCookie)-0xe])}, nil),
|
||||||
}, newI().
|
}, newI().
|
||||||
// state.ensureRuntimeDir
|
// state.ensureRuntimeDir
|
||||||
Ensure(m(wantRunDirPath), 0700).
|
|
||||||
UpdatePermType(system.User, m(wantRunDirPath), acl.Execute).
|
|
||||||
Ensure(m(wantRuntimePath), 0700).
|
Ensure(m(wantRuntimePath), 0700).
|
||||||
UpdatePermType(system.User, m(wantRuntimePath), acl.Execute).
|
UpdatePermType(system.User, m(wantRuntimePath), acl.Execute).
|
||||||
|
Ensure(m(wantRunDirPath), 0700).
|
||||||
|
UpdatePermType(system.User, m(wantRunDirPath), acl.Execute).
|
||||||
// state.runtime
|
// state.runtime
|
||||||
Ephemeral(system.Process, m(wantRuntimeSharePath), 0700).
|
Ephemeral(system.Process, m(wantRuntimeSharePath), 0700).
|
||||||
UpdatePerm(m(wantRuntimeSharePath), acl.Execute).
|
UpdatePerm(m(wantRuntimeSharePath), acl.Execute).
|
||||||
@ -192,10 +192,10 @@ func TestSpPulseOp(t *testing.T) {
|
|||||||
call("open", stub.ExpectArgs{"/proc/nonexistent/cookie"}, &stubOsFile{Reader: bytes.NewReader(sampleCookie)}, nil),
|
call("open", stub.ExpectArgs{"/proc/nonexistent/cookie"}, &stubOsFile{Reader: bytes.NewReader(sampleCookie)}, nil),
|
||||||
}, newI().
|
}, newI().
|
||||||
// state.ensureRuntimeDir
|
// state.ensureRuntimeDir
|
||||||
Ensure(m(wantRunDirPath), 0700).
|
|
||||||
UpdatePermType(system.User, m(wantRunDirPath), acl.Execute).
|
|
||||||
Ensure(m(wantRuntimePath), 0700).
|
Ensure(m(wantRuntimePath), 0700).
|
||||||
UpdatePermType(system.User, m(wantRuntimePath), acl.Execute).
|
UpdatePermType(system.User, m(wantRuntimePath), acl.Execute).
|
||||||
|
Ensure(m(wantRunDirPath), 0700).
|
||||||
|
UpdatePermType(system.User, m(wantRunDirPath), acl.Execute).
|
||||||
// state.runtime
|
// state.runtime
|
||||||
Ephemeral(system.Process, m(wantRuntimeSharePath), 0700).
|
Ephemeral(system.Process, m(wantRuntimeSharePath), 0700).
|
||||||
UpdatePerm(m(wantRuntimeSharePath), acl.Execute).
|
UpdatePerm(m(wantRuntimeSharePath), acl.Execute).
|
||||||
@ -222,10 +222,10 @@ func TestSpPulseOp(t *testing.T) {
|
|||||||
call("verbose", stub.ExpectArgs{[]any{"cannot locate PulseAudio cookie (tried $PULSE_COOKIE, $XDG_CONFIG_HOME/pulse/cookie, $HOME/.pulse-cookie)"}}, nil, nil),
|
call("verbose", stub.ExpectArgs{[]any{"cannot locate PulseAudio cookie (tried $PULSE_COOKIE, $XDG_CONFIG_HOME/pulse/cookie, $HOME/.pulse-cookie)"}}, nil, nil),
|
||||||
}, newI().
|
}, newI().
|
||||||
// state.ensureRuntimeDir
|
// state.ensureRuntimeDir
|
||||||
Ensure(m(wantRunDirPath), 0700).
|
|
||||||
UpdatePermType(system.User, m(wantRunDirPath), acl.Execute).
|
|
||||||
Ensure(m(wantRuntimePath), 0700).
|
Ensure(m(wantRuntimePath), 0700).
|
||||||
UpdatePermType(system.User, m(wantRuntimePath), acl.Execute).
|
UpdatePermType(system.User, m(wantRuntimePath), acl.Execute).
|
||||||
|
Ensure(m(wantRunDirPath), 0700).
|
||||||
|
UpdatePermType(system.User, m(wantRunDirPath), acl.Execute).
|
||||||
// state.runtime
|
// state.runtime
|
||||||
Ephemeral(system.Process, m(wantRuntimeSharePath), 0700).
|
Ephemeral(system.Process, m(wantRuntimeSharePath), 0700).
|
||||||
UpdatePerm(m(wantRuntimeSharePath), acl.Execute).
|
UpdatePerm(m(wantRuntimeSharePath), acl.Execute).
|
||||||
|
|||||||
@ -64,10 +64,10 @@ func TestSpWaylandOp(t *testing.T) {
|
|||||||
call("verbose", stub.ExpectArgs{[]any{"direct wayland access, PROCEED WITH CAUTION"}}, nil, nil),
|
call("verbose", stub.ExpectArgs{[]any{"direct wayland access, PROCEED WITH CAUTION"}}, nil, nil),
|
||||||
}, newI().
|
}, newI().
|
||||||
// state.ensureRuntimeDir
|
// state.ensureRuntimeDir
|
||||||
Ensure(m(wantRunDirPath), 0700).
|
|
||||||
UpdatePermType(system.User, m(wantRunDirPath), acl.Execute).
|
|
||||||
Ensure(m(wantRuntimePath), 0700).
|
Ensure(m(wantRuntimePath), 0700).
|
||||||
UpdatePermType(system.User, m(wantRuntimePath), acl.Execute).
|
UpdatePermType(system.User, m(wantRuntimePath), acl.Execute).
|
||||||
|
Ensure(m(wantRunDirPath), 0700).
|
||||||
|
UpdatePermType(system.User, m(wantRunDirPath), acl.Execute).
|
||||||
// toSystem
|
// toSystem
|
||||||
UpdatePermType(hst.EWayland, m("/proc/nonexistent/wayland"), acl.Read, acl.Write, acl.Execute), nil, nil, insertsOps(afterSpRuntimeOp(nil)), []stub.Call{
|
UpdatePermType(hst.EWayland, m("/proc/nonexistent/wayland"), acl.Read, acl.Write, acl.Execute), nil, nil, insertsOps(afterSpRuntimeOp(nil)), []stub.Call{
|
||||||
// this op configures the container state and does not make calls during toContainer
|
// this op configures the container state and does not make calls during toContainer
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user