]> Cypherpunks repositories - gostls13.git/commitdiff
os/user: implement (*User).GroupIds on solaris
authorTobias Klauser <tklauser@distanz.ch>
Sat, 1 May 2021 15:41:34 +0000 (15:41 +0000)
committerTobias Klauser <tobias.klauser@gmail.com>
Sun, 2 May 2021 21:27:08 +0000 (21:27 +0000)
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>
src/os/user/getgrouplist_unix.go
src/os/user/listgroups_illumos.go [moved from src/os/user/listgroups_solaris.go with 74% similarity]
src/os/user/listgroups_unix.go
src/os/user/user_test.go

index 8393c5a474c24ce58eb1c612fc05701dd69155ac..fd66961ccf716616648d8132413169672bc7e6da 100644 (file)
@@ -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
 
similarity index 74%
rename from src/os/user/listgroups_solaris.go
rename to src/os/user/listgroups_illumos.go
index d993d3057024dd753182c739b166afbc01ffdb9d..d25e0339b99593d909c012cbdc274de242f68dad 100644 (file)
@@ -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)
 }
index c7b72062d5cbf2e01776940ec88f21609eb6e7b8..38aa7653b054f6b2cb101b76865b4cc7aa75017d 100644 (file)
@@ -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
 
index 8c4c817c2b63cd1a0d798b4d3cb91f7274423ec7..49920317bed93b9c7c32baea3d4f809c2127f538 100644 (file)
@@ -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()