From 3e4540b49d3066ee3fd57f3456506f6d09d0129b Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 11 Sep 2025 09:57:00 -0700 Subject: [PATCH] os/user: use getgrouplist on illumos && cgo The getgrouplist call is available on Illumos since December 2020: https://github.com/illumos/illumos-gate/commit/f2c438c5058c64b7373448f239156bf60009abcb We can assume it is available for users now. Let's switch to using it when cgo is enabled. Since neither LUCY nor legacy trybots provide illumos, I tested this locally in a OpenIndiana VM, with and without osusergo, with cgo enabled and disabled. This is a continuation of CL 315278. Fixes #14709 Change-Id: I922049e7ea5f450f6900914b30967e522e56cfc9 Reviewed-on: https://go-review.googlesource.com/c/go/+/702975 Reviewed-by: Andrew Stormont Auto-Submit: Damien Neil Reviewed-by: Tobias Klauser Reviewed-by: Ian Lance Taylor Reviewed-by: Cherry Mui Reviewed-by: Damien Neil Auto-Submit: Kirill Kolyshkin TryBot-Bypass: Kirill Kolyshkin --- src/os/user/cgo_listgroups_unix.go | 2 +- src/os/user/getgrouplist_unix.go | 2 +- src/os/user/listgroups_unix.go | 2 +- src/os/user/listgroups_unix_test.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/os/user/cgo_listgroups_unix.go b/src/os/user/cgo_listgroups_unix.go index 59636954b2..6b88f30c55 100644 --- a/src/os/user/cgo_listgroups_unix.go +++ b/src/os/user/cgo_listgroups_unix.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build (cgo || darwin) && !osusergo && (darwin || dragonfly || freebsd || (linux && !android) || netbsd || openbsd || (solaris && !illumos)) +//go:build (cgo || darwin) && !osusergo && (darwin || dragonfly || freebsd || (linux && !android) || netbsd || openbsd || solaris) package user diff --git a/src/os/user/getgrouplist_unix.go b/src/os/user/getgrouplist_unix.go index fb482d35ba..81b4cb74f9 100644 --- a/src/os/user/getgrouplist_unix.go +++ b/src/os/user/getgrouplist_unix.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build cgo && !osusergo && (dragonfly || freebsd || (!android && linux) || netbsd || openbsd || (solaris && !illumos)) +//go:build cgo && !osusergo && (dragonfly || freebsd || (!android && linux) || netbsd || openbsd || solaris) package user diff --git a/src/os/user/listgroups_unix.go b/src/os/user/listgroups_unix.go index 67bd8a776e..570926fae0 100644 --- a/src/os/user/listgroups_unix.go +++ b/src/os/user/listgroups_unix.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build ((darwin || dragonfly || freebsd || (js && wasm) || wasip1 || (!android && linux) || netbsd || openbsd || solaris) && ((!cgo && !darwin) || osusergo)) || aix || illumos +//go:build ((darwin || dragonfly || freebsd || (js && wasm) || wasip1 || (!android && linux) || netbsd || openbsd || solaris) && ((!cgo && !darwin) || osusergo)) || aix package user diff --git a/src/os/user/listgroups_unix_test.go b/src/os/user/listgroups_unix_test.go index 9619462cec..252eef07ee 100644 --- a/src/os/user/listgroups_unix_test.go +++ b/src/os/user/listgroups_unix_test.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build ((darwin || dragonfly || freebsd || (js && wasm) || wasip1 || (!android && linux) || netbsd || openbsd || solaris) && ((!cgo && !darwin) || osusergo)) || aix || illumos +//go:build ((darwin || dragonfly || freebsd || (js && wasm) || wasip1 || (!android && linux) || netbsd || openbsd || solaris) && ((!cgo && !darwin) || osusergo)) || aix package user -- 2.52.0