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

use getrandom function #5851

Closed
mmeeks opened this issue Feb 14, 2023 · 4 comments · Fixed by #5897 or #6211
Closed

use getrandom function #5851

mmeeks opened this issue Feb 14, 2023 · 4 comments · Fixed by #5897 or #6211

Comments

@mmeeks
Copy link
Contributor

mmeeks commented Feb 14, 2023

This is an Easy Hack.
Potential mentors: @Ashod

Detailed description and rationale

Currently we need the capability CAP_MKNOD in order to create our jails - but we only use this to create /dev/random and /dev/urandom. There is however no need for these nodes on modern systems:
https://lwn.net/Articles/711013/
Suggests this is un-necessary - and we can detect and use 'getrandom' on Linux, and getentropy on BSD which should use direct sys-calls. That should let us drop this un-necessary capability.

Code pointers

git grep /dev/urandom # in online - and also in core.
git grep CAP_MKNOD

Hopefully not a horribly hard one. Quite probably we want to test hard vs. eg. inserting https:// URLs to ensure our required openssl / nss etc. libraries can live without /dev/urandom and /dev/random.

@Ashod
Copy link
Contributor

Ashod commented Feb 24, 2023

Worth mentioning that we also need to test password-protected files and document signing, which both depend on /dev/[u]random to be available.

@Ashod
Copy link
Contributor

Ashod commented Feb 25, 2023

While getrandom() can replace /dev/[u]random on Linux, we still need to support non-Linux systems. So, the correct way to support this is to check in configure.ac for getrandom() and only then enable using it, via #ifdef compiler directives.

Basically, we need to add a check in configure.ac to see if getrandom() is available. If yes, then we need to define a compile-time directive (say, ENABLE_GET_RANDOM or something like that, compatible with the current naming convention) and in the code have #ifdef ENABLE_GET_RANDOM to use either getrandom() or the old code.

We cannot remove the old code, just yet.

@Ashod
Copy link
Contributor

Ashod commented Mar 17, 2023

The Linux side is now supported, thanks to #5897 and @bayramcicek. However, BSD is still missing, so will keep this open until we support BSD as well.

@arrowd
Copy link
Contributor

arrowd commented May 1, 2023

Thanks for not forgetting FreeBSD when adding new features!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
4 participants