guix-devel
[Top][All Lists]
Advanced

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

Re: 05/07: inferior: Fix concurrent cached-profile calls.


From: Ludovic Courtès
Subject: Re: 05/07: inferior: Fix concurrent cached-profile calls.
Date: Wed, 10 Mar 2021 10:48:21 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

Hi Mathieu,

guix-commits@gnu.org skribis:

> commit 6ee7e3d26b8f5d2a234518cc2ab1bfeba7cd7c18
> Author: Mathieu Othacehe <othacehe@gnu.org>
> AuthorDate: Fri Mar 5 12:49:06 2021 +0100
>
>     inferior: Fix concurrent cached-profile calls.
>     
>     * guix/inferior.scm (cached-profile): Do not create the profile symlink 
> if it
>     already exists.

[...]

> +++ b/guix/inferior.scm
> @@ -755,8 +755,9 @@ seconds.  This procedure opens a new connection to the 
> build daemon."
>              (built-derivations (list profile))
>              ;; Note: Caching is fine even when AUTHENTICATE? is false because
>              ;; we always call 'latest-channel-instances?'.
> -            (symlink* (derivation->output-path profile) cached)
> -            (add-indirect-root* cached)
> +            (unless (file-exists? cached)
> +              (symlink* (derivation->output-path profile) cached)
> +              (add-indirect-root* cached))
>              (return cached))))))

It should be ‘munless’ instead of ‘unless’ since we’re in an ‘mbegin’.

However, there’s already a (file-exists? cached) call a few lines
above.  So what you need instead is a TOCTTOU-free ‘symlink’, along
these lines:

  (define (symlink/safe old new)
    (catch 'system-error
      (lambda ()
        (symlink old new))
      (lambda args
        (unless (= EEXIST (system-error-errno args))
          (apply throw args)))))

  ;; …

  (define symlink*
    (lift2 symlink/safe %store-monad))

WDYT?

Ludo’.



reply via email to

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