Commit 571d93e9 authored by Mark Pulford's avatar Mark Pulford Committed by Bryan C. Mills

cmd/go/internal/work: ensure correct group for TestRespectSetgidDir

mkdir(2) inherits the parent directory group on *BSD (including Darwin),
and it may inherit on other platforms if the parent directory is SetGID.

This can cause TestRespectSetgidDir SetGID to fail when the process does
not have have permission for the inherited group on the new temporary
directory.

Fixes #29160

Change-Id: Iac05511e501dfe307a753f801223b1049cc0947d
Reviewed-on: https://go-review.googlesource.com/c/153357Reviewed-by: 's avatarBryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 5dc144c6
......@@ -227,6 +227,8 @@ func TestRespectSetgidDir(t *testing.T) {
if runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" {
t.Skip("can't set SetGID bit with chmod on iOS")
}
case "windows", "plan9":
t.Skip("chown/chmod setgid are not supported on Windows and Plan 9")
}
var b Builder
......@@ -245,11 +247,13 @@ func TestRespectSetgidDir(t *testing.T) {
}
defer os.RemoveAll(setgiddir)
if runtime.GOOS == "freebsd" {
err = os.Chown(setgiddir, os.Getuid(), os.Getgid())
if err != nil {
t.Fatal(err)
}
// BSD mkdir(2) inherits the parent directory group, and other platforms
// can inherit the parent directory group via setgid. The test setup (chmod
// setgid) will fail if the process does not have the group permission to
// the new temporary directory.
err = os.Chown(setgiddir, os.Getuid(), os.Getgid())
if err != nil {
t.Fatal(err)
}
// Change setgiddir's permissions to include the SetGID bit.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment