[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r111256: Add support for preserving A
From: |
Michael Albinus |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r111256: Add support for preserving ACL entries of files. |
Date: |
Mon, 17 Dec 2012 15:38:07 +0100 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 111256
committer: Michael Albinus <address@hidden
branch nick: trunk
timestamp: Mon 2012-12-17 15:38:07 +0100
message:
Add support for preserving ACL entries of files.
* net/tramp.el (tramp-file-name-for-operation): Add `file-acl' and
`set-file-acl' handlers.
* net/tramp-adb.el (tramp-adb-handle-copy-file): Handle
PRESERVE-EXTENDED-ATTRIBUTES.
* net/tramp-compat.el (tramp-compat-copy-file): Handle
PRESERVE-EXTENDED-ATTRIBUTES.
* net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): Add
`file-acl' and `set-file-acl' handlers.
(tramp-gvfs-handle-copy-file): Handle
PRESERVE-EXTENDED-ATTRIBUTES.
(tramp-gvfs-handle-file-acl, tramp-gvfs-handle-set-file-acl): New
defuns.
* net/tramp-sh.el (tramp-sh-file-name-handler-alist): Add
`file-acl' and `set-file-acl' handlers.
(tramp-remote-acl-p, tramp-sh-handle-file-acl)
(tramp-sh-handle-set-file-acl): New defuns.
(tramp-sh-handle-copy-file, tramp-do-copy-or-rename-file): Handle
PRESERVE-EXTENDED-ATTRIBUTES.
* net/tramp-smb.el (tramp-smb-file-name-handler-alist): Add
`file-acl' and `set-file-acl' handlers.
(tramp-smb-handle-copy-file): Handle PRESERVE-EXTENDED-ATTRIBUTES.
modified:
lisp/ChangeLog
lisp/net/tramp-adb.el
lisp/net/tramp-compat.el
lisp/net/tramp-gvfs.el
lisp/net/tramp-sh.el
lisp/net/tramp-smb.el
lisp/net/tramp.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2012-12-17 07:54:57 +0000
+++ b/lisp/ChangeLog 2012-12-17 14:38:07 +0000
@@ -1,3 +1,34 @@
+2012-12-17 Michael Albinus <address@hidden>
+
+ Add support for preserving ACL entries of files.
+
+ * net/tramp.el (tramp-file-name-for-operation): Add `file-acl' and
+ `set-file-acl' handlers.
+
+ * net/tramp-adb.el (tramp-adb-handle-copy-file): Handle
+ PRESERVE-EXTENDED-ATTRIBUTES.
+
+ * net/tramp-compat.el (tramp-compat-copy-file): Handle
+ PRESERVE-EXTENDED-ATTRIBUTES.
+
+ * net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): Add
+ `file-acl' and `set-file-acl' handlers.
+ (tramp-gvfs-handle-copy-file): Handle
+ PRESERVE-EXTENDED-ATTRIBUTES.
+ (tramp-gvfs-handle-file-acl, tramp-gvfs-handle-set-file-acl): New
+ defuns.
+
+ * net/tramp-sh.el (tramp-sh-file-name-handler-alist): Add
+ `file-acl' and `set-file-acl' handlers.
+ (tramp-remote-acl-p, tramp-sh-handle-file-acl)
+ (tramp-sh-handle-set-file-acl): New defuns.
+ (tramp-sh-handle-copy-file, tramp-do-copy-or-rename-file): Handle
+ PRESERVE-EXTENDED-ATTRIBUTES.
+
+ * net/tramp-smb.el (tramp-smb-file-name-handler-alist): Add
+ `file-acl' and `set-file-acl' handlers.
+ (tramp-smb-handle-copy-file): Handle PRESERVE-EXTENDED-ATTRIBUTES.
+
2012-12-17 Kelly Dean <address@hidden> (tiny change)
* help-macro.el (make-help-screen): Instead of switch-to-buffer
=== modified file 'lisp/net/tramp-adb.el'
--- a/lisp/net/tramp-adb.el 2012-12-14 09:02:34 +0000
+++ b/lisp/net/tramp-adb.el 2012-12-17 14:38:07 +0000
@@ -526,9 +526,9 @@
(defun tramp-adb-handle-copy-file
(filename newname &optional ok-if-already-exists keep-date
- preserve-uid-gid preserve-selinux-context)
+ preserve-uid-gid preserve-extended-attributes)
"Like `copy-file' for Tramp files.
-PRESERVE-UID-GID and PRESERVE-SELINUX-CONTEXT are completely ignored."
+PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
(setq filename (expand-file-name filename)
newname (expand-file-name newname))
=== modified file 'lisp/net/tramp-compat.el'
--- a/lisp/net/tramp-compat.el 2012-12-06 09:15:27 +0000
+++ b/lisp/net/tramp-compat.el 2012-12-17 14:38:07 +0000
@@ -304,16 +304,17 @@
(wrong-number-of-arguments (file-attributes filename))))))
;; PRESERVE-UID-GID does not exist in XEmacs.
-;; PRESERVE-SELINUX-CONTEXT has been introduced with Emacs 24.1.
+;; PRESERVE-EXTENDED-ATTRIBUTES has been introduced with Emacs 24.1
+;; (as PRESERVE-SELINUX-CONTEXT), and renamed in Emacs 24.3.
(defun tramp-compat-copy-file
(filename newname &optional ok-if-already-exists keep-date
- preserve-uid-gid preserve-selinux-context)
+ preserve-uid-gid preserve-extended-attributes)
"Like `copy-file' for Tramp files (compat function)."
(cond
- (preserve-selinux-context
+ (preserve-extended-attributes
(tramp-compat-funcall
'copy-file filename newname ok-if-already-exists keep-date
- preserve-uid-gid preserve-selinux-context))
+ preserve-uid-gid preserve-extended-attributes))
(preserve-uid-gid
(tramp-compat-funcall
'copy-file filename newname ok-if-already-exists keep-date
=== modified file 'lisp/net/tramp-gvfs.el'
--- a/lisp/net/tramp-gvfs.el 2012-12-14 09:02:34 +0000
+++ b/lisp/net/tramp-gvfs.el 2012-12-17 14:38:07 +0000
@@ -385,6 +385,7 @@
;; `executable-find' is not official yet. performed by default handler.
(expand-file-name . tramp-gvfs-handle-expand-file-name)
;; `file-accessible-directory-p' performed by default handler.
+ (file-acl . tramp-gvfs-handle-file-acl)
(file-attributes . tramp-gvfs-handle-file-attributes)
(file-directory-p . tramp-gvfs-handle-file-directory-p)
(file-executable-p . tramp-gvfs-handle-file-executable-p)
@@ -417,6 +418,7 @@
(make-symbolic-link . ignore)
(process-file . tramp-gvfs-handle-process-file)
(rename-file . tramp-gvfs-handle-rename-file)
+ (set-file-acl . tramp-gvfs-handle-set-file-acl)
(set-file-modes . tramp-gvfs-handle-set-file-modes)
(set-file-selinux-context . tramp-gvfs-handle-set-file-selinux-context)
(set-visited-file-modtime . tramp-gvfs-handle-set-visited-file-modtime)
@@ -539,7 +541,7 @@
(defun tramp-gvfs-handle-copy-file
(filename newname &optional ok-if-already-exists keep-date
- preserve-uid-gid preserve-selinux-context)
+ preserve-uid-gid preserve-extended-attributes)
"Like `copy-file' for Tramp files."
(with-parsed-tramp-file-name
(if (tramp-tramp-file-p filename) filename newname) nil
@@ -555,8 +557,8 @@
(tramp-gvfs-fuse-file-name newname)
newname)
ok-if-already-exists keep-date preserve-uid-gid)))
- (when preserve-selinux-context
- (setq args (append args (list preserve-selinux-context))))
+ (when preserve-extended-attributes
+ (setq args (append args (list preserve-extended-attributes))))
(apply 'copy-file args))
;; Error case. Let's try it with the GVFS utilities.
@@ -655,6 +657,10 @@
(tramp-run-real-handler
'expand-file-name (list localname))))))
+(defun tramp-gvfs-handle-file-acl (filename)
+ "Like `file-acl' for Tramp files."
+ (tramp-compat-funcall 'file-acl (tramp-gvfs-fuse-file-name filename)))
+
(defun tramp-gvfs-handle-file-attributes (filename &optional id-format)
"Like `file-attributes' for Tramp files."
(file-attributes (tramp-gvfs-fuse-file-name filename) id-format))
@@ -781,6 +787,11 @@
(tramp-flush-file-property v (file-name-directory localname))
(tramp-flush-file-property v localname))))
+(defun tramp-gvfs-handle-set-file-acl (filename acl-string)
+ "Like `set-file-acl' for Tramp files."
+ (with-tramp-gvfs-error-message filename 'set-file-acl
+ (tramp-gvfs-fuse-file-name filename) acl-string))
+
(defun tramp-gvfs-handle-set-file-modes (filename mode)
"Like `set-file-modes' for Tramp files."
(with-tramp-gvfs-error-message filename 'set-file-modes
=== modified file 'lisp/net/tramp-sh.el'
--- a/lisp/net/tramp-sh.el 2012-12-14 18:59:00 +0000
+++ b/lisp/net/tramp-sh.el 2012-12-17 14:38:07 +0000
@@ -985,6 +985,8 @@
(verify-visited-file-modtime . tramp-sh-handle-verify-visited-file-modtime)
(file-selinux-context . tramp-sh-handle-file-selinux-context)
(set-file-selinux-context . tramp-sh-handle-set-file-selinux-context)
+ (file-acl . tramp-sh-handle-file-acl)
+ (set-file-acl . tramp-sh-handle-set-file-acl)
(vc-registered . tramp-sh-handle-vc-registered))
"Alist of handler functions.
Operations not mentioned here will be handled by the normal Emacs functions.")
@@ -1532,6 +1534,39 @@
;; We always return nil.
nil)
+(defun tramp-remote-acl-p (vec)
+ "Check, whether ACL is enabled on the remote host."
+ (with-tramp-connection-property (tramp-get-connection-process vec) "acl-p"
+ (tramp-send-command-and-check vec "getfacl /")))
+
+(defun tramp-sh-handle-file-acl (filename)
+ "Like `file-acl' for Tramp files."
+ (with-parsed-tramp-file-name filename nil
+ (with-tramp-file-property v localname "file-acl"
+ (when (and (tramp-remote-acl-p v)
+ (tramp-send-command-and-check
+ v (format
+ "getfacl -ac %s 2>/dev/null"
+ (tramp-shell-quote-argument localname))))
+ (with-current-buffer (tramp-get-connection-buffer v)
+ (buffer-string))))))
+
+(defun tramp-sh-handle-set-file-acl (filename acl-string)
+ "Like `set-file-acl' for Tramp files."
+ (with-parsed-tramp-file-name filename nil
+ (if (and (stringp acl-string)
+ (tramp-remote-acl-p v)
+ (tramp-send-command-and-check
+ v
+ (format "setfacl --set-file=- %s <<'EOF'\n%s\nEOF\n"
+ (tramp-shell-quote-argument localname)
+ acl-string)
+ t))
+ (tramp-set-file-property v localname "file-acl" acl-string)
+ (tramp-set-file-property v localname "file-acl-string" 'undef)))
+ ;; We always return nil.
+ nil)
+
;; Simple functions using the `test' command.
(defun tramp-sh-handle-file-executable-p (filename)
@@ -1883,7 +1918,7 @@
(defun tramp-sh-handle-copy-file
(filename newname &optional ok-if-already-exists keep-date
- preserve-uid-gid preserve-selinux-context)
+ preserve-uid-gid preserve-extended-attributes)
"Like `copy-file' for Tramp files."
(setq filename (expand-file-name filename))
(setq newname (expand-file-name newname))
@@ -1893,13 +1928,13 @@
(tramp-tramp-file-p newname))
(tramp-do-copy-or-rename-file
'copy filename newname ok-if-already-exists keep-date
- preserve-uid-gid preserve-selinux-context))
+ preserve-uid-gid preserve-extended-attributes))
;; Compat section.
- (preserve-selinux-context
+ (preserve-extended-attributes
(tramp-run-real-handler
'copy-file
(list filename newname ok-if-already-exists keep-date
- preserve-uid-gid preserve-selinux-context)))
+ preserve-uid-gid preserve-extended-attributes)))
(preserve-uid-gid
(tramp-run-real-handler
'copy-file
@@ -1962,7 +1997,7 @@
(defun tramp-do-copy-or-rename-file
(op filename newname &optional ok-if-already-exists keep-date
- preserve-uid-gid preserve-selinux-context)
+ preserve-uid-gid preserve-extended-attributes)
"Copy or rename a remote file.
OP must be `copy' or `rename' and indicates the operation to perform.
FILENAME specifies the file to copy or rename, NEWNAME is the name of
@@ -1971,7 +2006,7 @@
KEEP-DATE means to make sure that NEWNAME has the same timestamp
as FILENAME. PRESERVE-UID-GID, when non-nil, instructs to keep
the uid and gid if both files are on the same host.
-PRESERVE-SELINUX-CONTEXT activates selinux commands.
+PRESERVE-EXTENDED-ATTRIBUTES activates selinux and acl commands.
This function is invoked by `tramp-sh-handle-copy-file' and
`tramp-sh-handle-rename-file'. It is an error if OP is neither
@@ -1982,8 +2017,8 @@
(let ((t1 (tramp-tramp-file-p filename))
(t2 (tramp-tramp-file-p newname))
(length (nth 7 (file-attributes (file-truename filename))))
- (context (and preserve-selinux-context
- (apply 'file-selinux-context (list filename))))
+ (attributes (and preserve-extended-attributes
+ (apply 'file-extended-attributes (list filename))))
pr tm)
(with-parsed-tramp-file-name (if t1 filename newname) nil
@@ -2053,8 +2088,9 @@
;; One of them must be a Tramp file.
(error "Tramp implementation says this cannot happen")))
- ;; Handle `preserve-selinux-context'.
- (when context (apply 'set-file-selinux-context (list newname context)))
+ ;; Handle `preserve-extended-attributes'.
+ (when attributes
+ (apply 'set-file-extended-attributes (list newname attributes)))
;; In case of `rename', we must flush the cache of the source file.
(when (and t1 (eq op 'rename))
=== modified file 'lisp/net/tramp-smb.el'
--- a/lisp/net/tramp-smb.el 2012-12-14 09:02:34 +0000
+++ b/lisp/net/tramp-smb.el 2012-12-17 14:38:07 +0000
@@ -195,6 +195,7 @@
(dired-uncache . tramp-handle-dired-uncache)
(expand-file-name . tramp-smb-handle-expand-file-name)
(file-accessible-directory-p . tramp-smb-handle-file-directory-p)
+ (file-acl . ignore)
(file-attributes . tramp-smb-handle-file-attributes)
(file-directory-p . tramp-smb-handle-file-directory-p)
(file-executable-p . tramp-handle-file-exists-p)
@@ -227,6 +228,7 @@
(make-symbolic-link . tramp-smb-handle-make-symbolic-link)
(process-file . tramp-smb-handle-process-file)
(rename-file . tramp-smb-handle-rename-file)
+ (set-file-acl . ignore)
(set-file-modes . tramp-smb-handle-set-file-modes)
;; `set-file-selinux-context' performed by default handler.
(set-file-times . ignore)
@@ -487,10 +489,10 @@
(defun tramp-smb-handle-copy-file
(filename newname &optional ok-if-already-exists keep-date
- preserve-uid-gid preserve-selinux-context)
+ preserve-uid-gid preserve-extended-attributes)
"Like `copy-file' for Tramp files.
KEEP-DATE has no effect in case NEWNAME resides on an SMB server.
-PRESERVE-UID-GID and PRESERVE-SELINUX-CONTEXT are completely ignored."
+PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
(setq filename (expand-file-name filename)
newname (expand-file-name newname))
(with-tramp-progress-reporter
@@ -1813,5 +1815,6 @@
;; * Try to remove the inclusion of dummy "" directory. Seems to be at
;; several places, especially in `tramp-smb-handle-insert-directory'.
;; * Ignore case in file names.
+;; * Implement `tramp-smb-handle-file-acl' for proper Samba versions.
;;; tramp-smb.el ends here
=== modified file 'lisp/net/tramp.el'
--- a/lisp/net/tramp.el 2012-12-06 09:15:27 +0000
+++ b/lisp/net/tramp.el 2012-12-17 14:38:07 +0000
@@ -1879,7 +1879,8 @@
;; Emacs 22+ only.
'set-file-times
;; Emacs 24+ only.
- 'file-selinux-context 'set-file-selinux-context
+ 'file-acl 'file-selinux-context
+ 'set-file-acl 'set-file-selinux-context
;; XEmacs only.
'abbreviate-file-name 'create-file-buffer
'dired-file-modtime 'dired-make-compressed-filename
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r111256: Add support for preserving ACL entries of files.,
Michael Albinus <=