mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-17 19:30:38 -08:00
Fix extended attributes for Tramp's sudoedit method (bug#49724)
* lisp/net/tramp-sh.el (tramp-do-copy-or-rename-file):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-do-copy-or-rename-file):
Remove compat code for `{set-}file-extended-attributes'.
(tramp-sudoedit-handle-write-region): Handle extended attributes.
(Bug#49724)
* test/lisp/net/tramp-tests.el (tramp-test25-file-selinux):
Fix test for sudoedit method.
This commit is contained in:
parent
cb28b2e32b
commit
41e62df73a
3 changed files with 15 additions and 9 deletions
|
|
@ -1946,7 +1946,7 @@ file names."
|
||||||
(length (tramp-compat-file-attribute-size
|
(length (tramp-compat-file-attribute-size
|
||||||
(file-attributes (file-truename filename))))
|
(file-attributes (file-truename filename))))
|
||||||
(attributes (and preserve-extended-attributes
|
(attributes (and preserve-extended-attributes
|
||||||
(apply #'file-extended-attributes (list filename))))
|
(file-extended-attributes filename)))
|
||||||
(msg-operation (if (eq op 'copy) "Copying" "Renaming")))
|
(msg-operation (if (eq op 'copy) "Copying" "Renaming")))
|
||||||
|
|
||||||
(with-parsed-tramp-file-name (if t1 filename newname) nil
|
(with-parsed-tramp-file-name (if t1 filename newname) nil
|
||||||
|
|
@ -2022,7 +2022,7 @@ file names."
|
||||||
;; errors, because ACL strings could be incompatible.
|
;; errors, because ACL strings could be incompatible.
|
||||||
(when attributes
|
(when attributes
|
||||||
(ignore-errors
|
(ignore-errors
|
||||||
(apply #'set-file-extended-attributes (list newname attributes))))
|
(set-file-extended-attributes newname attributes)))
|
||||||
|
|
||||||
;; In case of `rename', we must flush the cache of the source file.
|
;; In case of `rename', we must flush the cache of the source file.
|
||||||
(when (and t1 (eq op 'rename))
|
(when (and t1 (eq op 'rename))
|
||||||
|
|
|
||||||
|
|
@ -237,7 +237,7 @@ absolute file names."
|
||||||
(file-attributes filename)))
|
(file-attributes filename)))
|
||||||
(file-modes (tramp-default-file-modes filename))
|
(file-modes (tramp-default-file-modes filename))
|
||||||
(attributes (and preserve-extended-attributes
|
(attributes (and preserve-extended-attributes
|
||||||
(apply #'file-extended-attributes (list filename))))
|
(file-extended-attributes filename)))
|
||||||
(sudoedit-operation
|
(sudoedit-operation
|
||||||
(cond
|
(cond
|
||||||
((and (eq op 'copy) preserve-uid-gid) '("cp" "-f" "-p"))
|
((and (eq op 'copy) preserve-uid-gid) '("cp" "-f" "-p"))
|
||||||
|
|
@ -293,7 +293,7 @@ absolute file names."
|
||||||
;; errors, because ACL strings could be incompatible.
|
;; errors, because ACL strings could be incompatible.
|
||||||
(when attributes
|
(when attributes
|
||||||
(ignore-errors
|
(ignore-errors
|
||||||
(apply #'set-file-extended-attributes (list newname attributes))))
|
(set-file-extended-attributes newname attributes)))
|
||||||
|
|
||||||
(when (and t1 (eq op 'rename))
|
(when (and t1 (eq op 'rename))
|
||||||
(with-parsed-tramp-file-name filename v1
|
(with-parsed-tramp-file-name filename v1
|
||||||
|
|
@ -726,13 +726,14 @@ ID-FORMAT valid values are `string' and `integer'."
|
||||||
(file-attributes filename 'integer))
|
(file-attributes filename 'integer))
|
||||||
(tramp-get-remote-gid v 'integer)))
|
(tramp-get-remote-gid v 'integer)))
|
||||||
(flag (and (eq mustbenew 'excl) 'nofollow))
|
(flag (and (eq mustbenew 'excl) 'nofollow))
|
||||||
(modes (tramp-default-file-modes filename flag)))
|
(modes (tramp-default-file-modes filename flag))
|
||||||
|
(attributes (file-extended-attributes filename)))
|
||||||
(prog1
|
(prog1
|
||||||
(tramp-handle-write-region
|
(tramp-handle-write-region
|
||||||
start end filename append visit lockname mustbenew)
|
start end filename append visit lockname mustbenew)
|
||||||
|
|
||||||
;; Set the ownership and modes. This is not performed in
|
;; Set the ownership, modes and extended attributes. This is
|
||||||
;; `tramp-handle-write-region'.
|
;; not performed in `tramp-handle-write-region'.
|
||||||
(unless (and (= (tramp-compat-file-attribute-user-id
|
(unless (and (= (tramp-compat-file-attribute-user-id
|
||||||
(file-attributes filename 'integer))
|
(file-attributes filename 'integer))
|
||||||
uid)
|
uid)
|
||||||
|
|
@ -740,7 +741,12 @@ ID-FORMAT valid values are `string' and `integer'."
|
||||||
(file-attributes filename 'integer))
|
(file-attributes filename 'integer))
|
||||||
gid))
|
gid))
|
||||||
(tramp-set-file-uid-gid filename uid gid))
|
(tramp-set-file-uid-gid filename uid gid))
|
||||||
(tramp-compat-set-file-modes filename modes flag)))))
|
(tramp-compat-set-file-modes filename modes flag)
|
||||||
|
;; We ignore possible errors, because ACL strings could be
|
||||||
|
;; incompatible.
|
||||||
|
(when attributes
|
||||||
|
(ignore-errors
|
||||||
|
(set-file-extended-attributes filename attributes)))))))
|
||||||
|
|
||||||
|
|
||||||
;; Internal functions.
|
;; Internal functions.
|
||||||
|
|
|
||||||
|
|
@ -4096,7 +4096,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
|
||||||
(write-region "foo" nil tmp-name1)
|
(write-region "foo" nil tmp-name1)
|
||||||
(should (file-exists-p tmp-name1))
|
(should (file-exists-p tmp-name1))
|
||||||
(should (file-selinux-context tmp-name1))
|
(should (file-selinux-context tmp-name1))
|
||||||
(copy-file tmp-name1 tmp-name2)
|
(copy-file tmp-name1 tmp-name2 nil nil nil 'preserve-permissions)
|
||||||
(should (file-selinux-context tmp-name2))
|
(should (file-selinux-context tmp-name2))
|
||||||
(should
|
(should
|
||||||
(equal
|
(equal
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue