mirror of
https://github.com/golang/go
synced 2024-11-07 01:56:17 -07:00
os/user: implement (*User).GroupIds on solaris
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
f2c438c505
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>
This commit is contained in:
parent
b177b2d51e
commit
abb110bf3d
@ -2,8 +2,8 @@
|
||||
// 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
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// 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.
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
// +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
|
||||
@ -14,5 +14,5 @@ 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)
|
||||
}
|
@ -2,8 +2,8 @@
|
||||
// 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
|
||||
|
||||
|
@ -132,7 +132,7 @@ func TestGroupIds(t *testing.T) {
|
||||
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()
|
||||
|
Loading…
Reference in New Issue
Block a user