Skip to content

Commit 7a7d2d1

Browse files
committed
fix command-create-pidfd test inside unprivileged docker containers
1 parent 4e90017 commit 7a7d2d1

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/test/ui/command/command-create-pidfd.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,18 @@ fn has_clone3() -> bool {
1515
let err = (res == -1)
1616
.then(|| Error::last_os_error())
1717
.expect("probe syscall should not succeed");
18-
err.raw_os_error() != Some(libc::ENOSYS)
18+
19+
// If the `clone3` syscall is not implemented in the current kernel version it should return an
20+
// `ENOSYS` error. Docker also blocks the whole syscall inside unprivileged containers, and
21+
// returns `EPERM` (instead of `ENOSYS`) when a program tries to invoke the syscall. Because of
22+
// that we need to check for *both* `ENOSYS` and `EPERM`.
23+
//
24+
// Note that Docker's behavior is breaking other projects (notably glibc), so they're planning
25+
// to update their filtering to return `ENOSYS` in a future release:
26+
//
27+
// https://github.com/moby/moby/issues/42680
28+
//
29+
err.raw_os_error() != Some(libc::ENOSYS) && err.raw_os_error() != Some(libc::EPERM)
1930
}
2031

2132
fn main() {

0 commit comments

Comments
 (0)