unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: Maxime Devos <maximedevos@telenet.be>
To: 52452@debbugs.gnu.org
Subject: bug#52452: PATCH v2 2/4] activation: Add 'lchown-recursive'.
Date: Wed, 22 Dec 2021 19:14:14 +0000	[thread overview]
Message-ID: <2877ff704a262640a315063c536e67b0efc2d487.camel@telenet.be> (raw)
In-Reply-To: <8735mx26qr.fsf@cbaines.net>

>+(define (lchown-recursive file owner group)
>+  "As 'lchown' but recursively, change ownership of FILE to the
>integer values
>+OWNER and GROUP without dereferencing symbolic links it encounter."
>+  (nftw file
>+        (lambda (filename statinfo flag base level)
>+          (catch 'system-error
>+            (lambda ()
>+              (when (member flag '(regular directory symlink))
>+                (lchown filename owner group)))
>+            (lambda args
>+              (format (current-error-port)
>+                      "warning: failed to chown ~s: ~a~%"
>+                      filename
>+                      (strerror (system-error-errno args)))))
>+          #t)
>+        'physical))

This is racy (compare with mkdir-p/perms for example).
This race can be resolved by using 'openat' & 'chownat' &
'AT_SYMLINK_NOFOLLOW' from
<https://lists.gnu.org/archive/html/guile-devel/2021-11/msg00005.html>.

Greetings,
Maxime.





      reply	other threads:[~2021-12-22 19:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-12 15:13 bug#52452: Guix related downloads from ftp.gnu.org are slow over IPv6 Christopher Baines
2021-12-22 19:14 ` Maxime Devos [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2877ff704a262640a315063c536e67b0efc2d487.camel@telenet.be \
    --to=maximedevos@telenet.be \
    --cc=52452@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).