bug-guix
[Top][All Lists]
Advanced

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

bug#52452: PATCH v2 2/4] activation: Add 'lchown-recursive'.


From: Maxime Devos
Subject: bug#52452: PATCH v2 2/4] activation: Add 'lchown-recursive'.
Date: Wed, 22 Dec 2021 19:14:14 +0000
User-agent: Evolution 3.38.3-1

>+(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 via email to

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