container: Gracefully handle failure to set up user namespaces.
authorLudovic Courtès <ludo@gnu.org>
Mon, 30 May 2016 20:13:09 +0000 (22:13 +0200)
committerLudovic Courtès <ludo@gnu.org>
Mon, 30 May 2016 22:11:04 +0000 (00:11 +0200)
* gnu/build/linux-container.scm (run-container): Exit when the parent
process doesn't say 'ready.

gnu/build/linux-container.scm

index ec68679..562d50b 100644 (file)
@@ -214,15 +214,18 @@ host user identifiers to map into the user namespace."
            (lambda ()
              (close out)
              ;; Wait for parent to set things up.
-             (read in)
-             (close in)
-             (purify-environment)
-             (when (memq 'mnt namespaces)
-               (mount-file-systems root mounts
-                                   #:mount-/proc? (memq 'pid namespaces)
-                                   #:mount-/sys?  (memq 'net namespaces)))
-             ;; TODO: Manage capabilities.
-             (thunk))))
+             (match (read in)
+               ('ready
+                (close in)
+                (purify-environment)
+                (when (memq 'mnt namespaces)
+                  (mount-file-systems root mounts
+                                      #:mount-/proc? (memq 'pid namespaces)
+                                      #:mount-/sys?  (memq 'net namespaces)))
+                ;; TODO: Manage capabilities.
+                (thunk))
+               (_                                 ;parent died or something
+                (primitive-exit 2))))))
          (pid
           (when (memq 'user namespaces)
             (initialize-user-namespace pid host-uids))