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

getrandom(2) is missing from the bindings #659

Closed
marmistrz opened this issue Jul 10, 2017 · 5 comments · Fixed by #1399
Closed

getrandom(2) is missing from the bindings #659

marmistrz opened this issue Jul 10, 2017 · 5 comments · Fixed by #1399
Labels
C-API-request Category: API request

Comments

@marmistrz
Copy link
Contributor

We have getentropy, but not getrandom

@marmistrz
Copy link
Contributor Author

This can't be implemented until glibc in CI becomes 2.25, adding this binding will break the crate for < 2.25.

@kristate
Copy link
Contributor

Hi @marmistrz ! I am trying to clean-up issues: is this still an issue for you?
(btw, I would recommend lib rand or other cryptographic libraries instead of relying on getrandom(2))

@marmistrz
Copy link
Contributor Author

@kristate I'm not currently working on the project which needed that, but I still consider this an issue. I should be able use getrandom if my libc is new enough. Otherwise, it defies the purpose of this crate.

IIRC the project did something pretty low-level and thus I wanted to use the syscall directly, but I don't remember the details.

maybe you should do a feature build, just like gtk-rs does - e.g. I can explicitly demand glibc >= 2.25 in my cargo.toml - or just say that I demand that the libc supports getrandom, and then the bindings are generated.

@gnzlbg
Copy link
Contributor

gnzlbg commented May 24, 2019

The version of glibc being targeted on CI (and therefore, the minimum version of glibc supported), has been updated. Please feel free to submit a PR implementing these.

@briansmith
Copy link

The version of glibc being targeted on CI (and therefore, the minimum version of glibc supported), has been updated. Please feel free to submit a PR implementing these.

My understanding from https://lwn.net/Articles/711013/ is that glibc does NOT implement a fallback in the case that the getrandom() syscall is unavailable. Is that correct, or have things changed? If so, I agree it is a really good idea to expose libc::getrandom() so that no Rust code needs to use the vararg syscall function. (varargs are a bad idea, in general.)

josephlr added a commit to josephlr/libc that referenced this issue Jun 13, 2019
bors added a commit that referenced this issue Jun 17, 2019
Add getrandom() bindings on Linux

Closes #659
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-API-request Category: API request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants