[PATCH v2 2/4] activation: Add 'lchown-recursive'.

  • Open
  • quality assurance status badge
Details
One participant
  • Brice Waegeneire
Owner
unassigned
Submitted by
Brice Waegeneire
Severity
normal
Merged with
B
B
Brice Waegeneire wrote on 21 Dec 2021 20:36
(address . guix-patches@gnu.org)
20211221193646.16849-2-brice@waegenei.re
* gnu/build/activation.scm (lchown-recursive): New procedure.
---
gnu/build/activation.scm | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)

Toggle diff (40 lines)
diff --git a/gnu/build/activation.scm b/gnu/build/activation.scm
index 9f6126023c..fff2d61b13 100644
--- a/gnu/build/activation.scm
+++ b/gnu/build/activation.scm
@@ -46,7 +46,8 @@ (define-module (gnu build activation)
activate-firmware
activate-ptrace-attach
activate-current-system
- mkdir-p/perms))
+ mkdir-p/perms
+ lchown-recursive))
;;; Commentary:
;;;
@@ -105,6 +106,23 @@ (define (mkdir-p/perms directory owner bits)
(chown directory (passwd:uid owner) (passwd:gid owner))
(chmod directory bits))
+(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))
+
(define* (copy-account-skeletons home
#:key
(directory %skeleton-directory)
--
2.34.0
B
B
Brice Waegeneire wrote on 21 Dec 2021 21:10
control message for bug #52713
(address . control@debbugs.gnu.org)
E1mzlTW-00083L-0S@debbugs.gnu.org
merge 52713 52454
quit
B
B
Brice Waegeneire wrote on 21 Dec 2021 21:11
control message for bug #52712
(address . control@debbugs.gnu.org)
E1mzlTe-00083g-5l@debbugs.gnu.org
merge 52712 52454
quit
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 52713@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 52713
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch