]> Cypherpunks repositories - gostls13.git/commit
os/user: implement go native GroupIds
authorKir Kolyshkin <kolyshkin@gmail.com>
Thu, 24 Jun 2021 03:46:11 +0000 (20:46 -0700)
committerIan Lance Taylor <iant@golang.org>
Tue, 21 Sep 2021 23:11:47 +0000 (23:11 +0000)
commit30faf968b1f348e944db3bde24c13462125007b1
tree2e7d72bf58812fbb48d7c44b42afea6b234f9071
parent48cf96c256ff1ec68fd9f9daa59900352d916730
os/user: implement go native GroupIds

Currently, GroupIds (a method that returns supplementary group IDs
for a user) is not implemented when cgo is not available, or osusergo
build tag is set, or the underlying OS lacks getgrouplist(3).

This adds a native Go implementation of GroupIds (which parses
/etc/group) for such cases, together with some tests.

This implementation is used:
 - when cgo is not available;
 - when osusergo build tag is set;
 - on AIX (which lacks getgrouplist(3));
 - on Illumos (which only recently added getgrouplist(3)).

This commit moves listgroups_unix.go to cgo_listgroups_unix.go, and adds
listgroups_unix.go which implements the feature.

NOTE the +build equivalent of go:build expression in listgroups_unix.go
is not provided as it is going to be bulky. Go 1.17 already prefers
go:build over +build, and no longer fail if a file contains go:build
without +build, so the absence of +build is not a problem even with Go
1.17, and this code is targeted for Go 1.18.

Updates #14709
Updates #30563

Change-Id: Icc95cda97ee3bcb03ef028b16eab7d3faba9ffab
Reviewed-on: https://go-review.googlesource.com/c/go/+/330753
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
src/os/user/cgo_listgroups_unix.go [new file with mode: 0644]
src/os/user/listgroups_aix.go [deleted file]
src/os/user/listgroups_illumos.go [deleted file]
src/os/user/listgroups_stub.go [new file with mode: 0644]
src/os/user/listgroups_unix.go
src/os/user/listgroups_unix_test.go [new file with mode: 0644]
src/os/user/lookup_stubs.go
src/os/user/lookup_unix.go
src/os/user/lookup_unix_test.go
src/os/user/user.go