aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-04-11 16:55:13 +0200
committerLudovic Courtès <ludo@gnu.org>2019-04-11 18:18:13 +0200
commitc1df77e215b6e69dccbe781307836a3b962c5968 (patch)
tree7045054e33e28b3525b230974b56dd8ba914a538
parentc2f6f4e50074ac12fa3bee51d793eeaadce99f55 (diff)
downloadguix-c1df77e215b6e69dccbe781307836a3b962c5968.tar.gz
guix-c1df77e215b6e69dccbe781307836a3b962c5968.zip
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.
-rw-r--r--guix/scripts/gc.scm6
1 files changed, 5 insertions, 1 deletions
diff --git a/guix/scripts/gc.scm b/guix/scripts/gc.scm
index 00f1eb8d00..9a57e5fd1e 100644
--- a/guix/scripts/gc.scm
+++ b/guix/scripts/gc.scm
@@ -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)))