New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
os/user: add illumos getgroups support #14709
Comments
Apparently Solaris didn't have getgrouplist until recently. I found elsewhere that "getgrouplist() is provided by the latest Solaris 11.2 SRU 11.2.10.5.0, released 15 May 2015. It will be available in all future updates/releases." But apparently our builders don't have that. @4ad, advice? |
Actually, we should just not try to build it & test it. I'll send out a CL. We can keep this bug open to add support later. |
Or rather, I'll wait for @zombiezen to finish his pending CLs, since my change would necessarily split lookup_unix.go into two halves probably (user lookup vs group lookup, with different build tags), or maybe add a group_solaris.go file with an Ross, let me know if you prefer to tackle this. |
We will have to implement getgrouplist for Solaris ourselves. In the meantime we can stub it. |
I can roll in the stub as part of https://golang.org/cl/20348, since I'm already splitting out the OS-specific functionality. |
Great, thanks. |
CL https://golang.org/cl/20348 mentions this issue. |
Just to point out, the other group-related functionality should still work on Solaris (let me know if it doesn't). |
Parsing /etc/groups as a fallback seems fine too. |
Repurposing this bug to add Solaris support, since this is the bug number references in the |
Some versions of Solaris support this function, so ideally, if there is a sanctioned way to see if we can import the symbol from libc, and if it's nil, then fallback to the other functionality, that seems like the best option. |
use dlsym?
ideally we should use weak symbols, but our linker doesn't
support that.
|
We are talking about cgo here, and my understanding is that Solaris doesn't support internal linking anyhow. So I think we could use a weak reference in the C code. |
The internal linker works just fine on Solaris. Not sure I understand? |
Sorry, I expect it is me that does not understand. |
I guess I was assuming that cgo import dynamic would simply assign nil for symbols it can't find: //go:cgo_import_dynamic libc_Getgrouplist getgrouplist "libc.so" My assumption was we could just check for nil in the wrapper function, if not nil, call the function, and if nil, fallback to other logic. But I don't know if that's possible. |
A little clarification.
The current os/user on other Unix platforms uses cgo
to access libc functions, however, on Solaris, every
program is dynamic linked, and even pure Go program
to access libc functions by using //go:cgo_import_dynamic.
That is, pure Go programs on Solaris will use internal
linking, but are still able to call arbitrary libc functions.
My comment about lack of weak symbols is primarily
about this case.
Also note that solaris cgo also supports internal linking,
so I'm afraid we can't use weak symbols if still want to
be able to internal linking on programs that uses os/user.
In summary, I propose we just use dlsym at runtime.
|
Stumbled on this issue yesterday while working on the application for Illumnos based OS. And I see there are existing private functions for /etc/group parsing inside user package. |
No, we need to do what @minux said in his last reply. |
I'm not sure why nobody suggested implementing this using getgrent. There's no actual need to have getgrouplist. |
See: #40667 |
Change https://golang.org/cl/315278 mentions this issue: |
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 illumos/illumos-gate@f2c438c 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>
https://golang.org/cl/315278 added support for solaris, repurposing this issue to add support on illumos. |
https://go-review.googlesource.com/c/go/+/330753 implements /etc/passwd parsing, and unconditionally enables that for illumos. As far as I understand this lands in Go 1.18. Ideally, what's needed (on top of the above, for Illumos) is a dynamic check if |
Change https://golang.org/cl/330753 mentions this issue: |
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>
Solaris is broken after the os/user groups change:
http://build.golang.org/log/26a14fbc0126ab1ed65eaeffe18362689b13a54f
Let me know if you need help testing on Solaris. It's not yet a trybot, due to lack of time.
The text was updated successfully, but these errors were encountered: