I am trying to start a new process from within a rootless golang program, give that process root privileges, and execute a command using sudo. However, I am getting the following output:
sudo: /etc/sudo.conf is owned by uid 65534, should be 0
sudo: /etc/sudo.conf is owned by uid 65534, should be 0
sudo: error in /etc/sudo.conf, line 0 while loading plugin "sudoers_policy"
sudo: /usr/libexec/sudo/sudoers.so must be owned by uid 0
sudo: fatal error, unable to load plugins
exit status 1
Which I am assuming means I need to chown some files temporarily in order to have sudo access. Is this process possible? here is my StartProcess code currently
cred := &syscall.Credential{0, 0, []uint32{}, false}
sys := &syscall.SysProcAttr{Credential: cred, Noctty: false}
attr := os.ProcAttr{Env: os.Environ(), Files: []*os.File{os.Stdin, os.Stdout, os.Stderr}, Sys: sys}
proc, err := os.StartProcess("/bin/sudo", []string{"/bin/podman", "image", "load", "--input=" + scpOpts.Save.Output}, &attr)
if err != nil {
return err
}
state, err := proc.Wait()
if err != nil {
return err
}
fmt.Println(state.String())