mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-01 11:14:55 +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:
parent
87e4427a0d
commit
710dec6300
@ -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>
|
||||
|
||||
* mail/smtpmail.el (smtpmail-via-smtp): Ignore errors that arise
|
||||
|
@ -41,6 +41,7 @@
|
||||
(require 'advice)
|
||||
(require 'custom)
|
||||
(require 'format-spec)
|
||||
(require 'shell)
|
||||
|
||||
;; As long as password.el is not part of (X)Emacs, it shouldn't be
|
||||
;; mandatory.
|
||||
|
@ -2280,7 +2280,7 @@ The method used must be an out-of-band method."
|
||||
;; password.
|
||||
(setq tramp-current-method (tramp-file-name-method 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.
|
||||
(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))
|
||||
(g-method (and gw (tramp-file-name-method 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)
|
||||
;; We don't create the temporary file. In fact,
|
||||
;; it is just a prefix for the ControlPath option
|
||||
@ -4721,16 +4721,6 @@ This is used internally by `tramp-file-mode-from-int'."
|
||||
x))
|
||||
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)
|
||||
(with-connection-property vec "ls"
|
||||
(tramp-message vec 5 "Finding a suitable `ls' command")
|
||||
|
@ -38,7 +38,15 @@
|
||||
;; ... and add it to the method list.
|
||||
;;;###tramp-autoload
|
||||
(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
|
||||
;; a domain in USER, it must be the SMB method.
|
||||
@ -98,7 +106,8 @@ call, letting the SMB client use the default one."
|
||||
"ERRnomem"
|
||||
"ERRnosuchshare"
|
||||
;; 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_ACCOUNT_LOCKED_OUT"
|
||||
"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_DUPLICATE_NAME"
|
||||
"NT_STATUS_FILE_IS_A_DIRECTORY"
|
||||
"NT_STATUS_IMAGE_ALREADY_LOADED"
|
||||
"NT_STATUS_IO_TIMEOUT"
|
||||
"NT_STATUS_LOGON_FAILURE"
|
||||
"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)
|
||||
"Like `file-attributes' for Tramp files."
|
||||
(unless id-format (setq id-format 'integer))
|
||||
(with-parsed-tramp-file-name filename nil
|
||||
(with-file-property v localname (format "file-attributes-%s" id-format)
|
||||
(if (and (tramp-smb-get-share v) (tramp-smb-get-stat-capability v))
|
||||
(tramp-smb-do-file-attributes-with-stat v id-format)
|
||||
;; Reading just the filename entry via "dir localname" is not
|
||||
;; possible, because when filename is a directory, some
|
||||
;; smbclient versions return the content of the directory, and
|
||||
;; other versions don't. Therefore, the whole content of the
|
||||
;; upper directory is retrieved, and the entry of the filename
|
||||
;; is extracted from.
|
||||
(let* ((entries (tramp-smb-get-file-entries
|
||||
(file-name-directory filename)))
|
||||
(entry (assoc (file-name-nondirectory filename) entries))
|
||||
(uid (if (equal id-format 'string) "nobody" -1))
|
||||
(gid (if (equal id-format 'string) "nogroup" -1))
|
||||
(inode (tramp-get-inode v))
|
||||
(device (tramp-get-device v)))
|
||||
(ignore-errors
|
||||
(with-parsed-tramp-file-name filename nil
|
||||
(with-file-property v localname (format "file-attributes-%s" id-format)
|
||||
(if (and (tramp-smb-get-share v) (tramp-smb-get-stat-capability v))
|
||||
(tramp-smb-do-file-attributes-with-stat v id-format)
|
||||
;; Reading just the filename entry via "dir localname" is not
|
||||
;; possible, because when filename is a directory, some
|
||||
;; smbclient versions return the content of the directory, and
|
||||
;; other versions don't. Therefore, the whole content of the
|
||||
;; upper directory is retrieved, and the entry of the filename
|
||||
;; is extracted from.
|
||||
(let* ((entries (tramp-smb-get-file-entries
|
||||
(file-name-directory filename)))
|
||||
(entry (assoc (file-name-nondirectory filename) entries))
|
||||
(uid (if (equal id-format 'string) "nobody" -1))
|
||||
(gid (if (equal id-format 'string) "nogroup" -1))
|
||||
(inode (tramp-get-inode v))
|
||||
(device (tramp-get-device v)))
|
||||
|
||||
;; Check result.
|
||||
(when entry
|
||||
(list (and (string-match "d" (nth 1 entry))
|
||||
t) ;0 file type
|
||||
-1 ;1 link count
|
||||
uid ;2 uid
|
||||
gid ;3 gid
|
||||
'(0 0) ;4 atime
|
||||
(nth 3 entry) ;5 mtime
|
||||
'(0 0) ;6 ctime
|
||||
(nth 2 entry) ;7 size
|
||||
(nth 1 entry) ;8 mode
|
||||
nil ;9 gid weird
|
||||
inode ;10 inode number
|
||||
device))))))) ;11 file system number
|
||||
;; Check result.
|
||||
(when entry
|
||||
(list (and (string-match "d" (nth 1 entry))
|
||||
t) ;0 file type
|
||||
-1 ;1 link count
|
||||
uid ;2 uid
|
||||
gid ;3 gid
|
||||
'(0 0) ;4 atime
|
||||
(nth 3 entry) ;5 mtime
|
||||
'(0 0) ;6 ctime
|
||||
(nth 2 entry) ;7 size
|
||||
(nth 1 entry) ;8 mode
|
||||
nil ;9 gid weird
|
||||
inode ;10 inode number
|
||||
device)))))))) ;11 file system number
|
||||
|
||||
(defun tramp-smb-do-file-attributes-with-stat (vec &optional id-format)
|
||||
"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))
|
||||
(re-search-forward tramp-smb-prompt nil t)))
|
||||
(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
|
||||
;; 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.
|
||||
(while (and (not found) (not err))
|
||||
(while (and (not found) (not err) (memq (process-status p) '(run open)))
|
||||
|
||||
;; Accept pending output.
|
||||
(tramp-accept-process-output p)
|
||||
@ -1393,12 +1405,11 @@ Returns nil if an error message has appeared."
|
||||
;;; TODO:
|
||||
|
||||
;; * Error handling in case password is wrong.
|
||||
;; * Read password from "~/.netrc".
|
||||
;; * Return more comprehensive file permission string.
|
||||
;; * Try to remove the inclusion of dummy "" directory. Seems to be at
|
||||
;; several places, especially in `tramp-smb-handle-insert-directory'.
|
||||
;; * (RMS) Use unwind-protect to clean up the state so as to make the state
|
||||
;; regular again.
|
||||
;; * Make it multi-hop capable.
|
||||
;; * Ignore case in file names.
|
||||
|
||||
;;; tramp-smb.el ends here
|
||||
|
@ -58,7 +58,6 @@
|
||||
;;; Code:
|
||||
|
||||
(require 'tramp-compat)
|
||||
(require 'shell)
|
||||
|
||||
;;; 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
|
||||
pair of the form (KEY VALUE). The following KEYs are defined:
|
||||
* `tramp-remote-shell'
|
||||
This specifies the Bourne shell to use on the remote host. This
|
||||
MUST be a Bourne-like shell. It is normally not necessary to set
|
||||
this to any value other than \"/bin/sh\": Tramp wants to use a shell
|
||||
which groks tilde expansion, but it can search for it. Also note
|
||||
that \"/bin/sh\" exists on all Unixen, this might not be true for
|
||||
the value that you decide to use. You Have Been Warned.
|
||||
This specifies the shell to use on the remote host. This
|
||||
MUST be a Bourne-like shell. It is normally not necessary to
|
||||
set this to any value other than \"/bin/sh\": Tramp wants to
|
||||
use a shell which groks tilde expansion, but it can search
|
||||
for it. Also note that \"/bin/sh\" exists on all Unixen,
|
||||
this might not be true for the value that you decide to use.
|
||||
You Have Been Warned.
|
||||
* `tramp-remote-shell-args'
|
||||
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'
|
||||
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,
|
||||
@ -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
|
||||
programs are happy with just one character, the newline character.
|
||||
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'
|
||||
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.
|
||||
(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)
|
||||
"Create a temporary file on the remote host identified by VEC.
|
||||
Return the local name of the temporary file."
|
||||
(let ((prefix
|
||||
(tramp-make-tramp-file-name
|
||||
(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)))))
|
||||
(let ((prefix (expand-file-name
|
||||
tramp-temp-name-prefix (tramp-get-remote-tmpdir vec)))
|
||||
result)
|
||||
(while (not result)
|
||||
;; `make-temp-file' would be the natural choice for
|
||||
|
Loading…
Reference in New Issue
Block a user