Skip to content

Commit 7782703

Browse files
author
Askar Safin
committed
This commit is part of clone3 clean up. As part of clean up we will
remove tests/ui/command/command-create-pidfd.rs . But it contains very useful comment, so let's move the comment to library/std/src/sys/pal/unix/rand.rs , which contains another instance of the same Docker problem
1 parent f8ec171 commit 7782703

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

std/src/sys/pal/unix/rand.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,18 @@ mod imp {
106106
// supported on the current kernel.
107107
//
108108
// Also fall back in case it is disabled by something like
109-
// seccomp or inside of virtual machines.
109+
// seccomp or inside of docker.
110+
//
111+
// If the `getrandom` syscall is not implemented in the current kernel version it should return an
112+
// `ENOSYS` error. Docker also blocks the whole syscall inside unprivileged containers, and
113+
// returns `EPERM` (instead of `ENOSYS`) when a program tries to invoke the syscall. Because of
114+
// that we need to check for *both* `ENOSYS` and `EPERM`.
115+
//
116+
// Note that Docker's behavior is breaking other projects (notably glibc), so they're planning
117+
// to update their filtering to return `ENOSYS` in a future release:
118+
//
119+
// https://github.com/moby/moby/issues/42680
120+
//
110121
GETRANDOM_UNAVAILABLE.store(true, Ordering::Relaxed);
111122
return false;
112123
} else if err == libc::EAGAIN {

0 commit comments

Comments
 (0)