aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog22
-rw-r--r--lisp/net/tramp-compat.el1
-rw-r--r--lisp/net/tramp-sh.el14
-rw-r--r--lisp/net/tramp-smb.el91
-rw-r--r--lisp/net/tramp.el47
5 files changed, 104 insertions, 71 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index cf5c9326d23..6b83f7c1c77 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,25 @@
12011-09-18 Michael Albinus <michael.albinus@gmx.de>
2
3 * net/tramp.el (top): Don't require 'shell.
4 (tramp-methods): Fix docstring.
5 (tramp-get-remote-tmpdir): New defun, moved from tramp-sh.el.
6 Return complete remote file name. Handle "smb" case. Use
7 `tramp-tmpdir', if defined for the respective method.
8 (tramp-make-tramp-temp-file): Adapt call of `tramp-get-remote-tmpdir'.
9
10 * net/tramp-compat.el (top): Require 'shell.
11
12 * net/tramp-sh.el (tramp-do-copy-or-rename-file-out-of-band)
13 (tramp-maybe-open-connection): Use `tramp-file-name-real-host' for
14 `tramp-current-host'.
15 (tramp-get-remote-tmpdir): Remove.
16
17 * net/tramp-smb.el (tramp-methods): Add `tramp-remote-shell' and
18 `tramp-tmpdir' entries.
19 (tramp-smb-errors): Add "NT_STATUS_IMAGE_ALREADY_LOADED".
20 (tramp-smb-handle-file-attributes): Ignore errors.
21 (tramp-smb-wait-for-output): Check also for process end.
22
12011-09-18 Lars Magne Ingebrigtsen <larsi@gnus.org> 232011-09-18 Lars Magne Ingebrigtsen <larsi@gnus.org>
2 24
3 * mail/smtpmail.el (smtpmail-via-smtp): Ignore errors that arise 25 * mail/smtpmail.el (smtpmail-via-smtp): Ignore errors that arise
diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el
index 460c9f0e118..5054f1d232d 100644
--- a/lisp/net/tramp-compat.el
+++ b/lisp/net/tramp-compat.el
@@ -41,6 +41,7 @@
41 (require 'advice) 41 (require 'advice)
42 (require 'custom) 42 (require 'custom)
43 (require 'format-spec) 43 (require 'format-spec)
44 (require 'shell)
44 45
45 ;; As long as password.el is not part of (X)Emacs, it shouldn't be 46 ;; As long as password.el is not part of (X)Emacs, it shouldn't be
46 ;; mandatory. 47 ;; mandatory.
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 1fa358e9277..e50bb8498db 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -2280,7 +2280,7 @@ The method used must be an out-of-band method."
2280 ;; password. 2280 ;; password.
2281 (setq tramp-current-method (tramp-file-name-method v) 2281 (setq tramp-current-method (tramp-file-name-method v)
2282 tramp-current-user (tramp-file-name-user v) 2282 tramp-current-user (tramp-file-name-user v)
2283 tramp-current-host (tramp-file-name-host v)) 2283 tramp-current-host (tramp-file-name-real-host v))
2284 2284
2285 ;; Expand hops. Might be necessary for gateway methods. 2285 ;; Expand hops. Might be necessary for gateway methods.
2286 (setq v (car (tramp-compute-multi-hops v))) 2286 (setq v (car (tramp-compute-multi-hops v)))
@@ -4292,7 +4292,7 @@ connection if a previous connection has died for some reason."
4292 (gw (tramp-get-file-property hop "" "gateway" nil)) 4292 (gw (tramp-get-file-property hop "" "gateway" nil))
4293 (g-method (and gw (tramp-file-name-method gw))) 4293 (g-method (and gw (tramp-file-name-method gw)))
4294 (g-user (and gw (tramp-file-name-user gw))) 4294 (g-user (and gw (tramp-file-name-user gw)))
4295 (g-host (and gw (tramp-file-name-host gw))) 4295 (g-host (and gw (tramp-file-name-real-host gw)))
4296 (command login-program) 4296 (command login-program)
4297 ;; We don't create the temporary file. In fact, 4297 ;; We don't create the temporary file. In fact,
4298 ;; it is just a prefix for the ControlPath option 4298 ;; it is just a prefix for the ControlPath option
@@ -4721,16 +4721,6 @@ This is used internally by `tramp-file-mode-from-int'."
4721 x)) 4721 x))
4722 remote-path))))) 4722 remote-path)))))
4723 4723
4724(defun tramp-get-remote-tmpdir (vec)
4725 (with-connection-property vec "tmp-directory"
4726 (let ((dir (tramp-shell-quote-argument "/tmp")))
4727 (if (and (tramp-send-command-and-check
4728 vec (format "%s -d %s" (tramp-get-test-command vec) dir))
4729 (tramp-send-command-and-check
4730 vec (format "%s -w %s" (tramp-get-test-command vec) dir)))
4731 dir
4732 (tramp-error vec 'file-error "Directory %s not accessible" dir)))))
4733
4734(defun tramp-get-ls-command (vec) 4724(defun tramp-get-ls-command (vec)
4735 (with-connection-property vec "ls" 4725 (with-connection-property vec "ls"
4736 (tramp-message vec 5 "Finding a suitable `ls' command") 4726 (tramp-message vec 5 "Finding a suitable `ls' command")
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index eb456298c1a..150ef18be52 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -38,7 +38,15 @@
38;; ... and add it to the method list. 38;; ... and add it to the method list.
39;;;###tramp-autoload 39;;;###tramp-autoload
40(unless (memq system-type '(cygwin windows-nt)) 40(unless (memq system-type '(cygwin windows-nt))
41 (add-to-list 'tramp-methods (cons tramp-smb-method nil))) 41 (add-to-list 'tramp-methods
42 `(,tramp-smb-method
43 ;; We define an empty command, because `tramp-smb-call-winexe'
44 ;; opens already the powershell. Used in `tramp-handle-shell-command'.
45 (tramp-remote-shell "")
46 ;; This is just a guess. We don't know whether the share "$C"
47 ;; is available for public use, and whether the user has write
48 ;; access.
49 (tramp-tmpdir "/C$/Temp"))))
42 50
43;; Add a default for `tramp-default-method-alist'. Rule: If there is 51;; Add a default for `tramp-default-method-alist'. Rule: If there is
44;; a domain in USER, it must be the SMB method. 52;; a domain in USER, it must be the SMB method.
@@ -98,7 +106,8 @@ call, letting the SMB client use the default one."
98 "ERRnomem" 106 "ERRnomem"
99 "ERRnosuchshare" 107 "ERRnosuchshare"
100 ;; Windows 4.0 (Windows NT), Windows 5.0 (Windows 2000), 108 ;; Windows 4.0 (Windows NT), Windows 5.0 (Windows 2000),
101 ;; Windows 5.1 (Windows XP), Windows 5.2 (Windows Server 2003). 109 ;; Windows 5.1 (Windows XP), Windows 5.2 (Windows Server 2003),
110 ;; Windows 6.0 (Windows Vista), Windows 6.1 (Windows 7).
102 "NT_STATUS_ACCESS_DENIED" 111 "NT_STATUS_ACCESS_DENIED"
103 "NT_STATUS_ACCOUNT_LOCKED_OUT" 112 "NT_STATUS_ACCOUNT_LOCKED_OUT"
104 "NT_STATUS_BAD_NETWORK_NAME" 113 "NT_STATUS_BAD_NETWORK_NAME"
@@ -107,6 +116,7 @@ call, letting the SMB client use the default one."
107 "NT_STATUS_DIRECTORY_NOT_EMPTY" 116 "NT_STATUS_DIRECTORY_NOT_EMPTY"
108 "NT_STATUS_DUPLICATE_NAME" 117 "NT_STATUS_DUPLICATE_NAME"
109 "NT_STATUS_FILE_IS_A_DIRECTORY" 118 "NT_STATUS_FILE_IS_A_DIRECTORY"
119 "NT_STATUS_IMAGE_ALREADY_LOADED"
110 "NT_STATUS_IO_TIMEOUT" 120 "NT_STATUS_IO_TIMEOUT"
111 "NT_STATUS_LOGON_FAILURE" 121 "NT_STATUS_LOGON_FAILURE"
112 "NT_STATUS_NETWORK_ACCESS_DENIED" 122 "NT_STATUS_NETWORK_ACCESS_DENIED"
@@ -490,39 +500,40 @@ PRESERVE-UID-GID and PRESERVE-SELINUX-CONTEXT are completely ignored."
490(defun tramp-smb-handle-file-attributes (filename &optional id-format) 500(defun tramp-smb-handle-file-attributes (filename &optional id-format)
491 "Like `file-attributes' for Tramp files." 501 "Like `file-attributes' for Tramp files."
492 (unless id-format (setq id-format 'integer)) 502 (unless id-format (setq id-format 'integer))
493 (with-parsed-tramp-file-name filename nil 503 (ignore-errors
494 (with-file-property v localname (format "file-attributes-%s" id-format) 504 (with-parsed-tramp-file-name filename nil
495 (if (and (tramp-smb-get-share v) (tramp-smb-get-stat-capability v)) 505 (with-file-property v localname (format "file-attributes-%s" id-format)
496 (tramp-smb-do-file-attributes-with-stat v id-format) 506 (if (and (tramp-smb-get-share v) (tramp-smb-get-stat-capability v))
497 ;; Reading just the filename entry via "dir localname" is not 507 (tramp-smb-do-file-attributes-with-stat v id-format)
498 ;; possible, because when filename is a directory, some 508 ;; Reading just the filename entry via "dir localname" is not
499 ;; smbclient versions return the content of the directory, and 509 ;; possible, because when filename is a directory, some
500 ;; other versions don't. Therefore, the whole content of the 510 ;; smbclient versions return the content of the directory, and
501 ;; upper directory is retrieved, and the entry of the filename 511 ;; other versions don't. Therefore, the whole content of the
502 ;; is extracted from. 512 ;; upper directory is retrieved, and the entry of the filename
503 (let* ((entries (tramp-smb-get-file-entries 513 ;; is extracted from.
504 (file-name-directory filename))) 514 (let* ((entries (tramp-smb-get-file-entries
505 (entry (assoc (file-name-nondirectory filename) entries)) 515 (file-name-directory filename)))
506 (uid (if (equal id-format 'string) "nobody" -1)) 516 (entry (assoc (file-name-nondirectory filename) entries))
507 (gid (if (equal id-format 'string) "nogroup" -1)) 517 (uid (if (equal id-format 'string) "nobody" -1))
508 (inode (tramp-get-inode v)) 518 (gid (if (equal id-format 'string) "nogroup" -1))
509 (device (tramp-get-device v))) 519 (inode (tramp-get-inode v))
510 520 (device (tramp-get-device v)))
511 ;; Check result. 521
512 (when entry 522 ;; Check result.
513 (list (and (string-match "d" (nth 1 entry)) 523 (when entry
514 t) ;0 file type 524 (list (and (string-match "d" (nth 1 entry))
515 -1 ;1 link count 525 t) ;0 file type
516 uid ;2 uid 526 -1 ;1 link count
517 gid ;3 gid 527 uid ;2 uid
518 '(0 0) ;4 atime 528 gid ;3 gid
519 (nth 3 entry) ;5 mtime 529 '(0 0) ;4 atime
520 '(0 0) ;6 ctime 530 (nth 3 entry) ;5 mtime
521 (nth 2 entry) ;7 size 531 '(0 0) ;6 ctime
522 (nth 1 entry) ;8 mode 532 (nth 2 entry) ;7 size
523 nil ;9 gid weird 533 (nth 1 entry) ;8 mode
524 inode ;10 inode number 534 nil ;9 gid weird
525 device))))))) ;11 file system number 535 inode ;10 inode number
536 device)))))))) ;11 file system number
526 537
527(defun tramp-smb-do-file-attributes-with-stat (vec &optional id-format) 538(defun tramp-smb-do-file-attributes-with-stat (vec &optional id-format)
528 "Implement `file-attributes' for Tramp files using stat command." 539 "Implement `file-attributes' for Tramp files using stat command."
@@ -1352,12 +1363,13 @@ Returns nil if an error message has appeared."
1352 (found (progn (goto-char (point-min)) 1363 (found (progn (goto-char (point-min))
1353 (re-search-forward tramp-smb-prompt nil t))) 1364 (re-search-forward tramp-smb-prompt nil t)))
1354 (err (progn (goto-char (point-min)) 1365 (err (progn (goto-char (point-min))
1355 (re-search-forward tramp-smb-errors nil t)))) 1366 (re-search-forward tramp-smb-errors nil t)))
1367 buffer-read-only)
1356 1368
1357 ;; Algorithm: get waiting output. See if last line contains 1369 ;; Algorithm: get waiting output. See if last line contains
1358 ;; tramp-smb-prompt sentinel or tramp-smb-errors strings. 1370 ;; `tramp-smb-prompt' sentinel or `tramp-smb-errors' strings.
1359 ;; If not, wait a bit and again get waiting output. 1371 ;; If not, wait a bit and again get waiting output.
1360 (while (and (not found) (not err)) 1372 (while (and (not found) (not err) (memq (process-status p) '(run open)))
1361 1373
1362 ;; Accept pending output. 1374 ;; Accept pending output.
1363 (tramp-accept-process-output p) 1375 (tramp-accept-process-output p)
@@ -1393,12 +1405,11 @@ Returns nil if an error message has appeared."
1393;;; TODO: 1405;;; TODO:
1394 1406
1395;; * Error handling in case password is wrong. 1407;; * Error handling in case password is wrong.
1396;; * Read password from "~/.netrc".
1397;; * Return more comprehensive file permission string. 1408;; * Return more comprehensive file permission string.
1398;; * Try to remove the inclusion of dummy "" directory. Seems to be at 1409;; * Try to remove the inclusion of dummy "" directory. Seems to be at
1399;; several places, especially in `tramp-smb-handle-insert-directory'. 1410;; several places, especially in `tramp-smb-handle-insert-directory'.
1400;; * (RMS) Use unwind-protect to clean up the state so as to make the state 1411;; * (RMS) Use unwind-protect to clean up the state so as to make the state
1401;; regular again. 1412;; regular again.
1402;; * Make it multi-hop capable. 1413;; * Ignore case in file names.
1403 1414
1404;;; tramp-smb.el ends here 1415;;; tramp-smb.el ends here
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 6475ea42ec8..3384a6d776b 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -58,7 +58,6 @@
58;;; Code: 58;;; Code:
59 59
60(require 'tramp-compat) 60(require 'tramp-compat)
61(require 'shell)
62 61
63;;; User Customizable Internal Variables: 62;;; User Customizable Internal Variables:
64 63
@@ -192,15 +191,16 @@ This is a list of entries of the form (NAME PARAM1 PARAM2 ...).
192Each NAME stands for a remote access method. Each PARAM is a 191Each NAME stands for a remote access method. Each PARAM is a
193pair of the form (KEY VALUE). The following KEYs are defined: 192pair of the form (KEY VALUE). The following KEYs are defined:
194 * `tramp-remote-shell' 193 * `tramp-remote-shell'
195 This specifies the Bourne shell to use on the remote host. This 194 This specifies the shell to use on the remote host. This
196 MUST be a Bourne-like shell. It is normally not necessary to set 195 MUST be a Bourne-like shell. It is normally not necessary to
197 this to any value other than \"/bin/sh\": Tramp wants to use a shell 196 set this to any value other than \"/bin/sh\": Tramp wants to
198 which groks tilde expansion, but it can search for it. Also note 197 use a shell which groks tilde expansion, but it can search
199 that \"/bin/sh\" exists on all Unixen, this might not be true for 198 for it. Also note that \"/bin/sh\" exists on all Unixen,
200 the value that you decide to use. You Have Been Warned. 199 this might not be true for the value that you decide to use.
200 You Have Been Warned.
201 * `tramp-remote-shell-args' 201 * `tramp-remote-shell-args'
202 For implementation of `shell-command', this specifies the 202 For implementation of `shell-command', this specifies the
203 argument to let `tramp-remote-shell' run a command. 203 arguments to let `tramp-remote-shell' run a single command.
204 * `tramp-login-program' 204 * `tramp-login-program'
205 This specifies the name of the program to use for logging in to the 205 This specifies the name of the program to use for logging in to the
206 remote host. This may be the name of rsh or a workalike program, 206 remote host. This may be the name of rsh or a workalike program,
@@ -255,6 +255,9 @@ pair of the form (KEY VALUE). The following KEYs are defined:
255 not have to be newline or carriage return characters. Other login 255 not have to be newline or carriage return characters. Other login
256 programs are happy with just one character, the newline character. 256 programs are happy with just one character, the newline character.
257 We use \"xy\" as the value for methods using \"plink\". 257 We use \"xy\" as the value for methods using \"plink\".
258 * `tramp-tmpdir'
259 A directory on the remote host for temporary files. If not
260 specified, \"/tmp\" is taken as default.
258 261
259What does all this mean? Well, you should specify `tramp-login-program' 262What does all this mean? Well, you should specify `tramp-login-program'
260for all methods; this program is used to log in to the remote site. Then, 263for all methods; this program is used to log in to the remote site. Then,
@@ -3531,20 +3534,26 @@ If the `tramp-methods' entry does not exist, return nil."
3531 ;; loaded already. 3534 ;; loaded already.
3532 (zerop (tramp-compat-funcall 'tramp-get-remote-uid vec 'integer)))))) 3535 (zerop (tramp-compat-funcall 'tramp-get-remote-uid vec 'integer))))))
3533 3536
3537(defun tramp-get-remote-tmpdir (vec)
3538 "Return directory for temporary files on the remote host identified by VEC."
3539 (with-connection-property vec "tmpdir"
3540 (let ((dir (tramp-make-tramp-file-name
3541 (tramp-file-name-method vec)
3542 (tramp-file-name-user vec)
3543 (tramp-file-name-host vec)
3544 (or
3545 (tramp-get-method-parameter
3546 (tramp-file-name-method vec) 'tramp-tmpdir)
3547 "/tmp"))))
3548 (if (and (file-directory-p dir) (file-writable-p dir))
3549 dir
3550 (tramp-error vec 'file-error "Directory %s not accessible" dir)))))
3551
3534(defun tramp-make-tramp-temp-file (vec) 3552(defun tramp-make-tramp-temp-file (vec)
3535 "Create a temporary file on the remote host identified by VEC. 3553 "Create a temporary file on the remote host identified by VEC.
3536Return the local name of the temporary file." 3554Return the local name of the temporary file."
3537 (let ((prefix 3555 (let ((prefix (expand-file-name
3538 (tramp-make-tramp-file-name 3556 tramp-temp-name-prefix (tramp-get-remote-tmpdir vec)))
3539 (tramp-file-name-method vec)
3540 (tramp-file-name-user vec)
3541 (tramp-file-name-host vec)
3542 (tramp-drop-volume-letter
3543 (expand-file-name
3544 tramp-temp-name-prefix
3545 ;; This is defined in tramp-sh.el. Let's assume this is
3546 ;; loaded already.
3547 (tramp-compat-funcall 'tramp-get-remote-tmpdir vec)))))
3548 result) 3557 result)
3549 (while (not result) 3558 (while (not result)
3550 ;; `make-temp-file' would be the natural choice for 3559 ;; `make-temp-file' would be the natural choice for