1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-04 11:40:22 +00:00

* net/tramp.el (top): Don't require 'shell.

(tramp-methods): Fix docstring.
(tramp-get-remote-tmpdir): New defun, moved from tramp-sh.el.
Return complete remote file name.  Handle "smb" case.  Use
`tramp-tmpdir', if defined for the respective method.
(tramp-make-tramp-temp-file): Adapt call of `tramp-get-remote-tmpdir'.

* net/tramp-compat.el (top): Require 'shell.

* net/tramp-sh.el (tramp-do-copy-or-rename-file-out-of-band)
(tramp-maybe-open-connection): Use `tramp-file-name-real-host' for
`tramp-current-host'.
(tramp-get-remote-tmpdir): Remove.

* net/tramp-smb.el (tramp-methods): Add `tramp-remote-shell' and
`tramp-tmpdir' entries.
(tramp-smb-errors): Add "NT_STATUS_IMAGE_ALREADY_LOADED".
(tramp-smb-handle-file-attributes): Ignore errors.
(tramp-smb-wait-for-output): Check also for process end.
This commit is contained in:
Michael Albinus 2011-09-18 13:26:15 +02:00
parent 87e4427a0d
commit 710dec6300
5 changed files with 103 additions and 70 deletions

View File

@ -1,3 +1,25 @@
2011-09-18 Michael Albinus <michael.albinus@gmx.de>
* net/tramp.el (top): Don't require 'shell.
(tramp-methods): Fix docstring.
(tramp-get-remote-tmpdir): New defun, moved from tramp-sh.el.
Return complete remote file name. Handle "smb" case. Use
`tramp-tmpdir', if defined for the respective method.
(tramp-make-tramp-temp-file): Adapt call of `tramp-get-remote-tmpdir'.
* net/tramp-compat.el (top): Require 'shell.
* net/tramp-sh.el (tramp-do-copy-or-rename-file-out-of-band)
(tramp-maybe-open-connection): Use `tramp-file-name-real-host' for
`tramp-current-host'.
(tramp-get-remote-tmpdir): Remove.
* net/tramp-smb.el (tramp-methods): Add `tramp-remote-shell' and
`tramp-tmpdir' entries.
(tramp-smb-errors): Add "NT_STATUS_IMAGE_ALREADY_LOADED".
(tramp-smb-handle-file-attributes): Ignore errors.
(tramp-smb-wait-for-output): Check also for process end.
2011-09-18 Lars Magne Ingebrigtsen <larsi@gnus.org> 2011-09-18 Lars Magne Ingebrigtsen <larsi@gnus.org>
* mail/smtpmail.el (smtpmail-via-smtp): Ignore errors that arise * mail/smtpmail.el (smtpmail-via-smtp): Ignore errors that arise

View File

