summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaleb Ristvedt <caleb.ristvedt@cune.org>2019-12-12 07:04:07 -0600
committerCaleb Ristvedt <caleb.ristvedt@cune.org>2020-04-13 13:14:50 -0500
commit73da0e3a2396cabbeafa12b31f37ada05a95e762 (patch)
treed52da38238286e5cca486222fef95a136c56ce5e
parent14499efc250282cd0fc305fe19a927feb26d1916 (diff)
gnu: linux-container: Make it more suitable for derivation-building.
* gnu/build/linux-container.scm (mount-file-systems): First remount all filesystems in the current mount namespace as private (by mounting / with MS_PRIVATE and MS_REC), so that the set of mounts cannot increase except from within the container. Also, the tmpfs mounted over the chroot directory now inherits the chroot directory's permissions (p11-kit, for example, has a test that assumes that the root directory is not writable for the current user, and tmpfs is by default 1777 when created). * guix/build/syscalls.scm (MS_PRIVATE, MS_REC): new variables.
-rw-r--r--gnu/build/linux-container.scm9
-rw-r--r--guix/build/syscalls.scm4
2 files changed, 12 insertions, 1 deletions
diff --git a/gnu/build/linux-container.scm b/gnu/build/linux-container.scm
index 87695c98fdd..adfcc32d2c6 100644
--- a/gnu/build/linux-container.scm
+++ b/gnu/build/linux-container.scm
@@ -99,7 +99,14 @@ for the process."
99 99
100 ;; The container's file system is completely ephemeral, sans directories 100 ;; The container's file system is completely ephemeral, sans directories
101 ;; bind-mounted from the host. 101 ;; bind-mounted from the host.
102 (mount "none" root "tmpfs") 102 ;; Make this private in the container namespace so everything mounted under
103 ;; it is local to this namespace.
104 (mount "none" "/" "none" (logior MS_REC MS_PRIVATE))
105 (let ((current-perms (stat:perms (stat root))))
106 (mount "none" root "tmpfs" 0 (string-append "mode="
107 (number->string current-perms
108 8))))
109
103 110
104 ;; A proc mount requires a new pid namespace. 111 ;; A proc mount requires a new pid namespace.
105 (when mount-/proc? 112 (when mount-/proc?
diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm
index 0938ec0ff10..b9d19380caa 100644
--- a/guix/build/syscalls.scm
+++ b/guix/build/syscalls.scm
@@ -45,6 +45,8 @@
45 MS_MOVE 45 MS_MOVE
46 MS_STRICTATIME 46 MS_STRICTATIME
47 MS_LAZYTIME 47 MS_LAZYTIME
48 MS_PRIVATE
49 MS_REC
48 MNT_FORCE 50 MNT_FORCE
49 MNT_DETACH 51 MNT_DETACH
50 MNT_EXPIRE 52 MNT_EXPIRE
@@ -452,6 +454,8 @@ the returned procedure is called."
452(define MS_NOATIME 1024) 454(define MS_NOATIME 1024)
453(define MS_BIND 4096) 455(define MS_BIND 4096)
454(define MS_MOVE 8192) 456(define MS_MOVE 8192)
457(define MS_REC 16384)
458(define MS_PRIVATE 262144)
455(define MS_STRICTATIME 16777216) 459(define MS_STRICTATIME 16777216)
456(define MS_LAZYTIME 33554432) 460(define MS_LAZYTIME 33554432)
457 461