summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnu/build/activation.scm41
1 files changed, 25 insertions, 16 deletions
diff --git a/gnu/build/activation.scm b/gnu/build/activation.scm
index 272a7892910..690d86a0383 100644
--- a/gnu/build/activation.scm
+++ b/gnu/build/activation.scm
@@ -11,6 +11,7 @@
11;;; Copyright © 2022 Tobias Geerinckx-Rice <me@tobias.gr> 11;;; Copyright © 2022 Tobias Geerinckx-Rice <me@tobias.gr>
12;;; Copyright © 2024 Nicolas Graves <ngraves@ngraves.fr> 12;;; Copyright © 2024 Nicolas Graves <ngraves@ngraves.fr>
13;;; Copyright © 2024 Giacomo Leidi <goodoldpaul@autistici.org> 13;;; Copyright © 2024 Giacomo Leidi <goodoldpaul@autistici.org>
14;;; Copyright © 2025 Maxim Cournoyer <maxim@guixotic.coop>
14;;; 15;;;
15;;; This file is part of GNU Guix. 16;;; This file is part of GNU Guix.
16;;; 17;;;
@@ -278,6 +279,17 @@ they already exist."
278 279
279 (for-each ensure-user-home users)) 280 (for-each ensure-user-home users))
280 281
282(define* (canonicalize-path* file)
283 "A safe version of `canonicalize-path' that warns rather than raises on errors.
284`canonicalize-path' uses `realpath(2)', which can return various errors like
285EINVAL, ELOOP, etc."
286 (or (false-if-exception (canonicalize-path file))
287 (begin
288 (format (warning-error-port)
289 "warning: could not canonicalize file `~a'; using as-is~%"
290 file)
291 file)))
292
281(define (activate-etc etc) 293(define (activate-etc etc)
282 "Install ETC, a directory in the store, as the source of static files for 294 "Install ETC, a directory in the store, as the source of static files for
283/etc." 295/etc."
@@ -300,26 +312,23 @@ they already exist."
300 (rm-f "/etc/ssl") 312 (rm-f "/etc/ssl")
301 (symlink "/run/current-system/profile/etc/ssl" "/etc/ssl") 313 (symlink "/run/current-system/profile/etc/ssl" "/etc/ssl")
302 314
303 (rm-f "/etc/static")
304 (symlink etc "/etc/static")
305 (for-each (lambda (file) 315 (for-each (lambda (file)
306 (let ((target (string-append "/etc/" file)) 316 (let ((target (string-append "/etc/" file))
307 (source (string-append "/etc/static/" file))) 317 ;; Canonicalize the file names to resolve any symlinks, to
318 ;; ensure /etc/localtime points to a timezone data file in
319 ;; the store containing the timezone name. This is done
320 ;; for compatibility with software expecting this systemd
321 ;; convention to be followed.
322 (source (canonicalize-path* (string-append etc "/" file))))
308 (rm-f target) 323 (rm-f target)
309 324 (if (string=? (basename target) "sudoers")
310 ;; Things such as /etc/sudoers must be regular files, not 325 (begin
311 ;; symlinks; furthermore, they could be modified behind our 326 ;; /etc/sudoers must be a regular file.
312 ;; back---e.g., with 'visudo'. Thus, make a copy instead of 327 (copy-file source target)
313 ;; symlinking them. 328 ;; XXX: dirty hack to meet sudo's expectations
314 (if (file-is-directory? source) 329 (chmod target #o440))
315 (symlink source target) 330 (symlink source target)))) ;usual case
316 (copy-file source target))
317
318 ;; XXX: Dirty hack to meet sudo's expectations.
319 (when (string=? (basename target) "sudoers")
320 (chmod target #o440))))
321 (scandir etc (negate dot-or-dot-dot?) 331 (scandir etc (negate dot-or-dot-dot?)
322
323 ;; The default is 'string-locale<?', but we don't have 332 ;; The default is 'string-locale<?', but we don't have
324 ;; it when run from the initrd's statically-linked 333 ;; it when run from the initrd's statically-linked
325 ;; Guile. 334 ;; Guile.