Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: TestRespectSetgidDir can fail on *BSD #29160

Closed
mpx opened this issue Dec 9, 2018 · 2 comments
Closed

cmd/go: TestRespectSetgidDir can fail on *BSD #29160

mpx opened this issue Dec 9, 2018 · 2 comments
Labels
FrozenDueToAge GoCommand cmd/go NeedsFix The path to resolution is known, but the work has not been done. Testing An issue that has been verified to require only test changes, not just a test failure.
Milestone

Comments

@mpx
Copy link
Contributor

mpx commented Dec 9, 2018

TestRespectSetgidDir assumes it can create a temporary directory with setgid. However, on *BSD mkdir will inherit the parent directory group. If the test process does not have permission for the group it will be unable to setgid.

This was fixed for FreeBSD in go1.9 (#19596), but remains a potential problem for other BSD platforms (including Darwin).

In particular, I found this with /tmp on OpenBSD:

drwxrwxrwt  14 root  wheel  512 Dec  9 12:23 /tmp

A process without wheel permissions will end up with a test temporary directory owned by "user:wheel" and fail to chmod setgid:

--- FAIL: TestRespectSetgidDir (0.00s)
    build_test.go:257: chmod /tmp/SetGroupID303193776: operation not permitted
FAIL
FAIL    cmd/go/internal/work    0.527s

mkdir(2) documentation for each BSD:
Darwin: https://github.com/apple/darwin-xnu/blob/master/bsd/man/man2/mkdir.2#L65
NetBSD: http://netbsd.gw.com/cgi-bin/man-cgi?mkdir+2+NetBSD-current
OpenBSD: http://man.openbsd.org/mkdir.2
FreeBSD: https://www.freebsd.org/cgi/man.cgi?query=mkdir&sektion=2
DragonFly: https://www.dragonflybsd.org/cgi/web-man?command=mkdir&section=2

@gopherbot
Copy link

Change https://golang.org/cl/153357 mentions this issue: cmd/go: fix group for TestRespectSetgidDir chmod on BSD

@bcmills bcmills added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. GoCommand cmd/go labels Dec 10, 2018
@bcmills bcmills added this to the Go1.13 milestone Dec 10, 2018
@gopherbot
Copy link

Change https://golang.org/cl/153820 mentions this issue: cmd/go/internal/work: always chown directory in TestRespectSetgidDir

@bcmills bcmills modified the milestones: Go1.13, Go1.12 Dec 12, 2018
@bcmills bcmills added Testing An issue that has been verified to require only test changes, not just a test failure. NeedsFix The path to resolution is known, but the work has not been done. labels Dec 12, 2018
@gopherbot gopherbot removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Dec 12, 2018
@golang golang locked and limited conversation to collaborators Dec 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go NeedsFix The path to resolution is known, but the work has not been done. Testing An issue that has been verified to require only test changes, not just a test failure.
Projects
None yet
Development

No branches or pull requests

3 participants