Skip to content
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

Got an error while building to SunOS #36

Open
KrutNA opened this issue Feb 2, 2020 · 6 comments
Open

Got an error while building to SunOS #36

KrutNA opened this issue Feb 2, 2020 · 6 comments

Comments

@KrutNA
Copy link

KrutNA commented Feb 2, 2020

Steps to reproduce:

Try to build users crate to sparcv9-sun-solaris or x86_64-sun-solaris archs.
I'm trying to cross compile fselect and used cross for cross compiling to other archs

Expected:

Compiled successfully.

Got:

   Compiling users v0.9.1
error[E0425]: cannot find function `getgrouplist` in crate `libc`
   --> /cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/users-0.9.1/src/base.rs:707:15
    |
707 |         libc::getgrouplist(name.as_ptr(), gid, buff.as_mut_ptr(), &mut count)
    |               ^^^^^^^^^^^^ help: a function with a similar name exists: `getgroups`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0425`.
error: could not compile `users`.
warning: build failed, waiting for other jobs to finish...
error: build failed

As I checked crate libc, I found in documentation: there is no functions getgrouplist for this archs.
libc/platform-specific-documentation

@KrutNA KrutNA changed the title Building to Solaris Building to SunOS Feb 2, 2020
@KrutNA KrutNA changed the title Building to SunOS Got an error while building to SunOS Feb 2, 2020
@ogham
Copy link
Owner

ogham commented Oct 8, 2020

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.

@Toasterson
Copy link

Toasterson commented Jan 30, 2022

@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

@papertigers
Copy link

papertigers commented Jan 30, 2022

@Toasterson
Copy link

Awesome thanks. Now with a modern enough version of libc and your PR it compiled. Up to testing metadata agent on bhyve :)

@nospam3089
Copy link

For what it's worth, the addition of getgrouplist was mentioned in the Release Notes for r151038.

@Toasterson
Copy link

Ping @ogham getgrouplist has been added for illumos libc in rust. do you need anything else?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants