Mark H Weaver <[email protected]> skribis:
> The problem turned out to be that on rekado's system, / was owned by
> user "rekado" with mode 700.
Oh, I see. I would never have thought of this!
> Perhaps 'guix system init' should explicitly set the ownership and
> permissions on the target root directory?
Here’s a tentative patch.
I wonder if the activation code shouldn’t systematically do
(chown "/" 0 0) as well.
Thoughts?
Thank you both for investigating!
Ludo’.
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 8d5fbe5..2cf6a43 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -145,6 +145,14 @@ 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.)
+ (if (zero? (getuid))
+ (chown target 0 0)
+ (warning (_ "not running as 'root', so \
+the ownership of '~a' may be incorrect!~%")
+ target))
+
(let ((os-dir (derivation->output-path os-drv))
(format (lift format %store-monad))
(populate (lift2 populate-root-file-system %store-monad)))