+ (progn
+ (tramp-set-file-property v localname "file-selinux-context" context)
+ t)
+ (tramp-set-file-property v localname "file-selinux-context" 'undef)
+ 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 -acs %s 2>/dev/null"
+ (tramp-shell-quote-argument localname))))
+ (with-current-buffer (tramp-get-connection-buffer v)
+ (goto-char (point-max))
+ (delete-blank-lines)
+ (when (> (point-max) (point-min))
+ (substring-no-properties (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
+ (when (tramp-remote-acl-p v)
+ (condition-case nil
+ (when (stringp acl-string)
+ (tramp-set-file-property v localname "file-acl" acl-string)
+ (dolist (line (split-string acl-string nil t) t)
+ (unless (tramp-send-command-and-check
+ v (format
+ "setfacl -m %s %s"
+ line (tramp-shell-quote-argument localname)))
+ (error nil))))
+ ;; In case of errors, we return `nil'.
+ (error
+ (tramp-set-file-property v localname "file-acl" 'undef)
+ nil)))))