Sync with Tramp 2.1.19.

* net/tramp-cmds.el (tramp-cleanup-all-connections)
(tramp-reporter-dump-variable, tramp-load-report-modules)
(tramp-append-tramp-buffers): Use `tramp-compat-funcall'.
(tramp-bug): Recommend setting of `tramp-verbose' to 9.

* net/tramp-compat.el (top): Do not autoload
`tramp-handle-file-remote-p'.  Load tramp-util.el and tramp-vc.el
only when `start-file-process' is not bound.
(byte-compile-not-obsolete-vars): Define if not bound.
(tramp-compat-funcall): New defmacro.
(tramp-compat-line-beginning-position)
(tramp-compat-line-end-position)
(tramp-compat-temporary-file-directory)
(tramp-compat-make-temp-file, tramp-compat-file-attributes)
(tramp-compat-copy-file, tramp-compat-copy-directory)
(tramp-compat-delete-file, tramp-compat-delete-directory)
(tramp-compat-number-sequence, tramp-compat-process-running-p):
Use it.
(tramp-advice-file-expand-wildcards): Do not use
`tramp-handle-file-remote-p'.
(tramp-compat-make-temp-file): Simplify fallback implementation.
(tramp-compat-copy-file): Add PRESERVE-SELINUX-CONTEXT.
(tramp-compat-copy-tree): Remove function.
(tramp-compat-delete-file): New defun.
(tramp-compat-delete-directory): Provide implementation for older
Emacsen.
(tramp-compat-file-attributes): Handle only
`wrong-number-of-arguments' error.

* net/tramp-fish.el (tramp-fish-handle-copy-file): Add
PRESERVE_SELINUX_CONTEXT.
(tramp-fish-handle-delete-file): Add TRASH arg.
(tramp-fish-handle-directory-files-and-attributes):
Do not use `tramp-fish-handle-file-attributes.
(tramp-fish-handle-file-local-copy)
(tramp-fish-handle-insert-file-contents)
(tramp-fish-maybe-open-connection): Use `with-progress-reporter'.

* net/tramp-gvfs.el (top): Require url-util.
(tramp-gvfs-mount-point): Remove.
(tramp-gvfs-file-name-handler-alist): Add `file-selinux-context'
and `set-file-selinux-context'.
(tramp-gvfs-stringify-dbus-message, tramp-gvfs-send-command)
(tramp-gvfs-handle-file-selinux-context)
(tramp-gvfs-handle-set-file-selinux-context): New defuns.
(with-tramp-dbus-call-method): Format trace message.
(tramp-gvfs-handle-copy-file): Handle PRESERVE-SELINUX-CONTEXT.
(tramp-gvfs-handle-copy-file, tramp-gvfs-handle-rename-file):
Implement backup call, when operation on local files fails.  Use
progress reporter.  Flush properties of changed files.
(tramp-gvfs-handle-delete-file): Add TRASH arg.  Use
`tramp-compat-delete-file'.
(tramp-gvfs-handle-expand-file-name): Expand "~/".
(tramp-gvfs-handle-make-directory): Make more traces.
(tramp-gvfs-handle-write-region): Protect deleting tmpfile.
(tramp-gvfs-url-file-name): Hexify file name in url.
(tramp-gvfs-fuse-file-name): Take also prefix (like dav shares)
into account for the resulting file name.
(tramp-gvfs-handler-askquestion): Preserve current message, in
order to let progress reporter continue afterwards.  (Bug#6257)
Return dummy mountpoint, when the answer is "no".  See
`tramp-gvfs-maybe-open-connection'.
(tramp-gvfs-handler-mounted-unmounted)
(tramp-gvfs-connection-mounted-p): Test also for new mountspec
attribute "default_location".  Set "prefix" property.  Handle
default-location.
(tramp-gvfs-mount-spec): Return both prefix and mountspec.
(tramp-gvfs-maybe-open-connection): Test, whether mountpoint
exists.  Raise an error, if not (due to a corresponding answer
"no" in interactive questions, for example). Use
`tramp-compat-funcall'.

* net/tramp-imap.el (top): Autoload `epg-make-context'.
(tramp-imap-handle-copy-file): Add PRESERVE-SELINUX-CONTEXT.
(tramp-imap-do-copy-or-rename-file)
(tramp-imap-handle-insert-file-contents)
(tramp-imap-handle-file-local-copy): Use `with-progress-reporter'.
(tramp-imap-handle-delete-file): Add TRASH arg.

* net/tramp-smb.el (tramp-smb-handle-copy-file): Add
PRESERVE-SELINUX-CONTEXT.
(tramp-smb-handle-copy-file)
(tramp-smb-handle-file-local-copy, tramp-smb-handle-rename-file)
(tramp-smb-handle-write-region, tramp-smb-maybe-open-connection):
Use `with-progress-reporter'.
(tramp-smb-handle-delete-file): Add TRASH arg.

