diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2019-09-12 22:17:43 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2019-09-12 23:07:42 +0200 |
| commit | 5ccec77176b7e0c67ed58c8849e5e76f3dd79a88 (patch) | |
| tree | c2979713d92479d096ec4133f6b1c2457539dd2c /gnu | |
| parent | f58b2f38e4dfdbb8473fb2816d44fae6ad9cbc79 (diff) | |
file-systems: Add /var/run/nscd to '%network-file-mappings'.
This allows containers created by "guix environment -CN" or by
"guix system container -N" to talk to the host nscd.
* gnu/system/file-systems.scm (%network-file-mappings): Add
"/var/run/nscd".
* gnu/build/shepherd.scm (default-mounts)[nscd-socket]: Remove.
* gnu/system/linux-container.scm (container-script)[nscd-run-directory]
[nscd-mapping, nscd-os, nscd-specs]: Remove.
[script]: Filter out from SPECS bind-mounts where the device does not
exist.
* guix/scripts/environment.scm (launch-environment/container)
[optional-mapping->fs]: New procedure.
[mappings]: Remove %NETWORK-FILE-MAPPINGS.
[file-systems]: Add %NETWORK-FILE-MAPPINGS here, filtered through
'optional-mapping->fs'.
Diffstat (limited to 'gnu')
| -rw-r--r-- | gnu/build/shepherd.scm | 8 | ||||
| -rw-r--r-- | gnu/system/file-systems.scm | 2 | ||||
| -rw-r--r-- | gnu/system/linux-container.scm | 35 |
3 files changed, 16 insertions, 29 deletions
diff --git a/gnu/build/shepherd.scm b/gnu/build/shepherd.scm index cf68f2108b7..b32765ed5e4 100644 --- a/gnu/build/shepherd.scm +++ b/gnu/build/shepherd.scm | |||
| @@ -67,16 +67,10 @@ | |||
| 67 | (file-system-mapping | 67 | (file-system-mapping |
| 68 | (source "/etc/group") (target source)))) | 68 | (source "/etc/group") (target source)))) |
| 69 | 69 | ||
| 70 | (define nscd-socket | ||
| 71 | (file-system-mapping | ||
| 72 | (source "/var/run/nscd") (target source) | ||
| 73 | (writable? #t))) | ||
| 74 | |||
| 75 | (append (cons (tmpfs "/tmp") %container-file-systems) | 70 | (append (cons (tmpfs "/tmp") %container-file-systems) |
| 76 | (let ((mappings `(,@(if (memq 'net namespaces) | 71 | (let ((mappings `(,@(if (memq 'net namespaces) |
| 77 | '() | 72 | '() |
| 78 | (cons nscd-socket | 73 | %network-file-mappings) |
| 79 | %network-file-mappings)) | ||
| 80 | ,@(if (and (memq 'mnt namespaces) | 74 | ,@(if (and (memq 'mnt namespaces) |
| 81 | (not (memq 'user namespaces))) | 75 | (not (memq 'user namespaces))) |
| 82 | accounts | 76 | accounts |
diff --git a/gnu/system/file-systems.scm b/gnu/system/file-systems.scm index d11b36f25da..6cf6ccc53eb 100644 --- a/gnu/system/file-systems.scm +++ b/gnu/system/file-systems.scm | |||
| @@ -508,7 +508,7 @@ a bind mount." | |||
| 508 | ;; symlink to a file in a tmpfs which, for an unknown reason, | 508 | ;; symlink to a file in a tmpfs which, for an unknown reason, |
| 509 | ;; cannot be bind mounted read-only within the container. | 509 | ;; cannot be bind mounted read-only within the container. |
| 510 | (writable? (string=? file "/etc/resolv.conf")))) | 510 | (writable? (string=? file "/etc/resolv.conf")))) |
| 511 | %network-configuration-files)) | 511 | (cons "/var/run/nscd" %network-configuration-files))) |
| 512 | 512 | ||
| 513 | (define (file-system-type-predicate type) | 513 | (define (file-system-type-predicate type) |
| 514 | "Return a predicate that, when passed a file system, returns #t if that file | 514 | "Return a predicate that, when passed a file system, returns #t if that file |
diff --git a/gnu/system/linux-container.scm b/gnu/system/linux-container.scm index 6273cee3d30..451a72762c7 100644 --- a/gnu/system/linux-container.scm +++ b/gnu/system/linux-container.scm | |||
| @@ -147,13 +147,6 @@ containerized OS. EXTRA-FILE-SYSTEMS is a list of file systems to add to OS." | |||
| 147 | "Return a derivation of a script that runs OS as a Linux container. | 147 | "Return a derivation of a script that runs OS as a Linux container. |
| 148 | MAPPINGS is a list of <file-system> objects that specify the files/directories | 148 | MAPPINGS is a list of <file-system> objects that specify the files/directories |
| 149 | that will be shared with the host system." | 149 | that will be shared with the host system." |
| 150 | (define nscd-run-directory "/var/run/nscd") | ||
| 151 | |||
| 152 | (define nscd-mapping | ||
| 153 | (file-system-mapping | ||
| 154 | (source nscd-run-directory) | ||
| 155 | (target nscd-run-directory))) | ||
| 156 | |||
| 157 | (define (mountable-file-system? file-system) | 150 | (define (mountable-file-system? file-system) |
| 158 | ;; Return #t if FILE-SYSTEM should be mounted in the container. | 151 | ;; Return #t if FILE-SYSTEM should be mounted in the container. |
| 159 | (and (not (string=? "/" (file-system-mount-point file-system))) | 152 | (and (not (string=? "/" (file-system-mount-point file-system))) |
| @@ -168,12 +161,7 @@ that will be shared with the host system." | |||
| 168 | os (cons %store-mapping mappings) | 161 | os (cons %store-mapping mappings) |
| 169 | #:shared-network? shared-network? | 162 | #:shared-network? shared-network? |
| 170 | #:extra-file-systems %container-file-systems)) | 163 | #:extra-file-systems %container-file-systems)) |
| 171 | (nscd-os (containerized-operating-system | 164 | (specs (os-file-system-specs os))) |
| 172 | os (cons* nscd-mapping %store-mapping mappings) | ||
| 173 | #:shared-network? shared-network? | ||
| 174 | #:extra-file-systems %container-file-systems)) | ||
| 175 | (specs (os-file-system-specs os)) | ||
| 176 | (nscd-specs (os-file-system-specs nscd-os))) | ||
| 177 | 165 | ||
| 178 | (define script | 166 | (define script |
| 179 | (with-imported-modules (source-module-closure | 167 | (with-imported-modules (source-module-closure |
| @@ -182,14 +170,19 @@ that will be shared with the host system." | |||
| 182 | #~(begin | 170 | #~(begin |
| 183 | (use-modules (gnu build linux-container) | 171 | (use-modules (gnu build linux-container) |
| 184 | (gnu system file-systems) ;spec->file-system | 172 | (gnu system file-systems) ;spec->file-system |
| 185 | (guix build utils)) | 173 | (guix build utils) |
| 186 | 174 | (srfi srfi-1)) | |
| 187 | (call-with-container | 175 | |
| 188 | (map spec->file-system | 176 | (define file-systems |
| 189 | (if (and #$shared-network? | 177 | (filter-map (lambda (spec) |
| 190 | (file-exists? #$nscd-run-directory)) | 178 | (let* ((fs (spec->file-system spec)) |
| 191 | '#$nscd-specs | 179 | (flags (file-system-flags fs))) |
| 192 | '#$specs)) | 180 | (and (or (not (memq 'bind-mount flags)) |
| 181 | (file-exists? (file-system-device fs))) | ||
| 182 | fs))) | ||
| 183 | '#$specs)) | ||
| 184 | |||
| 185 | (call-with-container file-systems | ||
| 193 | (lambda () | 186 | (lambda () |
| 194 | (setenv "HOME" "/root") | 187 | (setenv "HOME" "/root") |
| 195 | (setenv "TMPDIR" "/tmp") | 188 | (setenv "TMPDIR" "/tmp") |
