aboutsummaryrefslogtreecommitdiffhomepage
path: root/system
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-08-11 02:52:32 +0900
committerOphestra <cat@gensokyo.uk>2025-08-11 04:56:42 +0900
commite99d7affb0c128fa82722f9b3d79c99b5e5918cd (patch)
tree387e08d6c4363d8b9e0462f069c140fbdb15c917 /system
parent41ac2be9658b49c68cb793f3a6f0c5932d82e1c2 (diff)
container: use absolute for pathname
This is simultaneously more efficient and less error-prone. This change caused minor API changes in multiple other packages. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'system')
-rw-r--r--system/dbus/proc.go34
1 files changed, 18 insertions, 16 deletions
diff --git a/system/dbus/proc.go b/system/dbus/proc.go
index d6f98907..0e5f1cef 100644
--- a/system/dbus/proc.go
+++ b/system/dbus/proc.go
@@ -5,8 +5,6 @@ import (
"errors"
"os"
"os/exec"
- "path"
- "slices"
"strconv"
"syscall"
@@ -53,7 +51,7 @@ func (p *Proxy) Start() error {
toolPath = a
}
- var libPaths []string
+ var libPaths []*container.Absolute
if entries, err := ldd.Exec(ctx, toolPath.String()); err != nil {
return err
} else {
@@ -77,42 +75,46 @@ func (p *Proxy) Start() error {
}
// upstream bus directories
- upstreamPaths := make([]string, 0, 2)
+ upstreamPaths := make([]*container.Absolute, 0, 2)
for _, addr := range [][]AddrEntry{p.final.SessionUpstream, p.final.SystemUpstream} {
for _, ent := range addr {
if ent.Method != "unix" {
continue
}
for _, pair := range ent.Values {
- if pair[0] != "path" || !path.IsAbs(pair[1]) {
+ if pair[0] != "path" {
continue
}
- upstreamPaths = append(upstreamPaths, path.Dir(pair[1]))
+ if a, err := container.NewAbs(pair[1]); err != nil {
+ continue
+ } else {
+ upstreamPaths = append(upstreamPaths, a.Dir())
+ }
}
}
}
- slices.Sort(upstreamPaths)
- upstreamPaths = slices.Compact(upstreamPaths)
+ container.SortAbs(upstreamPaths)
+ upstreamPaths = container.CompactAbs(upstreamPaths)
for _, name := range upstreamPaths {
z.Bind(name, name, 0)
}
// parent directories of bind paths
- sockDirPaths := make([]string, 0, 2)
- if d := path.Dir(p.final.Session[1]); path.IsAbs(d) {
- sockDirPaths = append(sockDirPaths, d)
+ sockDirPaths := make([]*container.Absolute, 0, 2)
+ if a, err := container.NewAbs(p.final.Session[1]); err == nil {
+ sockDirPaths = append(sockDirPaths, a.Dir())
}
- if d := path.Dir(p.final.System[1]); path.IsAbs(d) {
- sockDirPaths = append(sockDirPaths, d)
+ if a, err := container.NewAbs(p.final.System[1]); err == nil {
+ sockDirPaths = append(sockDirPaths, a.Dir())
}
- slices.Sort(sockDirPaths)
- sockDirPaths = slices.Compact(sockDirPaths)
+ container.SortAbs(sockDirPaths)
+ sockDirPaths = container.CompactAbs(sockDirPaths)
for _, name := range sockDirPaths {
z.Bind(name, name, container.BindWritable)
}
// xdg-dbus-proxy bin path
- binPath := path.Dir(toolPath.String())
+ binPath := toolPath.Dir()
z.Bind(binPath, binPath, 0)
}, nil)
}