1
0
mirror of https://github.com/golang/go synced 2024-11-11 18:21:40 -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.

Fixes #60690.

Change-Id: I62d27aa63f225f8247c324b87b5e688319061f4f
GitHub-Last-Rev: 217813a4d5
GitHub-Pull-Request: golang/go#60742
Reviewed-on: https://go-review.googlesource.com/c/go/+/502575
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
Josh Rickmar 2023-06-12 16:10:55 +00:00 committed by David Chase
parent 8faa79e91f
commit 8b5ed3cdae

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, " ")))
}