Open KrutNA opened 4 years ago
I did some digging into this. Oracle's libc documentation has a page for getgrouplist
, but I've seen references to other projects saying Solaris doesn't have that function, so there must be a reason why it's missing from Rust's libc.
If we can't use getgrouplist
, then, we'd have to write our own version. However — and this is where it gets difficult — we'd have to iterate through the groups list using getgrent
/setgrent
/endgrent
, which mutates a structure internal to libc that's effectively global. See the doc comment for all_users
for why this is so annoying. As this is meant to be a library, rather than an application, we have no way of ensuring that our getgrouplist
replacement is the only code using those three functions exclusively.
I'll have to mark this one as "help wanted" until a better solution comes along. The only workaround I can offer is to add a feature flag to omit all the functions that use getgrouplist
, but that doesn't help you if you're trying to port an existing application.
@papertigers @jclulow can we push that function on the illumos side into libc? I think this library is the only one implementing user related functionality in rust so some better support is good for rust projects wanting to check/modify os user configs.
I get this error aswell on illumos
It's there now: https://rust-lang.github.io/libc/x86_64-unknown-illumos/doc/libc/fn.getgrouplist.html And the corresponding illumos commit: https://github.com/illumos/illumos-gate/commit/f2c438c5058c64b7373448f239156bf60009abcb
Awesome thanks. Now with a modern enough version of libc and your PR it compiled. Up to testing metadata agent on bhyve :)
For what it's worth, the addition of getgrouplist
was mentioned in the Release Notes for r151038.
Ping @ogham getgrouplist
has been added for illumos libc in rust. do you need anything else?
Steps to reproduce:
Try to build
users
crate tosparcv9-sun-solaris
orx86_64-sun-solaris
archs. I'm trying to cross compilefselect
and usedcross
for cross compiling to other archsExpected:
Compiled successfully.
Got:
As I checked crate
libc
, I found in documentation: there is no functionsgetgrouplist
for this archs. libc/platform-specific-documentation