GNU bug report logs - #40955
[PATCH 0/5] Add new image API.

Previous Next

Package: guix-patches;

Reported by: Mathieu Othacehe <m.othacehe <at> gmail.com>

Date: Wed, 29 Apr 2020 08:42:01 UTC

Severity: normal

Tags: patch

Done: Mathieu Othacehe <m.othacehe <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Ludovic Courtès <ludo <at> gnu.org>
To: Mathieu Othacehe <m.othacehe <at> gmail.com>
Cc: 40955 <at> debbugs.gnu.org
Subject: [bug#40955] [PATCH 2/5] build: install: Ignore chown exceptions.
Date: Sat, 02 May 2020 13:09:43 +0200
Hey!

Mathieu Othacehe <m.othacehe <at> gmail.com> skribis:

> Changing ownership may require root permissions. As image can now be generated
> without root permissions (no VM involved), ignore those exceptions.
>
> * gnu/build/install.scm (evaluate-populate-directive): Ignore chown
> exceptions.
> ---
>  gnu/build/install.scm | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/gnu/build/install.scm b/gnu/build/install.scm
> index c0d4d44091..0b0d01cf86 100644
> --- a/gnu/build/install.scm
> +++ b/gnu/build/install.scm
> @@ -63,7 +63,9 @@ directory TARGET."
>            (('directory name uid gid)
>             (let ((dir (string-append target name)))
>               (mkdir-p dir)
> -             (chown dir uid gid)))
> +             ;; This will fail if this is not run from a VM, ignore those
> +             ;; errors.
> +             (false-if-exception (chown dir uid gid))))

We still want the directives to be honored though.

How about having a procedure like:

  (define (ensure-ownership file uid gid)
    (catch 'system-error
      (lambda ()
        (chown file uid gid))
      (lambda args
        (if (= EPERM (system-error-errno args))
            (let ((st (lstat file)))
              (or (and (= uid (stat:uid st)) (= gid (stat:gid st)))
                  (apply throw args)))
            (apply throw args)))))

and use that?

Or perhaps that’s still not helpful but we instead need a guarantee
elsewhere that the UID/GID is going to be honored, perhaps by calling:

  (evaluate-populate-directive … #:default-gid 0 #:default-uid 0)

and have it ignore chown when it matches #:default-uid and
#:default-gid.

Thoughts?

Ludo’.




This bug report was last modified 5 years and 13 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.