guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A corner case of broken reproducibility


From: Ludovic Courtès
Subject: Re: A corner case of broken reproducibility
Date: Thu, 02 Jun 2022 16:08:52 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux)

Maxime Devos <maximedevos@telenet.be> skribis:

> Ludovic Courtès schreef op wo 01-06-2022 om 18:38 [+0200]:
>> There’s a talk by Lennart Poettering where he explains that, contrary to
>> what one might think, “chown -R $HOME” turns out to be fast enough that
>> systemd-homed can do that unconditionally (off the of my head).
>
> Interesting.

‘%gdm-activation’ has an optimization to recurse only if the top-level
directory has itself the wrong UID:

--8<---------------cut here---------------start------------->8---
(define %gdm-activation
  ;; Ensure /var/lib/gdm is owned by the "gdm" user.  This is normally the
  ;; case but could be wrong if the "gdm" user was created, then removed, and
  ;; then recreated under a different UID/GID: <https://bugs.gnu.org/37423>.
  (with-imported-modules '((guix build utils))
    #~(begin
        (use-modules (guix build utils))

        (let* ((gdm (getpwnam "gdm"))
               (uid (passwd:uid gdm))
               (gid (passwd:gid gdm))
               (st  (stat "/var/lib/gdm" #f)))
          ;; Recurse into /var/lib/gdm only if it has wrong ownership.
          (when (and st
                     (or (not (= uid (stat:uid st)))
                         (not (= gid (stat:gid st)))))
            (for-each (lambda (file)
                        (chown file uid gid))
                      (find-files "/var/lib/gdm"
                                  #:directories? #t)))))))
--8<---------------cut here---------------end--------------->8---

We can use that trick if needed: we’d get only one stat(2) call in the
common case.

Ludo’.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]