diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-08-09 19:08:54 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-08-09 19:08:54 +0900 |
| commit | 02271583fb791987a9406c9ba282c75ff7a0e395 (patch) | |
| tree | 00b35900e1ff7bf4fa5f24e7322a9beb222098b9 /ldd/exec.go | |
| parent | ef54b2cd086ee8a3186c9646711d70e226815973 (diff) | |
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 <cat@gensokyo.uk>
Diffstat (limited to 'ldd/exec.go')
| -rw-r--r-- | ldd/exec.go | 18 |
1 files changed, 15 insertions, 3 deletions
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) |
