summaryrefslogtreecommitdiff
path: root/gnu/build
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/build')
-rw-r--r--gnu/build/file-systems.scm15
-rw-r--r--gnu/build/linux-boot.scm18
-rw-r--r--gnu/build/shepherd.scm3
3 files changed, 25 insertions, 11 deletions
diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm
index b9d46c9350..0ed5dc5671 100644
--- a/gnu/build/file-systems.scm
+++ b/gnu/build/file-systems.scm
@@ -98,6 +98,18 @@ standard input is /dev/null."
system*/console)
program args))
+(define (call-with-input-file file proc)
+ "Like 'call-with-input-file', but pass O_CLOEXEC."
+ (let ((port #f))
+ (dynamic-wind
+ (lambda ()
+ (set! port (open file (logior O_RDONLY O_CLOEXEC))))
+ (lambda ()
+ (proc port))
+ (lambda ()
+ (close-port port)
+ (set! port #f)))))
+
(define (bind-mount source target)
"Bind-mount SOURCE at TARGET."
(mount source target "" MS_BIND))
@@ -1183,7 +1195,8 @@ corresponds to the symbols listed in FLAGS."
(not (file-is-directory? source)))
(unless (file-exists? target)
(mkdir-p (dirname target))
- (call-with-output-file target (const #t)))
+ (close-fdes
+ (open-fdes target (logior O_WRONLY O_CREAT O_CLOEXEC))))
(mkdir-p target))
(cond
diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm
index 7d41537652..84726363c0 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -589,15 +589,6 @@ upon error."
(load-linux-modules-from-directory linux-modules
linux-module-directory)
- (unless (or (member "hibernate=noresume" args)
- ;; Also handle the equivalent old-style argument.
- ;; See Documentation/admin-guide/kernel-parameters.txt.
- (member "noresume" args))
- ;; Try to resume immediately after loading (storage) modules
- ;; but before any on-disk file systems have been mounted.
- (false-if-exception ; failure is not fatal
- (resume-if-hibernated (find-long-option "resume" args))))
-
(when keymap-file
(let ((status (system* "loadkeys" keymap-file)))
(unless (zero? status)
@@ -631,6 +622,15 @@ the root file system...\n" root-delay)
(unless (pre-mount)
(error "pre-mount actions failed")))
+ (unless (or (member "hibernate=noresume" args)
+ ;; Also handle the equivalent old-style argument.
+ ;; See Documentation/admin-guide/kernel-parameters.txt.
+ (member "noresume" args))
+ ;; Try to resume immediately after loading (storage) modules
+ ;; but before any on-disk file systems have been mounted.
+ (false-if-exception ; failure is not fatal
+ (resume-if-hibernated (find-long-option "resume" args))))
+
(setenv "EXT2FS_NO_MTAB_OK" "1")
;; Mount the root file system.
diff --git a/gnu/build/shepherd.scm b/gnu/build/shepherd.scm
index f4caefce3c..9d9bfcfbc0 100644
--- a/gnu/build/shepherd.scm
+++ b/gnu/build/shepherd.scm
@@ -2,6 +2,7 @@
;;; Copyright © 2017, 2018, 2019, 2020, 2022 Ludovic Courtès <[email protected]>
;;; Copyright © 2020 Mathieu Othacehe <[email protected]>
;;; Copyright © 2022 Leo Nikkilä <[email protected]>
+;;; Copyright © 2022 Arun Isaac <[email protected]>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -186,7 +187,7 @@ namespace, in addition to essential bind-mounts such /proc."
(when log-file
;; Create LOG-FILE so we can map it in the container.
(unless (file-exists? log-file)
- (call-with-output-file log-file (const #t))
+ (close (open log-file (logior O_CREAT O_APPEND O_CLOEXEC) #o640))
(when user
(let ((pw (getpwnam user)))
(chown log-file (passwd:uid pw) (passwd:gid pw))))))