From 04bef4978cb16648d43264673791d9235539a648 Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Wed, 19 Aug 2026 08:50:36 +0200 Subject: [PATCH] fix tests --- cmd/toolsrv/internal/sandbox/native_linux.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/cmd/toolsrv/internal/sandbox/native_linux.go b/cmd/toolsrv/internal/sandbox/native_linux.go index 1385a45..8ba95a1 100644 --- a/cmd/toolsrv/internal/sandbox/native_linux.go +++ b/cmd/toolsrv/internal/sandbox/native_linux.go @@ -7,6 +7,8 @@ import ( "encoding/json" "fmt" "os" + "os/exec" + "strings" "syscall" "unsafe" @@ -41,7 +43,14 @@ func ExecHelper(args []string) error { if err := syscall.Chdir(p.CWD); err != nil { return err } - return syscall.Exec(p.Command[0], p.Command, envList(p.Env)) + // syscall.Exec requires an absolute path; resolve via PATH if needed + cmd0 := p.Command[0] + if !strings.HasPrefix(cmd0, "/") { + if resolved, err := exec.LookPath(cmd0); err == nil { + cmd0 = resolved + } + } + return syscall.Exec(cmd0, p.Command, envList(p.Env)) } func envList(env map[string]string) []string { @@ -76,10 +85,10 @@ func restrict(cfg *Config, cwd string, env map[string]string) error { Allowed uint64 ParentFD int }{access, int(f)} - _, _, e = unix.Syscall6(unix.SYS_LANDLOCK_ADD_RULE, fd, uintptr(1), uintptr(unsafe.Pointer(&rule)), 0, 0, 0) + _, _, errno := unix.Syscall6(unix.SYS_LANDLOCK_ADD_RULE, fd, uintptr(1), uintptr(unsafe.Pointer(&rule)), 0, 0, 0) unix.Close(f) - if e != nil { - return fmt.Errorf("add landlock path %s: %w", p, e) + if errno != 0 { + return fmt.Errorf("add landlock path %s: %w", p, errno) } } return nil