diff options
Diffstat (limited to 'gnu')
| -rw-r--r-- | gnu/build/linux-container.scm | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/gnu/build/linux-container.scm b/gnu/build/linux-container.scm index 556422bc38f..eb5dbf94a31 100644 --- a/gnu/build/linux-container.scm +++ b/gnu/build/linux-container.scm | |||
| @@ -19,16 +19,36 @@ | |||
| 19 | (define-module (gnu build linux-container) | 19 | (define-module (gnu build linux-container) |
| 20 | #:use-module (ice-9 format) | 20 | #:use-module (ice-9 format) |
| 21 | #:use-module (ice-9 match) | 21 | #:use-module (ice-9 match) |
| 22 | #:use-module (ice-9 rdelim) | ||
| 22 | #:use-module (srfi srfi-98) | 23 | #:use-module (srfi srfi-98) |
| 23 | #:use-module (guix utils) | 24 | #:use-module (guix utils) |
| 24 | #:use-module (guix build utils) | 25 | #:use-module (guix build utils) |
| 25 | #:use-module (guix build syscalls) | 26 | #:use-module (guix build syscalls) |
| 26 | #:use-module ((gnu build file-systems) #:select (mount-file-system)) | 27 | #:use-module ((gnu build file-systems) #:select (mount-file-system)) |
| 27 | #:export (%namespaces | 28 | #:export (user-namespace-supported? |
| 29 | unprivileged-user-namespace-supported? | ||
| 30 | setgroups-supported? | ||
| 31 | %namespaces | ||
| 28 | run-container | 32 | run-container |
| 29 | call-with-container | 33 | call-with-container |
| 30 | container-excursion)) | 34 | container-excursion)) |
| 31 | 35 | ||
| 36 | (define (user-namespace-supported?) | ||
| 37 | "Return #t if user namespaces are supported on this system." | ||
| 38 | (file-exists? "/proc/self/ns/user")) | ||
| 39 | |||
| 40 | (define (unprivileged-user-namespace-supported?) | ||
| 41 | "Return #t if user namespaces can be created by unprivileged users." | ||
| 42 | (let ((userns-file "/proc/sys/kernel/unprivileged_userns_clone")) | ||
| 43 | (if (file-exists? userns-file) | ||
| 44 | (string=? "1" (call-with-input-file userns-file read-string)) | ||
| 45 | #t))) | ||
| 46 | |||
| 47 | (define (setgroups-supported?) | ||
| 48 | "Return #t if the setgroups proc file, introduced in Linux-libre 3.19, | ||
| 49 | exists." | ||
| 50 | (file-exists? "/proc/self/setgroups")) | ||
| 51 | |||
| 32 | (define %namespaces | 52 | (define %namespaces |
| 33 | '(mnt pid ipc uts user net)) | 53 | '(mnt pid ipc uts user net)) |
| 34 | 54 | ||