@ -41,6 +41,7 @@
(require 'advice) (require 'advice)
(require 'custom) (require 'custom)
(require 'format-spec) (require 'format-spec)
(require 'shell)
;; As long as password.el is not part of (X)Emacs, it shouldn't be ;; As long as password.el is not part of (X)Emacs, it shouldn't be
;; mandatory. ;; mandatory.

View File

@ -2280,7 +2280,7 @@ The method used must be an out-of-band method."
;; password. ;; password.
(setq tramp-current-method (tramp-file-name-method v) (setq tramp-current-method (tramp-file-name-method v)
tramp-current-user (tramp-file-name-user v) tramp-current-user (tramp-file-name-user v)
tramp-current-host (tramp-file-name-host v)) tramp-current-host (tramp-file-name-real-host v))
;; Expand hops. Might be necessary for gateway methods. ;; Expand hops. Might be necessary for gateway methods.
(setq v (car (tramp-compute-multi-hops v))) (setq v (car (tramp-compute-multi-hops v)))
@ -4292,7 +4292,7 @@ connection if a previous connection has died for some reason."
(gw (tramp-get-file-property hop "" "gateway" nil)) (gw (tramp-get-file-property hop "" "gateway" nil))
(g-method (and gw (tramp-file-name-method gw))) (g-method (and gw (tramp-file-name-method gw)))
(g-user (and gw (tramp-file-name-user gw))) (g-user (and gw (tramp-file-name-user gw)))
(g-host (and gw (tramp-file-name-host gw))) (g-host (and gw (tramp-file-name-real-host gw)))
(command login-program) (command login-program)
;; We don't create the temporary file. In fact, ;; We don't create the temporary file. In fact,
;; it is just a prefix for the ControlPath option ;; it is just a prefix for the ControlPath option
@ -4721,16 +4721,6 @@ This is used internally by `tramp-file-mode-from-int'."
x)) x))
remote-path))))) remote-path)))))
(defun tramp-get-remote-tmpdir (vec)
(with-connection-property vec "tmp-directory"
(let ((dir (tramp-shell-quote-argument "/tmp")))
(if (and (tramp-send-command-and-check
vec (format "%s -d %s" (tramp-get-test-command vec) dir))
(tramp-send-command-and-check
vec (format "%s -w %s" (tramp-get-test-command vec) dir)))
dir
(tramp-error vec 'file-error "Directory %s not accessible" dir)))))
(defun tramp-get-ls-command (vec) (defun tramp-get-ls-command (vec)
(with-connection-property vec "ls" (with-connection-property vec "ls"
(tramp-message vec 5 "Finding a suitable `ls' command") (tramp-message vec 5 "Finding a suitable `ls' command")

View File

@ -38,7 +38,15 @@
;; ... and add it to the method list. ;; ... and add it to the method list.
;;;###tramp-autoload ;;;###tramp-autoload
(unless (memq system-type '(cygwin windows-nt)) (unless (memq system-type '(cygwin windows-nt))
(add-to-list 'tramp-methods (cons tramp-smb-method nil))) (add-to-list 'tramp-methods
`(,tramp-smb-method
;; We define an empty command, because `tramp-smb-call-winexe'
;; opens already the powershell. Used in `tramp-handle-shell-command'.
(tramp-remote-shell "")
;; This is just a guess. We don't know whether the share "$C"
;; is available for public use, and whether the user has write
;; access.
(tramp-tmpdir "/C$/Temp"))))
;; Add a default for `tramp-default-method-alist'. Rule: If there is ;; Add a default for `tramp-default-method-alist'. Rule: If there is
;; a domain in USER, it must be the SMB method. ;; a domain in USER, it must be the SMB method.
@ -98,7 +106,8 @@ call, letting the SMB client use the default one."
"ERRnomem" "ERRnomem"
"ERRnosuchshare" "ERRnosuchshare"
;; Windows 4.0 (Windows NT), Windows 5.0 (Windows 2000), ;; Windows 4.0 (Windows NT), Windows 5.0 (Windows 2000),
;; Windows 5.1 (Windows XP), Windows 5.2 (Windows Server 2003). ;; Windows 5.1 (Windows XP), Windows 5.2 (Windows Server 2003),
;; Windows 6.0 (Windows Vista), Windows 6.1 (Windows 7).
"NT_STATUS_ACCESS_DENIED" "NT_STATUS_ACCESS_DENIED"
"NT_STATUS_ACCOUNT_LOCKED_OUT" "NT_STATUS_ACCOUNT_LOCKED_OUT"
"NT_STATUS_BAD_NETWORK_NAME" "NT_STATUS_BAD_NETWORK_NAME"
@ -107,6 +116,7 @@ call, letting the SMB client use the default one."
"NT_STATUS_DIRECTORY_NOT_EMPTY" "NT_STATUS_DIRECTORY_NOT_EMPTY"
"NT_STATUS_DUPLICATE_NAME" "NT_STATUS_DUPLICATE_NAME"
"NT_STATUS_FILE_IS_A_DIRECTORY" "NT_STATUS_FILE_IS_A_DIRECTORY"
"NT_STATUS_IMAGE_ALREADY_LOADED"
"NT_STATUS_IO_TIMEOUT" "NT_STATUS_IO_TIMEOUT"
"NT_STATUS_LOGON_FAILURE" "NT_STATUS_LOGON_FAILURE"
"NT_STATUS_NETWORK_ACCESS_DENIED" "NT_STATUS_NETWORK_ACCESS_DENIED"
@ -490,39 +500,40 @@ PRESERVE-UID-GID and PRESERVE-SELINUX-CONTEXT are completely ignored."
(defun tramp-smb-handle-file-attributes (filename &optional id-format) (defun tramp-smb-handle-file-attributes (filename &optional id-format)
"Like `file-attributes' for Tramp files." "Like `file-attributes' for Tramp files."
(unless id-format (setq id-format 'integer)) (unless id-format (setq id-format 'integer))
(with-parsed-tramp-file-name filename nil (ignore-errors
(with-file-property v localname (format "file-attributes-%s" id-format) (with-parsed-tramp-file-name filename nil
(if (and (tramp-smb-get-share v) (tramp-smb-get-stat-capability v)) (with-file-property v localname (format "file-attributes-%s" id-format)
(tramp-smb-do-file-attributes-with-stat v id-format) (if (and (tramp-smb-get-share v) (tramp-smb-get-stat-capability v))
;; Reading just the filename entry via "dir localname" is not (tramp-smb-do-file-attributes-with-stat v id-format)
;; possible, because when filename is a directory, some ;; Reading just the filename entry via "dir localname" is not
;; smbclient versions return the content of the directory, and ;; possible, because when filename is a directory, some
;; other versions don't. Therefore, the whole content of the ;; smbclient versions return the content of the directory, and
;; upper directory is retrieved, and the entry of the filename ;; other versions don't. Therefore, the whole content of the
;; is extracted from. ;; upper directory is retrieved, and the entry of the filename
(let* ((entries (tramp-smb-get-file-entries ;; is extracted from.
(file-name-directory filename))) (let* ((entries (tramp-smb-get-file-entries
(entry (assoc (file-name-nondirectory filename) entries)) (file-name-directory filename)))
(uid (if (equal id-format 'string) "nobody" -1)) (entry (assoc (file-name-nondirectory filename) entries))
(gid (if (equal id-format 'string) "nogroup" -1)) (uid (if (equal id-format 'string) "nobody" -1))
(inode (tramp-get-inode v)) (gid (if (equal id-format 'string) "nogroup" -1))
(device (tramp-get-device v))) (inode (tramp-get-inode v))
(device (tramp-get-device v)))
;; Check result. ;; Check result.
(when entry (when entry
(list (and (string-match "d" (nth 1 entry)) (list (and (string-match "d" (nth 1 entry))
t) ;0 file type t) ;0 file type
-1 ;1 link count -1 ;1 link count
uid ;2 uid uid ;2 uid
gid ;3 gid gid ;3 gid
'(0 0) ;4 atime '(0 0) ;4 atime
(nth 3 entry) ;5 mtime (nth 3 entry) ;5 mtime
'(0 0) ;6 ctime '(0 0) ;6 ctime
(nth 2 entry) ;7 size (nth 2 entry) ;7 size
(nth 1 entry) ;8 mode (nth 1 entry) ;8 mode
nil ;9 gid weird nil ;9 gid weird
inode ;10 inode number inode ;10 inode number
device))))))) ;11 file system number device)))))))) ;11 file system number
(defun tramp-smb-do-file-attributes-with-stat (vec &optional id-format) (defun tramp-smb-do-file-attributes-with-stat (vec &optional id-format)
"Implement `file-attributes' for Tramp files using stat command." "Implement `file-attributes' for Tramp files using stat command."
@ -1352,12 +1363,13 @@ Returns nil if an error message has appeared."
(found (progn (goto-char (point-min)) (found (progn (goto-char (point-min))
(re-search-forward tramp-smb-prompt nil t))) (re-search-forward tramp-smb-prompt nil t)))
(err (progn (goto-char (point-min)) (err (progn (goto-char (point-min))
(re-search-forward tramp-smb-errors nil t)))) (re-search-forward tramp-smb-errors nil t)))
buffer-read-only)
;; Algorithm: get waiting output. See if last line contains ;; Algorithm: get waiting output. See if last line contains
;; tramp-smb-prompt sentinel or tramp-smb-errors strings. ;; `tramp-smb-prompt' sentinel or `tramp-smb-errors' strings.
;; If not, wait a bit and again get waiting output. ;; If not, wait a bit and again get waiting output.
(while (and (not found) (not err)) (while (and (not found) (not err) (memq (process-status p) '(run open)))
;; Accept pending output. ;; Accept pending output.
(tramp-accept-process-output p) (tramp-accept-process-output p)
@ -1393,12 +1405,11 @@ Returns nil if an error message has appeared."
;;; TODO: ;;; TODO:
;; * Error handling in case password is wrong. ;; * Error handling in case password is wrong.
;; * Read password from "~/.netrc".
;; * Return more comprehensive file permission string. ;; * Return more comprehensive file permission string.
;; * Try to remove the inclusion of dummy "" directory. Seems to be at ;; * Try to remove the inclusion of dummy "" directory. Seems to be at
;; several places, especially in `tramp-smb-handle-insert-directory'. ;; several places, especially in `tramp-smb-handle-insert-directory'.
;; * (RMS) Use unwind-protect to clean up the state so as to make the state ;; * (RMS) Use unwind-protect to clean up the state so as to make the state
;; regular again. ;; regular again.
;; * Make it multi-hop capable. ;; * Ignore case in file names.
;;; tramp-smb.el ends here ;;; tramp-smb.el ends here

View File

@ -58,7 +58,6 @@
;;; Code: ;;; Code:
(require 'tramp-compat) (require 'tramp-compat)
(require 'shell)
;;; User Customizable Internal Variables: ;;; User Customizable Internal Variables:
@ -192,15 +191,16 @@ This is a list of entries of the form (NAME PARAM1 PARAM2 ...).
Each NAME stands for a remote access method. Each PARAM is a Each NAME stands for a remote access method. Each PARAM is a
pair of the form (KEY VALUE). The following KEYs are defined: pair of the form (KEY VALUE). The following KEYs are defined:
* `tramp-remote-shell' * `tramp-remote-shell'
This specifies the Bourne shell to use on the remote host. This This specifies the shell to use on the remote host. This
MUST be a Bourne-like shell. It is normally not necessary to set MUST be a Bourne-like shell. It is normally not necessary to
this to any value other than \"/bin/sh\": Tramp wants to use a shell set this to any value other than \"/bin/sh\": Tramp wants to
which groks tilde expansion, but it can search for it. Also note use a shell which groks tilde expansion, but it can search
that \"/bin/sh\" exists on all Unixen, this might not be true for for it. Also note that \"/bin/sh\" exists on all Unixen,
the value that you decide to use. You Have Been Warned. this might not be true for the value that you decide to use.
You Have Been Warned.
* `tramp-remote-shell-args' * `tramp-remote-shell-args'
For implementation of `shell-command', this specifies the For implementation of `shell-command', this specifies the
argument to let `tramp-remote-shell' run a command. arguments to let `tramp-remote-shell' run a single command.
* `tramp-login-program' * `tramp-login-program'
This specifies the name of the program to use for logging in to the This specifies the name of the program to use for logging in to the
remote host. This may be the name of rsh or a workalike program, 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:
not have to be newline or carriage return characters. Other login not have to be newline or carriage return characters. Other login
programs are happy with just one character, the newline character. programs are happy with just one character, the newline character.
We use \"xy\" as the value for methods using \"plink\". We use \"xy\" as the value for methods using \"plink\".
* `tramp-tmpdir'
A directory on the remote host for temporary files. If not
specified, \"/tmp\" is taken as default.
What does all this mean? Well, you should specify `tramp-login-program' What does all this mean? Well, you should specify `tramp-login-program'
for all methods; this program is used to log in to the remote site. Then, for 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."
;; loaded already. ;; loaded already.
(zerop (tramp-compat-funcall 'tramp-get-remote-uid vec 'integer)))))) (zerop (tramp-compat-funcall 'tramp-get-remote-uid vec 'integer))))))
(defun tramp-get-remote-tmpdir (vec)
"Return directory for temporary files on the remote host identified by VEC."
(with-connection-property vec "tmpdir"
(let ((dir (tramp-make-tramp-file-name
(tramp-file-name-method vec)
(tramp-file-name-user vec)
(tramp-file-name-host vec)
(or
(tramp-get-method-parameter
(tramp-file-name-method vec) 'tramp-tmpdir)
"/tmp"))))
(if (and (file-directory-p dir) (file-writable-p dir))
dir
(tramp-error vec 'file-error "Directory %s not accessible" dir)))))
(defun tramp-make-tramp-temp-file (vec) (defun tramp-make-tramp-temp-file (vec)
"Create a temporary file on the remote host identified by VEC. "Create a temporary file on the remote host identified by VEC.
Return the local name of the temporary file." Return the local name of the temporary file."
(let ((prefix (let ((prefix (expand-file-name
(tramp-make-tramp-file-name tramp-temp-name-prefix (tramp-get-remote-tmpdir vec)))
(tramp-file-name-method vec)
(tramp-file-name-user vec)
(tramp-file-name-host vec)
(tramp-drop-volume-letter
(expand-file-name
tramp-temp-name-prefix
;; This is defined in tramp-sh.el. Let's assume this is
;; loaded already.
(tramp-compat-funcall 'tramp-get-remote-tmpdir vec)))))
result) result)
(while (not result) (while (not result)
;; `make-temp-file' would be the natural choice for ;; `make-temp-file' would be the natural choice for