cmd := exec.Command(executable, newArgs...)
if env != nil && len(env) > 0 {
cmd.Env = env
}
outMsg, err := cmd.CombinedOutput()
if err != nil {
......
}
Then I tried to use "sudo" to execute the command, but the environment variables can't be carried over into the command;
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/8908b67e-d5d6-698b-bd54-f2c95fc2566f%40gmail.com.
is there some code available to dig into that? I plan to do something similar that a regular user process starts up a kind of a root broker which starts several other processes as different users.
Especially for the communication part I don’t have a good and secure idea so far.
Digging through my vast mess of code, I found this function which sets the real and effective user (Setreuid) of the calling process:func DegradeToUser(uname string) error {
On 31 Aug 2019, at 12:33, Ronny Bangsund <ronny....@gmail.com> wrote:
Digging through my vast mess of code, I found this function which sets the real and effective user (Setreuid) of the calling process:func DegradeToUser(uname string) error {
Doesn't this suffer from the issue of only affecting the current thread on Linux, and hence not being safe to use from Go?
Setting the uid/gid as part of starting a child process should be safe though (https://golang.org/pkg/syscall/#Credential).