-
Notifications
You must be signed in to change notification settings - Fork 18k
os/user: TestGroupIds on macOS fails #21067
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
Comments
When you say "Building the latest Go Compiler source (from source control)" were you trying to build the source for Go 1.8.3, or the source for tip? If tip, which commit? At the top of the all.bash output, it should say "Building Go toolchain using (x)", what is x when you get this failure? |
What happens when you run "groups csnelson" at the command line? It looks like this is the affected code in listgroups_unix.go rv := getGroupList(nameC, userGID, &gidsC[0], &n)
if rv == -1 {
// More than initial buffer, but now n contains the correct size.
const maxGroups = 2048
if n > maxGroups {
return nil, fmt.Errorf("user: list groups for %s: member of more than %d groups", u.Username, maxGroups)
}
gidsC = make([]C.gid_t, n)
rv := getGroupList(nameC, userGID, &gidsC[0], &n)
if rv == -1 {
return nil, fmt.Errorf("user: list groups for %s failed (changed groups?)", u.Username)
}
} |
I can't reproduce this one at the moment, so hoping we can find out what's the difference between the way that I'm running it and the way that you're running it. |
@kevinburke I am building tip. $ ./all.bash Building Go bootstrap tool.cmd/dist Building Go toolchain using /usr/local/go.$ /usr/local/go/bin/go version Running |
can you try editing the code in listgroups_unix.go as follows, and rerun all.bash and see what we get? I don't know how to debug this otherwise as it's tough for me to reproduce. The gidsC output is not important - I don't want you to reveal the groups - but I would like to know if the list has empty entries or full entries. rv := getGroupList(nameC, userGID, &gidsC[0], &n)
if rv == -1 {
fmt.Println("running get group list fallback, n:", n)
// More than initial buffer, but now n contains the correct size.
const maxGroups = 2048
if n > maxGroups {
return nil, fmt.Errorf("user: list groups for %s: member of more than %d groups", u.Username, maxGroups)
}
gidsC = make([]C.gid_t, n)
rv := getGroupList(nameC, userGID, &gidsC[0], &n)
fmt.Printf("len gidsC: %d, gidsC: %#v\n", len(gidsC), gidsC)
fmt.Println("new n:", n)
if rv == -1 {
return nil, fmt.Errorf("user: list groups for %s failed (changed groups?)", u.Username)
}
} |
Sure, that's no problem:
|
Interesting. So getgrouplist (the C call) is supposed to populate N with the number of groups to fetch. You say that list has 300 members, but getgrouplist only returns 256; I'm guessing that it's returning -1 because we can't handle more than 256 members in a group... Now the question is whether that's a C constraint or whether that's a Go constraint. |
Oh, huh. Here's the manpage for getgrouplist:
Compare that with the Linux
So maybe on Macs, getgrouplist does not set n correctly if there are more groups than in the array? What happens if you change the |
It does in fact work fine if I set c.int(1000) |
The following patch fixes the problem for me.
|
(FYI, it's easy to reproduce this by changing 256 to, say, 2). |
@nadiasvertex Thanks for sending the patch, I'll tweak it and submit it shortly. |
Change https://golang.org/cl/51892 mentions this issue: |
What version of Go are you using (
go version
)?go version go1.8.3 darwin/amd64
What operating system and processor architecture are you using (
go env
)?$ uname -a
Darwin USD25MC10EF8JC 16.4.0 Darwin Kernel Version 16.4.0: Thu Dec 22 22:53:21 PST 2016; root:xnu-3789.41.3~3/RELEASE_X86_64 x86_64
$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/csnelson/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/74/y_rffr315mn3j9d5v0q_8w9hwlsb1s/T/go-build117999026=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
What did you do?
Building the latest Go Compiler source (from source control):
$ ./all.bash
What did you expect to see?
Success.
What did you see instead?
The text was updated successfully, but these errors were encountered: