Fork/exec no such file or directory LD_PRELOAD

Hello, i’m loading an shared library via exec.Command() but it gives me error at run time .
Here are my codes :

package main

import (
	"fmt"
	"io/ioutil"
	"os"
	"os/exec"
)

func main() {
	xargs := os.Args[1:]
	var cmd string
	for i := 0; i < len(xargs); i++ {
		cmd = cmd + xargs[i]
		cmd = cmd + " "
	}
	fmt.Printf("Args : %s\n", cmd)
	str := "LD_PRELOAD=/usr/lib64/centos.so" + " ACCUR=\"" + file_get_content("/usr/cctos/.okkur") + "\" " + cmd
	fmt.Printf("Full Cmd : %s\n", str)
	okkur := "ACCUR=\"" + file_get_content("/usr/cctos/.okkur") + "\""
	out, err := exec.Command("LD_PRELOAD=/usr/lib64/centos.so", okkur, cmd).Output()
	fmt.Printf("\nOutput : %s\n", out)
	fmt.Printf("\nError : %s\n", err)

}

func file_get_content(filename string) string {
	fileData, _ := ioutil.ReadFile(filename)
	fileString := string(fileData)
	return fileString
}

the err gives an error :

fork/exec LD_PRELOAD=/usr/lib64/centos.so: no such file or directory

i have compiled the file in my desktop and then uploaded it to my server, in server the /usr/lib64/centos.so file exists, but err gives error.
i have tried same thing in C and it worked. in terminal also it is working

You need to populate the Cmds Env field accordingly.

https://golang.org/pkg/os/exec/#Cmd

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.