guix gc: '-d' does not attempt to delete non-user-owned roots.
authorLudovic Courtès <ludo@gnu.org>
Thu, 11 Apr 2019 14:55:13 +0000 (16:55 +0200)
committerLudovic Courtès <ludo@gnu.org>
Thu, 11 Apr 2019 16:18:13 +0000 (18:18 +0200)
* guix/scripts/gc.scm (guix-gc)[delete-generations]: Limit to user-owned
roots, unless we're running as root.

guix/scripts/gc.scm

index 00f1eb8..9a57e5f 100644 (file)
@@ -245,7 +245,11 @@ is deprecated; use '-D'~%"))
   (define (delete-generations store pattern)
     ;; Delete the generations matching PATTERN of all the user's profiles.
     (let ((profiles (delete-duplicates
-                     (filter-map generation-profile (gc-roots)))))
+                     (filter-map (lambda (root)
+                                   (and (or (zero? (getuid))
+                                            (user-owned? root))
+                                        (generation-profile root)))
+                                 (gc-roots)))))
       (for-each (lambda (profile)
                   (delete-old-generations store profile pattern))
                 profiles)))