* net/tramp.el (tramp-methods): Move hostname to the end in all
ssh `tramp-login-args'.  Add `tramp-async-args' attribute where
appropriate.
(tramp-verbose): Describe verbose level 9.
(tramp-completion-function-alist)
(tramp-file-name-regexp, tramp-chunksize)
(tramp-local-coding-commands, tramp-remote-coding-commands)
(with-connection-property, tramp-completion-mode-p)
(tramp-action-process-alive, tramp-action-out-of-band)
(tramp-check-for-regexp, tramp-file-name-p, tramp-equal-remote)
(tramp-exists-file-name-handler): Fix docstring.
(tramp-remote-process-environment): Use `format' instead of
`concat'.  Protect version string by apostroph.
(tramp-shell-prompt-pattern): Do not use a shy group in case of
XEmacs.
(tramp-file-name-regexp-unified)
(tramp-completion-file-name-regexp-unified): On W32 systems, do
not regard the volume letter as remote filename.  (Bug#5447)
(tramp-perl-file-attributes)
(tramp-perl-directory-files-and-attributes): Don't pass "$3".
(tramp-vc-registered-read-file-names): Read input as
here-document, otherwise the command could exceed maximum length
of command line.
(tramp-file-name-handler-alist): Add `file-selinux-context' and
`set-file-selinux-context'.
(tramp-debug-message): Add `tramp-compat-funcall' to ignored
backtrace functions.
(tramp-error-with-buffer): Don't show the connection buffer when
we are in completion mode.
(tramp-progress-reporter-update, tramp-remote-selinux-p)
(tramp-handle-file-selinux-context)
(tramp-handle-set-file-selinux-context, tramp-process-sentinel)
(tramp-connectable-p, tramp-open-shell, tramp-get-remote-trash):
New defuns.
(with-progress-reporter): New defmacro.
(tramp-debug-outline-regexp): New defconst.
(top, tramp-rfn-eshadow-setup-minibuffer)
(tramp-rfn-eshadow-update-overlay, tramp-handle-set-file-times)
(tramp-handle-dired-compress-file, tramp-handle-shell-command)
(tramp-completion-mode-p, tramp-check-for-regexp)
(tramp-open-connection-setup-interactive-shell)
(tramp-compute-multi-hops, tramp-read-passwd, tramp-clear-passwd)
(tramp-time-diff, tramp-coding-system-change-eol-conversion)
(tramp-set-process-query-on-exit-flag, tramp-unload-tramp):
Use `tramp-compat-funcall'.
(tramp-handle-make-symbolic-link): Flush file properties.
(tramp-handle-load, tramp-handle-file-local-copy)
(tramp-handle-insert-file-contents, tramp-handle-write-region)
(tramp-handle-vc-registered, tramp-maybe-send-script)
(tramp-find-shell): Use `with-progress-reporter'.
(tramp-do-file-attributes-with-stat): Add space in format string,
in order to work around a bug in pdksh.  Reported by Gilles Pion
<gpion@lfdj.com>.
(tramp-handle-verify-visited-file-modtime): Do not send a command
when the connection is not established.
(tramp-handle-set-file-times): Simplify the check for utc.
(tramp-handle-directory-files-and-attributes)
(tramp-get-remote-path): Use `copy-tree'.
(tramp-completion-handle-file-name-all-completions): Ensure, that
non remote files are still checked.  Oops.
(tramp-handle-copy-file, tramp-do-copy-or-rename-file): Handle
PRESERVE-SELINUX-CONTEXT.
(tramp-do-copy-or-rename-file): Add progress reporter.
(tramp-do-copy-or-rename-file-directly): Do not use
`tramp-handle-file-remote-p'.
(tramp-do-copy-or-rename-file-out-of-band):
Use `tramp-compat-delete-directory'.
(tramp-do-copy-or-rename-file-out-of-band)
(tramp-compute-multi-hops, tramp-maybe-open-connection):
Use `format-spec-make'.
(tramp-handle-delete-file): Add TRASH arg.
(tramp-handle-dired-uncache): Flush directory cache, not only file
cache.
(tramp-handle-expand-file-name)
(tramp-completion-handle-file-name-all-completions)
(tramp-completion-handle-file-name-completion): Use
`tramp-connectable-p'.
(tramp-handle-start-file-process): Set connection property "vec".
Use it, in order to invalidate file caches.  Check only for
`remote-tty' process property.
Implement tty setting.  (Bug#4604, Bug#6360)
(tramp-file-name-for-operation): Add `call-process-region' and
`set-file-selinux-context'.
(tramp-find-foreign-file-name-handler)
(tramp-advice-make-auto-save-file-name)
(tramp-set-auto-save-file-modes): Remove superfluous check for
`stringp'.  This is done inside `tramp-tramp-file-p'.
(tramp-file-name-handler): Trace 'quit.  Catch the error for some
operations when we are in completion mode.  This gives the user
the chance to correct the file name in the minibuffer.
(tramp-completion-mode-p): Use `non-essential'.
(tramp-handle-file-name-all-completions): Backward/ XEmacs
compatibility: Use `completion-ignore-case' if
`read-file-name-completion-ignore-case' does not exist.
(tramp-get-debug-buffer): Use `tramp-debug-outline-regexp'.
(tramp-find-shell, tramp-open-connection-setup-interactive-shell):
`tramp-open-shell'.
(tramp-action-password): Hide password prompt before next run.
(tramp-process-actions): Widen connection buffer for the trace.
(tramp-open-connection-setup-interactive-shell): Set `remote-tty'
process property.  Trace stty settings if `tramp-verbose' >= 9.
Apply workaround for IRIX64 bug.  Move argument of last
`tramp-send-command' where it belongs to.
(tramp-maybe-open-connection): Use `async-args' and `gw-args' in
front of `login-args'.
(tramp-get-ls-command, tramp-get-ls-command-with-dired): Run tests
on "/dev/null" instead of "/".
(tramp-get-ls-command-with-dired): Make test for "--dired"
stronger.
(tramp-set-auto-save-file-modes): Adapt version check.
(tramp-set-process-query-on-exit-flag): Fix wrong parentheses.
(tramp-handle-process-file): Call the program in a subshell, in
order to preserve working directory.
(tramp-handle-shell-command): Don't use hard-wired "/bin/sh" but
`tramp-remote-sh' from `tramp-methods'.
(tramp-get-ls-command): Make test for "--color=never" stronger.
(tramp-check-for-regexp): Use (forward-line 1).

* net/trampver.el: Update release number.

* net/tramp-gvfs.el (tramp-gvfs-handle-copy-file): Do not pass
empty argument to gvfs-copy.

* net/tramp-compat.el (tramp-compat-delete-file): Rewrite to
handle new TRASH arg of `delete-file'.

* net/tramp.el (tramp-handle-insert-directory): Don't use
`forward-word', its default syntax could be changed.

Implement compression for inline methods.

* net/tramp.el (tramp-inline-compress-start-size): New defcustom.
(tramp-copy-size-limit): Allow also nil.
(tramp-inline-compress-commands): New defconst.
(tramp-find-inline-compress, tramp-get-inline-compress)
(tramp-get-inline-coding): New defuns.
(tramp-get-remote-coding, tramp-get-local-coding): Remove,
replaced by `tramp-get-inline-coding'.
(tramp-handle-file-local-copy, tramp-handle-write-region)
(tramp-method-out-of-band-p): Use `tramp-get-inline-coding'.

Detect ssh 'ControlMaster' argument automatically in some cases.

* net/tramp.el (tramp-detect-ssh-controlmaster): New defun.
(tramp-default-method): Use it.

* net/tramp.el (tramp-file-name-for-operation):
Add file-selinux-context.
This commit is contained in:
Michael Albinus 2010-08-26 21:23:02 +02:00
parent d5720b4c5a
commit 20b8ac83f3
11 changed files with 2093 additions and 1300 deletions

View file

@ -1,3 +1,256 @@
2010-08-26 Michael Albinus <michael.albinus@gmx.de>
Sync with Tramp 2.1.19.
* net/tramp-cmds.el (tramp-cleanup-all-connections)
(tramp-reporter-dump-variable, tramp-load-report-modules)
(tramp-append-tramp-buffers): Use `tramp-compat-funcall'.
(tramp-bug): Recommend setting of `tramp-verbose' to 9.
* net/tramp-compat.el (top): Do not autoload
`tramp-handle-file-remote-p'. Load tramp-util.el and tramp-vc.el
only when `start-file-process' is not bound.
(byte-compile-not-obsolete-vars): Define if not bound.
(tramp-compat-funcall): New defmacro.
(tramp-compat-line-beginning-position)
(tramp-compat-line-end-position)
(tramp-compat-temporary-file-directory)
(tramp-compat-make-temp-file, tramp-compat-file-attributes)
(tramp-compat-copy-file, tramp-compat-copy-directory)
(tramp-compat-delete-file, tramp-compat-delete-directory)
(tramp-compat-number-sequence, tramp-compat-process-running-p):
Use it.
(tramp-advice-file-expand-wildcards): Do not use
`tramp-handle-file-remote-p'.
(tramp-compat-make-temp-file): Simplify fallback implementation.
(tramp-compat-copy-file): Add PRESERVE-SELINUX-CONTEXT.
(tramp-compat-copy-tree): Remove function.
(tramp-compat-delete-file): New defun.
(tramp-compat-delete-directory): Provide implementation for older
Emacsen.
(tramp-compat-file-attributes): Handle only
`wrong-number-of-arguments' error.
* net/tramp-fish.el (tramp-fish-handle-copy-file): Add
PRESERVE_SELINUX_CONTEXT.
(tramp-fish-handle-delete-file): Add TRASH arg.
(tramp-fish-handle-directory-files-and-attributes):
Do not use `tramp-fish-handle-file-attributes.
(tramp-fish-handle-file-local-copy)
(tramp-fish-handle-insert-file-contents)
(tramp-fish-maybe-open-connection): Use `with-progress-reporter'.
* net/tramp-gvfs.el (top): Require url-util.
(tramp-gvfs-mount-point): Remove.
(tramp-gvfs-file-name-handler-alist): Add `file-selinux-context'
and `set-file-selinux-context'.
(tramp-gvfs-stringify-dbus-message, tramp-gvfs-send-command)
(tramp-gvfs-handle-file-selinux-context)
(tramp-gvfs-handle-set-file-selinux-context): New defuns.
(with-tramp-dbus-call-method): Format trace message.
(tramp-gvfs-handle-copy-file): Handle PRESERVE-SELINUX-CONTEXT.
(tramp-gvfs-handle-copy-file, tramp-gvfs-handle-rename-file):
Implement backup call, when operation on local files fails. Use
progress reporter. Flush properties of changed files.
(tramp-gvfs-handle-delete-file): Add TRASH arg. Use
`tramp-compat-delete-file'.
(tramp-gvfs-handle-expand-file-name): Expand "~/".
(tramp-gvfs-handle-make-directory): Make more traces.
(tramp-gvfs-handle-write-region): Protect deleting tmpfile.
(tramp-gvfs-url-file-name): Hexify file name in url.
(tramp-gvfs-fuse-file-name): Take also prefix (like dav shares)
into account for the resulting file name.
(tramp-gvfs-handler-askquestion): Preserve current message, in
order to let progress reporter continue afterwards. (Bug#6257)
Return dummy mountpoint, when the answer is "no". See
`tramp-gvfs-maybe-open-connection'.
(tramp-gvfs-handler-mounted-unmounted)
(tramp-gvfs-connection-mounted-p): Test also for new mountspec
attribute "default_location". Set "prefix" property. Handle
default-location.
(tramp-gvfs-mount-spec): Return both prefix and mountspec.
(tramp-gvfs-maybe-open-connection): Test, whether mountpoint
exists. Raise an error, if not (due to a corresponding answer
"no" in interactive questions, for example). Use
`tramp-compat-funcall'.
* net/tramp-imap.el (top): Autoload `epg-make-context'.
(tramp-imap-handle-copy-file): Add PRESERVE-SELINUX-CONTEXT.
(tramp-imap-do-copy-or-rename-file)
(tramp-imap-handle-insert-file-contents)
(tramp-imap-handle-file-local-copy): Use `with-progress-reporter'.
(tramp-imap-handle-delete-file): Add TRASH arg.
* net/tramp-smb.el (tramp-smb-handle-copy-file): Add
PRESERVE-SELINUX-CONTEXT.
(tramp-smb-handle-copy-file)
(tramp-smb-handle-file-local-copy, tramp-smb-handle-rename-file)
(tramp-smb-handle-write-region, tramp-smb-maybe-open-connection):
Use `with-progress-reporter'.
(tramp-smb-handle-delete-file): Add TRASH arg.
* net/tramp.el (tramp-methods): Move hostname to the end in all
ssh `tramp-login-args'. Add `tramp-async-args' attribute where
appropriate.
(tramp-verbose): Describe verbose level 9.
(tramp-completion-function-alist)
(tramp-file-name-regexp, tramp-chunksize)
(tramp-local-coding-commands, tramp-remote-coding-commands)
(with-connection-property, tramp-completion-mode-p)
(tramp-action-process-alive, tramp-action-out-of-band)
(tramp-check-for-regexp, tramp-file-name-p, tramp-equal-remote)
(tramp-exists-file-name-handler): Fix docstring.
(tramp-remote-process-environment): Use `format' instead of
`concat'. Protect version string by apostroph.
(tramp-shell-prompt-pattern): Do not use a shy group in case of
XEmacs.
(tramp-file-name-regexp-unified)
(tramp-completion-file-name-regexp-unified): On W32 systems, do
not regard the volume letter as remote filename. (Bug#5447)
(tramp-perl-file-attributes)
(tramp-perl-directory-files-and-attributes): Don't pass "$3".
(tramp-vc-registered-read-file-names): Read input as
here-document, otherwise the command could exceed maximum length
of command line.
(tramp-file-name-handler-alist): Add `file-selinux-context' and
`set-file-selinux-context'.
(tramp-debug-message): Add `tramp-compat-funcall' to ignored
backtrace functions.
(tramp-error-with-buffer): Don't show the connection buffer when
we are in completion mode.
(tramp-progress-reporter-update, tramp-remote-selinux-p)
(tramp-handle-file-selinux-context)
(tramp-handle-set-file-selinux-context, tramp-process-sentinel)
(tramp-connectable-p, tramp-open-shell, tramp-get-remote-trash):
New defuns.
(with-progress-reporter): New defmacro.
(tramp-debug-outline-regexp): New defconst.
(top, tramp-rfn-eshadow-setup-minibuffer)
(tramp-rfn-eshadow-update-overlay, tramp-handle-set-file-times)
(tramp-handle-dired-compress-file, tramp-handle-shell-command)
(tramp-completion-mode-p, tramp-check-for-regexp)
(tramp-open-connection-setup-interactive-shell)
(tramp-compute-multi-hops, tramp-read-passwd, tramp-clear-passwd)
(tramp-time-diff, tramp-coding-system-change-eol-conversion)
(tramp-set-process-query-on-exit-flag, tramp-unload-tramp):
Use `tramp-compat-funcall'.
(tramp-handle-make-symbolic-link): Flush file properties.
(tramp-handle-load, tramp-handle-file-local-copy)
(tramp-handle-insert-file-contents, tramp-handle-write-region)
(tramp-handle-vc-registered, tramp-maybe-send-script)
(tramp-find-shell): Use `with-progress-reporter'.
(tramp-do-file-attributes-with-stat): Add space in format string,
in order to work around a bug in pdksh. Reported by Gilles Pion
<gpion@lfdj.com>.
(tramp-handle-verify-visited-file-modtime): Do not send a command
when the connection is not established.
(tramp-handle-set-file-times): Simplify the check for utc.
(tramp-handle-directory-files-and-attributes)
(tramp-get-remote-path): Use `copy-tree'.
(tramp-completion-handle-file-name-all-completions): Ensure, that
non remote files are still checked. Oops.
(tramp-handle-copy-file, tramp-do-copy-or-rename-file): Handle
PRESERVE-SELINUX-CONTEXT.
(tramp-do-copy-or-rename-file): Add progress reporter.
(tramp-do-copy-or-rename-file-directly): Do not use
`tramp-handle-file-remote-p'.
(tramp-do-copy-or-rename-file-out-of-band):
Use `tramp-compat-delete-directory'.
(tramp-do-copy-or-rename-file-out-of-band)
(tramp-compute-multi-hops, tramp-maybe-open-connection):
Use `format-spec-make'.
(tramp-handle-delete-file): Add TRASH arg.
(tramp-handle-dired-uncache): Flush directory cache, not only file
cache.
(tramp-handle-expand-file-name)
(tramp-completion-handle-file-name-all-completions)
(tramp-completion-handle-file-name-completion): Use
`tramp-connectable-p'.
(tramp-handle-start-file-process): Set connection property "vec".
Use it, in order to invalidate file caches. Check only for
`remote-tty' process property.
Implement tty setting. (Bug#4604, Bug#6360)
(tramp-file-name-for-operation): Add `call-process-region' and
`set-file-selinux-context'.
(tramp-find-foreign-file-name-handler)
(tramp-advice-make-auto-save-file-name)
(tramp-set-auto-save-file-modes): Remove superfluous check for
`stringp'. This is done inside `tramp-tramp-file-p'.
(tramp-file-name-handler): Trace 'quit. Catch the error for some
operations when we are in completion mode. This gives the user
the chance to correct the file name in the minibuffer.
(tramp-completion-mode-p): Use `non-essential'.
(tramp-handle-file-name-all-completions): Backward/ XEmacs
compatibility: Use `completion-ignore-case' if
`read-file-name-completion-ignore-case' does not exist.
(tramp-get-debug-buffer): Use `tramp-debug-outline-regexp'.
(tramp-find-shell, tramp-open-connection-setup-interactive-shell):
`tramp-open-shell'.
(tramp-action-password): Hide password prompt before next run.
(tramp-process-actions): Widen connection buffer for the trace.
(tramp-open-connection-setup-interactive-shell): Set `remote-tty'
process property. Trace stty settings if `tramp-verbose' >= 9.
Apply workaround for IRIX64 bug. Move argument of last
`tramp-send-command' where it belongs to.
(tramp-maybe-open-connection): Use `async-args' and `gw-args' in
front of `login-args'.
(tramp-get-ls-command, tramp-get-ls-command-with-dired): Run tests
on "/dev/null" instead of "/".
(tramp-get-ls-command-with-dired): Make test for "--dired"
stronger.
(tramp-set-auto-save-file-modes): Adapt version check.
(tramp-set-process-query-on-exit-flag): Fix wrong parentheses.
(tramp-handle-process-file): Call the program in a subshell, in
order to preserve working directory.
(tramp-handle-shell-command): Don't use hard-wired "/bin/sh" but
`tramp-remote-sh' from `tramp-methods'.
(tramp-get-ls-command): Make test for "--color=never" stronger.
(tramp-check-for-regexp): Use (forward-line 1).
* net/trampver.el: Update release number.
2010-08-26 Magnus Henoch <magnus.henoch@gmail.com>
* net/tramp-gvfs.el (tramp-gvfs-handle-copy-file): Do not pass
empty argument to gvfs-copy.
2010-08-26 Chong Yidong <cyd@stupidchicken.com>
* net/tramp-compat.el (tramp-compat-delete-file): Rewrite to
handle new TRASH arg of `delete-file'.
2010-08-26 Christian Lynbech <christian.lynbech@tieto.com> (tiny change)
* net/tramp.el (tramp-handle-insert-directory): Don't use
`forward-word', its default syntax could be changed.
2010-08-26 Toru TSUNEYOSHI <t_tuneyosi@hotmail.com>
Michael Albinus <michael.albinus@gmx.de>
Implement compression for inline methods.
* net/tramp.el (tramp-inline-compress-start-size): New defcustom.
(tramp-copy-size-limit): Allow also nil.
(tramp-inline-compress-commands): New defconst.
(tramp-find-inline-compress, tramp-get-inline-compress)
(tramp-get-inline-coding): New defuns.
(tramp-get-remote-coding, tramp-get-local-coding): Remove,
replaced by `tramp-get-inline-coding'.
(tramp-handle-file-local-copy, tramp-handle-write-region)
(tramp-method-out-of-band-p): Use `tramp-get-inline-coding'.
2010-08-26 Noah Lavine <noah549@gmail.com> (tiny change)
Detect ssh 'ControlMaster' argument automatically in some cases.
* net/tramp.el (tramp-detect-ssh-controlmaster): New defun.
(tramp-default-method): Use it.
2010-08-26 Karel Klíč <kklic@redhat.com>
* net/tramp.el (tramp-file-name-for-operation):
Add file-selinux-context.
2010-08-26 Łukasz Stelmach <lukasz.stelmach@iem.pw.edu.pl> (tiny change)
* play/cookie1.el (read-cookie): Fix off-by-one error (bug#6921).

View file

@ -106,8 +106,7 @@ This includes password cache, file cache, connection cache, buffers."
(setq tramp-locked nil)
;; Flush password cache.
(when (functionp 'password-reset)
(funcall (symbol-function 'password-reset)))
(tramp-compat-funcall 'password-reset)
;; Flush file and connection cache.
(clrhash tramp-cache-data)
@ -226,7 +225,7 @@ Before reproducing the bug, you might apply
This allows to investigate from a clean environment. Another
useful thing to do is to put
(setq tramp-verbose 8)
(setq tramp-verbose 9)
in the ~/.emacs file and to repeat the bug. Then, include the
contents of the *tramp/foo* buffer and the *debug tramp/foo*
@ -254,7 +253,7 @@ Used for non-7bit chars in strings."
(base64-encode-string val))))))
;; Dump variable.
(funcall (symbol-function 'reporter-dump-variable) varsym mailbuf)
(tramp-compat-funcall 'reporter-dump-variable varsym mailbuf)
(unless (hash-table-p val)
;; Remove string quotation.
@ -283,10 +282,8 @@ Used for non-7bit chars in strings."
(load "mml" 'noerror))
(require 'message nil 'noerror)
(require 'mml nil 'noerror))
(when (functionp 'message-mode)
(funcall (symbol-function 'message-mode)))
(when (functionp 'mml-mode)
(funcall (symbol-function 'mml-mode) t)))
(tramp-compat-funcall 'message-mode)
(tramp-compat-funcall 'mml-mode t))
(defun tramp-append-tramp-buffers ()
"Append Tramp buffers and buffer local variables into the bug report."
@ -308,15 +305,14 @@ Used for non-7bit chars in strings."
(erase-buffer)
(insert "\n(setq\n")
(lisp-indent-line)
(funcall (symbol-function 'reporter-dump-variable)
'buffer-name (current-buffer))
(tramp-compat-funcall
'reporter-dump-variable 'buffer-name (current-buffer))
(dolist (varsym-or-cons-cell (buffer-local-variables buffer))
(let ((varsym (or (car-safe varsym-or-cons-cell)
varsym-or-cons-cell)))
(when (string-match "tramp" (symbol-name varsym))
(funcall
(symbol-function 'reporter-dump-variable)
varsym (current-buffer)))))
(tramp-compat-funcall
'reporter-dump-variable varsym (current-buffer)))))
(lisp-indent-line)
(insert ")\n"))
(insert-buffer-substring elbuf)))
@ -328,7 +324,7 @@ Used for non-7bit chars in strings."
(symbol-value 'mml-mode))
(let ((tramp-buf-regexp "\\*\\(debug \\)?tramp/")
(buffer-list (funcall (symbol-function 'tramp-list-tramp-buffers)))
(buffer-list (tramp-compat-funcall 'tramp-list-tramp-buffers))
(curbuf (current-buffer)))
;; There is at least one Tramp buffer.
@ -376,10 +372,10 @@ This is a special notion of the `gnus/message' package. If you
use another mail agent (by copying the contents of this buffer)
please ensure that the buffers are attached to your email.\n\n")
(dolist (buffer buffer-list)
(funcall (symbol-function 'mml-insert-empty-tag)
'part 'type "text/plain" 'encoding "base64"
'disposition "attachment" 'buffer buffer
'description buffer))
(tramp-compat-funcall
'mml-insert-empty-tag 'part 'type "text/plain"
'encoding "base64" 'disposition "attachment" 'buffer buffer
'description buffer))
(set-buffer-modified-p nil))
;; Don't send. Delete the message buffer.

View file

@ -22,9 +22,9 @@
;;; Commentary:
;; Tramp's main Emacs version for development is GNU Emacs 23. This
;; package provides compatibility functions for GNU Emacs 21, GNU
;; Emacs 22 and XEmacs 21.4+.
;; Tramp's main Emacs version for development is GNU Emacs 24. This
;; package provides compatibility functions for GNU Emacs 22, GNU
;; Emacs 23 and XEmacs 21.4+.
;;; Code:
@ -44,33 +44,31 @@
(autoload 'tramp-tramp-file-p "tramp")
(autoload 'tramp-file-name-handler "tramp")
(autoload 'tramp-handle-file-remote-p "tramp")
;; tramp-util offers integration into other (X)Emacs packages like
;; compile.el, gud.el etc. Not necessary in Emacs 23.
(eval-after-load "tramp"
;; We check whether `start-file-process' is an alias.
'(when (or (not (fboundp 'start-file-process))
(symbolp (symbol-function 'start-file-process)))
(require 'tramp-util)
(add-hook 'tramp-unload-hook
'(lambda ()
(when (featurep 'tramp-util)
(unload-feature 'tramp-util 'force))))))
;; We check whether `start-file-process' is bound.
(unless (fboundp 'start-file-process)
;; Make sure that we get integration with the VC package. When it
;; is loaded, we need to pull in the integration module. Not
;; necessary in Emacs 23.
(eval-after-load "vc"
;; tramp-util offers integration into other (X)Emacs packages like
;; compile.el, gud.el etc. Not necessary in Emacs 23.
(eval-after-load "tramp"
;; We check whether `start-file-process' is an alias.
'(when (or (not (fboundp 'start-file-process))
(symbolp (symbol-function 'start-file-process)))
(require 'tramp-vc)
'(progn
(require 'tramp-util)
(add-hook 'tramp-unload-hook
'(lambda ()
(when (featurep 'tramp-vc)
(unload-feature 'tramp-vc 'force)))))))
(when (featurep 'tramp-util)
(unload-feature 'tramp-util 'force))))))
;; Make sure that we get integration with the VC package. When it
;; is loaded, we need to pull in the integration module. Not
;; necessary in Emacs 23.
(eval-after-load "vc"
(eval-after-load "tramp"
'(progn
(require 'tramp-vc)
(add-hook 'tramp-unload-hook
'(lambda ()
(when (featurep 'tramp-vc)
(unload-feature 'tramp-vc 'force))))))))
;; Avoid byte-compiler warnings if the byte-compiler supports this.
;; Currently, XEmacs supports this.
@ -89,14 +87,25 @@
(unless (boundp 'byte-compile-not-obsolete-var)
(defvar byte-compile-not-obsolete-var nil))
(setq byte-compile-not-obsolete-var 'directory-sep-char)
(if (boundp 'byte-compile-not-obsolete-vars) ; Emacs 23.2
(setq byte-compile-not-obsolete-vars '(directory-sep-char)))
;; Emacs 23.2.
(unless (boundp 'byte-compile-not-obsolete-vars)
(defvar byte-compile-not-obsolete-vars nil))
(setq byte-compile-not-obsolete-vars '(directory-sep-char))
;; `with-temp-message' does not exists in XEmacs.
(condition-case nil
(with-temp-message (current-message) nil)
(error (defmacro with-temp-message (message &rest body) `(progn ,@body))))
;; For not existing functions, or functions with a changed argument
;; list, there are compiler warnings. We want to avoid them in
;; cases we know what we do.
(defmacro tramp-compat-funcall (function &rest arguments)
(if (featurep 'xemacs)
`(funcall (symbol-function ,function) ,@arguments)
`(when (or (subrp ,function) (functionp ,function))
(with-no-warnings (funcall ,function ,@arguments)))))
;; `set-buffer-multibyte' comes from Emacs Leim.
(unless (fboundp 'set-buffer-multibyte)
(defalias 'set-buffer-multibyte 'ignore))
@ -120,7 +129,7 @@
(tramp-file-name-handler
'file-remote-p file identification connected)))))
;; `process-file' exists since Emacs 22.
;; `process-file' does not exist in XEmacs.
(unless (fboundp 'process-file)
(defalias 'process-file
(lambda (program &optional infile buffer display &rest args)
@ -154,7 +163,9 @@
;; return the original filename if it can't expand anything. Let's
;; just hope that this doesn't break anything else.
;; It is not needed anymore since GNU Emacs 23.2.
(unless (or (featurep 'xemacs) (featurep 'files 'remote-wildcards))
(unless (or (featurep 'xemacs)
;; `featurep' has only one argument in XEmacs.
(funcall 'featurep 'files 'remote-wildcards))
(defadvice file-expand-wildcards
(around tramp-advice-file-expand-wildcards activate)
(let ((name (ad-get-arg 0)))
@ -163,7 +174,8 @@
(if (and
(tramp-tramp-file-p name)
(not (string-match
"[[*?]" (tramp-handle-file-remote-p name 'localname))))
"[[*?]" (tramp-compat-funcall
'file-remote-p name 'localname))))
(setq ad-return-value (list name))
;; Otherwise, just run the original function.
ad-do-it)))
@ -180,8 +192,8 @@ Calls `line-beginning-position' or `point-at-bol' if defined, else
own implementation."
(cond
((fboundp 'line-beginning-position)
(funcall (symbol-function 'line-beginning-position)))
((fboundp 'point-at-bol) (funcall (symbol-function 'point-at-bol)))
(tramp-compat-funcall 'line-beginning-position))
((fboundp 'point-at-bol) (tramp-compat-funcall 'point-at-bol))
(t (save-excursion (beginning-of-line) (point)))))
(defsubst tramp-compat-line-end-position ()
@ -189,8 +201,8 @@ own implementation."
Calls `line-end-position' or `point-at-eol' if defined, else
own implementation."
(cond
((fboundp 'line-end-position) (funcall (symbol-function 'line-end-position)))
((fboundp 'point-at-eol) (funcall (symbol-function 'point-at-eol)))
((fboundp 'line-end-position) (tramp-compat-funcall 'line-end-position))
((fboundp 'point-at-eol) (tramp-compat-funcall 'point-at-eol))
(t (save-excursion (end-of-line) (point)))))
(defsubst tramp-compat-temporary-file-directory ()
@ -199,7 +211,7 @@ For Emacs, this is the variable `temporary-file-directory', for XEmacs
this is the function `temp-directory'."
(cond
((boundp 'temporary-file-directory) (symbol-value 'temporary-file-directory))
((fboundp 'temp-directory) (funcall (symbol-function 'temp-directory)))
((fboundp 'temp-directory) (tramp-compat-funcall 'temp-directory))
((let ((d (getenv "TEMP"))) (and d (file-directory-p d)))
(file-name-as-directory (getenv "TEMP")))
((let ((d (getenv "TMP"))) (and d (file-directory-p d)))
@ -211,10 +223,9 @@ this is the function `temp-directory'."
"`temp-directory' is defined -- using /tmp."))
(file-name-as-directory "/tmp"))))
;; `make-temp-file' exists in Emacs only. The third parameter SUFFIX
;; has been introduced with Emacs 22. We try it, if it fails, we fall
;; back to `make-temp-name', creating the temporary file immediately
;; in order to avoid a security hole.
;; `make-temp-file' exists in Emacs only. On XEmacs, we use our own
;; implementation with `make-temp-name', creating the temporary file
;; immediately in order to avoid a security hole.
(defsubst tramp-compat-make-temp-file (filename &optional dir-flag)
"Create a temporary file (compat function).
Add the extension of FILENAME, if existing."
@ -226,8 +237,7 @@ Add the extension of FILENAME, if existing."
result)
(condition-case nil
(setq result
(funcall
(symbol-function 'make-temp-file) prefix dir-flag extension))
(tramp-compat-funcall 'make-temp-file prefix dir-flag extension))
(error
;; We use our own implementation, taken from files.el.
(while
@ -236,14 +246,7 @@ Add the extension of FILENAME, if existing."
(setq result (concat (make-temp-name prefix) extension))
(if dir-flag
(make-directory result)
(write-region
"" nil result nil 'silent nil
;; 7th parameter is MUSTBENEW in Emacs, and
;; CODING-SYSTEM in XEmacs. It is not a security
;; hole in XEmacs if we cannot use this parameter,
;; because XEmacs uses a user-specific
;; subdirectory with 0700 permissions.
(when (not (featurep 'xemacs)) 'excl)))
(write-region "" nil result nil 'silent))
nil)
(file-already-exists t))
;; The file was somehow created by someone else between
@ -251,16 +254,15 @@ Add the extension of FILENAME, if existing."
nil)))
result))
;; `most-positive-fixnum' arrived in Emacs 22. Before, and in XEmacs,
;; it is a fixed value.
;; `most-positive-fixnum' does not exist in XEmacs.
(defsubst tramp-compat-most-positive-fixnum ()
"Return largest positive integer value (compat function)."
(cond
((boundp 'most-positive-fixnum) (symbol-value 'most-positive-fixnum))
;; Default value in XEmacs and Emacs 21.
;; Default value in XEmacs.
(t 134217727)))
;; ID-FORMAT exists since Emacs 22.
;; ID-FORMAT does not exists in XEmacs.
(defun tramp-compat-file-attributes (filename &optional id-format)
"Like `file-attributes' for Tramp files (compat function)."
(cond
@ -269,19 +271,27 @@ Add the extension of FILENAME, if existing."
((tramp-tramp-file-p filename)
(tramp-file-name-handler 'file-attributes filename id-format))
(t (condition-case nil
(funcall (symbol-function 'file-attributes) filename id-format)
(error (file-attributes filename))))))
(tramp-compat-funcall 'file-attributes filename id-format)
(wrong-number-of-arguments (file-attributes filename))))))
;; PRESERVE-UID-GID has been introduced with Emacs 23. It does not
;; hurt to ignore it for other (X)Emacs versions.
;; PRESERVE-SELINUX-CONTEXT has been introduced with Emacs 24.
(defun tramp-compat-copy-file
(filename newname &optional ok-if-already-exists keep-date preserve-uid-gid)
(filename newname &optional ok-if-already-exists keep-date
preserve-uid-gid preserve-selinux-context)
"Like `copy-file' for Tramp files (compat function)."
(if preserve-uid-gid
(funcall
(symbol-function 'copy-file)
filename newname ok-if-already-exists keep-date preserve-uid-gid)
(copy-file filename newname ok-if-already-exists keep-date)))
(cond
(preserve-selinux-context
(tramp-compat-funcall
'copy-file filename newname ok-if-already-exists keep-date
preserve-uid-gid preserve-selinux-context))
(preserve-uid-gid
(tramp-compat-funcall
'copy-file filename newname ok-if-already-exists keep-date
preserve-uid-gid))
(t
(copy-file filename newname ok-if-already-exists keep-date))))
;; `copy-directory' is a new function in Emacs 23.2. Implementation
;; is taken from there.
@ -289,11 +299,10 @@ Add the extension of FILENAME, if existing."
(directory newname &optional keep-time parents)
"Make a copy of DIRECTORY (compat function)."
(if (fboundp 'copy-directory)
(funcall
(symbol-function 'copy-directory) directory newname keep-time parents)
(tramp-compat-funcall 'copy-directory directory newname keep-time parents)
;; If default-directory is a remote directory, make sure we find
;; its copy-directory handler.
;; If `default-directory' is a remote directory, make sure we find
;; its `copy-directory' handler.
(let ((handler (or (find-file-name-handler directory 'copy-directory)
(find-file-name-handler newname 'copy-directory))))
(if handler
@ -325,36 +334,45 @@ Add the extension of FILENAME, if existing."
(if keep-time
(set-file-times newname (nth 5 (file-attributes directory))))))))
;; `copy-tree' is a built-in function in XEmacs. In Emacs 21, it is
;; an autoloaded function in cl-extra.el. Since Emacs 22, it is part
;; of subr.el. There are problems when autoloading, therefore we test
;; for `subrp' and `symbol-file'. Implementation is taken from Emacs 23.
(defun tramp-compat-copy-tree (tree)
"Make a copy of TREE (compat function)."
(if (or (subrp 'copy-tree) (symbol-file 'copy-tree))
(funcall (symbol-function 'copy-tree) tree)
(let (result)
(while (consp tree)
(let ((newcar (car tree)))
(if (consp (car tree))
(setq newcar (tramp-compat-copy-tree (car tree))))
(push newcar result))
(setq tree (cdr tree)))
(nconc (nreverse result) tree))))
;; TRASH has been introduced with Emacs 24.1.
(defun tramp-compat-delete-file (filename &optional trash)
"Like `delete-file' for Tramp files (compat function)."
(condition-case nil
(tramp-compat-funcall 'delete-file filename trash)
;; This Emacs version does not support the TRASH flag.
(wrong-number-of-arguments
(let ((delete-by-moving-to-trash
(and (boundp 'delete-by-moving-to-trash)
(symbol-value 'delete-by-moving-to-trash)
trash)))
(delete-file filename)))))
;; RECURSIVE has been introduced with Emacs 23.2.
(defun tramp-compat-delete-directory (directory &optional recursive)
"Like `delete-directory' for Tramp files (compat function)."
(if recursive
(funcall (symbol-function 'delete-directory) directory recursive)
(delete-directory directory)))
(if (null recursive)
(delete-directory directory)
(condition-case nil
(tramp-compat-funcall 'delete-directory directory recursive)
;; This Emacs version does not support the RECURSIVE flag. We
;; use the implementation from Emacs 23.2.
(wrong-number-of-arguments
(setq directory (directory-file-name (expand-file-name directory)))
(if (not (file-symlink-p directory))
(mapc (lambda (file)
(if (eq t (car (file-attributes file)))
(tramp-compat-delete-directory file recursive)
(delete-file file)))
(directory-files
directory 'full "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*")))
(delete-directory directory)))))
;; `number-sequence' has been introduced in Emacs 22. Implementation
;; is taken from Emacs 23.
;; `number-sequence' does not exist in XEmacs. Implementation is
;; taken from Emacs 23.
(defun tramp-compat-number-sequence (from &optional to inc)
"Return a sequence of numbers from FROM to TO as a list (compat function)."
(if (or (subrp 'number-sequence) (symbol-file 'number-sequence))
(funcall (symbol-function 'number-sequence) from to inc)
(tramp-compat-funcall 'number-sequence from to inc)
(if (or (not to) (= from to))
(list from)
(or inc (setq inc 1))
@ -384,15 +402,13 @@ element is not omitted."
(cond
;; GNU Emacs 22 on w32.
((fboundp 'w32-window-exists-p)
(funcall (symbol-function 'w32-window-exists-p)
process-name process-name))
(tramp-compat-funcall 'w32-window-exists-p process-name process-name))
;; GNU Emacs 23.
((and (fboundp 'list-system-processes) (fboundp 'process-attributes))
(let (result)
(dolist (pid (funcall (symbol-function 'list-system-processes)) result)
(let ((attributes
(funcall (symbol-function 'process-attributes) pid)))
(dolist (pid (tramp-compat-funcall 'list-system-processes) result)
(let ((attributes (tramp-compat-funcall 'process-attributes pid)))
(when (and (string-equal
(cdr (assoc 'user attributes)) (user-login-name))
(let ((comm (cdr (assoc 'comm attributes))))

View file

@ -149,9 +149,12 @@
;; parameter of `write-region'. Transfer of binary data fails due to
;; Emacs' process input/output handling.
;;; Code:
(eval-when-compile
;; Pacify byte-compiler.
(require 'cl))
(require 'tramp)
(require 'tramp-cache)
(require 'tramp-compat)
@ -217,7 +220,6 @@ Used instead of analyzing error codes of commands.")
(file-executable-p . tramp-fish-handle-file-executable-p)
(file-exists-p . tramp-fish-handle-file-exists-p)
(file-local-copy . tramp-fish-handle-file-local-copy)
(file-remote-p . tramp-handle-file-remote-p)
(file-modes . tramp-handle-file-modes)
(file-name-all-completions . tramp-fish-handle-file-name-all-completions)
(file-name-as-directory . tramp-handle-file-name-as-directory)
@ -229,6 +231,8 @@ Used instead of analyzing error codes of commands.")
(file-ownership-preserved-p . ignore)
(file-readable-p . tramp-fish-handle-file-readable-p)
(file-regular-p . tramp-handle-file-regular-p)
(file-remote-p . tramp-handle-file-remote-p)
;; `file-selinux-context' performed by default handler.
(file-symlink-p . tramp-handle-file-symlink-p)
;; `file-truename' performed by default handler
(file-writable-p . tramp-fish-handle-file-writable-p)
@ -243,6 +247,7 @@ Used instead of analyzing error codes of commands.")
(make-symbolic-link . tramp-fish-handle-make-symbolic-link)
(rename-file . tramp-fish-handle-rename-file)
(set-file-modes . tramp-fish-handle-set-file-modes)
;; `set-file-selinux-context' performed by default handler.
(set-file-times . tramp-fish-handle-set-file-times)
(set-visited-file-modtime . ignore)
(shell-command . tramp-handle-shell-command)
@ -307,7 +312,8 @@ pass to the OPERATION."
v1 'file-error "Error with add-name-to-file %s" newname)))))
(defun tramp-fish-handle-copy-file
(filename newname &optional ok-if-already-exists keep-date preserve-uid-gid)
(filename newname &optional ok-if-already-exists keep-date
preserve-uid-gid preserve-selinux-context)
"Like `copy-file' for Tramp files."
(tramp-fish-do-copy-or-rename-file
'copy filename newname ok-if-already-exists keep-date preserve-uid-gid))
@ -324,12 +330,12 @@ pass to the OPERATION."
;; We do not want to delete "." and "..".
(directory-files
directory 'full "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*")))
(with-parsed-tramp-file-name
(with-parsed-tramp-file-name
(directory-file-name (expand-file-name directory)) nil
(tramp-flush-directory-property v localname)
(tramp-fish-send-command-and-check v (format "#RMD %s" localname)))))
(defun tramp-fish-handle-delete-file (filename)
(defun tramp-fish-handle-delete-file (filename &optional trash)
"Like `delete-file' for Tramp files."
(when (file-exists-p filename)
(with-parsed-tramp-file-name (expand-file-name filename) nil
@ -341,10 +347,10 @@ pass to the OPERATION."
"Like `directory-files-and-attributes' for Tramp files."
(mapcar
(lambda (x)
;; We cannot call `file-attributes' for backward compatibility reasons.
;; Its optional parameter ID-FORMAT is introduced with Emacs 22.
(cons x (tramp-fish-handle-file-attributes
(if full x (expand-file-name x directory)) id-format)))
(cons x
(tramp-compat-file-attributes
(if full x (expand-file-name x directory))
id-format)))
(directory-files directory full match nosort)))
(defun tramp-fish-handle-expand-file-name (name &optional dir)
@ -484,13 +490,13 @@ pass to the OPERATION."
v 'file-error
"Cannot make local copy of non-existing file `%s'" filename))
(let ((tmpfile (tramp-compat-make-temp-file filename)))
(tramp-message v 4 "Fetching %s to tmp file %s..." filename tmpfile)
(when (tramp-fish-retrieve-data v)
;; Save file
(with-current-buffer (tramp-get-buffer v)
(write-region (point-min) (point-max) tmpfile))
(tramp-message v 4 "Fetching %s to tmp file %s...done" filename tmpfile)
tmpfile))))
(with-progress-reporter
v 3 (format "Fetching %s to tmp file %s" filename tmpfile)
(when (tramp-fish-retrieve-data v)
;; Save file
(with-current-buffer (tramp-get-buffer v)
(write-region (point-min) (point-max) tmpfile))
tmpfile)))))
;; This function should return "foo/" for directories and "bar" for
;; files.
@ -588,17 +594,16 @@ WILDCARD and FULL-DIRECTORY-P are not handled."
(let ((point (point))
size)
(tramp-message v 4 "Fetching file %s..." filename)
(when (tramp-fish-retrieve-data v)
;; Insert file
(insert
(with-current-buffer (tramp-get-buffer v)
(let ((beg (or beg (point-min)))
(end (min (or end (point-max)) (point-max))))
(setq size (- end beg))
(buffer-substring beg end))))
(goto-char point))
(tramp-message v 4 "Fetching file %s...done" filename)
(with-progress-reporter v 3 (format "Fetching file %s" filename)
(when (tramp-fish-retrieve-data v)
;; Insert file
(insert
(with-current-buffer (tramp-get-buffer v)
(let ((beg (or beg (point-min)))
(end (min (or end (point-max)) (point-max))))
(setq size (- end beg))
(buffer-substring beg end))))
(goto-char point)))
(list (expand-file-name filename) size)))))
@ -1030,15 +1035,15 @@ SIZE MODE WEIRD)."
;; last line
((looking-at "^$")
(return)))
;; delete line
;; Delete line.
(forward-line)
(delete-region (point-min) (point))))
;; delete trailing empty line
;; Delete trailing empty line.
(forward-line)
(delete-region (point-min) (point))
;; Return entry in file-attributes format
;; Return entry in `file-attributes' format.
(list localname link -1 uid gid '(0 0) mtime '(0 0) size mode nil)))
(defun tramp-fish-retrieve-data (vec)
@ -1112,34 +1117,36 @@ connection if a previous connection has died for some reason."
(delete-process p))
(setenv "TERM" tramp-terminal-type)
(setenv "PS1" tramp-initial-end-of-output)
(tramp-message
vec 3 "Opening connection for %s@%s using %s..."
tramp-current-user tramp-current-host tramp-current-method)
(with-progress-reporter
vec 3
(format "Opening connection for %s@%s using %s"
tramp-current-user tramp-current-host tramp-current-method)
(let* ((process-connection-type tramp-process-connection-type)
(inhibit-eol-conversion nil)
(coding-system-for-read 'binary)
(coding-system-for-write 'binary)
;; This must be done in order to avoid our file name handler.
(p (let ((default-directory
(tramp-compat-temporary-file-directory)))
(start-process
(or (tramp-get-connection-property vec "process-name" nil)
(tramp-buffer-name vec))
(tramp-get-connection-buffer vec)
"ssh" "-l"
(tramp-file-name-user vec)
(tramp-file-name-host vec)))))
(tramp-message vec 6 "%s" (mapconcat 'identity (process-command p) " "))
(let* ((process-connection-type tramp-process-connection-type)
(inhibit-eol-conversion nil)
(coding-system-for-read 'binary)
(coding-system-for-write 'binary)
;; This must be done in order to avoid our file name handler.
(p (let ((default-directory
(tramp-compat-temporary-file-directory)))
(start-process
(or (tramp-get-connection-property vec "process-name" nil)
(tramp-buffer-name vec))
(tramp-get-connection-buffer vec)
"ssh" "-l"
(tramp-file-name-user vec)
(tramp-file-name-host vec)))))
(tramp-message
vec 6 "%s" (mapconcat 'identity (process-command p) " "))
;; Check whether process is alive.
(tramp-set-process-query-on-exit-flag p nil)
;; Check whether process is alive.
(tramp-set-process-query-on-exit-flag p nil)
(tramp-process-actions p vec tramp-actions-before-shell 60)
(tramp-fish-send-command vec tramp-fish-start-fish-server-command)
(tramp-message
vec 3
"Found remote shell prompt on `%s'" (tramp-file-name-host vec))))))
(tramp-process-actions p vec tramp-actions-before-shell 60)
(tramp-fish-send-command vec tramp-fish-start-fish-server-command)
(tramp-message
vec 3
"Found remote shell prompt on `%s'" (tramp-file-name-host vec)))))))
(defun tramp-fish-send-command (vec command)
"Send the COMMAND to connection VEC."

View file

@ -1,7 +1,7 @@
;;; tramp-ftp.el --- Tramp convenience functions for Ange-FTP
;; Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007,
;; 2008, 2009, 2010 Free Software Foundation, Inc.
;; Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008,
;; 2009, 2010 Free Software Foundation, Inc.
;; Author: Michael Albinus <michael.albinus@gmx.de>
;; Keywords: comm, processes

View file

@ -28,6 +28,10 @@
;; incompatibility with the mount_info structure, which has been
;; worked around.
;; It has also been tested with GVFS 1.6.2 (Ubuntu 10.04, Gnome 2.30),
;; where the default_location has been added to mount_info (see
;; <https://bugzilla.gnome.org/show_bug.cgi?id=561998>.
;; All actions to mount a remote location, and to retrieve mount
;; information, are performed by D-Bus messages. File operations
;; themselves are performed via the mounted filesystem in ~/.gvfs.
@ -100,6 +104,7 @@
(require 'tramp)
(require 'dbus)
(require 'url-parse)
(require 'url-util)
(require 'zeroconf)
(defcustom tramp-gvfs-methods '("dav" "davs" "obex" "synce")
@ -133,10 +138,6 @@
(unless (assoc elt tramp-methods)
(add-to-list 'tramp-methods (cons elt nil))))))
(defconst tramp-gvfs-mount-point
(file-name-as-directory (expand-file-name ".gvfs" "~/"))
"The directory name, fuses mounts remote ressources.")
(defconst tramp-gvfs-path-tramp (concat dbus-path-emacs "/Tramp")
"The preceeding object path for own objects.")
@ -156,7 +157,7 @@
;; <interface name='org.gtk.vfs.MountTracker'>
;; <method name='listMounts'>
;; <arg name='mount_info_list'
;; type='a{sosssssbay{aya{say}}}'
;; type='a{sosssssbay{aya{say}}ay}'
;; direction='out'/>
;; </method>
;; <method name='mountLocation'>
@ -166,11 +167,11 @@
;; </method>
;; <signal name='mounted'>
;; <arg name='mount_info'
;; type='{sosssssbay{aya{say}}}'/>
;; type='{sosssssbay{aya{say}}ay}'/>
;; </signal>
;; <signal name='unmounted'>
;; <arg name='mount_info'
;; type='{sosssssbay{aya{say}}}'/>
;; type='{sosssssbay{aya{say}}ay}'/>
;; </signal>
;; </interface>
;;
@ -190,6 +191,7 @@
;; STRUCT mount_spec_item
;; STRING key (server, share, type, user, host, port)
;; ARRAY BYTE value
;; ARRAY BYTE default_location Since GVFS 1.5 only !!!
(defconst tramp-gvfs-interface-mountoperation "org.gtk.vfs.MountOperation"
"Used by the dbus-proxying implementation of GMountOperation.")
@ -386,7 +388,6 @@ Every entry is a list (NAME ADDRESS).")
(file-executable-p . tramp-gvfs-handle-file-executable-p)
(file-exists-p . tramp-gvfs-handle-file-exists-p)
(file-local-copy . tramp-gvfs-handle-file-local-copy)
(file-remote-p . tramp-handle-file-remote-p)
;; `file-modes' performed by default handler.
(file-name-all-completions . tramp-gvfs-handle-file-name-all-completions)
(file-name-as-directory . tramp-handle-file-name-as-directory)
@ -398,6 +399,8 @@ Every entry is a list (NAME ADDRESS).")
(file-ownership-preserved-p . ignore)
(file-readable-p . tramp-gvfs-handle-file-readable-p)
(file-regular-p . tramp-handle-file-regular-p)
(file-remote-p . tramp-handle-file-remote-p)
(file-selinux-context . tramp-gvfs-handle-file-selinux-context)
(file-symlink-p . tramp-handle-file-symlink-p)
;; `file-truename' performed by default handler.
(file-writable-p . tramp-gvfs-handle-file-writable-p)
@ -413,6 +416,7 @@ Every entry is a list (NAME ADDRESS).")
(process-file . tramp-gvfs-handle-process-file)
(rename-file . tramp-gvfs-handle-rename-file)
(set-file-modes . tramp-gvfs-handle-set-file-modes)
(set-file-selinux-context . tramp-gvfs-handle-set-file-selinux-context)
(set-visited-file-modtime . tramp-gvfs-handle-set-visited-file-modtime)
(shell-command . tramp-gvfs-handle-shell-command)
(start-file-process . tramp-gvfs-handle-start-file-process)
@ -447,6 +451,17 @@ pass to the OPERATION."
(add-to-list 'tramp-foreign-file-name-handler-alist
(cons 'tramp-gvfs-file-name-p 'tramp-gvfs-file-name-handler))
(defun tramp-gvfs-stringify-dbus-message (message)
"Convert a D-Bus message into readable UTF8 strings, used for traces."
(cond
((and (consp message) (characterp (car message)))
(format "%S" (dbus-byte-array-to-string message)))
((consp message)
(mapcar 'tramp-gvfs-stringify-dbus-message message))
((stringp message)
(format "%S" message))
(t message)))
(defmacro with-tramp-dbus-call-method
(vec synchronous bus service path interface method &rest args)
"Apply a D-Bus call on bus BUS.
@ -464,7 +479,7 @@ will be traced by Tramp with trace level 6."
result)
(tramp-message ,vec 6 "%s %s" func args)
(setq result (apply func args))
(tramp-message ,vec 6 "\n%s" result)
(tramp-message ,vec 6 "%s" (tramp-gvfs-stringify-dbus-message result))
result))
(put 'with-tramp-dbus-call-method 'lisp-indent-function 2)
@ -478,7 +493,7 @@ In case of an error, modify the error message by replacing
`(let ((fuse-file-name (regexp-quote (tramp-gvfs-fuse-file-name ,filename)))
elt)
(condition-case err
(apply ,handler (list ,@args))
(funcall ,handler ,@args)
(error
(setq elt (cdr err))
(while elt
@ -510,25 +525,56 @@ is no information where to trace the message.")
;; File name primitives.
(defun tramp-gvfs-handle-copy-file
(filename newname &optional ok-if-already-exists keep-date preserve-uid-gid)
(filename newname &optional ok-if-already-exists keep-date
preserve-uid-gid preserve-selinux-context)
"Like `copy-file' for Tramp files."
(copy-file
(if (tramp-gvfs-file-name-p filename)
(tramp-gvfs-fuse-file-name filename)
filename)
(if (tramp-gvfs-file-name-p newname)
(tramp-gvfs-fuse-file-name newname)
newname)
ok-if-already-exists keep-date preserve-uid-gid))
(with-parsed-tramp-file-name
(if (tramp-tramp-file-p filename) filename newname) nil
(with-progress-reporter
v 0 (format "Copying %s to %s" filename newname)
(condition-case err
(let ((args
(list
(if (tramp-gvfs-file-name-p filename)
(tramp-gvfs-fuse-file-name filename)
filename)
(if (tramp-gvfs-file-name-p newname)
(tramp-gvfs-fuse-file-name newname)
newname)
ok-if-already-exists keep-date preserve-uid-gid)))
(when preserve-selinux-context
(setq args (append args (list preserve-selinux-context))))
(apply 'copy-file args))
;; Error case. Let's try it with the GVFS utilities.
(error
(tramp-message v 4 "`copy-file' failed, trying `gvfs-copy'")
(unless
(zerop
(let ((args
(append (if (or keep-date preserve-uid-gid)
(list "--preserve")
nil)
(list
(tramp-gvfs-url-file-name filename)
(tramp-gvfs-url-file-name newname)))))
(apply 'tramp-gvfs-send-command v "gvfs-copy" args)))
;; Propagate the error.
(tramp-error v (car err) "%s" (cdr err)))))))
(when (file-remote-p newname)
(with-parsed-tramp-file-name newname nil
(tramp-flush-file-property v (file-name-directory localname))
(tramp-flush-file-property v localname))))
(defun tramp-gvfs-handle-delete-directory (directory &optional recursive)
"Like `delete-directory' for Tramp files."
(tramp-compat-delete-directory
(tramp-gvfs-fuse-file-name directory) recursive))
(defun tramp-gvfs-handle-delete-file (filename)
(defun tramp-gvfs-handle-delete-file (filename &optional trash)
"Like `delete-file' for Tramp files."
(delete-file (tramp-gvfs-fuse-file-name filename)))
(tramp-compat-delete-file (tramp-gvfs-fuse-file-name filename) trash))
(defun tramp-gvfs-handle-directory-files
(directory &optional full match nosort)
@ -565,6 +611,14 @@ is no information where to trace the message.")
(tramp-run-real-handler 'expand-file-name (list name nil))
;; Dissect NAME.
(with-parsed-tramp-file-name name nil
;; If there is a default location, expand tilde.
(when (string-match "\\`\\(~\\)\\(/\\|\\'\\)" localname)
(save-match-data
(tramp-gvfs-maybe-open-connection (vector method user host "/")))
(setq localname
(replace-match
(tramp-get-file-property v "/" "default-location" "~")
nil t localname 1)))
;; Tilde expansion is not possible.
(when (string-match "\\`\\(~[^/]*\\)\\(.*\\)\\'" localname)
(tramp-error
@ -620,6 +674,11 @@ is no information where to trace the message.")
"Like `file-readable-p' for Tramp files."
(file-readable-p (tramp-gvfs-fuse-file-name filename)))
(defun tramp-gvfs-handle-file-selinux-context (filename)
"Like `file-selinux-context' for Tramp files."
(tramp-compat-funcall
'file-selinux-context (tramp-gvfs-fuse-file-name filename)))
(defun tramp-gvfs-handle-file-writable-p (filename)
"Like `file-writable-p' for Tramp files."
(file-writable-p (tramp-gvfs-fuse-file-name filename)))
@ -645,19 +704,20 @@ is no information where to trace the message.")
(defun tramp-gvfs-handle-make-directory (dir &optional parents)
"Like `make-directory' for Tramp files."
(condition-case err
(with-tramp-gvfs-error-message dir 'make-directory
(tramp-gvfs-fuse-file-name dir) parents)
;; Error case. Let's try it with the GVFS utilities.
(error
(with-parsed-tramp-file-name dir nil
(with-parsed-tramp-file-name dir nil
(condition-case err
(with-tramp-gvfs-error-message dir 'make-directory
(tramp-gvfs-fuse-file-name dir) parents)
;; Error case. Let's try it with the GVFS utilities.
(error
(tramp-message v 4 "`make-directory' failed, trying `gvfs-mkdir'")
(unless
(zerop
(tramp-local-call-process
"gvfs-mkdir" nil (tramp-get-buffer v) nil
(tramp-gvfs-url-file-name dir)))
(signal (car err) (cdr err)))))))
(tramp-gvfs-send-command
v "gvfs-mkdir" (tramp-gvfs-url-file-name dir)))
;; Propagate the error.
(tramp-error v (car err) "%s" (cdr err)))))))
(defun tramp-gvfs-handle-process-file
(program &optional infile destination display &rest args)
@ -668,20 +728,52 @@ is no information where to trace the message.")
(defun tramp-gvfs-handle-rename-file
(filename newname &optional ok-if-already-exists)
"Like `rename-file' for Tramp files."
(rename-file
(if (tramp-gvfs-file-name-p filename)
(tramp-gvfs-fuse-file-name filename)
filename)
(if (tramp-gvfs-file-name-p newname)
(tramp-gvfs-fuse-file-name newname)
newname)
ok-if-already-exists))
(with-parsed-tramp-file-name
(if (tramp-tramp-file-p filename) filename newname) nil
(with-progress-reporter
v 0 (format "Renaming %s to %s" filename newname)
(condition-case err
(rename-file
(if (tramp-gvfs-file-name-p filename)
(tramp-gvfs-fuse-file-name filename)
filename)
(if (tramp-gvfs-file-name-p newname)
(tramp-gvfs-fuse-file-name newname)
newname)
ok-if-already-exists)
;; Error case. Let's try it with the GVFS utilities.
(error
(tramp-message v 4 "`rename-file' failed, trying `gvfs-move'")
(unless
(zerop
(tramp-gvfs-send-command
v "gvfs-move"
(tramp-gvfs-url-file-name filename)
(tramp-gvfs-url-file-name newname)))
;; Propagate the error.
(tramp-error v (car err) "%s" (cdr err)))))))
(when (file-remote-p filename)
(with-parsed-tramp-file-name filename nil
(tramp-flush-file-property v (file-name-directory localname))
(tramp-flush-file-property v localname)))
(when (file-remote-p newname)
(with-parsed-tramp-file-name newname nil
(tramp-flush-file-property v (file-name-directory localname))
(tramp-flush-file-property v localname))))
(defun tramp-gvfs-handle-set-file-modes (filename mode)
"Like `set-file-modes' for Tramp files."
(with-tramp-gvfs-error-message filename 'set-file-modes
(tramp-gvfs-fuse-file-name filename) mode))
(defun tramp-gvfs-handle-set-file-selinux-context (filename context)
"Like `set-file-selinux-context' for Tramp files."
(with-tramp-gvfs-error-message filename 'set-file-selinux-context
(tramp-gvfs-fuse-file-name filename) context))
(defun tramp-gvfs-handle-set-visited-file-modtime (&optional time-list)
"Like `set-visited-file-modtime' for Tramp files."
(let ((buffer-file-name (tramp-gvfs-fuse-file-name (buffer-file-name))))
@ -713,19 +805,16 @@ is no information where to trace the message.")
start end (tramp-gvfs-fuse-file-name filename)
append visit lockname confirm)
;; Error case. Let's try it with the GVFS utilities.
;; Error case. Let's try rename.
(error
(let ((tmpfile (tramp-compat-make-temp-file filename)))
(tramp-message v 4 "`write-region' failed, trying `gvfs-save'")
(tramp-message v 4 "`write-region' failed, trying `rename-file'")
(write-region start end tmpfile)
(unwind-protect
(unless
(zerop
(tramp-local-call-process
"gvfs-save" tmpfile (tramp-get-buffer v) nil
(tramp-gvfs-url-file-name filename)))
(signal (car err) (cdr err)))
(delete-file tmpfile)))))
(condition-case nil
(rename-file tmpfile filename)
(error
(delete-file tmpfile)
(tramp-error v (car err) "%s" (cdr err)))))))
;; Set file modification time.
(when (or (eq visit t) (stringp visit))
@ -741,16 +830,20 @@ is no information where to trace the message.")
(defun tramp-gvfs-url-file-name (filename)
"Return FILENAME in URL syntax."
(url-recreate-url
(if (tramp-tramp-file-p filename)
(with-parsed-tramp-file-name (file-truename filename) nil
(when (string-match tramp-user-with-domain-regexp user)
(setq user
(concat (match-string 2 user) ";" (match-string 2 user))))
(url-parse-make-urlobj
method user nil
(tramp-file-name-real-host v) (tramp-file-name-port v) localname))
(url-parse-make-urlobj "file" nil nil nil nil (file-truename filename)))))
;; "/" must NOT be hexlified.
(let ((url-unreserved-chars (append '(?/) url-unreserved-chars)))
(url-recreate-url
(if (tramp-tramp-file-p filename)
(with-parsed-tramp-file-name (file-truename filename) nil
(when (string-match tramp-user-with-domain-regexp user)
(setq user
(concat (match-string 2 user) ";" (match-string 2 user))))
(url-parse-make-urlobj
method user nil
(tramp-file-name-real-host v) (tramp-file-name-port v)
(url-hexify-string localname)))
(url-parse-make-urlobj
"file" nil nil nil nil (url-hexify-string (file-truename filename)))))))
(defun tramp-gvfs-object-path (filename)
"Create a D-Bus object path from FILENAME."
@ -765,15 +858,19 @@ is no information where to trace the message.")
"Return FUSE file name, which is directly accessible."
(with-parsed-tramp-file-name (expand-file-name filename) nil
(tramp-gvfs-maybe-open-connection v)
(let ((fuse-mountpoint
(let ((prefix (tramp-get-file-property v "/" "prefix" ""))
(fuse-mountpoint
(tramp-get-file-property v "/" "fuse-mountpoint" nil)))
(unless fuse-mountpoint
(tramp-error
v 'file-error "There is no FUSE mount point for `%s'" filename))
;; We must remove the share from the local name.
(when (and (string-equal "smb" method) (string-match "/[^/]+" localname))
;; We must hide the prefix, if any.
(when (string-match (concat "^" (regexp-quote prefix)) localname)
(setq localname (replace-match "" t t localname)))
(concat tramp-gvfs-mount-point fuse-mountpoint localname))))
(tramp-message
v 10 "remote file `%s' is local file `%s'"
filename (concat fuse-mountpoint localname))
(concat fuse-mountpoint localname))))
(defun tramp-bluez-address (device)
"Return bluetooth device address from a given bluetooth DEVICE name."
@ -857,59 +954,79 @@ ADDRESS can have the form \"xx:xx:xx:xx:xx:xx\" or \"[xx:xx:xx:xx:xx:xx]\"."
;; there is only the question whether to accept an unknown
;; host signature.
(with-temp-buffer
(insert message)
(pop-to-buffer (current-buffer))
(setq choice (if (yes-or-no-p (concat (car choices) " ")) 0 1))
(tramp-message v 6 "%d" choice))
;; Preserve message for `progress-reporter'.
(with-temp-message ""
(insert message)
(pop-to-buffer (current-buffer))
(setq choice (if (yes-or-no-p (concat (car choices) " ")) 0 1))
(tramp-message v 6 "%d" choice)))
;; When the choice is "no", we set an empty
;; fuse-mountpoint in order to leave the timeout.
;; When the choice is "no", we set a dummy fuse-mountpoint
;; in order to leave the timeout.
(unless (zerop choice)
(tramp-set-file-property v "/" "fuse-mountpoint" ""))
(tramp-set-file-property v "/" "fuse-mountpoint" "/"))
(list
t ;; handled.
nil ;; no abort of D-Bus.
choice))
;; When QUIT is raised, we shall return this information to D-Bus.
(quit (list nil t 0))))))
;; When QUIT is raised, we shall return this information to D-Bus.
(quit (list nil t 0))))))
(defun tramp-gvfs-handler-mounted-unmounted (mount-info)
"Signal handler for the \"org.gtk.vfs.MountTracker.mounted\" and
\"org.gtk.vfs.MountTracker.unmounted\" signals."
(ignore-errors
(let* ((signal-name (dbus-event-member-name last-input-event))
(mount-spec (cadar (last mount-info)))
(method (dbus-byte-array-to-string (cadr (assoc "type" mount-spec))))
(user (dbus-byte-array-to-string (cadr (assoc "user" mount-spec))))
(domain (dbus-byte-array-to-string
(cadr (assoc "domain" mount-spec))))
(host (dbus-byte-array-to-string
(cadr (or (assoc "host" mount-spec)
(assoc "server" mount-spec)))))
(port (dbus-byte-array-to-string (cadr (assoc "port" mount-spec))))
(ssl (dbus-byte-array-to-string (cadr (assoc "ssl" mount-spec)))))
(when (string-match "^smb" method)
(setq method "smb"))
(when (string-equal "obex" method)
(setq host (tramp-bluez-device host)))
(when (and (string-equal "dav" method) (string-equal "true" ssl))
(setq method "davs"))
(unless (zerop (length domain))
(setq user (concat user tramp-prefix-domain-format domain)))
(unless (zerop (length port))
(setq host (concat host tramp-prefix-port-format port)))
(with-parsed-tramp-file-name
(tramp-make-tramp-file-name method user host "") nil
(tramp-message v 6 "%s %s" signal-name mount-info)
(tramp-set-file-property v "/" "list-mounts" 'undef)
(if (string-equal signal-name "unmounted")
(tramp-set-file-property v "/" "fuse-mountpoint" nil)
(tramp-set-file-property
v "/" "fuse-mountpoint"
(file-name-nondirectory
(dbus-byte-array-to-string (car (last mount-info 2))))))))))
(let ((signal-name (dbus-event-member-name last-input-event))
(elt mount-info))
;; Jump over the first elements of the mount info. Since there
;; were changes in the antries, we cannot access dedicated
;; elements.
(while (stringp (car elt)) (setq elt (cdr elt)))
(let* ((fuse-mountpoint (dbus-byte-array-to-string (cadr elt)))
(mount-spec (caddr elt))
(default-location (dbus-byte-array-to-string (cadddr elt)))
(method (dbus-byte-array-to-string
(cadr (assoc "type" (cadr mount-spec)))))
(user (dbus-byte-array-to-string
(cadr (assoc "user" (cadr mount-spec)))))
(domain (dbus-byte-array-to-string
(cadr (assoc "domain" (cadr mount-spec)))))
(host (dbus-byte-array-to-string
(cadr (or (assoc "host" (cadr mount-spec))
(assoc "server" (cadr mount-spec))))))
(port (dbus-byte-array-to-string
(cadr (assoc "port" (cadr mount-spec)))))
(ssl (dbus-byte-array-to-string
(cadr (assoc "ssl" (cadr mount-spec)))))
(prefix (concat (dbus-byte-array-to-string (car mount-spec))
(dbus-byte-array-to-string
(cadr (assoc "share" (cadr mount-spec)))))))
(when (string-match "^smb" method)
(setq method "smb"))
(when (string-equal "obex" method)
(setq host (tramp-bluez-device host)))
(when (and (string-equal "dav" method) (string-equal "true" ssl))
(setq method "davs"))
(unless (zerop (length domain))
(setq user (concat user tramp-prefix-domain-format domain)))
(unless (zerop (length port))
(setq host (concat host tramp-prefix-port-format port)))
(with-parsed-tramp-file-name
(tramp-make-tramp-file-name method user host "") nil
(tramp-message
v 6 "%s %s"
signal-name (tramp-gvfs-stringify-dbus-message mount-info))
(tramp-set-file-property v "/" "list-mounts" 'undef)
(if (string-equal signal-name "unmounted")
(tramp-set-file-property v "/" "fuse-mountpoint" nil)
;; Set prefix, mountpoint and location.
(unless (string-equal prefix "/")
(tramp-set-file-property v "/" "prefix" prefix))
(tramp-set-file-property v "/" "fuse-mountpoint" fuse-mountpoint)
(tramp-set-file-property
v "/" "default-location" default-location)))))))
(dbus-register-signal
:session nil tramp-gvfs-path-mounttracker
@ -923,47 +1040,63 @@ ADDRESS can have the form \"xx:xx:xx:xx:xx:xx\" or \"[xx:xx:xx:xx:xx:xx]\"."
(defun tramp-gvfs-connection-mounted-p (vec)
"Check, whether the location is already mounted."
(catch 'mounted
(dolist
(elt
(with-file-property vec "/" "list-mounts"
(with-tramp-dbus-call-method vec t
:session tramp-gvfs-service-daemon tramp-gvfs-path-mounttracker
tramp-gvfs-interface-mounttracker "listMounts"))
nil)
(let* ((mount-spec (cadar (last elt)))
(method (dbus-byte-array-to-string
(cadr (assoc "type" mount-spec))))
(user (dbus-byte-array-to-string
(cadr (assoc "user" mount-spec))))
(domain (dbus-byte-array-to-string
(cadr (assoc "domain" mount-spec))))
(host (dbus-byte-array-to-string
(cadr (or (assoc "host" mount-spec)
(assoc "server" mount-spec)))))
(port (dbus-byte-array-to-string (cadr (assoc "port" mount-spec))))
(ssl (dbus-byte-array-to-string (cadr (assoc "ssl" mount-spec)))))
(when (string-match "^smb" method)
(setq method "smb"))
(when (string-equal "obex" method)
(setq host (tramp-bluez-device host)))
(when (and (string-equal "dav" method) (string-equal "true" ssl))
(setq method "davs"))
(when (and (string-equal "synce" method) (zerop (length user)))
(setq user (or (tramp-file-name-user vec) "")))
(unless (zerop (length domain))
(setq user (concat user tramp-prefix-domain-format domain)))
(unless (zerop (length port))
(setq host (concat host tramp-prefix-port-format port)))
(when (and
(string-equal method (tramp-file-name-method vec))
(string-equal user (or (tramp-file-name-user vec) ""))
(string-equal host (tramp-file-name-host vec)))
(tramp-set-file-property
vec "/" "fuse-mountpoint"
(file-name-nondirectory
(dbus-byte-array-to-string (car (last elt 2)))))
(throw 'mounted t))))))
(or
(tramp-get-file-property vec "/" "fuse-mountpoint" nil)
(catch 'mounted
(dolist
(elt
(with-file-property vec "/" "list-mounts"
(with-tramp-dbus-call-method vec t
:session tramp-gvfs-service-daemon tramp-gvfs-path-mounttracker
tramp-gvfs-interface-mounttracker "listMounts"))
nil)
;; Jump over the first elements of the mount info. Since there
;; were changes in the antries, we cannot access dedicated
;; elements.
(while (stringp (car elt)) (setq elt (cdr elt)))
(let* ((fuse-mountpoint (dbus-byte-array-to-string (cadr elt)))
(mount-spec (caddr elt))
(default-location (dbus-byte-array-to-string (cadddr elt)))
(method (dbus-byte-array-to-string
(cadr (assoc "type" (cadr mount-spec)))))
(user (dbus-byte-array-to-string
(cadr (assoc "user" (cadr mount-spec)))))
(domain (dbus-byte-array-to-string
(cadr (assoc "domain" (cadr mount-spec)))))
(host (dbus-byte-array-to-string
(cadr (or (assoc "host" (cadr mount-spec))
(assoc "server" (cadr mount-spec))))))
(port (dbus-byte-array-to-string
(cadr (assoc "port" (cadr mount-spec)))))
(ssl (dbus-byte-array-to-string
(cadr (assoc "ssl" (cadr mount-spec)))))
(prefix (concat (dbus-byte-array-to-string (car mount-spec))
(dbus-byte-array-to-string
(cadr (assoc "share" (cadr mount-spec)))))))
(when (string-match "^smb" method)
(setq method "smb"))
(when (string-equal "obex" method)
(setq host (tramp-bluez-device host)))
(when (and (string-equal "dav" method) (string-equal "true" ssl))
(setq method "davs"))
(when (and (string-equal "synce" method) (zerop (length user)))
(setq user (or (tramp-file-name-user vec) "")))
(unless (zerop (length domain))
(setq user (concat user tramp-prefix-domain-format domain)))
(unless (zerop (length port))
(setq host (concat host tramp-prefix-port-format port)))
(when (and
(string-equal method (tramp-file-name-method vec))
(string-equal user (or (tramp-file-name-user vec) ""))
(string-equal host (tramp-file-name-host vec))
(string-match (concat "^" (regexp-quote prefix))
(tramp-file-name-localname vec)))
;; Set prefix, mountpoint and location.
(unless (string-equal prefix "/")
(tramp-set-file-property vec "/" "prefix" prefix))
(tramp-set-file-property vec "/" "fuse-mountpoint" fuse-mountpoint)
(tramp-set-file-property vec "/" "default-location" default-location)
(throw 'mounted t)))))))
(defun tramp-gvfs-mount-spec (vec)
"Return a mount-spec for \"org.gtk.vfs.MountTracker.mountLocation\"."
@ -974,7 +1107,8 @@ ADDRESS can have the form \"xx:xx:xx:xx:xx:xx\" or \"[xx:xx:xx:xx:xx:xx]\"."
(port (tramp-file-name-port vec))
(localname (tramp-file-name-localname vec))
(ssl (if (string-match "^davs" method) "true" "false"))
(mount-spec `(:array)))
(mount-spec '(:array))
(mount-pref "/"))
(setq
mount-spec
@ -1017,8 +1151,12 @@ ADDRESS can have the form \"xx:xx:xx:xx:xx:xx\" or \"[xx:xx:xx:xx:xx:xx]\"."
`(:struct "port" ,(dbus-string-to-byte-array (number-to-string port)))
'append))
(when (and (string-match "^dav" method)
(string-match "^/?[^/]+" localname))
(setq mount-pref (match-string 0 localname)))
;; Return.
mount-spec))
`(:struct ,(dbus-string-to-byte-array mount-pref) ,mount-spec)))
;; Connection functions
@ -1050,65 +1188,73 @@ connection if a previous connection has died for some reason."
(tramp-gvfs-object-path
(tramp-make-tramp-file-name method user host ""))))
(if (zerop (length (tramp-file-name-user vec)))
(tramp-message
vec 3 "Opening connection for %s using %s..." host method)
(tramp-message
vec 3 "Opening connection for %s@%s using %s..." user host method))
(with-progress-reporter
vec 3
(if (zerop (length user))
(format "Opening connection for %s using %s" host method)
(format "Opening connection for %s@%s using %s" user host method))
;; Enable auth-sorce and password-cache.
(tramp-set-connection-property vec "first-password-request" t)
;; Enable auth-sorce and password-cache.
(tramp-set-connection-property vec "first-password-request" t)
;; There will be a callback of "askPassword", when a password is
;; needed.
(dbus-register-method
:session dbus-service-emacs object-path
tramp-gvfs-interface-mountoperation "askPassword"
'tramp-gvfs-handler-askpassword)
;; There will be a callback of "askPassword", when a password is
;; needed.
(dbus-register-method
:session dbus-service-emacs object-path
tramp-gvfs-interface-mountoperation "askPassword"
'tramp-gvfs-handler-askpassword)
;; There could be a callback of "askQuestion", when adding fingerprint.
(dbus-register-method
:session dbus-service-emacs object-path
tramp-gvfs-interface-mountoperation "askQuestion"
'tramp-gvfs-handler-askquestion)
;; There could be a callback of "askQuestion", when adding fingerprint.
(dbus-register-method
:session dbus-service-emacs object-path
tramp-gvfs-interface-mountoperation "askQuestion"
'tramp-gvfs-handler-askquestion)
;; The call must be asynchronously, because of the "askPassword"
;; or "askQuestion"callbacks.
(with-tramp-dbus-call-method vec nil
:session tramp-gvfs-service-daemon tramp-gvfs-path-mounttracker
tramp-gvfs-interface-mounttracker "mountLocation"
`(:struct
,(dbus-string-to-byte-array "/")
,(tramp-gvfs-mount-spec vec))
(dbus-get-unique-name :session)
:object-path object-path)
;; The call must be asynchronously, because of the "askPassword"
;; or "askQuestion"callbacks.
(with-tramp-dbus-call-method vec nil
:session tramp-gvfs-service-daemon tramp-gvfs-path-mounttracker
tramp-gvfs-interface-mounttracker "mountLocation"
(tramp-gvfs-mount-spec vec) (dbus-get-unique-name :session)
:object-path object-path)
;; We must wait, until the mount is applied. This will be
;; indicated by the "mounted" signal, i.e. the "fuse-mountpoint"
;; file property.
(with-timeout
(60
(if (zerop (length (tramp-file-name-user vec)))
;; We must wait, until the mount is applied. This will be
;; indicated by the "mounted" signal, i.e. the "fuse-mountpoint"
;; file property.
(with-timeout
(60
(if (zerop (length (tramp-file-name-user vec)))
(tramp-error
vec 'file-error
"Timeout reached mounting %s using %s" host method)
(tramp-error
vec 'file-error
"Timeout reached mounting %s using %s" host method)
(tramp-error
vec 'file-error
"Timeout reached mounting %s@%s using %s" user host method)))
(while (not (tramp-get-file-property vec "/" "fuse-mountpoint" nil))
(read-event nil nil 0.1)))
"Timeout reached mounting %s@%s using %s" user host method)))
(while (not (tramp-get-file-property vec "/" "fuse-mountpoint" nil))
(read-event nil nil 0.1)))
;; We set the connection property "started" in order to put the
;; remote location into the cache, which is helpful for further
;; completion.
(tramp-set-connection-property vec "started" t)
;; If `tramp-gvfs-handler-askquestion' has returned "No", it
;; is marked with the fuse-mountpoint "/". We shall react.
(when (string-equal
(tramp-get-file-property vec "/" "fuse-mountpoint" "") "/")
(tramp-error vec 'file-error "FUSE mount denied"))
(if (zerop (length (tramp-file-name-user vec)))
(tramp-message
vec 3 "Opening connection for %s using %s...done" host method)
(tramp-message
vec 3
"Opening connection for %s@%s using %s...done" user host method)))))
;; We set the connection property "started" in order to put the
;; remote location into the cache, which is helpful for further
;; completion.
(tramp-set-connection-property vec "started" t)))))
(defun tramp-gvfs-send-command (vec command &rest args)
"Send the COMMAND with its ARGS to connection VEC.
COMMAND is usually a command from the gvfs-* utilities.
`call-process' is applied, and its return code is returned."
(let (result)
(with-current-buffer (tramp-get-buffer vec)
(erase-buffer)
(tramp-message vec 6 "%s %s" command (mapconcat 'identity args " "))
(setq result (apply 'tramp-local-call-process command nil t nil args))
(tramp-message vec 6 "%s" (buffer-string))
result)))
;; D-Bus BLUEZ functions.

View file

@ -63,6 +63,7 @@
(autoload 'epg-context-set-progress-callback "epg")
(autoload 'epg-decrypt-string "epg")
(autoload 'epg-encrypt-string "epg")
(autoload 'epg-make-context "epg")
(autoload 'imap-hash-get "imap-hash")
(autoload 'imap-hash-make "imap-hash")
(autoload 'imap-hash-map "imap-hash")
@ -124,7 +125,6 @@
(file-executable-p . tramp-imap-handle-file-executable-p)
(file-exists-p . tramp-imap-handle-file-exists-p)
(file-local-copy . tramp-imap-handle-file-local-copy)
(file-remote-p . tramp-handle-file-remote-p)
(file-modes . tramp-handle-file-modes)
(file-name-all-completions . tramp-imap-handle-file-name-all-completions)
(file-name-as-directory . tramp-handle-file-name-as-directory)
@ -136,6 +136,8 @@
(file-ownership-preserved-p . ignore)
(file-readable-p . tramp-imap-handle-file-readable-p)
(file-regular-p . tramp-handle-file-regular-p)
(file-remote-p . tramp-handle-file-remote-p)
;; `file-selinux-context' performed by default handler.
(file-symlink-p . tramp-handle-file-symlink-p)
;; `file-truename' performed by default handler
(file-writable-p . tramp-imap-handle-file-writable-p)
@ -150,6 +152,7 @@
(make-symbolic-link . ignore)
(rename-file . tramp-imap-handle-rename-file)
(set-file-modes . ignore)
;; `set-file-selinux-context' performed by default handler.
(set-file-times . ignore) ;; tramp-imap-handle-set-file-times)
(set-visited-file-modtime . ignore)
(shell-command . ignore)
@ -168,7 +171,7 @@ Operations not mentioned here will be handled by the default Emacs primitives.")
(defgroup tramp-imap nil
"Tramp over IMAP configuration."
:version "23.2"
:group 'applications)
:group 'tramp)
(defcustom tramp-imap-subject-marker "tramp-imap-subject-marker"
"The subject marker that Tramp-IMAP will use."
@ -200,7 +203,8 @@ pass to the OPERATION."
(cons 'tramp-imap-file-name-p 'tramp-imap-file-name-handler))
(defun tramp-imap-handle-copy-file
(filename newname &optional ok-if-already-exists keep-date preserve-uid-gid)
(filename newname &optional ok-if-already-exists keep-date
preserve-uid-gid preserve-selinux-context)
"Like `copy-file' for Tramp files."
(tramp-imap-do-copy-or-rename-file
'copy filename newname ok-if-already-exists keep-date preserve-uid-gid))
@ -237,35 +241,33 @@ of `copy' and `rename'."
(t2 (and (tramp-tramp-file-p newname)
(tramp-imap-file-name-p newname))))
(when (and (not ok-if-already-exists) (file-exists-p newname))
(with-parsed-tramp-file-name (if t1 filename newname) nil
(with-parsed-tramp-file-name (if t1 filename newname) nil
(when (and (not ok-if-already-exists) (file-exists-p newname))
(tramp-error
v 'file-already-exists "File %s already exists" newname)))
v 'file-already-exists "File %s already exists" newname))
(with-parsed-tramp-file-name (if t1 filename newname) nil
(tramp-message v 0 "Transferring %s to %s..." filename newname))
(with-progress-reporter
v 0 (format "%s %s to %s"
(if (eq op 'copy) "Copying" "Renaming")
filename newname)
;; We just make a local copy of FILENAME, and write it then to
;; NEWNAME. This must be optimized, when both files are located
;; on the same IMAP server.
(with-temp-buffer
(if (and t1 t2)
;; We don't encrypt.
(with-parsed-tramp-file-name newname nil
(insert (tramp-imap-get-file filename nil))
(tramp-imap-put-file
v (current-buffer)
(tramp-imap-file-name-name v)
nil nil (nth 7 (file-attributes filename))))
;; One of them is not located on a IMAP mailbox.
(insert-file-contents filename)
(write-region (point-min) (point-max) newname)))
;; We just make a local copy of FILENAME, and write it then to
;; NEWNAME. This must be optimized, when both files are
;; located on the same IMAP server.
(with-temp-buffer
(if (and t1 t2)
;; We don't encrypt.
(with-parsed-tramp-file-name newname v1
(insert (tramp-imap-get-file filename nil))
(tramp-imap-put-file
v1 (current-buffer)
(tramp-imap-file-name-name v1)
nil nil (nth 7 (file-attributes filename))))
;; One of them is not located on a IMAP mailbox.
(insert-file-contents filename)
(write-region (point-min) (point-max) newname)))))
(with-parsed-tramp-file-name (if t1 filename newname) nil
(tramp-message v 0 "Transferring %s to %s...done" filename newname))
(when (eq op 'rename)
(delete-file filename))))
(when (eq op 'rename) (delete-file filename))))
;; TODO: revise this much
(defun tramp-imap-handle-expand-file-name (name &optional dir)
@ -501,17 +503,16 @@ SIZE MODE WEIRD INODE DEVICE)."
v 'file-error "File `%s' not found on remote host" filename)
(let ((point (point))
size data)
(tramp-message v 4 "Fetching file %s..." filename)
(insert (tramp-imap-get-file filename t))
(setq size (- (point) point))
(with-progress-reporter v 3 (format "Fetching file %s" filename)
(insert (tramp-imap-get-file filename t))
(setq size (- (point) point))
;;; TODO: handle ranges.
;;; (let ((beg (or beg (point-min)))
;;; (end (min (or end (point-max)) (point-max))))
;;; (setq size (- end beg))
;;; (buffer-substring beg end))
(goto-char point)
(tramp-message v 4 "Fetching file %s...done" filename)
(list (expand-file-name filename) size)))))
(goto-char point)
(list (expand-file-name filename) size))))))
(defun tramp-imap-handle-file-exists-p (filename)
"Like `file-exists-p' for Tramp files."
@ -550,7 +551,7 @@ SIZE MODE WEIRD INODE DEVICE)."
;; (file-exists-p (file-name-directory filename)))
(file-directory-p (file-name-directory filename)))
(defun tramp-imap-handle-delete-file (filename)
(defun tramp-imap-handle-delete-file (filename &optional trash)
"Like `delete-file' for Tramp files."
(cond
((not (file-exists-p filename)) nil)
@ -584,12 +585,12 @@ SIZE MODE WEIRD INODE DEVICE)."
v 'file-error
"Cannot make local copy of non-existing file `%s'" filename))
(let ((tmpfile (tramp-compat-make-temp-file filename)))
(tramp-message v 4 "Fetching %s to tmp file %s..." filename tmpfile)
(with-temp-buffer
(insert-file-contents filename)
(write-region (point-min) (point-max) tmpfile)
(tramp-message v 4 "Fetching %s to tmp file %s...done" filename tmpfile)
tmpfile))))
(with-progress-reporter
v 3 (format "Fetching %s to tmp file %s" filename tmpfile)
(with-temp-buffer
(insert-file-contents filename)
(write-region (point-min) (point-max) tmpfile)
tmpfile)))))
(defun tramp-imap-put-file
(vec filename-or-buffer &optional subject inode encode size)

View file

@ -164,7 +164,6 @@ See `tramp-actions-before-shell' for more info.")
(file-executable-p . tramp-smb-handle-file-exists-p)
(file-exists-p . tramp-smb-handle-file-exists-p)
(file-local-copy . tramp-smb-handle-file-local-copy)
(file-remote-p . tramp-handle-file-remote-p)
(file-modes . tramp-handle-file-modes)
(file-name-all-completions . tramp-smb-handle-file-name-all-completions)
(file-name-as-directory . tramp-handle-file-name-as-directory)
@ -176,6 +175,8 @@ See `tramp-actions-before-shell' for more info.")
(file-ownership-preserved-p . ignore)
(file-readable-p . tramp-smb-handle-file-exists-p)
(file-regular-p . tramp-handle-file-regular-p)
(file-remote-p . tramp-handle-file-remote-p)
;; `file-selinux-context' performed by default handler.
(file-symlink-p . tramp-handle-file-symlink-p)
;; `file-truename' performed by default handler.
(file-writable-p . tramp-smb-handle-file-writable-p)
@ -190,6 +191,7 @@ See `tramp-actions-before-shell' for more info.")
(make-symbolic-link . tramp-smb-handle-make-symbolic-link)
(rename-file . tramp-smb-handle-rename-file)
(set-file-modes . tramp-smb-handle-set-file-modes)
;; `set-file-selinux-context' performed by default handler.
(set-file-times . ignore)
(set-visited-file-modtime . ignore)
(shell-command . ignore)
@ -325,47 +327,48 @@ pass to the OPERATION."
'copy-directory (list dirname newname keep-date parents)))))))
(defun tramp-smb-handle-copy-file
(filename newname &optional ok-if-already-exists keep-date preserve-uid-gid)
(filename newname &optional ok-if-already-exists keep-date
preserve-uid-gid preserve-selinux-context)
"Like `copy-file' for Tramp files.
KEEP-DATE is not handled in case NEWNAME resides on an SMB server.
PRESERVE-UID-GID is completely ignored."
(setq filename (expand-file-name filename)
newname (expand-file-name newname))
(with-progress-reporter
(tramp-dissect-file-name (if (file-remote-p filename) filename newname))
0 (format "Copying %s to %s" filename newname)
(let ((tmpfile (file-local-copy filename)))
(let ((tmpfile (file-local-copy filename)))
(if tmpfile
;; Remote filename.
(condition-case err
(rename-file tmpfile newname ok-if-already-exists)
((error quit)
(delete-file tmpfile)
(signal (car err) (cdr err))))
(if tmpfile
;; Remote filename.
(condition-case err
(rename-file tmpfile newname ok-if-already-exists)
((error quit)
(delete-file tmpfile)
(signal (car err) (cdr err))))
;; Remote newname.
(when (file-directory-p newname)
(setq newname (expand-file-name
(file-name-nondirectory filename) newname)))
;; Remote newname.
(when (file-directory-p newname)
(setq newname
(expand-file-name (file-name-nondirectory filename) newname)))
(with-parsed-tramp-file-name newname nil
(when (and (not ok-if-already-exists)
(file-exists-p newname))
(tramp-error v 'file-already-exists newname))
(with-parsed-tramp-file-name newname nil
(when (and (not ok-if-already-exists)
(file-exists-p newname))
(tramp-error v 'file-already-exists newname))
;; We must also flush the cache of the directory, because
;; `file-attributes' reads the values from there.
(tramp-flush-file-property v (file-name-directory localname))
(tramp-flush-file-property v localname)
(unless (tramp-smb-get-share v)
(tramp-error
v 'file-error "Target `%s' must contain a share name" newname))
(tramp-message v 0 "Copying file %s to file %s..." filename newname)
(if (tramp-smb-send-command
v (format "put \"%s\" \"%s\""
filename (tramp-smb-get-localname v)))
(tramp-message
v 0 "Copying file %s to file %s...done" filename newname)
(tramp-error v 'file-error "Cannot copy `%s'" filename)))))
;; We must also flush the cache of the directory, because
;; `file-attributes' reads the values from there.
(tramp-flush-file-property v (file-name-directory localname))
(tramp-flush-file-property v localname)
(unless (tramp-smb-get-share v)
(tramp-error
v 'file-error "Target `%s' must contain a share name" newname))
(unless (tramp-smb-send-command
v (format "put \"%s\" \"%s\""
filename (tramp-smb-get-localname v)))
(tramp-error v 'file-error "Cannot copy `%s'" filename))))))
;; KEEP-DATE handling.
(when keep-date (set-file-times newname (nth 5 (file-attributes filename)))))
@ -401,7 +404,7 @@ PRESERVE-UID-GID is completely ignored."
(tramp-error
v 'file-error "%s `%s'" (match-string 0) directory))))))
(defun tramp-smb-handle-delete-file (filename)
(defun tramp-smb-handle-delete-file (filename &optional trash)
"Like `delete-file' for Tramp files."
(setq filename (expand-file-name filename))
(when (file-exists-p filename)
@ -602,15 +605,15 @@ PRESERVE-UID-GID is completely ignored."
v 'file-error
"Cannot make local copy of non-existing file `%s'" filename))
(let ((tmpfile (tramp-compat-make-temp-file filename)))
(tramp-message v 4 "Fetching %s to tmp file %s..." filename tmpfile)
(if (tramp-smb-send-command
v (format "get \"%s\" \"%s\"" (tramp-smb-get-localname v) tmpfile))
(tramp-message
v 4 "Fetching %s to tmp file %s...done" filename tmpfile)
;; Oops, an error. We shall cleanup.
(delete-file tmpfile)
(tramp-error
v 'file-error "Cannot make local copy of file `%s'" filename))
(with-progress-reporter
v 3 (format "Fetching %s to tmp file %s" filename tmpfile)
(unless (tramp-smb-send-command
v (format "get \"%s\" \"%s\""
(tramp-smb-get-localname v) tmpfile))
;; Oops, an error. We shall cleanup.
(delete-file tmpfile)
(tramp-error
v 'file-error "Cannot make local copy of file `%s'" filename)))
tmpfile)))
;; This function should return "foo/" for directories and "bar" for
@ -847,38 +850,39 @@ target of the symlink differ."
"Like `rename-file' for Tramp files."
(setq filename (expand-file-name filename)
newname (expand-file-name newname))
(with-progress-reporter
(tramp-dissect-file-name (if (file-remote-p filename) filename newname))
0 (format "Renaming %s to %s" filename newname)
(let ((tmpfile (file-local-copy filename)))
(let ((tmpfile (file-local-copy filename)))
(if tmpfile
;; Remote filename.
(condition-case err
(rename-file tmpfile newname ok-if-already-exists)
((error quit)
(delete-file tmpfile)
(signal (car err) (cdr err))))
(if tmpfile
;; Remote filename.
(condition-case err
(rename-file tmpfile newname ok-if-already-exists)
((error quit)
(delete-file tmpfile)
(signal (car err) (cdr err))))
;; Remote newname.
(when (file-directory-p newname)
(setq newname (expand-file-name
(file-name-nondirectory filename) newname)))
;; Remote newname.
(when (file-directory-p newname)
(setq newname (expand-file-name
(file-name-nondirectory filename) newname)))
(with-parsed-tramp-file-name newname nil
(when (and (not ok-if-already-exists)
(file-exists-p newname))
(tramp-error v 'file-already-exists newname))
;; We must also flush the cache of the directory, because
;; `file-attributes' reads the values from there.
(tramp-flush-file-property v (file-name-directory localname))
(tramp-flush-file-property v localname)
(tramp-message v 0 "Copying file %s to file %s..." filename newname)
(if (tramp-smb-send-command
v (format "put %s \"%s\"" filename (tramp-smb-get-localname v)))
(tramp-message
v 0 "Copying file %s to file %s...done" filename newname)
(tramp-error v 'file-error "Cannot rename `%s'" filename)))))
(with-parsed-tramp-file-name newname nil
(when (and (not ok-if-already-exists)
(file-exists-p newname))
(tramp-error v 'file-already-exists newname))
;; We must also flush the cache of the directory, because
;; `file-attributes' reads the values from there.
(tramp-flush-file-property v (file-name-directory localname))
(tramp-flush-file-property v localname)
(unless (tramp-smb-send-command
v (format "put %s \"%s\""
filename (tramp-smb-get-localname v)))
(tramp-error v 'file-error "Cannot rename `%s'" filename)))))
(delete-file filename))
(delete-file filename)))
(defun tramp-smb-handle-set-file-modes (filename mode)
"Like `set-file-modes' for Tramp files."
@ -935,14 +939,14 @@ errors for shares like \"C$/\", which are common in Microsoft Windows."
(list start end tmpfile append 'no-message lockname confirm)
(list start end tmpfile append 'no-message lockname)))
(tramp-message v 5 "Writing tmp file %s to file %s..." tmpfile filename)
(unwind-protect
(if (tramp-smb-send-command
v (format "put %s \"%s\"" tmpfile (tramp-smb-get-localname v)))
(tramp-message
v 5 "Writing tmp file %s to file %s...done" tmpfile filename)
(tramp-error v 'file-error "Cannot write `%s'" filename))
(delete-file tmpfile))
(with-progress-reporter
v 3 (format "Moving tmp file %s to %s" tmpfile filename)
(unwind-protect
(unless (tramp-smb-send-command
v (format "put %s \"%s\""
tmpfile (tramp-smb-get-localname v)))
(tramp-error v 'file-error "Cannot write `%s'" filename))
(delete-file tmpfile)))
(unless (equal curbuf (current-buffer))
(tramp-error
@ -1299,60 +1303,57 @@ connection if a previous connection has died for some reason."
(setq args (append args (list "-s" tramp-smb-conf))))
;; OK, let's go.
(tramp-message
vec 3 "Opening connection for //%s%s/%s..."
(if (not (zerop (length user))) (concat user "@") "")
host (or share ""))
(with-progress-reporter
vec 3
(format "Opening connection for //%s%s/%s"
(if (not (zerop (length user))) (concat user "@") "")
host (or share ""))
(let* ((coding-system-for-read nil)
(process-connection-type tramp-process-connection-type)
(p (let ((default-directory
(tramp-compat-temporary-file-directory)))
(apply #'start-process
(tramp-buffer-name vec) (tramp-get-buffer vec)
tramp-smb-program args))))
(let* ((coding-system-for-read nil)
(process-connection-type tramp-process-connection-type)
(p (let ((default-directory
(tramp-compat-temporary-file-directory)))
(apply #'start-process
(tramp-buffer-name vec) (tramp-get-buffer vec)
tramp-smb-program args))))
(tramp-message
vec 6 "%s" (mapconcat 'identity (process-command p) " "))
(tramp-set-process-query-on-exit-flag p nil)
(tramp-message
vec 6 "%s" (mapconcat 'identity (process-command p) " "))
(tramp-set-process-query-on-exit-flag p nil)
;; Set variables for computing the prompt for reading password.
(setq tramp-current-method tramp-smb-method
tramp-current-user user
tramp-current-host host)
;; Set variables for computing the prompt for reading password.
(setq tramp-current-method tramp-smb-method
tramp-current-user user
tramp-current-host host)
;; Play login scenario.
(tramp-process-actions
p vec
(if share
tramp-smb-actions-with-share
tramp-smb-actions-without-share))
;; Play login scenario.
(tramp-process-actions
p vec
(if share
tramp-smb-actions-with-share
tramp-smb-actions-without-share))
;; Check server version.
(with-current-buffer (tramp-get-connection-buffer vec)
(goto-char (point-min))
(search-forward-regexp
"Domain=\\[[^]]*\\] OS=\\[[^]]*\\] Server=\\[[^]]*\\]" nil t)
(let ((smbserver-version (match-string 0)))
(unless
(string-equal
smbserver-version
(tramp-get-connection-property
vec "smbserver-version" smbserver-version))
(tramp-flush-directory-property vec "")
(tramp-flush-connection-property vec))
(tramp-set-connection-property
vec "smbserver-version" smbserver-version)))
;; Check server version.
(with-current-buffer (tramp-get-connection-buffer vec)
(goto-char (point-min))
(search-forward-regexp
"Domain=\\[[^]]*\\] OS=\\[[^]]*\\] Server=\\[[^]]*\\]" nil t)
(let ((smbserver-version (match-string 0)))
(unless
(string-equal
smbserver-version
(tramp-get-connection-property
vec "smbserver-version" smbserver-version))
(tramp-flush-directory-property vec "")
(tramp-flush-connection-property vec))
(tramp-set-connection-property
vec "smbserver-version" smbserver-version)))
;; Set chunksize. Otherwise, `tramp-send-string' might
;; try it itself.
(tramp-set-connection-property p "smb-share" share)
(tramp-set-connection-property p "chunksize" tramp-chunksize)
(tramp-message
vec 3 "Opening connection for //%s%s/%s...done"
(if (not (zerop (length user))) (concat user "@") "")
host (or share ""))))))))
;; Set chunksize. Otherwise, `tramp-send-string' might
;; try it itself.
(tramp-set-connection-property p "smb-share" share)
(tramp-set-connection-property
p "chunksize" tramp-chunksize))))))))
;; We don't use timeouts. If needed, the caller shall wrap around.
(defun tramp-smb-wait-for-output (vec)

View file

@ -1,7 +1,7 @@
;;; tramp-uu.el --- uuencode in Lisp
;; Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007,
;; 2008, 2009, 2010 Free Software Foundation, Inc.
;; Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008,
;; 2009, 2010 Free Software Foundation, Inc.
;; Author: Kai Großjohann <kai.grossjohann@gmx.net>
;; Keywords: comm, terminals

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,8 @@
;;; trampver.el --- Transparent Remote Access, Multiple Protocol
;;; lisp/trampver.el. Generated from trampver.el.in by configure.
;; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008,
;; 2009, 2010 Free Software Foundation, Inc.
;; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009,
;; 2010 Free Software Foundation, Inc.
;; Author: Kai Großjohann <kai.grossjohann@gmx.net>
;; Keywords: comm, processes
@ -24,19 +24,20 @@
;;; Code:
;; In the Tramp CVS repository, the version numer and the bug report address
;; are auto-frobbed from configure.ac, so you should edit that file and run
;; "autoconf && ./configure" to change them. (X)Emacs version check is defined
;; in macro AC_EMACS_INFO of aclocal.m4; should be changed only there.
;; In the Tramp CVS repository, the version number and the bug report
;; address are auto-frobbed from configure.ac, so you should edit that
;; file and run "autoconf && ./configure" to change them. (X)Emacs
;; version check is defined in macro AC_EMACS_INFO of aclocal.m4;
;; should be changed only there.
(defconst tramp-version "2.1.18-23.2"
(defconst tramp-version "2.1.19"
"This version of Tramp.")
(defconst tramp-bug-report-address "tramp-devel@gnu.org"
"Email address to send bug reports to.")
;; Check for (X)Emacs version.
(let ((x (if (or (< emacs-major-version 21) (and (featurep 'xemacs) (= emacs-major-version 21) (< emacs-minor-version 4))) (format "Tramp 2.1.18-pre is not fit for %s" (when (string-match "^.*$" (emacs-version)) (match-string 0 (emacs-version)))) "ok")))
(let ((x (if (or (>= emacs-major-version 22) (and (featurep 'xemacs) (= emacs-major-version 21) (>= emacs-minor-version 4))) "ok" (format "Tramp 2.1.19 is not fit for %s" (when (string-match "^.*$" (emacs-version)) (match-string 0 (emacs-version)))))))
(unless (string-match "\\`ok\\'" x) (error "%s" x)))
(provide 'trampver)