diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-10-07 20:06:26 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-10-07 20:57:58 +0900 |
| commit | 0e6c1a50260de141c50bb50fd3f2b2bcf9a3fe64 (patch) | |
| tree | dfe9c40ceb8c1be8d2728a2db9017bffef174d3d /system | |
| parent | d23b4dc9e64d3f00e746c65f3038a1a6de44b8f5 (diff) | |
container/check: move absolute pathname
This allows use of absolute pathname values without importing container.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'system')
| -rw-r--r-- | system/acl.go | 6 | ||||
| -rw-r--r-- | system/dbus.go | 5 | ||||
| -rw-r--r-- | system/dbus/proc.go | 27 | ||||
| -rw-r--r-- | system/link.go | 6 | ||||
| -rw-r--r-- | system/mkdir.go | 6 | ||||
| -rw-r--r-- | system/system_test.go | 3 | ||||
| -rw-r--r-- | system/tmpfiles.go | 4 | ||||
| -rw-r--r-- | system/wayland.go | 4 |
8 files changed, 32 insertions, 29 deletions
diff --git a/system/acl.go b/system/acl.go index e2e00823..c89a4780 100644 --- a/system/acl.go +++ b/system/acl.go @@ -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 } diff --git a/system/dbus.go b/system/dbus.go index 1a0b099e..1cc24a22 100644 --- a/system/dbus.go +++ b/system/dbus.go @@ -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 diff --git a/system/dbus/proc.go b/system/dbus/proc.go index 01e836da..a4c9300a 100644 --- a/system/dbus/proc.go +++ b/system/dbus/proc.go @@ -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) } diff --git a/system/link.go b/system/link.go index dcd742c2..a13adaae 100644 --- a/system/link.go +++ b/system/link.go @@ -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 } diff --git a/system/mkdir.go b/system/mkdir.go index fc6a8306..f375579c 100644 --- a/system/mkdir.go +++ b/system/mkdir.go @@ -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 } diff --git a/system/system_test.go b/system/system_test.go index 91d8a87e..5a361b95 100644 --- a/system/system_test.go +++ b/system/system_test.go @@ -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) } diff --git a/system/tmpfiles.go b/system/tmpfiles.go index 0fe61176..8d94ceee 100644 --- a/system/tmpfiles.go +++ b/system/tmpfiles.go @@ -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}) diff --git a/system/wayland.go b/system/wayland.go index f987967b..bb144d8c 100644 --- a/system/wayland.go +++ b/system/wayland.go @@ -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, |
