diff options
| author | Arun Isaac <arunisaac@systemreboot.net> | 2019-05-22 01:46:54 +0530 |
|---|---|---|
| committer | Arun Isaac <arunisaac@systemreboot.net> | 2019-05-25 11:06:22 +0530 |
| commit | d2928fa63f97844f8b60b9baf8e9a023ee7f2f80 (patch) | |
| tree | 5350efe6dbf81c68aee81618590c596ab2121705 /gnu/system | |
| parent | 8698d986db21d6399fb57f1af1e38d6223bf9b92 (diff) | |
linux-container: Check if nscd run directory exists when container is run.
* gnu/system/linux-container.scm (containerized-operating-system):
(container-script): Check for existence of the host nscd run directory in the
container script. This check should be run when the container is started, not
when the container script is created.
[network-mappings]: Delete variable.
[nscd-run-directory, nscd-mapping]: New variables.
Diffstat (limited to 'gnu/system')
| -rw-r--r-- | gnu/system/linux-container.scm | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/gnu/system/linux-container.scm b/gnu/system/linux-container.scm index 16eee7a3cd0..c1e963d0473 100644 --- a/gnu/system/linux-container.scm +++ b/gnu/system/linux-container.scm | |||
| @@ -109,7 +109,10 @@ containerized OS. EXTRA-FILE-SYSTEMS is a list of file systems to add to OS." | |||
| 109 | (memq (service-kind service) | 109 | (memq (service-kind service) |
| 110 | useless-services)) | 110 | useless-services)) |
| 111 | (operating-system-user-services os))) | 111 | (operating-system-user-services os))) |
| 112 | (file-systems (append (map mapping->fs mappings) | 112 | (file-systems (append (map mapping->fs |
| 113 | (if shared-network? | ||
| 114 | (append %network-file-mappings mappings) | ||
| 115 | mappings)) | ||
| 113 | extra-file-systems | 116 | extra-file-systems |
| 114 | user-file-systems | 117 | user-file-systems |
| 115 | 118 | ||
| @@ -124,32 +127,33 @@ containerized OS. EXTRA-FILE-SYSTEMS is a list of file systems to add to OS." | |||
| 124 | "Return a derivation of a script that runs OS as a Linux container. | 127 | "Return a derivation of a script that runs OS as a Linux container. |
| 125 | MAPPINGS is a list of <file-system> objects that specify the files/directories | 128 | MAPPINGS is a list of <file-system> objects that specify the files/directories |
| 126 | that will be shared with the host system." | 129 | that will be shared with the host system." |
| 127 | (define network-mappings | 130 | (define nscd-run-directory "/var/run/nscd") |
| 128 | ;; Files to map if network is to be shared with the host | 131 | |
| 129 | (append %network-file-mappings | 132 | (define nscd-mapping |
| 130 | (let ((nscd-run-directory "/var/run/nscd")) | 133 | (file-system-mapping |
| 131 | (if (file-exists? nscd-run-directory) | 134 | (source nscd-run-directory) |
| 132 | (list (file-system-mapping | 135 | (target nscd-run-directory))) |
| 133 | (source nscd-run-directory) | ||
| 134 | (target nscd-run-directory))) | ||
| 135 | '())))) | ||
| 136 | 136 | ||
| 137 | (define (mountable-file-system? file-system) | 137 | (define (mountable-file-system? file-system) |
| 138 | ;; Return #t if FILE-SYSTEM should be mounted in the container. | 138 | ;; Return #t if FILE-SYSTEM should be mounted in the container. |
| 139 | (and (not (string=? "/" (file-system-mount-point file-system))) | 139 | (and (not (string=? "/" (file-system-mount-point file-system))) |
| 140 | (file-system-needed-for-boot? file-system))) | 140 | (file-system-needed-for-boot? file-system))) |
| 141 | 141 | ||
| 142 | (let* ((os (containerized-operating-system | 142 | (define (os-file-system-specs os) |
| 143 | os | 143 | (map file-system->spec |
| 144 | (cons %store-mapping | 144 | (filter mountable-file-system? |
| 145 | (if shared-network? | 145 | (operating-system-file-systems os)))) |
| 146 | (append network-mappings mappings) | 146 | |
| 147 | mappings)) | 147 | (let* ((os (containerized-operating-system |
| 148 | #:shared-network? shared-network? | 148 | os (cons %store-mapping mappings) |
| 149 | #:extra-file-systems %container-file-systems)) | 149 | #:shared-network? shared-network? |
| 150 | (file-systems (filter mountable-file-system? | 150 | #:extra-file-systems %container-file-systems)) |
| 151 | (operating-system-file-systems os))) | 151 | (nscd-os (containerized-operating-system |
| 152 | (specs (map file-system->spec file-systems))) | 152 | os (cons* nscd-mapping %store-mapping mappings) |
| 153 | #:shared-network? shared-network? | ||
| 154 | #:extra-file-systems %container-file-systems)) | ||
| 155 | (specs (os-file-system-specs os)) | ||
| 156 | (nscd-specs (os-file-system-specs nscd-os))) | ||
| 153 | 157 | ||
| 154 | (define script | 158 | (define script |
| 155 | (with-imported-modules (source-module-closure | 159 | (with-imported-modules (source-module-closure |
| @@ -160,7 +164,12 @@ that will be shared with the host system." | |||
| 160 | (gnu system file-systems) ;spec->file-system | 164 | (gnu system file-systems) ;spec->file-system |
| 161 | (guix build utils)) | 165 | (guix build utils)) |
| 162 | 166 | ||
| 163 | (call-with-container (map spec->file-system '#$specs) | 167 | (call-with-container |
| 168 | (map spec->file-system | ||
| 169 | (if (and #$shared-network? | ||
| 170 | (file-exists? #$nscd-run-directory)) | ||
| 171 | '#$nscd-specs | ||
| 172 | '#$specs)) | ||
| 164 | (lambda () | 173 | (lambda () |
| 165 | (setenv "HOME" "/root") | 174 | (setenv "HOME" "/root") |
| 166 | (setenv "TMPDIR" "/tmp") | 175 | (setenv "TMPDIR" "/tmp") |
