[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#40955] [PATCH 2/5] build: install: Ignore chown exceptions.
From: |
Ludovic Courtès |
Subject: |
[bug#40955] [PATCH 2/5] build: install: Ignore chown exceptions. |
Date: |
Sat, 02 May 2020 13:09:43 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) |
Hey!
Mathieu Othacehe <address@hidden> 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’.
- [bug#40955] [PATCH 2/5] build: install: Ignore chown exceptions.,
Ludovic Courtès <=