From 02271583fb791987a9406c9ba282c75ff7a0e395 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Sat, 9 Aug 2025 19:08:54 +0900 Subject: container: remove PATH lookup behaviour This is way higher level than the container package and does not even work unless every path is mounted in the exact same location. This behaviour causes nothing but confusion and problems, Signed-off-by: Ophestra --- ldd/exec.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'ldd/exec.go') diff --git a/ldd/exec.go b/ldd/exec.go index 2abec46d..ac311fa2 100644 --- a/ldd/exec.go +++ b/ldd/exec.go @@ -5,13 +5,17 @@ import ( "context" "io" "os" + "os/exec" "time" "hakurei.app/container" "hakurei.app/container/seccomp" ) -const lddTimeout = 2 * time.Second +const ( + lddName = "ldd" + lddTimeout = 2 * time.Second +) var ( msgStatic = []byte("Not a valid dynamic program") @@ -21,8 +25,16 @@ var ( func Exec(ctx context.Context, p string) ([]*Entry, error) { c, cancel := context.WithTimeout(ctx, lddTimeout) defer cancel() - z := container.New(c, "ldd", p) - z.Hostname = "hakurei-ldd" + + var toolPath *container.Absolute + if s, err := exec.LookPath(lddName); err != nil { + return nil, err + } else if toolPath, err = container.NewAbsolute(s); err != nil { + return nil, err + } + + z := container.NewCommand(c, toolPath.String(), lddName, p) + z.Hostname = "hakurei-" + lddName z.SeccompFlags |= seccomp.AllowMultiarch z.SeccompPresets |= seccomp.PresetStrict stdout, stderr := new(bytes.Buffer), new(bytes.Buffer) -- cgit v1.3.1