guix gc: '-d' does not attempt to delete non-user-owned roots.

* guix/scripts/gc.scm (guix-gc)[delete-generations]: Limit to user-owned
roots, unless we're running as root.
This commit is contained in:
Ludovic Courtès 2019-04-11 16:55:13 +02:00
parent c2f6f4e500
commit c1df77e215
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 5 additions and 1 deletions

View File

@ -245,7 +245,11 @@ is deprecated; use '-D'~%"))
(define (delete-generations store pattern) (define (delete-generations store pattern)
;; Delete the generations matching PATTERN of all the user's profiles. ;; Delete the generations matching PATTERN of all the user's profiles.
(let ((profiles (delete-duplicates (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) (for-each (lambda (profile)
(delete-old-generations store profile pattern)) (delete-old-generations store profile pattern))
profiles))) profiles)))