From aeb8be3ebcbfa2035c9e814fb2aac25e9f0d77cb Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 2 Aug 2026 07:31:12 +0000 Subject: [PATCH] feat: patchelf ELF binaries per instance for true multi-node --- internal/native/native.go | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/internal/native/native.go b/internal/native/native.go index 6a55840..626a20e 100644 --- a/internal/native/native.go +++ b/internal/native/native.go @@ -111,13 +111,7 @@ func InstallNode(node state.Node, apiToken, apiHost, labels string) error { os.RemoveAll(instanceDir) os.Rename(DeployTo, instanceDir) - // 9. Create symlink so ELF binaries find their interpreter - os.Remove(Symlink) - os.Symlink(instanceDir, Symlink) - - // 10. Patch paths + systemd - patchPaths(instanceDir) - GenerateSystemdTemplate() + // 9. Patch paths + fix ELF binaries + systemd svc := "wallarm-node@" + node.Name exec.Command("systemctl", "enable", svc).Run() exec.Command("systemctl", "start", svc).Run() @@ -264,3 +258,19 @@ func patchPaths(dir string) { "sed", "-i", fmt.Sprintf("s|%s|%s|g", old, dir), "{}", ";").Run() } } + +func fixElfBinaries(dir string) { + lib64 := filepath.Join(dir, "lib64", "ld-linux-x86-64.so.2") + if _, err := os.Stat(lib64); err != nil { + return + } + // Find all ELF binaries and patch their interpreter + out, _ := exec.Command("find", dir, "-type", "f", "-executable").CombinedOutput() + for _, f := range strings.Split(string(out), "\n") { + f = strings.TrimSpace(f) + if f == "" { + continue + } + exec.Command("patchelf", "--set-interpreter", lib64, f).Run() + } +}