aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog26
-rw-r--r--lisp/net/tramp-cmds.el147
-rw-r--r--lisp/net/tramp-gw.el5
-rw-r--r--lisp/net/tramp.el523
-rw-r--r--lisp/net/trampver.el4
5 files changed, 425 insertions, 280 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index bd281c4521e..de0b965335f 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -6,6 +6,32 @@
6 * net/ange-ftp.el (ange-ftp-copy-file): Add PRESERVE-UID-GID for 6 * net/ange-ftp.el (ange-ftp-copy-file): Add PRESERVE-UID-GID for
7 compatibility. It is not used, though. 7 compatibility. It is not used, though.
8 8
9 * net/tramp.el (top): Put load of all tramp-* files into a dolist.
10 Require tramp-cmds.el.
11 (tramp-make-tramp-temp-file): We can get rid of DONT-CREATE.
12 (tramp-handle-file-name-all-completions): Expand DIRECTORY.
13 (tramp-do-copy-or-rename-file-directly): Make more rigid checks.
14 (tramp-do-copy-or-rename-file-out-of-band)
15 (tramp-maybe-open-connection): Use `make-temp-name'. This is
16 possible, because we don't need to create the temporary file, but
17 we need a prefix for ssh, which has its own temporary file
18 handling.
19 (tramp-handle-delete-directory): Add "-f" to rmdir.
20 (tramp-handle-dired-recursive-delete-directory): Call "rm -rf".
21 (tramp-handle-insert-file-contents): Don't raise a tramp-error but
22 a signal, in order to give the callee a chance to suppress.
23 (tramp-handle-write-region): Set owner also in case of short
24 track. Don't use compatibility calls for `write-region' anymore.
25 (tramp-clear-passwd): Add parameter VEC. Adapt all callees.
26 (tramp-append-tramp-buffers): Apply `tramp-list-tramp-buffers'.
27
28 * net/tramp-cmds.el: New file.
29
30 * net/tramp-gw.el (tramp-gw-basic-authentication): Apply VEC to
31 `tramp-clear-passwd'.
32
33 * net/trampver.el: Update release number.
34
92007-10-21 Dan Nicolaescu <dann@ics.uci.edu> 352007-10-21 Dan Nicolaescu <dann@ics.uci.edu>
10 36
11 * progmodes/gud.el (gud-target-name): Move definition before use. 37 * progmodes/gud.el (gud-target-name): Move definition before use.
diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el
new file mode 100644
index 00000000000..43df393ec69
--- /dev/null
+++ b/lisp/net/tramp-cmds.el
@@ -0,0 +1,147 @@
1;;; tramp-cmds.el --- Interactive commands for Tramp
2
3;; Copyright (C) 2007 Free Software Foundation, Inc.
4
5;; Author: Michael Albinus <michael.albinus@gmx.de>
6;; Keywords: comm, processes
7
8;; This file is part of GNU Emacs.
9
10;; GNU Emacs is free software; you can redistribute it and/or modify
11;; it under the terms of the GNU General Public License as published by
12;; the Free Software Foundation; either version 3, or (at your option)
13;; any later version.
14
15;; GNU Emacs is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
21;; along with GNU Emacs; see the file COPYING. If not, see
22;; <http://www.gnu.org/licenses/>.
23
24;;; Commentary:
25
26;; This package provides all interactive commands which are releated
27;; to Tramp.
28
29;;; Code:
30
31(require 'tramp)
32
33(defun tramp-list-tramp-buffers ()
34 "Return a list of all Tramp connection buffers."
35 (append
36 (all-completions
37 "*tramp" (mapcar 'list (mapcar 'buffer-name (buffer-list))))
38 (all-completions
39 "*debug tramp" (mapcar 'list (mapcar 'buffer-name (buffer-list))))))
40
41(defun tramp-list-remote-buffers ()
42 "Return a list of all buffers with remote default-directory."
43 (delq
44 nil
45 (mapcar
46 (lambda (x)
47 (with-current-buffer x
48 (when (and (stringp default-directory)
49 (file-remote-p default-directory))
50 x)))
51 (buffer-list))))
52
53(defun tramp-cleanup-connection (vec)
54 "Flush all connection related objects.
55This includes password cache, file cache, connection cache, buffers.
56When called interactively, a Tramp connection has to be selected."
57 (interactive
58 ;; When interactive, select the Tramp remote identification.
59 ;; Return nil when there is no Tramp connection.
60 (list
61 (let ((connections
62 (mapcar
63 (lambda (x)
64 (with-current-buffer x (list (file-remote-p default-directory))))
65 ;; We shall not count debug buffers, because their
66 ;; default-directory is random. It could be even a remote
67 ;; one from another connection.
68 (all-completions
69 "*tramp" (mapcar 'list (tramp-list-tramp-buffers)))))
70 name)
71
72 (when connections
73 (setq name
74 (completing-read
75 "Enter Tramp connection: " connections nil t
76 (try-completion "" connections)))
77 (when (and name (file-remote-p name))
78 (with-parsed-tramp-file-name name nil v))))))
79
80 (if (not vec)
81 ;; Nothing to do.
82 (message "No Tramp connection found.")
83
84 ;; Flush password cache.
85 (tramp-clear-passwd vec)
86
87 ;; Flush file cache.
88 (tramp-flush-directory-property vec "/")
89
90 ;; Flush connection cache.
91 (tramp-flush-connection-property (tramp-get-connection-process vec) nil)
92 (tramp-flush-connection-property vec nil)
93
94 ;; Remove buffers.
95 (dolist
96 (buf (list (get-buffer (tramp-buffer-name vec))
97 (get-buffer (tramp-debug-buffer-name vec))
98 (tramp-get-connection-property vec "process-buffer" nil)))
99 (when (bufferp buf) (kill-buffer buf)))))
100
101(defun tramp-cleanup-all-connections ()
102 "Flush all Tramp internal objects.
103This includes password cache, file cache, connection cache, buffers."
104 (interactive)
105
106 ;; Flush password cache.
107 (when (functionp 'password-reset)
108 (funcall (symbol-function 'password-reset)))
109
110 ;; Flush file and connection cache.
111 (clrhash tramp-cache-data)
112
113 ;; Remove buffers.
114 (dolist (name (tramp-list-tramp-buffers))
115 (when (bufferp (get-buffer name)) (kill-buffer name))))
116
117(defun tramp-cleanup-all-buffers ()
118 "Kill all remote buffers."
119 (interactive)
120
121 ;; Remove all Tramp related buffers.
122 (tramp-cleanup-all-connections)
123
124 ;; Remove all buffers with a remote default-directory.
125 (dolist (name (tramp-list-remote-buffers))
126 (when (bufferp (get-buffer name)) (kill-buffer name))))
127
128(provide 'tramp-cmds)
129
130;;; TODO:
131
132;; * Clean up unused *tramp/foo* buffers after a while. (Pete Forman)
133;; * WIBNI there was an interactive command prompting for tramp
134;; method, hostname, username and filename and translates the user
135;; input into the correct filename syntax (depending on the Emacs
136;; flavor) (Reiner Steib)
137;; * Let the user edit the connection properties interactively.
138;; Something like `gnus-server-edit-server' in Gnus' *Server* buffer.
139;; * It's just that when I come to Customize `tramp-default-user-alist'
140;; I'm presented with a mismatch and raw lisp for a value. It is my
141;; understanding that a variable declared with defcustom is a User
142;; Option and should not be modified by the code. add-to-list is
143;; called in several places. One way to handle that is to have a new
144;; ordinary variable that gets its initial value from
145;; tramp-default-user-alist and then is added to. (Pete Forman)
146
147;;; tramp-cmds.el ends here
diff --git a/lisp/net/tramp-gw.el b/lisp/net/tramp-gw.el
index 70a37f384fe..fa2e9ba68b0 100644
--- a/lisp/net/tramp-gw.el
+++ b/lisp/net/tramp-gw.el
@@ -284,12 +284,11 @@ PROXY is an indication whether we need a Proxy-Authorization header
284or an Authorization header. If PW-CACHE is non-nil, check for 284or an Authorization header. If PW-CACHE is non-nil, check for
285password in password cache. This is done for the first try only." 285password in password cache. This is done for the first try only."
286 286
287 ;; `tramp-current-*' must be set for `tramp-read-passwd' and 287 ;; `tramp-current-*' must be set for `tramp-read-passwd'.
288 ;; `tramp-clear-passwd'.
289 (let ((tramp-current-method (tramp-file-name-method tramp-gw-gw-vector)) 288 (let ((tramp-current-method (tramp-file-name-method tramp-gw-gw-vector))
290 (tramp-current-user (tramp-file-name-user tramp-gw-gw-vector)) 289 (tramp-current-user (tramp-file-name-user tramp-gw-gw-vector))
291 (tramp-current-host (tramp-file-name-host tramp-gw-gw-vector))) 290 (tramp-current-host (tramp-file-name-host tramp-gw-gw-vector)))
292 (unless pw-cache (tramp-clear-passwd)) 291 (unless pw-cache (tramp-clear-passwd tramp-gw-gw-vector))
293 ;; We are already in the right buffer. 292 ;; We are already in the right buffer.
294 (tramp-message 293 (tramp-message
295 tramp-gw-vector 5 "%s required" 294 tramp-gw-vector 5 "%s required"
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 0af9c457995..10c2043b204 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -115,41 +115,34 @@
115;; The following Tramp packages must be loaded after Tramp, because 115;; The following Tramp packages must be loaded after Tramp, because
116;; they require Tramp as well. 116;; they require Tramp as well.
117(eval-after-load "tramp" 117(eval-after-load "tramp"
118 '(progn 118 '(dolist
119 (feature
120 (list
121
122 ;; Tramp commands.
123 'tramp-cmds
124
125 ;; Load foreign FTP method.
126 (if (featurep 'xemacs) 'tramp-efs 'tramp-ftp)
127
128 ;; tramp-smb uses "smbclient" from Samba. Not available
129 ;; under Cygwin and Windows, because they don't offer
130 ;; "smbclient". And even not necessary there, because Emacs
131 ;; supports UNC file names like "//host/share/localname".
132 (unless (memq system-type '(cygwin windows-nt)) 'tramp-smb)
133
134 ;; Load foreign FISH method.
135 'tramp-fish
119 136
120 ;; Load foreign FTP method. 137 ;; Load gateways. It needs `make-network-process' from Emacs 22.
121 (let ((feature (if (featurep 'xemacs) 'tramp-efs 'tramp-ftp))) 138 (when (functionp 'make-network-process) 'tramp-gw)))
139
140 (when feature
122 (require feature) 141 (require feature)
123 (add-hook 'tramp-unload-hook 142 (add-hook 'tramp-unload-hook
124 `(lambda () 143 `(lambda ()
125 (when (featurep ,feature) 144 (when (featurep ,feature)
126 (unload-feature ,feature 'force))))) 145 (unload-feature ,feature 'force)))))))
127
128 ;; tramp-smb uses "smbclient" from Samba. Not available under
129 ;; Cygwin and Windows, because they don't offer "smbclient". And
130 ;; even not necessary there, because Emacs supports UNC file names
131 ;; like "//host/share/localname".
132 (unless (memq system-type '(cygwin windows-nt))
133 (require 'tramp-smb)
134 (add-hook 'tramp-unload-hook
135 '(lambda ()
136 (when (featurep 'tramp-smb)
137 (unload-feature 'tramp-smb 'force)))))
138
139 ;; Load foreign FISH method.
140 (require 'tramp-fish)
141 (add-hook 'tramp-unload-hook
142 '(lambda ()
143 (when (featurep 'tramp-fish)
144 (unload-feature 'tramp-fish 'force))))
145
146 ;; Load gateways. It needs `make-network-process' from Emacs 22.
147 (when (functionp 'make-network-process)
148 (require 'tramp-gw)
149 (add-hook 'tramp-unload-hook
150 '(lambda ()
151 (when (featurep 'tramp-gw)
152 (unload-feature 'tramp-gw 'force)))))))
153 146
154;;; User Customizable Internal Variables: 147;;; User Customizable Internal Variables:
155 148
@@ -1965,42 +1958,30 @@ The intent is to protect against `obsolete variable' warnings."
1965(put 'tramp-let-maybe 'lisp-indent-function 2) 1958(put 'tramp-let-maybe 'lisp-indent-function 2)
1966(put 'tramp-let-maybe 'edebug-form-spec t) 1959(put 'tramp-let-maybe 'edebug-form-spec t)
1967 1960
1968(defsubst tramp-make-tramp-temp-file (vec &optional dont-create) 1961(defsubst tramp-make-tramp-temp-file (vec)
1969 "Create a temporary file on the remote host identified by VEC. 1962 "Create a temporary file on the remote host identified by VEC.
1970Return the local name of the temporary file. 1963Return the local name of the temporary file."
1971If DONT-CREATE is non-nil, just the file name is returned without 1964 (let ((prefix
1972creation of the temporary file. This is not the preferred way to run, 1965 (tramp-make-tramp-file-name
1973but it is necessary during connection setup, because we cannot create 1966 (tramp-file-name-method vec)
1974a remote file at this time. This parameter shall NOT be set to 1967 (tramp-file-name-user vec)
1975non-nil else." 1968 (tramp-file-name-host vec)
1976 (if dont-create 1969 (expand-file-name tramp-temp-name-prefix "/tmp")))
1977 ;; It sounds a little bit stupid to create a LOCAL file name. 1970 result)
1978 ;; But we intend to use the remote directory "/tmp", and we have 1971 (while (not result)
1979 ;; no chance to check whether a temporary file exists already 1972 ;; `make-temp-file' would be the natural choice for
1980 ;; remotely, because we have no working connection yet. 1973 ;; implementation. But it calls `write-region' internally,
1981 (make-temp-name (expand-file-name tramp-temp-name-prefix "/tmp")) 1974 ;; which also needs a temporary file - we would end in an
1982 1975 ;; infinite loop.
1983 (let ((prefix 1976 (setq result (make-temp-name prefix))
1984 (tramp-make-tramp-file-name 1977 (if (file-exists-p result)
1985 (tramp-file-name-method vec) 1978 (setq result nil)
1986 (tramp-file-name-user vec) 1979 ;; This creates the file by side effect.
1987 (tramp-file-name-host vec) 1980 (set-file-times result)
1988 (expand-file-name tramp-temp-name-prefix "/tmp"))) 1981 (set-file-modes result (tramp-octal-to-decimal "0700"))))
1989 result) 1982
1990 (while (not result) 1983 ;; Return the local part.
1991 ;; `make-temp-file' would be the first choice for 1984 (with-parsed-tramp-file-name result nil localname)))
1992 ;; implementation. But it calls `write-region' internally,
1993 ;; which also needs a temporary file - we would end in an
1994 ;; infinite loop.
1995 (setq result (make-temp-name prefix))
1996 (if (file-exists-p result)
1997 (setq result nil)
1998 ;; This creates the file by side effect.
1999 (set-file-times result)
2000 (set-file-modes result (tramp-octal-to-decimal "0700"))))
2001
2002 ;; Return the local part.
2003 (with-parsed-tramp-file-name result nil localname))))
2004 1985
2005 1986
2006;;; Config Manipulation Functions: 1987;;; Config Manipulation Functions:
@@ -2824,7 +2805,7 @@ and gid of the corresponding user is taken. Both parameters must be integers."
2824(defun tramp-handle-file-name-all-completions (filename directory) 2805(defun tramp-handle-file-name-all-completions (filename directory)
2825 "Like `file-name-all-completions' for Tramp files." 2806 "Like `file-name-all-completions' for Tramp files."
2826 (unless (save-match-data (string-match "/" filename)) 2807 (unless (save-match-data (string-match "/" filename))
2827 (with-parsed-tramp-file-name directory nil 2808 (with-parsed-tramp-file-name (expand-file-name directory) nil
2828 (all-completions 2809 (all-completions
2829 filename 2810 filename
2830 (mapcar 2811 (mapcar
@@ -3114,7 +3095,9 @@ the uid and gid from FILENAME."
3114 (cond 3095 (cond
3115 ;; We can do it directly. 3096 ;; We can do it directly.
3116 ((and (file-readable-p localname1) 3097 ((and (file-readable-p localname1)
3117 (file-writable-p (file-name-directory localname2))) 3098 (file-writable-p (file-name-directory localname2))
3099 (or (file-directory-p localname2)
3100 (file-writable-p localname2)))
3118 (if (eq op 'copy) 3101 (if (eq op 'copy)
3119 (tramp-compat-copy-file 3102 (tramp-compat-copy-file
3120 localname1 localname2 ok-if-already-exists 3103 localname1 localname2 ok-if-already-exists
@@ -3209,7 +3192,8 @@ be a local filename. The method used must be an out-of-band method."
3209 3192
3210 ;; Compose copy command. 3193 ;; Compose copy command.
3211 (setq spec `((?h . ,host) (?u . ,user) (?p . ,port) 3194 (setq spec `((?h . ,host) (?u . ,user) (?p . ,port)
3212 (?t . ,(tramp-make-tramp-temp-file v 'dont-create)) 3195 (?t . ,(tramp-get-connection-property
3196 (tramp-get-connection-process v) "temp-file" ""))
3213 (?k . ,(if keep-date " " ""))) 3197 (?k . ,(if keep-date " " "")))
3214 copy-program (tramp-get-method-parameter 3198 copy-program (tramp-get-method-parameter
3215 method 'tramp-copy-program) 3199 method 'tramp-copy-program)
@@ -3224,8 +3208,7 @@ be a local filename. The method used must be an out-of-band method."
3224 ;; " " is indication for keep-date argument. 3208 ;; " " is indication for keep-date argument.
3225 x (delete " " (mapcar '(lambda (y) (format-spec y spec)) x))) 3209 x (delete " " (mapcar '(lambda (y) (format-spec y spec)) x)))
3226 (unless (member "" x) (mapconcat 'identity x " "))) 3210 (unless (member "" x) (mapconcat 'identity x " ")))
3227 (tramp-get-method-parameter 3211 (tramp-get-method-parameter method 'tramp-copy-args))))
3228 method 'tramp-copy-args))))
3229 3212
3230 ;; Check for program. 3213 ;; Check for program.
3231 (when (and (fboundp 'executable-find) 3214 (when (and (fboundp 'executable-find)
@@ -3293,7 +3276,7 @@ be a local filename. The method used must be an out-of-band method."
3293 (save-excursion 3276 (save-excursion
3294 (tramp-barf-unless-okay 3277 (tramp-barf-unless-okay
3295 v 3278 v
3296 (format " %s %s" 3279 (format "%s %s"
3297 (if parents "mkdir -p" "mkdir") 3280 (if parents "mkdir -p" "mkdir")
3298 (tramp-shell-quote-argument localname)) 3281 (tramp-shell-quote-argument localname))
3299 "Couldn't make directory %s" dir)))) 3282 "Couldn't make directory %s" dir))))
@@ -3305,7 +3288,7 @@ be a local filename. The method used must be an out-of-band method."
3305 (tramp-flush-directory-property v localname) 3288 (tramp-flush-directory-property v localname)
3306 (unless (zerop (tramp-send-command-and-check 3289 (unless (zerop (tramp-send-command-and-check
3307 v 3290 v
3308 (format "rmdir %s" 3291 (format "rmdir -f %s"
3309 (tramp-shell-quote-argument localname)))) 3292 (tramp-shell-quote-argument localname))))
3310 (tramp-error v 'file-error "Couldn't delete %s" directory)))) 3293 (tramp-error v 'file-error "Couldn't delete %s" directory))))
3311 3294
@@ -3336,7 +3319,7 @@ This is like `dired-recursive-delete-directory' for Tramp files."
3336 ;; Which is better, -r or -R? (-r works for me <daniel@danann.net>) 3319 ;; Which is better, -r or -R? (-r works for me <daniel@danann.net>)
3337 (tramp-send-command 3320 (tramp-send-command
3338 v 3321 v
3339 (format "rm -r %s" (tramp-shell-quote-argument localname)) 3322 (format "rm -rf %s" (tramp-shell-quote-argument localname))
3340 ;; Don't read the output, do it explicitely. 3323 ;; Don't read the output, do it explicitely.
3341 nil t) 3324 nil t)
3342 ;; Wait for the remote system to return to us... 3325 ;; Wait for the remote system to return to us...
@@ -3896,8 +3879,9 @@ beginning of local filename are not substituted."
3896 (setq buffer-file-name filename) 3879 (setq buffer-file-name filename)
3897 (set-visited-file-modtime) 3880 (set-visited-file-modtime)
3898 (set-buffer-modified-p nil)) 3881 (set-buffer-modified-p nil))
3899 (tramp-error 3882 ;; We don't raise a Tramp error, because it might be
3900 v 'file-error "File %s not found on remote host" filename) 3883 ;; suppressed, like in `find-file-noselect-1'.
3884 (signal 'file-error (list "File not found on remote host" filename))
3901 (list (expand-file-name filename) 0)) 3885 (list (expand-file-name filename) 0))
3902 3886
3903 (if (and (tramp-local-host-p v) 3887 (if (and (tramp-local-host-p v)
@@ -4065,166 +4049,177 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file."
4065 (unless (y-or-n-p (format "File %s exists; overwrite anyway? " filename)) 4049 (unless (y-or-n-p (format "File %s exists; overwrite anyway? " filename))
4066 (tramp-error v 'file-error "File not overwritten"))) 4050 (tramp-error v 'file-error "File not overwritten")))
4067 4051
4068 (if (and (tramp-local-host-p v) 4052 (let ((uid (or (nth 2 (file-attributes filename 'integer))
4069 (file-writable-p (file-name-directory localname))) 4053 (tramp-get-remote-uid v 'integer)))
4070 ;; Short track: if we are on the local host, we can run directly. 4054 (gid (or (nth 3 (file-attributes filename 'integer))
4071 (if confirm 4055 (tramp-get-remote-gid v 'integer))))
4072 (write-region 4056
4073 start end localname append 'no-message lockname confirm) 4057 (if (and (tramp-local-host-p v)
4074 (write-region start end localname append 'no-message lockname)) 4058 (file-writable-p (file-name-directory localname))
4075 4059 (or (file-directory-p localname)
4076 (let ((rem-dec (tramp-get-remote-coding v "remote-decoding")) 4060 (file-writable-p localname)))
4077 (loc-enc (tramp-get-local-coding v "local-encoding")) 4061 ;; Short track: if we are on the local host, we can run directly.
4078 (modes (save-excursion (file-modes filename))) 4062 (write-region start end localname append 'no-message lockname confirm)
4079 ;; We use this to save the value of `last-coding-system-used' 4063
4080 ;; after writing the tmp file. At the end of the function, 4064 (let ((rem-dec (tramp-get-remote-coding v "remote-decoding"))
4081 ;; we set `last-coding-system-used' to this saved value. 4065 (loc-enc (tramp-get-local-coding v "local-encoding"))
4082 ;; This way, any intermediary coding systems used while 4066 (modes (save-excursion (file-modes filename)))
4083 ;; talking to the remote shell or suchlike won't hose this 4067 ;; We use this to save the value of
4084 ;; variable. This approach was snarfed from ange-ftp.el. 4068 ;; `last-coding-system-used' after writing the tmp file.
4085 coding-system-used 4069 ;; At the end of the function, we set
4086 ;; Write region into a tmp file. This isn't really needed if we 4070 ;; `last-coding-system-used' to this saved value. This
4087 ;; use an encoding function, but currently we use it always 4071 ;; way, any intermediary coding systems used while
4088 ;; because this makes the logic simpler. 4072 ;; talking to the remote shell or suchlike won't hose
4089 (tmpfile (tramp-compat-make-temp-file filename))) 4073 ;; this variable. This approach was snarfed from
4090 4074 ;; ange-ftp.el.
4091 ;; We say `no-message' here because we don't want the visited file 4075 coding-system-used
4092 ;; modtime data to be clobbered from the temp file. We call 4076 ;; Write region into a tmp file. This isn't really
4093 ;; `set-visited-file-modtime' ourselves later on. 4077 ;; needed if we use an encoding function, but currently
4094 (tramp-run-real-handler 4078 ;; we use it always because this makes the logic
4095 'write-region 4079 ;; simpler.
4096 (if confirm ; don't pass this arg unless defined for backward compat. 4080 (tmpfile (tramp-compat-make-temp-file filename)))
4097 (list start end tmpfile append 'no-message lockname confirm) 4081
4098 (list start end tmpfile append 'no-message lockname))) 4082 ;; We say `no-message' here because we don't want the
4099 ;; Now, `last-coding-system-used' has the right value. Remember it. 4083 ;; visited file modtime data to be clobbered from the temp
4100 (when (boundp 'last-coding-system-used) 4084 ;; file. We call `set-visited-file-modtime' ourselves later
4101 (setq coding-system-used (symbol-value 'last-coding-system-used))) 4085 ;; on.
4102 ;; The permissions of the temporary file should be set. If 4086 (tramp-run-real-handler
4103 ;; filename does not exist (eq modes nil) it has been renamed to 4087 'write-region
4104 ;; the backup file. This case `save-buffer' handles 4088 (list start end tmpfile append 'no-message lockname confirm))
4105 ;; permissions. 4089 ;; Now, `last-coding-system-used' has the right value. Remember it.
4106 (when modes (set-file-modes tmpfile modes)) 4090 (when (boundp 'last-coding-system-used)
4107 4091 (setq coding-system-used (symbol-value 'last-coding-system-used)))
4108 ;; This is a bit lengthy due to the different methods possible for 4092 ;; The permissions of the temporary file should be set. If
4109 ;; file transfer. First, we check whether the method uses an rcp 4093 ;; filename does not exist (eq modes nil) it has been
4110 ;; program. If so, we call it. Otherwise, both encoding and 4094 ;; renamed to the backup file. This case `save-buffer'
4111 ;; decoding command must be specified. However, if the method 4095 ;; handles permissions.
4112 ;; _also_ specifies an encoding function, then that is used for 4096 (when modes (set-file-modes tmpfile modes))
4113 ;; encoding the contents of the tmp file. 4097
4114 (cond 4098 ;; This is a bit lengthy due to the different methods
4115 ;; `rename-file' handles direct copy and out-of-band methods. 4099 ;; possible for file transfer. First, we check whether the
4116 ((or (tramp-local-host-p v) 4100 ;; method uses an rcp program. If so, we call it.
4117 (and (tramp-method-out-of-band-p v) 4101 ;; Otherwise, both encoding and decoding command must be
4118 (integerp start) 4102 ;; specified. However, if the method _also_ specifies an
4119 (> (- end start) tramp-copy-size-limit))) 4103 ;; encoding function, then that is used for encoding the
4120 (rename-file tmpfile filename t)) 4104 ;; contents of the tmp file.
4121 4105 (cond
4122 ;; Use inline file transfer 4106 ;; `rename-file' handles direct copy and out-of-band methods.
4123 (rem-dec 4107 ((or (tramp-local-host-p v)
4124 ;; Encode tmpfile 4108 (and (tramp-method-out-of-band-p v)
4125 (tramp-message v 5 "Encoding region...") 4109 (integerp start)
4126 (unwind-protect 4110 (> (- end start) tramp-copy-size-limit)))
4127 (with-temp-buffer 4111 (rename-file tmpfile filename t))
4128 ;; Use encoding function or command. 4112
4129 (if (and (symbolp loc-enc) (fboundp loc-enc)) 4113 ;; Use inline file transfer
4130 (progn 4114 (rem-dec
4131 (tramp-message 4115 ;; Encode tmpfile
4132 v 5 "Encoding region using function `%s'..." 4116 (tramp-message v 5 "Encoding region...")
4133 (symbol-name loc-enc)) 4117 (unwind-protect
4134 (let ((coding-system-for-read 'binary)) 4118 (with-temp-buffer
4135 (insert-file-contents-literally tmpfile)) 4119 ;; Use encoding function or command.
4136 ;; CCC. The following `let' is a workaround for 4120 (if (and (symbolp loc-enc) (fboundp loc-enc))
4137 ;; the base64.el that comes with pgnus-0.84. If 4121 (progn
4138 ;; both of the following conditions are 4122 (tramp-message
4139 ;; satisfied, it tries to write to a local file 4123 v 5 "Encoding region using function `%s'..."
4140 ;; in default-directory, but at this point, 4124 (symbol-name loc-enc))
4141 ;; default-directory is remote. 4125 (let ((coding-system-for-read 'binary))
4142 ;; (CALL-PROCESS-REGION can't write to remote 4126 (insert-file-contents-literally tmpfile))
4143 ;; files, it seems.) The file in question is a 4127 ;; CCC. The following `let' is a workaround
4144 ;; tmp file anyway. 4128 ;; for the base64.el that comes with
4145 (let ((default-directory 4129 ;; pgnus-0.84. If both of the following
4146 (tramp-compat-temporary-file-directory))) 4130 ;; conditions are satisfied, it tries to write
4147 (funcall loc-enc (point-min) (point-max)))) 4131 ;; to a local file in default-directory, but
4132 ;; at this point, default-directory is remote.
4133 ;; (CALL-PROCESS-REGION can't write to remote
4134 ;; files, it seems.) The file in question is
4135 ;; a tmp file anyway.
4136 (let ((default-directory
4137 (tramp-compat-temporary-file-directory)))
4138 (funcall loc-enc (point-min) (point-max))))
4148 4139
4140 (tramp-message
4141 v 5 "Encoding region using command `%s'..." loc-enc)
4142 (unless (equal 0 (tramp-call-local-coding-command
4143 loc-enc tmpfile t))
4144 (tramp-error
4145 v 'file-error
4146 "Cannot write to `%s', local encoding command `%s' failed"
4147 filename loc-enc)))
4148
4149 ;; Send buffer into remote decoding command which
4150 ;; writes to remote file. Because this happens on
4151 ;; the remote host, we cannot use the function.
4152 (goto-char (point-max))
4153 (unless (bolp) (newline))
4149 (tramp-message 4154 (tramp-message
4150 v 5 "Encoding region using command `%s'..." loc-enc) 4155 v 5 "Decoding region into remote file %s..." filename)
4151 (unless (equal 0 (tramp-call-local-coding-command 4156 (tramp-send-command
4152 loc-enc tmpfile t)) 4157 v
4153 (tramp-error 4158 (format
4154 v 'file-error 4159 "%s >%s <<'EOF'\n%sEOF"
4155 "Cannot write to `%s', local encoding command `%s' failed" 4160 rem-dec
4156 filename loc-enc))) 4161 (tramp-shell-quote-argument localname)
4157 4162 (buffer-string)))
4158 ;; Send buffer into remote decoding command which 4163 (tramp-barf-unless-okay
4159 ;; writes to remote file. Because this happens on the 4164 v nil
4160 ;; remote host, we cannot use the function. 4165 "Couldn't write region to `%s', decode using `%s' failed"
4161 (goto-char (point-max)) 4166 filename rem-dec)
4162 (unless (bolp) (newline)) 4167 ;; When `file-precious-flag' is set, the region is
4163 (tramp-message 4168 ;; written to a temporary file. Check that the
4164 v 5 "Decoding region into remote file %s..." filename) 4169 ;; checksum is equal to that from the local tmpfile.
4165 (tramp-send-command 4170 (when file-precious-flag
4166 v 4171 (erase-buffer)
4167 (format 4172 (and
4168 "%s >%s <<'EOF'\n%sEOF" 4173 ;; cksum runs locally
4169 rem-dec 4174 (let ((default-directory
4170 (tramp-shell-quote-argument localname) 4175 (tramp-compat-temporary-file-directory)))
4171 (buffer-string))) 4176 (zerop (call-process "cksum" tmpfile t)))
4172 (tramp-barf-unless-okay 4177 ;; cksum runs remotely
4173 v nil 4178 (zerop
4174 "Couldn't write region to `%s', decode using `%s' failed" 4179 (tramp-send-command-and-check
4175 filename rem-dec) 4180 v
4176 ;; When `file-precious-flag' is set, the region is 4181 (format
4177 ;; written to a temporary file. Check that the 4182 "cksum <%s" (tramp-shell-quote-argument localname))))
4178 ;; checksum is equal to that from the local tmpfile. 4183 ;; ... they are different
4179 (when file-precious-flag 4184 (not
4180 (erase-buffer) 4185 (string-equal
4181 (and 4186 (buffer-string)
4182 ;; cksum runs locally 4187 (with-current-buffer (tramp-get-buffer v)
4183 (let ((default-directory 4188 (buffer-string))))
4184 (tramp-compat-temporary-file-directory))) 4189 (tramp-error
4185 (zerop (call-process "cksum" tmpfile t))) 4190 v 'file-error
4186 ;; cksum runs remotely 4191 (concat "Couldn't write region to `%s',"
4187 (zerop 4192 " decode using `%s' failed")
4188 (tramp-send-command-and-check 4193 filename rem-dec)))
4189 v 4194 (tramp-message
4190 (format "cksum <%s" (tramp-shell-quote-argument localname)))) 4195 v 5 "Decoding region into remote file %s...done" filename)
4191 ;; ... they are different 4196 (tramp-flush-file-property v localname))
4192 (not
4193 (string-equal
4194 (buffer-string)
4195 (with-current-buffer (tramp-get-buffer v) (buffer-string))))
4196 (tramp-error
4197 v 'file-error
4198 (concat "Couldn't write region to `%s',"
4199 " decode using `%s' failed")
4200 filename rem-dec)))
4201 (tramp-message
4202 v 5 "Decoding region into remote file %s...done" filename)
4203 (tramp-flush-file-property v localname))
4204 4197
4205 ;; Save exit. 4198 ;; Save exit.
4206 (delete-file tmpfile))) 4199 (delete-file tmpfile)))
4207 4200
4208 ;; That's not expected. 4201 ;; That's not expected.
4209 (t 4202 (t
4210 (tramp-error 4203 (tramp-error
4211 v 'file-error 4204 v 'file-error
4212 (concat "Method `%s' should specify both encoding and " 4205 (concat "Method `%s' should specify both encoding and "
4213 "decoding command or an rcp program") 4206 "decoding command or an rcp program")
4214 method))) 4207 method)))
4215 4208
4216 ;; Make `last-coding-system-used' have the right value. 4209 ;; Make `last-coding-system-used' have the right value.
4217 (when coding-system-used 4210 (when coding-system-used
4218 (set 'last-coding-system-used coding-system-used))) 4211 (set 'last-coding-system-used coding-system-used))))
4219 4212
4220 ;; Set file modification time. 4213 ;; Set file modification time.
4221 (when (or (eq visit t) (stringp visit)) 4214 (when (or (eq visit t) (stringp visit))
4222 (set-visited-file-modtime 4215 (set-visited-file-modtime
4223 ;; We must pass modtime explicitely, because filename can be different 4216 ;; We must pass modtime explicitely, because filename can
4224 ;; from (buffer-file-name), f.e. if `file-precious-flag' is set. 4217 ;; be different from (buffer-file-name), f.e. if
4218 ;; `file-precious-flag' is set.
4225 (nth 5 (file-attributes filename)))) 4219 (nth 5 (file-attributes filename))))
4220
4226 ;; Set the ownership. 4221 ;; Set the ownership.
4227 (tramp-set-file-uid-gid filename) 4222 (tramp-set-file-uid-gid filename uid gid)
4228 (when (or (eq visit t) (null visit) (stringp visit)) 4223 (when (or (eq visit t) (null visit) (stringp visit))
4229 (tramp-message v 0 "Wrote %s" filename)) 4224 (tramp-message v 0 "Wrote %s" filename))
4230 (run-hooks 'tramp-handle-write-region-hook)))) 4225 (run-hooks 'tramp-handle-write-region-hook))))
@@ -4559,8 +4554,7 @@ Falls back to normal file name handler if no tramp file name handler exists."
4559 (insert "\")") 4554 (insert "\")")
4560 (goto-char (point-min)) 4555 (goto-char (point-min))
4561 (mapcar 4556 (mapcar
4562 (function (lambda (x) 4557 (lambda (x) (tramp-make-tramp-file-name method user host x))
4563 (tramp-make-tramp-file-name method user host x)))
4564 (read (current-buffer))))))) 4558 (read (current-buffer)))))))
4565 (list (expand-file-name name)))))) 4559 (list (expand-file-name name))))))
4566 4560
@@ -5542,7 +5536,7 @@ The terminal type can be configured with `tramp-terminal-type'."
5542 (with-current-buffer (tramp-get-connection-buffer vec) 5536 (with-current-buffer (tramp-get-connection-buffer vec)
5543 (tramp-message vec 6 "\n%s" (buffer-string))) 5537 (tramp-message vec 6 "\n%s" (buffer-string)))
5544 (unless (eq exit 'ok) 5538 (unless (eq exit 'ok)
5545 (tramp-clear-passwd) 5539 (tramp-clear-passwd vec)
5546 (tramp-error-with-buffer 5540 (tramp-error-with-buffer
5547 nil vec 'file-error 5541 nil vec 'file-error
5548 (cond 5542 (cond
@@ -6158,6 +6152,18 @@ connection if a previous connection has died for some reason."
6158 (g-user (and gw (tramp-file-name-user gw))) 6152 (g-user (and gw (tramp-file-name-user gw)))
6159 (g-host (and gw (tramp-file-name-host gw))) 6153 (g-host (and gw (tramp-file-name-host gw)))
6160 (command login-program) 6154 (command login-program)
6155 ;; We don't create the temporary file. In fact, it
6156 ;; is just a prefix for the ControlPath option of
6157 ;; ssh; the real temporary file has another name, and
6158 ;; it is created and protected by ssh. It is also
6159 ;; removed by ssh, when the connection is closed.
6160 (tmpfile
6161 (tramp-set-connection-property
6162 p "temp-file"
6163 (make-temp-name
6164 (expand-file-name
6165 tramp-temp-name-prefix
6166 (tramp-compat-temporary-file-directory)))))
6161 spec) 6167 spec)
6162 6168
6163 ;; Add gateway arguments if necessary. 6169 ;; Add gateway arguments if necessary.
@@ -6182,7 +6188,7 @@ connection if a previous connection has died for some reason."
6182 l-user (or l-user "") 6188 l-user (or l-user "")
6183 l-port (or l-port "") 6189 l-port (or l-port "")
6184 spec `((?h . ,l-host) (?u . ,l-user) (?p . ,l-port) 6190 spec `((?h . ,l-host) (?u . ,l-user) (?p . ,l-port)
6185 (?t . ,(tramp-make-tramp-temp-file vec 'dont-create))) 6191 (?t . ,tmpfile))
6186 command 6192 command
6187 (concat 6193 (concat
6188 command " " 6194 command " "
@@ -7043,17 +7049,16 @@ Invokes `password-read' if available, `read-passwd' else."
7043 password) 7049 password)
7044 (read-passwd pw-prompt)))) 7050 (read-passwd pw-prompt))))
7045 7051
7046(defun tramp-clear-passwd () 7052(defun tramp-clear-passwd (vec)
7047 "Clear password cache for connection related to current-buffer. 7053 "Clear password cache for connection related to VEC."
7048If METHOD, USER or HOST is given, take then for computing the key."
7049 (interactive)
7050 (when (functionp 'password-cache-remove) 7054 (when (functionp 'password-cache-remove)
7051 (funcall (symbol-function 'password-cache-remove) 7055 (funcall
7052 (tramp-make-tramp-file-name 7056 (symbol-function 'password-cache-remove)
7053 tramp-current-method 7057 (tramp-make-tramp-file-name
7054 tramp-current-user 7058 (tramp-file-name-method vec)
7055 tramp-current-host 7059 (tramp-file-name-user vec)
7056 "")))) 7060 (tramp-file-name-host vec)
7061 ""))))
7057 7062
7058;; Snarfed code from time-date.el and parse-time.el 7063;; Snarfed code from time-date.el and parse-time.el
7059 7064
@@ -7410,13 +7415,9 @@ Used for non-7bit chars in strings."
7410 (boundp 'mml-mode) 7415 (boundp 'mml-mode)
7411 (symbol-value 'mml-mode)) 7416 (symbol-value 'mml-mode))
7412 7417
7413 (let* ((tramp-buf-regexp "\\*\\(debug \\)?tramp/") 7418 (let ((tramp-buf-regexp "\\*\\(debug \\)?tramp/")
7414 (buffer-list 7419 (buffer-list (funcall (symbol-function 'tramp-list-tramp-buffers)))
7415 (delq nil 7420 (curbuf (current-buffer)))
7416 (mapcar '(lambda (b)
7417 (when (string-match tramp-buf-regexp (buffer-name b)) b))
7418 (buffer-list))))
7419 (curbuf (current-buffer)))
7420 7421
7421 ;; There is at least one Tramp buffer. 7422 ;; There is at least one Tramp buffer.
7422 (when buffer-list 7423 (when buffer-list
@@ -7465,8 +7466,8 @@ please ensure that the buffers are attached to your email.\n\n")
7465 (dolist (buffer buffer-list) 7466 (dolist (buffer buffer-list)
7466 (funcall (symbol-function 'mml-insert-empty-tag) 7467 (funcall (symbol-function 'mml-insert-empty-tag)
7467 'part 'type "text/plain" 'encoding "base64" 7468 'part 'type "text/plain" 'encoding "base64"
7468 'disposition "attachment" 'buffer (buffer-name buffer) 7469 'disposition "attachment" 'buffer buffer
7469 'description (buffer-name buffer))) 7470 'description buffer))
7470 (set-buffer-modified-p nil)) 7471 (set-buffer-modified-p nil))
7471 7472
7472 ;; Don't send. Delete the message buffer. 7473 ;; Don't send. Delete the message buffer.
@@ -7516,20 +7517,6 @@ please ensure that the buffers are attached to your email.\n\n")
7516;; around one of the loops that calls accept-process-output) 7517;; around one of the loops that calls accept-process-output)
7517;; (Stefan Monnier). 7518;; (Stefan Monnier).
7518;; * Autodetect if remote `ls' groks the "--dired" switch. 7519;; * Autodetect if remote `ls' groks the "--dired" switch.
7519;; * Add fallback for inline encodings. This should be used
7520;; if the remote end doesn't support mimencode or a similar program.
7521;; For reading files from the remote host, we can just parse the output
7522;; of `od -b'. For writing files to the remote host, we construct
7523;; a shell program which contains only "safe" ascii characters
7524;; and which writes the right bytes to the file. We can use printf(1)
7525;; or "echo -e" or the printf function in awk and use octal escapes
7526;; for the "dangerous" characters. The null byte might be a problem.
7527;; On some systems, the octal escape doesn't work. So we try the following
7528;; two commands to write a null byte:
7529;; dd if=/dev/zero bs=1 count=1
7530;; echo | tr '\n' '\000'
7531;; * Cooperate with PCL-CVS. It uses start-process, which doesn't
7532;; work for remote files.
7533;; * Rewrite `tramp-shell-quote-argument' to abstain from using 7520;; * Rewrite `tramp-shell-quote-argument' to abstain from using
7534;; `shell-quote-argument'. 7521;; `shell-quote-argument'.
7535;; * Completion gets confused when you leave out the method name. 7522;; * Completion gets confused when you leave out the method name.
@@ -7565,7 +7552,6 @@ please ensure that the buffers are attached to your email.\n\n")
7565;; (Francesco Potort́) 7552;; (Francesco Potort́)
7566;; * Make it work for different encodings, and for different file name 7553;; * Make it work for different encodings, and for different file name
7567;; encodings, too. (Daniel Pittman) 7554;; encodings, too. (Daniel Pittman)
7568;; * Clean up unused *tramp/foo* buffers after a while. (Pete Forman)
7569;; * Progress reports while copying files. (Michael Kifer) 7555;; * Progress reports while copying files. (Michael Kifer)
7570;; * Don't search for perl5 and perl. Instead, only search for perl and 7556;; * Don't search for perl5 and perl. Instead, only search for perl and
7571;; then look if it's the right version (with `perl -v'). 7557;; then look if it's the right version (with `perl -v').
@@ -7600,21 +7586,8 @@ please ensure that the buffers are attached to your email.\n\n")
7600;; something. (David Kastrup) 7586;; something. (David Kastrup)
7601;; * Could Tramp reasonably look for a prompt after ^M rather than 7587;; * Could Tramp reasonably look for a prompt after ^M rather than
7602;; only after ^J ? (Stefan Monnier) 7588;; only after ^J ? (Stefan Monnier)
7603;; * WIBNI there was an interactive command prompting for tramp
7604;; method, hostname, username and filename and translates the user
7605;; input into the correct filename syntax (depending on the Emacs
7606;; flavor) (Reiner Steib)
7607;; * Let the user edit the connection properties interactively.
7608;; Something like `gnus-server-edit-server' in Gnus' *Server* buffer.
7609;; * Reconnect directly to a compliant shell without first going 7589;; * Reconnect directly to a compliant shell without first going
7610;; through the user's default shell. (Pete Forman) 7590;; through the user's default shell. (Pete Forman)
7611;; * It's just that when I come to Customize `tramp-default-user-alist'
7612;; I'm presented with a mismatch and raw lisp for a value. It is my
7613;; understanding that a variable declared with defcustom is a User
7614;; Option and should not be modified by the code. add-to-list is
7615;; called in several places. One way to handle that is to have a new
7616;; ordinary variable that gets its initial value from
7617;; tramp-default-user-alist and then is added to. (Pete Forman)
7618;; * Make `tramp-default-user' obsolete. 7591;; * Make `tramp-default-user' obsolete.
7619 7592
7620;; Functions for file-name-handler-alist: 7593;; Functions for file-name-handler-alist:
diff --git a/lisp/net/trampver.el b/lisp/net/trampver.el
index a83d81966a8..58ae73d8cd3 100644
--- a/lisp/net/trampver.el
+++ b/lisp/net/trampver.el
@@ -30,14 +30,14 @@
30;; "autoconf && ./configure" to change them. (X)Emacs version check is defined 30;; "autoconf && ./configure" to change them. (X)Emacs version check is defined
31;; in macro AC_EMACS_INFO of aclocal.m4; should be changed only there. 31;; in macro AC_EMACS_INFO of aclocal.m4; should be changed only there.
32 32
33(defconst tramp-version "2.1.11" 33(defconst tramp-version "2.1.12-pre"
34 "This version of Tramp.") 34 "This version of Tramp.")
35 35
36(defconst tramp-bug-report-address "tramp-devel@gnu.org" 36(defconst tramp-bug-report-address "tramp-devel@gnu.org"
37 "Email address to send bug reports to.") 37 "Email address to send bug reports to.")
38 38
39;; Check for (X)Emacs version. 39;; Check for (X)Emacs version.
40(let ((x (if (or (< emacs-major-version 21) (and (featurep 'xemacs) (< emacs-minor-version 4))) (format "Tramp 2.1.11 is not fit for %s" (when (string-match "^.*$" (emacs-version)) (match-string 0 (emacs-version)))) "ok"))) 40(let ((x (if (or (< emacs-major-version 21) (and (featurep 'xemacs) (< emacs-minor-version 4))) (format "Tramp 2.1.12-pre is not fit for %s" (when (string-match "^.*$" (emacs-version)) (match-string 0 (emacs-version)))) "ok")))
41 (unless (string-match "\\`ok\\'" x) (error x))) 41 (unless (string-match "\\`ok\\'" x) (error x)))
42 42
43(provide 'trampver) 43(provide 'trampver)