diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2023-01-30 22:20:18 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2023-01-30 22:24:27 +0100 |
| commit | 0ef8fe22ed8985c9656835fc25ab3463d55b6669 (patch) | |
| tree | 87f453456f8d29da3c4eca9f8f495e17ce9a3d97 /gnu/build/linux-container.scm | |
| parent | 52eb3db19cb9e5c294c86a8552a4baaa5b473672 (diff) | |
linux-container: 'container-excursion' forks to join the PID namespace.
Fixes <https://issues.guix.gnu.org/61156>.
* gnu/build/linux-container.scm (container-excursion): Add extra call to
'primitive-fork' and invoke THUNK in the child process.
* tests/containers.scm ("container-excursion"): Remove extra
'primitive-fork' call, now unnecessary.
("container-excursion*, /proc"): New test.
Diffstat (limited to 'gnu/build/linux-container.scm')
| -rw-r--r-- | gnu/build/linux-container.scm | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/gnu/build/linux-container.scm b/gnu/build/linux-container.scm index d11c49c0d80..dee68854004 100644 --- a/gnu/build/linux-container.scm +++ b/gnu/build/linux-container.scm | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2015 David Thompson <davet@gnu.org> | 2 | ;;; Copyright © 2015 David Thompson <davet@gnu.org> |
| 3 | ;;; Copyright © 2017-2019, 2022 Ludovic Courtès <ludo@gnu.org> | 3 | ;;; Copyright © 2017-2019, 2022, 2023 Ludovic Courtès <ludo@gnu.org> |
| 4 | ;;; | 4 | ;;; |
| 5 | ;;; This file is part of GNU Guix. | 5 | ;;; This file is part of GNU Guix. |
| 6 | ;;; | 6 | ;;; |
| @@ -432,7 +432,16 @@ return the exit status, an integer as returned by 'waitpid'." | |||
| 432 | '("user" "ipc" "uts" "net" "pid" "mnt")) | 432 | '("user" "ipc" "uts" "net" "pid" "mnt")) |
| 433 | (purify-environment) | 433 | (purify-environment) |
| 434 | (chdir "/") | 434 | (chdir "/") |
| 435 | (thunk)))) | 435 | |
| 436 | ;; Per setns(2), changing the PID namespace only applies to child | ||
| 437 | ;; processes, not to the process itself. Thus fork so that THUNK runs | ||
| 438 | ;; in the right PID namespace, which also gives it access to /proc. | ||
| 439 | (match (primitive-fork) | ||
| 440 | (0 (call-with-clean-exit thunk)) | ||
| 441 | (pid (primitive-exit | ||
| 442 | (match (waitpid pid) | ||
| 443 | ((_ . status) | ||
| 444 | (or (status:exit-val status) 127))))))))) | ||
| 436 | (pid | 445 | (pid |
| 437 | (match (waitpid pid) | 446 | (match (waitpid pid) |
| 438 | ((_ . status) | 447 | ((_ . status) |
