From 4a35a866be51361b80a5618e422d135959960c3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Sat, 23 May 2015 16:52:17 +0200 Subject: [PATCH] guix system: init: Make sure the target is root-owned. Suggested by Mark H Weaver . * guix/scripts/system.scm (install): Add 'chown' and 'chmod' calls for TARGET when running as root, and warn otherwise. --- guix/scripts/system.scm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 8d5fbe5a78..1feb821389 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -145,6 +145,16 @@ When GRUB? is true, install GRUB on DEVICE, using GRUB.CFG." ;; Copy items to the new store. (copy-closure to-copy target #:log-port log-port))))) + ;; Make sure TARGET is root-owned when running as root, but still allow + ;; non-root uses (useful for testing.) See + ;; . + (if (zero? (geteuid)) + (chown target 0 0) + (warning (_ "not running as 'root', so \ +the ownership of '~a' may be incorrect!~%") + target)) + + (chmod target #o755) (let ((os-dir (derivation->output-path os-drv)) (format (lift format %store-monad)) (populate (lift2 populate-root-file-system %store-monad)))