From 273d97af8502059193ccb6a188422f9d22eaf106 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Sun, 16 Mar 2025 01:20:09 +0900 Subject: ldd: lib paths resolve function This is what always happens right after a ldd call, so implement it here. Signed-off-by: Ophestra --- internal/sandbox/container_test.go | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) (limited to 'internal') diff --git a/internal/sandbox/container_test.go b/internal/sandbox/container_test.go index 566de75c..1a629d99 100644 --- a/internal/sandbox/container_test.go +++ b/internal/sandbox/container_test.go @@ -7,8 +7,6 @@ import ( "log" "os" "os/exec" - "path" - "slices" "syscall" "testing" "time" @@ -94,23 +92,10 @@ func TestContainer(t *testing.T) { }, os.Args[0]); err != nil { log.Fatalf("ldd: %v", err) } else { - libPathsM := make(map[string]struct{}, len(entries)) - for _, ent := range entries { - if path.IsAbs(ent.Path) { - libPathsM[path.Dir(ent.Path)] = struct{}{} - } - if path.IsAbs(ent.Name) { - libPathsM[path.Dir(ent.Name)] = struct{}{} - } - } - libPaths = make([]string, 0, len(libPathsM)) - for name := range libPathsM { - libPaths = append(libPaths, name) - } - slices.Sort(libPaths) - for _, name := range libPaths { - container.Bind(name, name, 0) - } + libPaths = ldd.Path(entries) + } + for _, name := range libPaths { + container.Bind(name, name, 0) } mnt := make([]*check.Mntent, 0, 3+len(libPaths)) -- cgit v1.3.1