1

The issue is not stably reproduced on mac. the code snippet is as below:

cmd := exec.Command("/bin/zsh", "-c", `brew info goland`)
cmd.SysProcAttr = &syscall.SysProcAttr{
    Credential: &syscall.Credential{
        Uid:    501,
        Gid:    20,
        Groups: []uint32{2, 3, 4},
    },
}
output, err := cmd.CombinedOutput()
if err != nil {
    println(err)
}

i run the process as root, and exec command with another user. It failed on some mac computer and report "fork/exec /bin/zsh invalid argument" error message. anybody know the cause? thanks~

Gordon Liu
  • 19
  • 2
  • What is different between the computers? Are the UID/GID/Groups values all valid on all systems, with all the same permissions? Is the Go version the same? Is the OS version the same? – JimB Jun 16 '22 at 13:27
  • 1
    Does the user have permission to run /bin/zsh? Does the computer have enough resources to create a new process? This probably doesn't have anything to do with Go itself but OS level fork/exec returning EINVAL. – blami Jun 16 '22 at 13:32
  • @JimB The UID/GID is different, they are generated by the user of the systems, and the OS version also different. – Gordon Liu Jun 17 '22 at 02:03
  • @blami they have permission to run /bin/zsh, they can manually run the command in the shell – Gordon Liu Jun 17 '22 at 02:04
  • 1
    I have found the root cause which is the NGROUP_MAX is 16 in mac, here the number of groups the user belongs to is more than 16. – Gordon Liu Jul 18 '22 at 06:46
  • You should promote your comment to an answer @GordonLiu I had exactly this same problem and your comment found the solution for me. Thanks! – Fsmv Jul 08 '23 at 06:21

0 Answers0