From: Mark Pulford Date: Sat, 8 Dec 2018 16:30:08 +0000 (+1100) Subject: cmd/go/internal/work: ensure correct group for TestRespectSetgidDir X-Git-Tag: go1.12beta1~73 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=571d93e977862f91bb153f0b98937ca655505fcd;p=gostls13.git 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/153357 Reviewed-by: Bryan C. Mills Run-TryBot: Bryan C. Mills TryBot-Result: Gobot Gobot --- diff --git a/src/cmd/go/internal/work/build_test.go b/src/cmd/go/internal/work/build_test.go index 010e17ee48..a875ec1aa6 100644 --- a/src/cmd/go/internal/work/build_test.go +++ b/src/cmd/go/internal/work/build_test.go @@ -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.