1
0
mirror of https://github.com/golang/go synced 2024-11-26 21:11:57 -07:00

runtime: Use doas -n in TestSUID on OpenBSD

This prevents a hang at a su password prompt when running this test on
OpenBSD.
This commit is contained in:
Josh Rickmar 2023-06-12 16:01:10 +00:00
parent 5e9b76fe2a
commit 217813a4d5

View File

@ -27,6 +27,8 @@ func privesc(command string, args ...string) error {
var cmd *exec.Cmd
if runtime.GOOS == "darwin" {
cmd = exec.CommandContext(ctx, "sudo", append([]string{"-n", command}, args...)...)
} else if runtime.GOOS == "openbsd" {
cmd = exec.CommandContext(ctx, "doas", append([]string{"-n", command}, args...)...)
} else {
cmd = exec.CommandContext(ctx, "su", highPrivUser, "-c", fmt.Sprintf("%s %s", command, strings.Join(args, " ")))
}