-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Description
The current git tip will fail to build on FreeBSD under some circumstances because it attempts to make a directory in /tmp
setgid and under some (possibly common) situations this will fail. The root of the issue is a FreeBSD feature where directories always behave as if they had the sticky bit set as far as mkdir(2)
is concerned, per the FreeBSD mkdir(2)
manpage.
How the bug happens:
/tmp
ownership is, say, userroot
and groupwheel
.- you (the UID building Go) are not in group
wheel
- you
mkdir /tmp/GroupSticky
. Due to the FreeBSDmkdir(2)
feature this new directory winds up with owner you but in groupwheel
, which you are not a member of. - you attempt to set setgid on something that is in a group that you are not a member of. FreeBSD correctly rejects this with
EPERM
.
There are two ways for the Go build to still succeed on FreeBSD as far as I know. The first is for the UID doing the build to be in the group that owns /tmp
. The other is to set TMPDIR
to a directory which you've created and that has the group owner as one of your groups; this will typically be the case if you create it under $HOME
.
What version of Go are you using (go version
)?
I am trying to build the latest git tip, 42e9746 as I write this. However this build failure happens as of commit e9bb9e5 which introduces this test. Reverting to 4e0f639 results in a tree that will build.
What operating system and processor architecture are you using (go env
)?
GOARCH="386"
GOHOSTARCH="386"
GOHOSTOS="freebsd"
GOOS="freebsd"
What did you do?
Attempted to build Go from git tip or any version since
What did you expect to see?
Success (ignoring issue #19592 for now, which also prevents the build from succeeding).
What did you see instead?
--- FAIL: TestRespectGroupSticky (0.00s)
build_test.go:203: chmod /tmp/GroupSticky: operation not permitted
FAIL
FAIL cmd/go/internal/work 0.015s
This machine's /tmp
and a manually created /tmp/GroupSticky
directory have the ownership:
drwxrwxrwt 146 root wheel 13824 Mar 17 16:03 /tmp/
drwxr-xr-x 2 cks wheel 512 Mar 17 16:02 /tmp/GroupSticky/
(I am not in group wheel
on this FreeBSD server; it is run by another group entirely.)