container/check: move absolute pathname
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Hpkg (push) Successful in 4m3s
Test / Sandbox (race detector) (push) Successful in 4m26s
Test / Hakurei (race detector) (push) Successful in 5m19s
Test / Sandbox (push) Successful in 1m28s
Test / Hakurei (push) Successful in 2m16s
Test / Flake checks (push) Successful in 1m37s
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Hpkg (push) Successful in 4m3s
Test / Sandbox (race detector) (push) Successful in 4m26s
Test / Hakurei (race detector) (push) Successful in 5m19s
Test / Sandbox (push) Successful in 1m28s
Test / Hakurei (push) Successful in 2m16s
Test / Flake checks (push) Successful in 1m37s
This allows use of absolute pathname values without importing container. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -6,19 +6,19 @@ import (
|
||||
"os"
|
||||
"slices"
|
||||
|
||||
"hakurei.app/container"
|
||||
"hakurei.app/container/check"
|
||||
"hakurei.app/hst"
|
||||
"hakurei.app/system/acl"
|
||||
)
|
||||
|
||||
// UpdatePerm calls UpdatePermType with the [Process] criteria.
|
||||
func (sys *I) UpdatePerm(path *container.Absolute, perms ...acl.Perm) *I {
|
||||
func (sys *I) UpdatePerm(path *check.Absolute, perms ...acl.Perm) *I {
|
||||
sys.UpdatePermType(Process, path, perms...)
|
||||
return sys
|
||||
}
|
||||
|
||||
// UpdatePermType maintains [acl.Perms] on a file until its [Enablement] is no longer satisfied.
|
||||
func (sys *I) UpdatePermType(et hst.Enablement, path *container.Absolute, perms ...acl.Perm) *I {
|
||||
func (sys *I) UpdatePermType(et hst.Enablement, path *check.Absolute, perms ...acl.Perm) *I {
|
||||
sys.ops = append(sys.ops, &aclUpdateOp{et, path.String(), perms})
|
||||
return sys
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"syscall"
|
||||
|
||||
"hakurei.app/container"
|
||||
"hakurei.app/container/check"
|
||||
"hakurei.app/hst"
|
||||
"hakurei.app/system/dbus"
|
||||
)
|
||||
@@ -21,7 +22,7 @@ var (
|
||||
)
|
||||
|
||||
// MustProxyDBus calls ProxyDBus and panics if an error is returned.
|
||||
func (sys *I) MustProxyDBus(sessionPath *container.Absolute, session *hst.BusConfig, systemPath *container.Absolute, system *hst.BusConfig) *I {
|
||||
func (sys *I) MustProxyDBus(sessionPath *check.Absolute, session *hst.BusConfig, systemPath *check.Absolute, system *hst.BusConfig) *I {
|
||||
if err := sys.ProxyDBus(session, system, sessionPath, systemPath); err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
@@ -31,7 +32,7 @@ func (sys *I) MustProxyDBus(sessionPath *container.Absolute, session *hst.BusCon
|
||||
|
||||
// ProxyDBus finalises configuration ahead of time and starts xdg-dbus-proxy via [dbus] and terminates it on revert.
|
||||
// This [Op] is always [Process] scoped.
|
||||
func (sys *I) ProxyDBus(session, system *hst.BusConfig, sessionPath, systemPath *container.Absolute) error {
|
||||
func (sys *I) ProxyDBus(session, system *hst.BusConfig, sessionPath, systemPath *check.Absolute) error {
|
||||
d := new(dbusProxyOp)
|
||||
|
||||
// session bus is required as otherwise this is effectively a very expensive noop
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
"hakurei.app/container"
|
||||
"hakurei.app/container/bits"
|
||||
"hakurei.app/container/check"
|
||||
"hakurei.app/container/seccomp"
|
||||
"hakurei.app/helper"
|
||||
"hakurei.app/ldd"
|
||||
@@ -41,18 +42,18 @@ func (p *Proxy) Start() error {
|
||||
cmd.Env = make([]string, 0)
|
||||
}, nil)
|
||||
} else {
|
||||
var toolPath *container.Absolute
|
||||
if a, err := container.NewAbs(p.name); err != nil {
|
||||
var toolPath *check.Absolute
|
||||
if a, err := check.NewAbs(p.name); err != nil {
|
||||
if p.name, err = exec.LookPath(p.name); err != nil {
|
||||
return err
|
||||
} else if toolPath, err = container.NewAbs(p.name); err != nil {
|
||||
} else if toolPath, err = check.NewAbs(p.name); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
toolPath = a
|
||||
}
|
||||
|
||||
var libPaths []*container.Absolute
|
||||
var libPaths []*check.Absolute
|
||||
if entries, err := ldd.Exec(ctx, p.msg, toolPath.String()); err != nil {
|
||||
return err
|
||||
} else {
|
||||
@@ -76,7 +77,7 @@ func (p *Proxy) Start() error {
|
||||
}
|
||||
|
||||
// upstream bus directories
|
||||
upstreamPaths := make([]*container.Absolute, 0, 2)
|
||||
upstreamPaths := make([]*check.Absolute, 0, 2)
|
||||
for _, addr := range [][]AddrEntry{p.final.SessionUpstream, p.final.SystemUpstream} {
|
||||
for _, ent := range addr {
|
||||
if ent.Method != "unix" {
|
||||
@@ -86,7 +87,7 @@ func (p *Proxy) Start() error {
|
||||
if pair[0] != "path" {
|
||||
continue
|
||||
}
|
||||
if a, err := container.NewAbs(pair[1]); err != nil {
|
||||
if a, err := check.NewAbs(pair[1]); err != nil {
|
||||
continue
|
||||
} else {
|
||||
upstreamPaths = append(upstreamPaths, a.Dir())
|
||||
@@ -94,8 +95,8 @@ func (p *Proxy) Start() error {
|
||||
}
|
||||
}
|
||||
}
|
||||
container.SortAbs(upstreamPaths)
|
||||
upstreamPaths = container.CompactAbs(upstreamPaths)
|
||||
check.SortAbs(upstreamPaths)
|
||||
upstreamPaths = check.CompactAbs(upstreamPaths)
|
||||
for _, name := range upstreamPaths {
|
||||
z.Bind(name, name, 0)
|
||||
}
|
||||
@@ -103,15 +104,15 @@ func (p *Proxy) Start() error {
|
||||
z.HostAbstract = z.HostNet
|
||||
|
||||
// parent directories of bind paths
|
||||
sockDirPaths := make([]*container.Absolute, 0, 2)
|
||||
if a, err := container.NewAbs(p.final.Session[1]); err == nil {
|
||||
sockDirPaths := make([]*check.Absolute, 0, 2)
|
||||
if a, err := check.NewAbs(p.final.Session[1]); err == nil {
|
||||
sockDirPaths = append(sockDirPaths, a.Dir())
|
||||
}
|
||||
if a, err := container.NewAbs(p.final.System[1]); err == nil {
|
||||
if a, err := check.NewAbs(p.final.System[1]); err == nil {
|
||||
sockDirPaths = append(sockDirPaths, a.Dir())
|
||||
}
|
||||
container.SortAbs(sockDirPaths)
|
||||
sockDirPaths = container.CompactAbs(sockDirPaths)
|
||||
check.SortAbs(sockDirPaths)
|
||||
sockDirPaths = check.CompactAbs(sockDirPaths)
|
||||
for _, name := range sockDirPaths {
|
||||
z.Bind(name, name, container.BindWritable)
|
||||
}
|
||||
|
||||
@@ -3,17 +3,17 @@ package system
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"hakurei.app/container"
|
||||
"hakurei.app/container/check"
|
||||
"hakurei.app/hst"
|
||||
)
|
||||
|
||||
// Link calls LinkFileType with the [Process] criteria.
|
||||
func (sys *I) Link(oldname, newname *container.Absolute) *I {
|
||||
func (sys *I) Link(oldname, newname *check.Absolute) *I {
|
||||
return sys.LinkFileType(Process, oldname, newname)
|
||||
}
|
||||
|
||||
// LinkFileType maintains a hardlink until its [Enablement] is no longer satisfied.
|
||||
func (sys *I) LinkFileType(et hst.Enablement, oldname, newname *container.Absolute) *I {
|
||||
func (sys *I) LinkFileType(et hst.Enablement, oldname, newname *check.Absolute) *I {
|
||||
sys.ops = append(sys.ops, &hardlinkOp{et, newname.String(), oldname.String()})
|
||||
return sys
|
||||
}
|
||||
|
||||
@@ -5,18 +5,18 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"hakurei.app/container"
|
||||
"hakurei.app/container/check"
|
||||
"hakurei.app/hst"
|
||||
)
|
||||
|
||||
// Ensure ensures the existence of a directory.
|
||||
func (sys *I) Ensure(name *container.Absolute, perm os.FileMode) *I {
|
||||
func (sys *I) Ensure(name *check.Absolute, perm os.FileMode) *I {
|
||||
sys.ops = append(sys.ops, &mkdirOp{User, name.String(), perm, false})
|
||||
return sys
|
||||
}
|
||||
|
||||
// Ephemeral ensures the existence of a directory until its [Enablement] is no longer satisfied.
|
||||
func (sys *I) Ephemeral(et hst.Enablement, name *container.Absolute, perm os.FileMode) *I {
|
||||
func (sys *I) Ephemeral(et hst.Enablement, name *check.Absolute, perm os.FileMode) *I {
|
||||
sys.ops = append(sys.ops, &mkdirOp{et, name.String(), perm, true})
|
||||
return sys
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"hakurei.app/container"
|
||||
"hakurei.app/container/check"
|
||||
"hakurei.app/container/stub"
|
||||
"hakurei.app/hst"
|
||||
"hakurei.app/system/internal/xcb"
|
||||
@@ -313,4 +314,4 @@ func TestNop(t *testing.T) {
|
||||
new(noCopy).Lock()
|
||||
}
|
||||
|
||||
func m(pathname string) *container.Absolute { return container.MustAbs(pathname) }
|
||||
func m(pathname string) *check.Absolute { return check.MustAbs(pathname) }
|
||||
|
||||
@@ -8,12 +8,12 @@ import (
|
||||
"os"
|
||||
"syscall"
|
||||
|
||||
"hakurei.app/container"
|
||||
"hakurei.app/container/check"
|
||||
"hakurei.app/hst"
|
||||
)
|
||||
|
||||
// CopyFile reads up to n bytes from src and writes the resulting byte slice to payloadP.
|
||||
func (sys *I) CopyFile(payloadP *[]byte, src *container.Absolute, cap int, n int64) *I {
|
||||
func (sys *I) CopyFile(payloadP *[]byte, src *check.Absolute, cap int, n int64) *I {
|
||||
buf := new(bytes.Buffer)
|
||||
buf.Grow(cap)
|
||||
sys.ops = append(sys.ops, &tmpfileOp{payloadP, src.String(), n, buf})
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"hakurei.app/container"
|
||||
"hakurei.app/container/check"
|
||||
"hakurei.app/hst"
|
||||
"hakurei.app/system/acl"
|
||||
"hakurei.app/system/wayland"
|
||||
@@ -20,7 +20,7 @@ type waylandConn interface {
|
||||
// Wayland maintains a wayland socket with security-context-v1 attached via [wayland].
|
||||
// The socket stops accepting connections once the pipe referred to by sync is closed.
|
||||
// The socket is pathname only and is destroyed on revert.
|
||||
func (sys *I) Wayland(dst, src *container.Absolute, appID, instanceID string) *I {
|
||||
func (sys *I) Wayland(dst, src *check.Absolute, appID, instanceID string) *I {
|
||||
sys.ops = append(sys.ops, &waylandOp{nil,
|
||||
dst.String(), src.String(),
|
||||
appID, instanceID,
|
||||
|
||||
Reference in New Issue
Block a user