summaryrefslogtreecommitdiff
path: root/gnu/installer
diff options
context:
space:
mode:
authorMathieu Othacehe <othacehe@gnu.org>2020-09-09 09:24:49 +0200
committerMathieu Othacehe <othacehe@gnu.org>2020-09-10 09:38:52 +0200
commitcafbc5f39084cff62879206d69a3890fce54dc27 (patch)
treed3391ae7234dc0958e9b96fc16c56edc47e3e051 /gnu/installer
parentb3a83f1ece4b6c8bfcc2a9875df51142c0e39904 (diff)
installer: final: Introduce call-with-mnt-container.
* gnu/installer/final.scm (call-with-mnt-container): New procedure, (install-system): use it instead of call-with-container, to make sure that the container is not jailed.
Diffstat (limited to 'gnu/installer')
-rw-r--r--gnu/installer/final.scm19
1 files changed, 16 insertions, 3 deletions
diff --git a/gnu/installer/final.scm b/gnu/installer/final.scm
index 11143b2adbe..fc0b7803fa7 100644
--- a/gnu/installer/final.scm
+++ b/gnu/installer/final.scm
@@ -135,6 +135,20 @@ USERS."
135 (_ #f)))))) 135 (_ #f))))))
136 pids))) 136 pids)))
137 137
138(define (call-with-mnt-container thunk)
139 "This is a variant of call-with-container. Run THUNK in a new container
140process, within a separate MNT namespace. The container is not jailed so that
141it can interact with the rest of the system."
142 (let ((pid (run-container "/" '() '(mnt) 1 thunk)))
143 ;; Catch SIGINT and kill the container process.
144 (sigaction SIGINT
145 (lambda (signum)
146 (false-if-exception
147 (kill pid SIGKILL))))
148
149 (match (waitpid pid)
150 ((_ . status) status))))
151
138(define* (install-system locale #:key (users '())) 152(define* (install-system locale #:key (users '()))
139 "Create /etc/shadow and /etc/passwd on the installation target for USERS. 153 "Create /etc/shadow and /etc/passwd on the installation target for USERS.
140Start COW-STORE service on target directory and launch guix install command in 154Start COW-STORE service on target directory and launch guix install command in
@@ -181,7 +195,7 @@ or #f. Return #t on success and #f on failure."
181 ;; To avoid this situation, mount the store overlay inside a container, 195 ;; To avoid this situation, mount the store overlay inside a container,
182 ;; and run the installation from within that container. 196 ;; and run the installation from within that container.
183 (zero? 197 (zero?
184 (call-with-container '() 198 (call-with-mnt-container
185 (lambda () 199 (lambda ()
186 (dynamic-wind 200 (dynamic-wind
187 (lambda () 201 (lambda ()
@@ -218,5 +232,4 @@ or #f. Return #t on success and #f on failure."
218 232
219 ;; Finally umount the cow-store and exit the container. 233 ;; Finally umount the cow-store and exit the container.
220 (unmount-cow-store (%installer-target-dir) backing-directory) 234 (unmount-cow-store (%installer-target-dir) backing-directory)
221 (assert-exit ret)))) 235 (assert-exit ret))))))))
222 #:namespaces '(mnt)))))