It seems like getgrouplist is supported since Solaris 11.3 (released in
2016):
https://docs.oracle.com/cd/E86824_01/html/E54766/getgrouplist-3c.html
Use it to implement (*User).GroupIds on solaris, like on other Unix
platforms.
Unfortunately it looks like getgrouplist was added to illumos only
fairly recently, see
https://github.com/illumos/illumos-gate/commit/
f2c438c5058c64b7373448f239156bf60009abcb
Thus, don't use it on GOOS=illumos for now.
Updates #14709
Change-Id: Ibfcdbfca6b7d1af96630512d08921e5637ca76d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/315278
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build (dragonfly || freebsd || (!android && linux) || netbsd || openbsd) && cgo && !osusergo
-// +build dragonfly freebsd !android,linux netbsd openbsd
+//go:build (dragonfly || freebsd || (!android && linux) || netbsd || openbsd || (solaris && !illumos)) && cgo && !osusergo
+// +build dragonfly freebsd !android,linux netbsd openbsd solaris,!illumos
// +build cgo
// +build !osusergo
-// Copyright 2016 The Go Authors. All rights reserved.
+// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build cgo,!osusergo
// Even though this file requires no C, it is used to provide a
-// listGroup stub because all the other Solaris calls work. Otherwise,
+// listGroup stub because all the other illumos calls work. Otherwise,
// this stub will conflict with the lookup_stubs.go fallback.
package user
import "fmt"
func listGroups(u *User) ([]string, error) {
- return nil, fmt.Errorf("user: list groups for %s: not supported on Solaris", u.Username)
+ return nil, fmt.Errorf("user: list groups for %s: not supported on illumos", u.Username)
}
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build (dragonfly || darwin || freebsd || (!android && linux) || netbsd || openbsd) && cgo && !osusergo
-// +build dragonfly darwin freebsd !android,linux netbsd openbsd
+//go:build (dragonfly || darwin || freebsd || (!android && linux) || netbsd || openbsd || (solaris && !illumos)) && cgo && !osusergo
+// +build dragonfly darwin freebsd !android,linux netbsd openbsd solaris,!illumos
// +build cgo
// +build !osusergo
if runtime.GOOS == "aix" {
t.Skip("skipping GroupIds, see golang.org/issue/30563")
}
- if runtime.GOOS == "solaris" || runtime.GOOS == "illumos" {
+ if runtime.GOOS == "illumos" {
t.Skip("skipping GroupIds, see golang.org/issue/14709")
}
user, err := Current()