aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2009-11-08 10:44:22 +0000
committerMichael Albinus2009-11-08 10:44:22 +0000
commit191bb792fb4bb1fcff4c1b613e0dd9a36dc1ac6b (patch)
treee3ea95a06e07632eb91d7d9c130451f4ce987aa9
parenta0a6324fdc21d9be9ef8e2da8fe26a3ecb4eafe2 (diff)
downloademacs-191bb792fb4bb1fcff4c1b613e0dd9a36dc1ac6b.tar.gz
emacs-191bb792fb4bb1fcff4c1b613e0dd9a36dc1ac6b.zip
* net/tramp.el (tramp-advice-make-auto-save-file-name)
(tramp-advice-file-expand-wildcards): Unload via `ad-remove-advice'. * net/tramp.el (tramp-advice-file-expand-wildcards): Don't rely on `ad-do-it'. * net/tramp.el (tramp-handle-write-region): Copy but rename temp file, in order to keep context in SELinux.
-rw-r--r--lisp/net/tramp.el55
1 files changed, 35 insertions, 20 deletions
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 7a6da178a61..fda9065c7e9 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -4927,22 +4927,25 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file."
4927 ((or (tramp-local-host-p v) 4927 ((or (tramp-local-host-p v)
4928 (tramp-method-out-of-band-p 4928 (tramp-method-out-of-band-p
4929 v (- (or end (point-max)) (or start (point-min))))) 4929 v (- (or end (point-max)) (or start (point-min)))))
4930 (condition-case err 4930 (if (and (= (or end (point-max)) (point-max))
4931 (if (and (= (or end (point-max)) (point-max)) 4931 (= (or start (point-min)) (point-min))
4932 (= (or start (point-min)) (point-min)) 4932 (tramp-get-method-parameter
4933 (tramp-get-method-parameter 4933 method 'tramp-copy-keep-tmpfile))
4934 method 'tramp-copy-keep-tmpfile)) 4934 (progn
4935 (progn 4935 (setq tramp-temp-buffer-file-name tmpfile)
4936 (condition-case err
4936 ;; We keep the local file for performance 4937 ;; We keep the local file for performance
4937 ;; reasons, useful for "rsync". 4938 ;; reasons, useful for "rsync".
4938 (setq tramp-temp-buffer-file-name tmpfile) 4939 (copy-file tmpfile filename t)
4939 (copy-file tmpfile filename t)) 4940 ((error quit)
4940 (setq tramp-temp-buffer-file-name nil) 4941 (setq tramp-temp-buffer-file-name nil)
4941 (rename-file tmpfile filename t)) 4942 (delete-file tmpfile)
4942 ((error quit) 4943 (signal (car err) (cdr err)))))
4943 (setq tramp-temp-buffer-file-name nil) 4944 (setq tramp-temp-buffer-file-name nil)
4944 (delete-file tmpfile) 4945 ;; Don't rename, in order to keep context in SELinux.
4945 (signal (car err) (cdr err))))) 4946 (unwind-protect
4947 (copy-file tmpfile filename t)
4948 (delete-file tmpfile))))
4946 4949
4947 ;; Use inline file transfer. 4950 ;; Use inline file transfer.
4948 (rem-dec 4951 (rem-dec
@@ -8123,8 +8126,12 @@ If the `tramp-methods' entry does not exist, return NIL."
8123 (setq ad-return-value 8126 (setq ad-return-value
8124 (tramp-file-name-handler 'make-auto-save-file-name)) 8127 (tramp-file-name-handler 'make-auto-save-file-name))
8125 ad-do-it)) 8128 ad-do-it))
8126 (add-hook 'tramp-unload-hook 8129 (add-hook
8127 (lambda () (ad-unadvise 'make-auto-save-file-name)))) 8130 'tramp-unload-hook
8131 (lambda ()
8132 (ad-remove-advice
8133 'make-auto-save-file-name
8134 'around 'tramp-advice-make-auto-save-file-name))))
8128 8135
8129;; In Emacs < 22 and XEmacs < 21.5 autosaved remote files have 8136;; In Emacs < 22 and XEmacs < 21.5 autosaved remote files have
8130;; permission 0666 minus umask. This is a security threat. 8137;; permission 0666 minus umask. This is a security threat.
@@ -8356,12 +8363,20 @@ Only works for Bourne-like shells."
8356 (if (string-match 8363 (if (string-match
8357 "[[*?]" 8364 "[[*?]"
8358 (tramp-file-name-localname (tramp-dissect-file-name name))) 8365 (tramp-file-name-localname (tramp-dissect-file-name name)))
8359 (setq ad-return-value (or ad-do-it (list name))) 8366 (progn
8367 ad-do-it
8368 (unless ad-return-value
8369 (setq ad-return-value (list name))))
8360 (setq ad-return-value (list name))) 8370 (setq ad-return-value (list name)))
8361 ;; If it is not a Tramp file, just run the original function. 8371 ;; If it is not a Tramp file, just run the original function.
8362 (setq ad-return-value (or ad-do-it (list name)))))) 8372 ad-do-it
8363 (add-hook 'tramp-unload-hook 8373 (unless ad-return-value
8364 (lambda () (ad-unadvise 'file-expand-wildcards)))) 8374 (setq ad-return-value (list name))))))
8375 (add-hook
8376 'tramp-unload-hook
8377 (lambda ()
8378 (ad-remove-advice
8379 'file-expand-wildcards 'around 'tramp-advice-file-expand-wildcards))))
8365 8380
8366;; Checklist for `tramp-unload-hook' 8381;; Checklist for `tramp-unload-hook'
8367;; - Unload all `tramp-*' packages 8382;; - Unload all `tramp-*' packages