summary refs log tree commit diff
path: root/gnu/build/vm.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2020-04-06 15:16:09 +0200
committerLudovic Courtès <ludo@gnu.org>2020-04-11 20:48:12 +0200
commit6a488a3504b345b193e24dfdba2a2ac6b1db1234 (patch)
treebcb26173f0a6641559837e028a4ae31d074bf7a2 /gnu/build/vm.scm
parent7fa6155b2396224360660c255b89865d065c9f96 (diff)
downloadguix-6a488a3504b345b193e24dfdba2a2ac6b1db1234.tar.gz
vm: Preserve file permissions on /dev.
Previously, when REGISTER-CLOSURES? was false, we'd set all the files
under /dev to #o644, including /dev/null, /dev/zero, etc.

* gnu/build/vm.scm (root-partition-initializer): Call 'reset-timestamps'
separately for /dev, with #:preserve-permissions? #t.
Diffstat (limited to 'gnu/build/vm.scm')
-rw-r--r--gnu/build/vm.scm12
1 files changed, 11 insertions, 1 deletions
diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
index 63140f1cee..84bb2592e2 100644
--- a/gnu/build/vm.scm
+++ b/gnu/build/vm.scm
@@ -33,6 +33,7 @@
   #:use-module (guix records)
   #:use-module ((guix combinators) #:select (fold2))
   #:use-module (ice-9 format)
+  #:use-module (ice-9 ftw)
   #:use-module (ice-9 match)
   #:use-module (ice-9 regex)
   #:use-module (ice-9 popen)
@@ -419,7 +420,16 @@ system that is passed to 'populate-root-file-system'."
     ;; 'register-closure' resets timestamps and everything, so no need to do it
     ;; once more in that case.
     (unless register-closures?
-      (reset-timestamps target))))
+      ;; 'reset-timestamps' also resets file permissions; do that everywhere
+      ;; except on /dev so that /dev/null remains writable, etc.
+      (for-each (lambda (directory)
+                  (reset-timestamps (string-append target "/" directory)))
+                (scandir target
+                         (match-lambda
+                           ((or "." ".." "dev") #f)
+                           (_ #t))))
+      (reset-timestamps (string-append target "/dev")
+                        #:preserve-permissions? #t))))
 
 (define (register-bootcfg-root target bootcfg)
   "On file system TARGET, register BOOTCFG as a GC root."