summaryrefslogtreecommitdiff
path: root/lisp/net
diff options
context:
space:
mode:
authorKai Großjohann <kgrossjo@eu.uu.net>2003-02-05 21:03:36 +0000
committerKai Großjohann <kgrossjo@eu.uu.net>2003-02-05 21:03:36 +0000
commit8daea7fc4639db177fdaf1a5d0a636edcb974280 (patch)
treea7cdae6af3cd847bae31cae656a514dfb6c6a1bc /lisp/net
parente37344094affb7e028bf2415e834b554209ba812 (diff)
downloademacs-8daea7fc4639db177fdaf1a5d0a636edcb974280.tar.gz
2003-02-05 Kai Gro�ohann <kai.grossjohann@uni-duisburg.de>
Version 2.0.29 released. * net/tramp.el (tramp-send-region): Protect against tramp-chunksize being nil. 2003-02-04 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-handle-directory-file-name): Handle the case PATH is "". (tramp-completion-handle-file-name-all-completions): Define `tramp-current-user' locally. See `tramp-parse-passwd'. (tramp-parse-passwd): For su-alike methods it would be desirable to return "root@localhost" as default. Unfortunately, we have no information whether any user name has been typed already. So we (mis-)use tramp-current-user as indication, assuming it is set in `tramp-completion-handle-file-name-all-completions'. (tramp-send-region): Handle the case `tramp-chunksize' is equal 0. I did it accidently. Infinite loop ... * net/tramp-ftp.el (top-level): eval-after-load "ange-ftp" '(tramp-disable-ange-ftp). Suggested by Kai. (tramp-ftp-file-name-handler): `tramp-disable-ange-ftp' not needed any longer. * net/tramp-smb.el (tramp-smb-file-name-handler-alist): Apply `tramp-handle-directory-file-name' in order to profit from Kai's yesterday changes. 2003-02-03 Kai Gro�ohann <kai.grossjohann@uni-duisburg.de> * net/tramp.el (tramp-chunksize): Set default to 500 as workaround for some ssh connections. (tramp-handle-directory-file-name): New implementation. Not sure if it works. 2003-01-28 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-get-device): `tramp-make-tramp-file-name' must not be called with NIL path. It fails in case of multi-method. 2003-01-27 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-file-name-for-operation): Apply `expand-file-name' for relative file names only. Otherwise there might be problems if the default directory is another Tramp directory as the directory the file is based on. (tramp-find-foreign-file-name-handler): Check whether FILENAME is a Tramp file name. It isn't if it comes from an expanded file name (like "/xx:yy//zz"). 2003-01-25 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-devices): New variable. Keeps virtual device numbers. Devices must distinguish physical file systems. The device numbers provided by "lstat" aren't unique, because we operate on different hosts. So we use virtual device numbers, generated by `tramp-get-device'. Both Ange-FTP and EFS use device number -1. In order to be different, we use device number (-1 x), whereby "x" is unique for a given (multi-method method user host). Suggested by Kai. (tramp-perl-file-attributes): Always return device number -1. There will be a virtual device number set in `tramp-handle-file-attributes', which replaces this one. (tramp-handle-file-attributes): Set virtual device number. (tramp-get-device): New function. Returns the virtual device number. If it doesn't exist, generate a new one. (tramp-handle-file-regular-p): Use Emacs file name primitives instead of calling tramp-handle-* equivalents directly. Needed for tramp-smb. * net/tramp-smb.el (tramp-smb-devices, tramp-smb-get-device): Removed. Functionality moved to tramp.el. (tramp-smb-handle-file-attributes): Apply `tramp-get-device'. ATIME and CTIME are (0 0) now (= "don't know"), which is more honest. (tramp-smb-handle-make-directory): Use Emacs file name primitives instead of calling tramp-smb-handle-* equivalents directly. (tramp-smb-read-file-entry): Return size as a number but a string. 2003-01-24 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-completion-function-alist-ssh): Add parsing of "/etc/ssh_config" and "~/.ssh/config". Suggested by Kai. (tramp-completion-function-alist, tramp-set-completion-function): Doc string update. (tramp-parse-sconfig, tramp-parse-sconfig-group): New functions. Provide parsing of "~/.ssh/config" style files. 2003-01-21 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-completion-handle-expand-file-name): Apply `tramp-drop-volume-letter'. Otherwise, there are problems on W32 systems. 2003-01-21 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp-smb.el (tramp-smb-get-device, tramp-smb-get-inode): New functions. Device number and inode number don't exist for SMB files. Therefore we must generate virtual ones. (tramp-smb-devices, tramp-smb-inodes): New variables. Keep generated virtual device numbers and inodes numbers for SMB files. (tramp-smb-handle-file-attributes): Apply them. 2003-01-14 Kai Gro�ohann <kai.grossjohann@uni-duisburg.de> * net/tramp.el (tramp-md5-function): Require md5 before checking function md5. If using md5-encode, put wrapper around it that converts vector of bytes to ascii text. 2003-01-13 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-completion-mode): Perform check (integerp last-input-event) before (event-modifiers last-input-event) - there might be problems if `last-input-event' is a mouse event. 2003-01-12 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-parse-rhosts, tramp-parse-shosts) (tramp-parse-hosts, tramp-parse-passwd, tramp-parse-netrc): Use `file-readable-p' instead of `file-exists-p'. Otherwise these functions might block. Reported by <kin@neoscale.com>. 2003-01-02 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp-ftp.el (top-level): Defaults for `tramp-default-method-alist' must be a list. * net/tramp-smb.el (top-level): Defaults for `tramp-default-method-alist' must be a list. 2003-01-02 Kai Gro�ohann <kai.grossjohann@uni-duisburg.de> * net/tramp.el (top-level): Avoid byte-compiler warnings of unused variables if the byte-compiler supports this. This is for the with-parsed-tramp-file-name macro which is wont to produce such stuff.
Diffstat (limited to 'lisp/net')
-rw-r--r--lisp/net/tramp-ftp.el12
-rw-r--r--lisp/net/tramp-smb.el44
-rw-r--r--lisp/net/tramp.el203
3 files changed, 185 insertions, 74 deletions
diff --git a/lisp/net/tramp-ftp.el b/lisp/net/tramp-ftp.el
index 88c395ab381..04f8bbeb323 100644
--- a/lisp/net/tramp-ftp.el
+++ b/lisp/net/tramp-ftp.el
@@ -1,6 +1,6 @@
;;; tramp-ftp.el --- Tramp convenience functions for Ange-FTP and EFS -*- coding: iso-8859-1; -*-
-;; Copyright (C) 2002 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2003 Free Software Foundation, Inc.
;; Author: Michael Albinus <Michael.Albinus@alcatel.de>
;; Keywords: comm, processes
@@ -25,7 +25,7 @@
;;; Commentary:
;; Convenience functions for calling Ange-FTP (and maybe EFS, later on)
-;; from Tramp. Most of them are displaced from tramp.el
+;; from Tramp. Most of them are displaced from tramp.el.
;;; Code:
@@ -64,6 +64,7 @@ present for backward compatibility."
(setq file-name-handler-alist
(delete a1 (delete a2 file-name-handler-alist)))))
(tramp-disable-ange-ftp)
+(eval-after-load "ange-ftp" '(tramp-disable-ange-ftp))
;; Define FTP method ...
(defcustom tramp-ftp-method "ftp"
@@ -76,9 +77,9 @@ present for backward compatibility."
;; Add some defaults for `tramp-default-method-alist'
(add-to-list 'tramp-default-method-alist
- '("\\`ftp\\." "" tramp-ftp-method))
+ (list "\\`ftp\\." "" tramp-ftp-method))
(add-to-list 'tramp-default-method-alist
- '("" "\\`\\(anonymous\\|ftp\\)\\'" tramp-ftp-method))
+ (list "" "\\`\\(anonymous\\|ftp\\)\\'" tramp-ftp-method))
;; Add completion function for FTP method.
(unless (memq system-type '(windows-nt))
@@ -92,8 +93,7 @@ First arg specifies the OPERATION, second arg is a list of arguments to
pass to the OPERATION."
(save-match-data
(or (boundp 'ange-ftp-name-format)
- (and (require 'ange-ftp)
- (tramp-disable-ange-ftp)))
+ (require 'ange-ftp))
(let* ((ange-ftp-name-format
(list (nth 0 tramp-file-name-structure)
(nth 3 tramp-file-name-structure)
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index eebd84a2673..0df9ddf668a 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -1,6 +1,6 @@
;;; tramp-smb.el --- Tramp access functions for SMB servers -*- coding: iso-8859-1; -*-
-;; Copyright (C) 2002 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2003 Free Software Foundation, Inc.
;; Author: Michael Albinus <Michael.Albinus@alcatel.de>
;; Keywords: comm, processes
@@ -50,7 +50,7 @@
;; Add a default for `tramp-default-method-alist'. Rule: If there is
;; a domain in USER, it must be the SMB method.
(add-to-list 'tramp-default-method-alist
- '("%" "" tramp-smb-method))
+ (list "%" "" tramp-smb-method))
;; Add completion function for SMB method.
(tramp-set-completion-function
@@ -108,6 +108,9 @@ Will be changed by corresponding `process-sentinel'.
This variable is local to each buffer.")
(make-variable-buffer-local 'tramp-smb-process-running)
+(defvar tramp-smb-inodes nil
+ "Keeps virtual inodes numbers for SMB files.")
+
;; New handlers should be added here.
(defconst tramp-smb-file-name-handler-alist
'(
@@ -118,7 +121,7 @@ This variable is local to each buffer.")
(delete-directory . tramp-smb-handle-delete-directory)
(delete-file . tramp-smb-handle-delete-file)
;; `diff-latest-backup-file' performed by default handler
- ;; `directory-file-name' performed by default handler
+ (directory-file-name . tramp-handle-directory-file-name)
(directory-files . tramp-smb-handle-directory-files)
(directory-files-and-attributes . tramp-smb-handle-directory-files-and-attributes)
(dired-call-process . tramp-smb-not-handled)
@@ -342,7 +345,10 @@ rather than as numbers."
(file (tramp-smb-get-path path nil))
(entries (tramp-smb-get-file-entries user host share file))
(entry (and entries
- (assoc (file-name-nondirectory file) entries))))
+ (assoc (file-name-nondirectory file) entries)))
+ (inode (tramp-smb-get-inode share file))
+ (device (tramp-get-device nil tramp-smb-method user host)))
+
; check result
(when entry
(list (and (string-match "d" (nth 1 entry))
@@ -350,14 +356,14 @@ rather than as numbers."
-1 ;1 link count
-1 ;2 uid
-1 ;3 gid
- (nth 3 entry) ;4 atime
+ '(0 0) ;4 atime
(nth 3 entry) ;5 mtime
- (nth 3 entry) ;6 ctime
+ '(0 0) ;6 ctime
(nth 2 entry) ;7 size
(nth 1 entry) ;8 mode
nil ;9 gid weird
- -1 ;10 inode number
- -1)))))) ;11 file system number
+ inode ;10 inode number
+ device)))))) ;11 file system number
(defun tramp-smb-handle-file-directory-p (filename)
"Like `file-directory-p' for tramp files."
@@ -532,7 +538,7 @@ WILDCARD and FULL-DIRECTORY-P are not handled."
(make-directory ldir parents))
;; Just do it
(when (file-directory-p ldir)
- (tramp-smb-handle-make-directory-internal dir))
+ (make-directory-internal dir))
(unless (file-directory-p dir)
(error "Couldn't make directory %s" dir))))))
@@ -822,8 +828,10 @@ Result is the list (PATH MODE SIZE MTIME)."
;; size
(if (string-match "\\([0-9]+\\)$" line)
- (setq size (match-string 1 line)
- line (substring line 0 (- (max 8 (1+ (length size))))))
+ (setq
+ size (string-to-number (match-string 1 line))
+ line (substring
+ line 0 (- (max 8 (1+ (length (match-string 1 line)))))))
(return))
;; mode
@@ -854,6 +862,20 @@ Result is the list (PATH MODE SIZE MTIME)."
'(0 0)))
(list path mode size mtime))))
+;; Inodes don't exist for SMB files. Therefore we must generate virtual ones.
+;; Used in `find-buffer-visiting'.
+;; The method applied might be not so efficient (Ange-FTP uses hashes). But
+;; performance isn't the major issue given that file transfer will take time.
+
+(defun tramp-smb-get-inode (share file)
+ "Returns the virtual inode number.
+If it doesn't exist, generate a new one."
+ (let ((string (concat share "/" (directory-file-name file))))
+ (unless (assoc string tramp-smb-inodes)
+ (add-to-list 'tramp-smb-inodes
+ (list string (length tramp-smb-inodes))))
+ (nth 1 (assoc string tramp-smb-inodes))))
+
;; Connection functions
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 1efc50f0d6b..b402dd673bd 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -1,6 +1,6 @@
;;; tramp.el --- Transparent Remote Access, Multiple Protocol -*- coding: iso-8859-1; -*-
-;; Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
;; Author: Kai.Grossjohann@CS.Uni-Dortmund.DE
;; Keywords: comm, processes
@@ -72,7 +72,7 @@
;; In the Tramp CVS repository, the version numer is auto-frobbed from
;; the Makefile, so you should edit the top-level Makefile to change
;; the version number.
-(defconst tramp-version "2.0.28"
+(defconst tramp-version "2.0.29"
"This version of tramp.")
(defconst tramp-bug-report-address "tramp-devel@mail.freesoftware.fsf.org"
@@ -125,6 +125,12 @@
(unless (boundp 'custom-print-functions)
(defvar custom-print-functions nil)) ; not autoloaded before Emacs 20.4
+;; Avoid bytecompiler warnings if the byte-compiler supports this.
+;; Currently, XEmacs supports this.
+(eval-when-compile
+ (when (fboundp 'byte-compiler-options)
+ (byte-compiler-options (warnings (- unused-vars)))))
+
;; XEmacs is distributed with few Lisp packages. Further packages are
;; installed using EFS. If we use a unified filename format, then
;; Tramp is required in addition to EFS. (But why can't Tramp just
@@ -667,12 +673,14 @@ See `tramp-methods' for a list of possibilities for METHOD."
;; Default values for non-Unices seeked
(defconst tramp-completion-function-alist-ssh
(unless (memq system-type '(windows-nt))
- '((tramp-parse-rhosts "/etc/hosts.equiv")
- (tramp-parse-rhosts "/etc/shosts.equiv")
- (tramp-parse-shosts "/etc/ssh_known_hosts")
- (tramp-parse-rhosts "~/.rhosts")
- (tramp-parse-rhosts "~/.shosts")
- (tramp-parse-shosts "~/.ssh/known_hosts")))
+ '((tramp-parse-rhosts "/etc/hosts.equiv")
+ (tramp-parse-rhosts "/etc/shosts.equiv")
+ (tramp-parse-shosts "/etc/ssh_known_hosts")
+ (tramp-parse-sconfig "/etc/ssh_config")
+ (tramp-parse-rhosts "~/.rhosts")
+ (tramp-parse-rhosts "~/.shosts")
+ (tramp-parse-shosts "~/.ssh/known_hosts")
+ (tramp-parse-sconfig "~/.ssh/config")))
"Default list of (FUNCTION FILE) pairs to be examined for ssh methods."
)
@@ -721,11 +729,12 @@ Each NAME stands for a remote access method. Each PAIR is of the form
\(FUNCTION FILE). FUNCTION is responsible to extract user names and host
names from FILE for completion. The following predefined FUNCTIONs exists:
- * `tramp-parse-rhosts' for \".rhosts\" like files,
- * `tramp-parse-shosts' for \"ssh_known_hosts\" like files,
- * `tramp-parse-hosts' for \"/etc/hosts\" like files, and
- * `tramp-parse-passwd' for \"/etc/passwd\" like files.
- * `tramp-parse-netrc' for \".netrc\" like files.
+ * `tramp-parse-rhosts' for \"~/.rhosts\" like files,
+ * `tramp-parse-shosts' for \"~/.ssh/known_hosts\" like files,
+ * `tramp-parse-sconfig' for \"~/.ssh/config\" like files,
+ * `tramp-parse-hosts' for \"/etc/hosts\" like files, and
+ * `tramp-parse-passwd' for \"/etc/passwd\" like files.
+ * `tramp-parse-netrc' for \"~/.netrc\" like files.
FUNCTION can also see a customer defined function. For more details see
the info pages."
@@ -1250,8 +1259,9 @@ the visited file modtime.")
(make-variable-buffer-local 'tramp-buffer-file-attributes)
(defvar tramp-md5-function
- (cond ((fboundp 'md5) 'md5)
- ((and (require 'md5) (fboundp 'md5-encode)) 'md5-encode)
+ (cond ((and (require 'md5) (fboundp 'md5)) 'md5)
+ ((fboundp 'md5-encode)
+ (lambda (x) (base64-encode-string (md5-encode x))))
(t (error "Coulnd't find an `md5' function")))
"Function to call for running the MD5 algorithm.")
@@ -1396,16 +1406,18 @@ some systems don't, and for them we have this shell function.")
;; output. If you are hacking on this, note that you get *no* output
;; unless this spits out a complete line, including the '\n' at the
;; end.
+;; The device number is returned as "-1", because there will be a virtual
+;; device number set in `tramp-handle-file-attributes'
(defconst tramp-perl-file-attributes "\
$f = $ARGV[0];
@s = lstat($f);
if (($s[2] & 0170000) == 0120000) { $l = readlink($f); $l = \"\\\"$l\\\"\"; }
elsif (($s[2] & 0170000) == 040000) { $l = \"t\"; }
else { $l = \"nil\" };
-printf(\"(%s %u %d %d (%u %u) (%u %u) (%u %u) %u %u t (%u . %u) (%u %u))\\n\",
+printf(\"(%s %u %d %d (%u %u) (%u %u) (%u %u) %u %u t (%u . %u) -1)\\n\",
$l, $s[3], $s[4], $s[5], $s[8] >> 16 & 0xffff, $s[8] & 0xffff,
$s[9] >> 16 & 0xffff, $s[9] & 0xffff, $s[10] >> 16 & 0xffff, $s[10] & 0xffff,
-$s[7], $s[2], $s[1] >> 16 & 0xffff, $s[1] & 0xffff, $s[0] >> 16 & 0xffff, $s[0] & 0xffff);"
+$s[7], $s[2], $s[1] >> 16 & 0xffff, $s[1] & 0xffff);"
"Perl script to produce output suitable for use with `file-attributes'
on the remote file system.")
@@ -1726,13 +1738,15 @@ FUNCTION-LIST is a list of entries of the form (FUNCTION FILE).
The FUNCTION is intended to parse FILE according its syntax.
It might be a predefined FUNCTION, or a user defined FUNCTION.
Predefined FUNCTIONs are `tramp-parse-rhosts', `tramp-parse-shosts',
-`tramp-parse-hosts', and `tramp-parse-passwd'.
+`tramp-parse-sconfig',`tramp-parse-hosts', `tramp-parse-passwd',
+and `tramp-parse-netrc'.
+
Example:
(tramp-set-completion-function
\"ssh\"
- '((tramp-parse-shosts \"/etc/ssh_known_hosts\")
- (tramp-parse-shosts \"~/.ssh/known_hosts\")))"
+ '((tramp-parse-sconfig \"/etc/ssh_config\")
+ (tramp-parse-sconfig \"~/.ssh/config\")))"
(let ((v (cdr (assoc method tramp-completion-function-alist))))
(if v (setcdr v function-list)
@@ -1944,6 +1958,14 @@ target of the symlink differ."
(tramp-get-file-exists-command multi-method method user host)
(tramp-shell-quote-argument path)))))))
+;; Devices must distinguish physical file systems. The device numbers
+;; provided by "lstat" aren't unique, because we operate on different hosts.
+;; So we use virtual device numbers, generated by Tramp. Both Ange-FTP and
+;; EFS use device number "-1". In order to be different, we use device number
+;; (-1 x), whereby "x" is unique for a given (multi-method method user host).
+(defvar tramp-devices nil
+ "Keeps virtual device numbers.")
+
;; CCC: This should check for an error condition and signal failure
;; when something goes wrong.
;; Daniel Pittman <daniel@danann.net>
@@ -1962,10 +1984,12 @@ rather than as numbers."
multi-method method user host path nonnumeric))
(setq result
(tramp-handle-file-attributes-with-ls
- multi-method method user host path nonnumeric))))))
+ multi-method method user host path nonnumeric)))
+ ;; set virtual device number
+ (setcar (nthcdr 11 result)
+ (tramp-get-device multi-method method user host)))))
result))
-
(defun tramp-handle-file-attributes-with-ls
(multi-method method user host path &optional nonnumeric)
"Implement `file-attributes' for tramp files using the ls(1) command."
@@ -2047,8 +2071,8 @@ rather than as numbers."
nil ;hm?
;; 10. inode number.
res-inode
- ;; 11. Device number.
- -1 ;hm?
+ ;; 11. Device number. Will be replaced by a virtual device number.
+ -1
)))
(defun tramp-handle-file-attributes-with-perl
@@ -2071,6 +2095,15 @@ is initially created and is kept cached by the remote shell."
(tramp-file-mode-from-int (nth 8 result)))
result))
+(defun tramp-get-device (multi-method method user host)
+ "Returns the virtual device number.
+If it doesn't exist, generate a new one."
+ (let ((string (tramp-make-tramp-file-name multi-method method user host "")))
+ (unless (assoc string tramp-devices)
+ (add-to-list 'tramp-devices
+ (list string (length tramp-devices))))
+ (list -1 (nth 1 (assoc string tramp-devices)))))
+
(defun tramp-handle-set-visited-file-modtime (&optional time-list)
"Like `set-visited-file-modtime' for tramp files."
(unless (buffer-file-name)
@@ -2261,8 +2294,8 @@ if the remote host can't provide the modtime."
(defun tramp-handle-file-regular-p (filename)
"Like `file-regular-p' for tramp files."
(with-parsed-tramp-file-name filename nil
- (and (tramp-handle-file-exists-p filename)
- (eq ?- (aref (nth 8 (tramp-handle-file-attributes filename)) 0)))))
+ (and (file-exists-p filename)
+ (eq ?- (aref (nth 8 (file-attributes filename)) 0)))))
(defun tramp-handle-file-symlink-p (filename)
"Like `file-symlink-p' for tramp files."
@@ -2299,17 +2332,30 @@ if the remote host can't provide the modtime."
;; (substring directory 0 (- (length directory) 1))
;; directory))
-;; Philippe Troin <phil@fifi.org>
+;; ;; Philippe Troin <phil@fifi.org>
+;; (defun tramp-handle-directory-file-name (directory)
+;; "Like `directory-file-name' for tramp files."
+;; (with-parsed-tramp-file-name directory nil
+;; (let ((directory-length-1 (1- (length directory))))
+;; (save-match-data
+;; (if (and (eq (aref directory directory-length-1) ?/)
+;; (eq (string-match tramp-file-name-regexp directory) 0)
+;; (/= (match-end 0) directory-length-1))
+;; (substring directory 0 directory-length-1)
+;; directory)))))
+
(defun tramp-handle-directory-file-name (directory)
"Like `directory-file-name' for tramp files."
+ ;; If path component of filename is "/", leave it unchanged.
+ ;; Otherwise, remove any trailing slash from path component.
+ ;; Method, host, etc, are unchanged. Does it make sense to try
+ ;; to avoid parsing the filename?
(with-parsed-tramp-file-name directory nil
- (let ((directory-length-1 (1- (length directory))))
- (save-match-data
- (if (and (eq (aref directory directory-length-1) ?/)
- (eq (string-match tramp-file-name-regexp directory) 0)
- (/= (match-end 0) directory-length-1))
- (substring directory 0 directory-length-1)
- directory)))))
+ (if (and (not (zerop (length path)))
+ (eq (aref path (1- (length path))) ?/)
+ (not (string= path "/")))
+ (substring directory 0 -1)
+ directory)))
;; Directory listings.
@@ -3345,7 +3391,9 @@ ARGS are the arguments OPERATION has been called with."
'dired-shell-unhandle-file-name 'dired-uucode-file
'insert-file-contents-literally 'recover-file
'vm-imap-check-mail 'vm-pop-check-mail 'vm-spool-check-mail))
- (expand-file-name (nth 0 args)))
+ (if (file-name-absolute-p (nth 0 args))
+ (nth 0 args)
+ (expand-file-name (nth 0 args))))
; FILE DIRECTORY resp FILE1 FILE2
((member operation
(list 'add-name-to-file 'copy-file 'expand-file-name
@@ -3380,11 +3428,12 @@ ARGS are the arguments OPERATION has been called with."
(defun tramp-find-foreign-file-name-handler (filename)
"Return foreign file name handler if exists."
- (let (elt res)
- (dolist (elt tramp-foreign-file-name-handler-alist res)
- (when (funcall (car elt) filename)
- (setq res (cdr elt))))
- res))
+ (when (tramp-tramp-file-p filename)
+ (let (elt res)
+ (dolist (elt tramp-foreign-file-name-handler-alist res)
+ (when (funcall (car elt) filename)
+ (setq res (cdr elt))))
+ res)))
;; Main function.
;;;###autoload
@@ -3523,8 +3572,8 @@ necessary anymore."
file)
(member (match-string 1 file) (mapcar 'car tramp-methods)))
((or (equal last-input-event 'tab)
- (and (not (event-modifiers last-input-event))
- (integerp last-input-event)
+ (and (integerp last-input-event)
+ (not (event-modifiers last-input-event))
(or (char-equal last-input-event ?\?)
(char-equal last-input-event ?\t) ; handled by 'tab already?
(char-equal last-input-event ?\ ))))
@@ -3578,6 +3627,7 @@ necessary anymore."
(host (tramp-file-name-host car))
(path (tramp-file-name-path car))
(m (tramp-find-method multi-method method user host))
+ (tramp-current-user user) ; see `tramp-parse-passwd'
all-user-hosts)
(unless (or multi-method ;; Not handled (yet).
@@ -3785,7 +3835,7 @@ PARTIAL-USER must match USER, PARTIAL-HOST must match HOST."
Either user or host may be nil."
(let (res)
- (when (file-exists-p filename)
+ (when (file-readable-p filename)
(with-temp-buffer
(insert-file-contents filename)
(goto-char (point-min))
@@ -3822,7 +3872,7 @@ Either user or host may be nil."
User is always nil."
(let (res)
- (when (file-exists-p filename)
+ (when (file-readable-p filename)
(with-temp-buffer
(insert-file-contents filename)
(goto-char (point-min))
@@ -3846,12 +3896,41 @@ User is always nil."
(forward-line 1))
result))
+(defun tramp-parse-sconfig (filename)
+ "Return a list of (user host) tuples allowed to access.
+User is always nil."
+
+ (let (res)
+ (when (file-readable-p filename)
+ (with-temp-buffer
+ (insert-file-contents filename)
+ (goto-char (point-min))
+ (while (not (eobp))
+ (push (tramp-parse-sconfig-group) res))))
+ res))
+
+(defun tramp-parse-sconfig-group ()
+ "Return a (user host) tuple allowed to access.
+User is always nil."
+
+ (let ((result)
+ (regexp (concat "^[ \t]*Host[ \t]+" "\\(" tramp-host-regexp "\\)")))
+
+ (narrow-to-region (point) (tramp-point-at-eol))
+ (when (re-search-forward regexp nil t)
+ (setq result (list nil (match-string 1))))
+ (widen)
+ (or
+ (> (skip-chars-forward ",") 0)
+ (forward-line 1))
+ result))
+
(defun tramp-parse-hosts (filename)
"Return a list of (user host) tuples allowed to access.
User is always nil."
(let (res)
- (when (file-exists-p filename)
+ (when (file-readable-p filename)
(with-temp-buffer
(insert-file-contents filename)
(goto-char (point-min))
@@ -3876,14 +3955,18 @@ User is always nil."
(forward-line 1))
result))
+;; For su-alike methods it would be desirable to return "root@localhost"
+;; as default. Unfortunately, we have no information whether any user name
+;; has been typed already. So we (mis-)use tramp-current-user as indication,
+;; assuming it is set in `tramp-completion-handle-file-name-all-completions'.
(defun tramp-parse-passwd (filename)
"Return a list of (user host) tuples allowed to access.
Host is always \"localhost\"."
(let (res)
- (if (and (symbolp 'user) (zerop (length user)))
+ (if (zerop (length tramp-current-user))
'(("root" nil))
- (when (file-exists-p filename)
+ (when (file-readable-p filename)
(with-temp-buffer
(insert-file-contents filename)
(goto-char (point-min))
@@ -3910,7 +3993,7 @@ Host is always \"localhost\"."
User may be nil."
(let (res)
- (when (file-exists-p filename)
+ (when (file-readable-p filename)
(with-temp-buffer
(insert-file-contents filename)
(goto-char (point-min))
@@ -3938,11 +4021,12 @@ User may be nil."
(defun tramp-completion-handle-expand-file-name (name &optional dir)
"Like `expand-file-name' for tramp files."
(let ((fullname (concat (or dir default-directory) name)))
- (if (tramp-completion-mode fullname)
- (tramp-run-real-handler
- 'expand-file-name (list name dir))
- (tramp-completion-run-real-handler
- 'expand-file-name (list name dir)))))
+ (tramp-drop-volume-letter
+ (if (tramp-completion-mode fullname)
+ (tramp-run-real-handler
+ 'expand-file-name (list name dir))
+ (tramp-completion-run-real-handler
+ 'expand-file-name (list name dir))))))
;;; Internal Functions:
@@ -5518,8 +5602,13 @@ FMT and ARGS which are passed to `error'."
(pop-to-buffer (current-buffer))
(funcall 'signal signal (apply 'format fmt args))))
-;; Chunked sending kluge.
-(defvar tramp-chunksize nil
+;; Chunked sending kluge. We set this to 500 just to be on the
+;; safe side; some ssh connections appear to drop bytes when data
+;; is sent too quickly.
+;; This happens when using `ssh' method using GNU Emacs 20.7.1
+;; (hppa1.1-hp-hpux10.20, Motif). (The connection is made to
+;; localhost.)
+(defvar tramp-chunksize 500
"If non-nil, chunksize for sending things to remote host.")
(defun tramp-send-region (multi-method method user host start end)
@@ -5529,7 +5618,7 @@ running as USER on HOST using METHOD."
(tramp-get-buffer multi-method method user host))))
(unless proc
(error "Can't send region to remote host -- not logged in"))
- (if tramp-chunksize
+ (if (and tramp-chunksize (not (zerop tramp-chunksize)))
(let ((pos start))
(while (< pos end)
(tramp-message-for-buffer
@@ -6439,7 +6528,7 @@ report.
;; how to suppress. Maybe not an essential problem.
;; ** Try to avoid usage of `last-input-event' in `tramp-completion-mode'.
;; ** Extend `tramp-get-completion-su' for NIS and shadow passwords.
-;; ** Unify `tramp-parse-{rhosts,shosts,hosts,passwd,netrc}'.
+;; ** Unify `tramp-parse-{rhosts,shosts,sconfig,hosts,passwd,netrc}'.
;; Code is nearly identical.
;; ** Decide whiche files to take for searching user/host names depending on
;; operating system (windows-nt) in `tramp-completion-function-alist'.