aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/net
diff options
context:
space:
mode:
authorKai Großjohann <[email protected]>2002-08-03 09:23:25 +0000
committerKai Großjohann <[email protected]>2002-08-03 09:23:25 +0000
commitb1d06e759a648bf657b510ca8d0234f097c51c10 (patch)
tree2dcec272c5e83ae002cd5e18daed5a978d896381 /lisp/net
parent336cd99d1bf52bc68e1aab92f4a6e4e390b0407f (diff)
Version 2.0.6.
(tramp-default-method): Change to "ssh" from "sm". (tramp-wrong-passwd-regexp): Restructure. Add additional alternative. (tramp-su-program): New internal variable for method parameter. (tramp-perl-encode-with-module, tramp-perl-decode-with-module): New variables. Very short Perl one-liner, but requires Perl module MIME::Base64 to be installed on the remote site. (tramp-perl-encode, tramp-perl-decode): New base64 encoder/decoder. From Juanma Barranquero <[email protected]>. (tramp-handle-file-truename): Invoke Ange-FTP properly (even though Ange-FTP doesn't do anything for this operation). (tramp-handle-set-visited-file-modtime): Comment change. (tramp-handle-make-directory): Save-excursion. (tramp-handle-expand-many-files): Don't try to invoke Ange-FTP twice, once is enough. (tramp-action-permission-denied): Show *tramp/foo* buffer so the user knows what's wrong. (tramp-post-connection): Support the two Perl encoders and decoders. (tramp-coding-commands): Ditto. Add some todo items.
Diffstat (limited to 'lisp/net')
-rw-r--r--lisp/net/tramp.el197
1 files changed, 168 insertions, 29 deletions
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 26141c0aa2..e6a13a0748 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -69,7 +69,10 @@
;;; Code:
-(defconst tramp-version "2.0.5"
+;; 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.6"
"This version of tramp.")
(defconst tramp-bug-report-address "[email protected]"
@@ -632,8 +635,7 @@ various functions for details."
:group 'tramp
:type '(repeat (list string function string)))
-(defcustom tramp-default-method "sm"
- ;;(if (featurep 'xemacs) "sm" "ftp")
+(defcustom tramp-default-method "ssh"
"*Default method to use for transferring files.
See `tramp-methods' for possibilities.
Also see `tramp-default-method-alist'.
@@ -707,9 +709,22 @@ The `sudo' program appears to insert a `^@' character into the prompt."
:type 'regexp)
(defcustom tramp-wrong-passwd-regexp
- (concat "^.*\\(Permission denied.\\|Login [Ii]ncorrect\\|"
- "Received signal [0-9]+\\|Connection \\(refused\\|closed\\)\\|"
- "Sorry, try again.\\|Name or service not known\\).*")
+ (concat "^.*"
+ ;; These strings should be on the last line
+ (regexp-opt '("Permission denied."
+ "Login incorrect"
+ "Login Incorrect"
+ "Connection refused"
+ "Connection closed"
+ "Sorry, try again."
+ "Name or service not known"
+ "Host key verification failed.") t)
+ ".*"
+ "\\|"
+ "^.*\\("
+ ;; Here comes a list of regexes, separated by \\|
+ "Received signal [0-9]+"
+ "\\).*")
"*Regexp matching a `login failed' message.
The regexp should match at end of buffer."
:group 'tramp
@@ -1145,6 +1160,11 @@ method parameter, as specified in `tramp-methods' (which see).")
In the connection buffer, this variable has the value of the like-named
method parameter, as specified in `tramp-methods' (which see).")
+(defvar tramp-su-program nil
+ "This internal variable holds a parameter for `tramp-methods'.
+In the connection buffer, this variable has the value of the like-named
+method parameter, as specified in `tramp-methods' (which see).")
+
;; CCC `local in each buffer'?
(defvar tramp-ls-command nil
"This command is used to get a long listing with numeric user and group ids.
@@ -1220,13 +1240,101 @@ on the remote file system.")
;; Escape sequence %s is replaced with name of Perl binary.")
;; These two use base64 encoding.
-(defvar tramp-perl-encode
+(defvar tramp-perl-encode-with-module
"perl -MMIME::Base64 -0777 -ne 'print encode_base64($_)'"
"Perl program to use for encoding a file.
+Escape sequence %s is replaced with name of Perl binary.
+This implementation requires the MIME::Base64 Perl module to be installed
+on the remote host.")
+
+(defvar tramp-perl-decode-with-module
+ "perl -MMIME::Base64 -0777 -ne 'print decode_base64($_)'"
+ "Perl program to use for decoding a file.
+Escape sequence %s is replaced with name of Perl binary.
+This implementation requires the MIME::Base64 Perl module to be installed
+on the remote host.")
+
+(defvar tramp-perl-encode
+ "%s -e '
+# This script contributed by Juanma Barranquero <[email protected]>.
+# Copyright (C) 2002 Free Software Foundation, Inc.
+use strict;
+
+my %trans = do {
+ my $i = 0;
+ map {(substr(unpack(q(B8), chr $i++), 2, 6), $_)}
+ split //, q(ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/);
+};
+
+binmode(\*STDIN);
+
+# We read in chunks of 54 bytes, to generate output lines
+# of 72 chars (plus end of line)
+$/ = \54;
+
+while (my $data = <STDIN>) {
+ my $pad = q();
+
+ # Only for the last chunk, and only if did not fill the last three-byte packet
+ if (eof) {
+ my $mod = length($data) % 3;
+ $pad = q(=) x (3 - $mod) if $mod;
+ }
+
+ # Not the fastest method, but it is simple: unpack to binary string, split
+ # by groups of 6 bits and convert back from binary to byte; then map into
+ # the translation table
+ print
+ join q(),
+ map($trans{$_},
+ (substr(unpack(q(B*), $data) . q(00000), 0, 432) =~ /....../g)),
+ $pad,
+ qq(\n);
+}
+'"
+ "Perl program to use for encoding a file.
Escape sequence %s is replaced with name of Perl binary.")
(defvar tramp-perl-decode
- "perl -MMIME::Base64 -0777 -ne 'print decode_base64($_)'"
+ "%s -e '
+# This script contributed by Juanma Barranquero <[email protected]>.
+# Copyright (C) 2002 Free Software Foundation, Inc.
+use strict;
+
+my %trans = do {
+ my $i = 0;
+ map {($_, sprintf(q(%06b), $i++))}
+ split //, q(ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/)
+};
+
+my %bytes = map {(unpack(q(B8), chr $_), chr $_)} 0 .. 255;
+
+binmode(\*STDOUT);
+
+# We are going to accumulate into $pending to accept any line length
+# (we do not check they are <= 76 chars as the RFC says)
+my $pending = q();
+
+while (my $data = <STDIN>) {
+ chomp $data;
+
+ # If we find one or two =, we have reached the end and
+ # any following data is to be discarded
+ my $finished = $data =~ s/(==?).*/$1/;
+ $pending .= $data;
+
+ my $len = length($pending);
+ my $chunk = substr($pending, 0, $len & ~3, q());
+
+ # Easy method: translate from chars to (pregenerated) six-bit packets, join,
+ # split in 8-bit chunks and convert back to char.
+ print join q(),
+ map $bytes{$_},
+ ((join q(), map {$trans{$_} || q()} split //, $chunk) =~ /......../g);
+
+ last if $finished;
+}
+'"
"Perl program to use for decoding a file.
Escape sequence %s is replaced with name of Perl binary.")
@@ -1512,10 +1620,11 @@ target of the symlink differ."
(defun tramp-handle-file-truename (filename &optional counter prev-dirs)
"Like `file-truename' for tramp files."
(with-parsed-tramp-file-name filename nil
- ;; Ange-FTP does not support truename processing. It returns the
- ;; file name as-is. So that's what we do, too.
+ ;; Ange-FTP does not support truename processing, but for
+ ;; convenience we pretend it did and forward the call to Ange-FTP
+ ;; anyway. Ange-FTP then just invokes `identity'.
(when (tramp-ange-ftp-file-name-p multi-method method)
- filename)
+ (tramp-invoke-ange-ftp 'file-truename filename))
(let* ((steps (tramp-split-string path "/"))
(pathdir (let ((directory-sep-char ?/))
(file-name-as-directory path)))
@@ -1546,7 +1655,9 @@ target of the symlink differ."
(tramp-make-tramp-file-name
multi-method method user host
(mapconcat 'identity
- (append '("") (reverse result) (list thisstep))
+ (append '("")
+ (reverse result)
+ (list thisstep))
"/")))))
(cond ((string= "." thisstep)
(tramp-message-for-buffer multi-method method user host
@@ -1733,7 +1844,11 @@ is initially created and is kept cached by the remote shell."
(let ((f (buffer-file-name))
(coding-system-used nil))
(with-parsed-tramp-file-name f nil
- ;; This operation is not handled by Ange-FTP!
+ ;; This operation is not handled by Ange-FTP! Compare this
+ ;; behavior with `file-truename' which Ange-FTP does not really
+ ;; handle, either, but at least it pretends to. I wonder if
+ ;; Ange-FTP should also pretend to grok
+ ;; `set-visited-file-modtime', for consistency?
(when (tramp-ange-ftp-file-name-p multi-method method)
(throw 'tramp-forward-to-ange-ftp
(tramp-run-real-handler 'set-visited-file-modtime
@@ -2297,13 +2412,14 @@ If KEEP-DATE is non-nil, preserve the time stamp when copying."
(with-parsed-tramp-file-name dir nil
(when (tramp-ange-ftp-file-name-p multi-method method)
(tramp-invoke-ange-ftp 'make-directory dir parents))
- (tramp-barf-unless-okay
- multi-method method user host
- (format " %s %s"
- (if parents "mkdir -p" "mkdir")
- (tramp-shell-quote-argument path))
- nil 'file-error
- "Couldn't make directory %s" dir)))
+ (save-excursion
+ (tramp-barf-unless-okay
+ multi-method method user host
+ (format " %s %s"
+ (if parents "mkdir -p" "mkdir")
+ (tramp-shell-quote-argument path))
+ nil 'file-error
+ "Couldn't make directory %s" dir))))
;; CCC error checking?
(defun tramp-handle-delete-directory (directory)
@@ -3087,11 +3203,7 @@ necessary anymore."
(string-match "\\?" name)
(string-match "\\[.*\\]" name))
(save-excursion
- ;; Dissect NAME.
(let (bufstr)
- ;; Perhaps invoke Ange-FTP.
- (when (string= method tramp-ftp-method)
- (signal 'tramp-run-ange-ftp (list 0)))
;; CCC: To do it right, we should quote certain characters
;; in the file name, but since the echo command is going to
;; break anyway when there are spaces in the file names, we
@@ -3485,9 +3597,9 @@ Returns nil if none was found, else the command is returned."
(defun tramp-action-permission-denied (p multi-method method user host)
"Signal permission denied."
+ (pop-to-buffer (tramp-get-buffer multi-method method user host))
(tramp-message 9 "Permission denied by remote host.")
(kill-process p)
- (erase-buffer)
(throw 'tramp-action 'permission-denied))
(defun tramp-action-yesno (p multi-method method user host)
@@ -4399,7 +4511,7 @@ locale to C and sets up the remote shell search path."
" -e '" tramp-perl-file-attributes "' $1 2>/dev/null\n"
"}"))
(tramp-wait-for-output)
- (tramp-message 5 "Sending the Perl `mime-encode' implementation.")
+ (tramp-message 5 "Sending the Perl `mime-encode' implementations.")
(tramp-send-linewise
multi-method method user host
(concat "tramp_encode () {\n"
@@ -4407,13 +4519,27 @@ locale to C and sets up the remote shell search path."
" 2>/dev/null"
"\n}"))
(tramp-wait-for-output)
- (tramp-message 5 "Sending the Perl `mime-decode' implementation.")
+ (tramp-send-linewise
+ multi-method method user host
+ (concat "tramp_encode_with_module () {\n"
+ (format tramp-perl-encode-with-module tramp-remote-perl)
+ " 2>/dev/null"
+ "\n}"))
+ (tramp-wait-for-output)
+ (tramp-message 5 "Sending the Perl `mime-decode' implementations.")
(tramp-send-linewise
multi-method method user host
(concat "tramp_decode () {\n"
(format tramp-perl-decode tramp-remote-perl)
" 2>/dev/null"
"\n}"))
+ (tramp-wait-for-output)
+ (tramp-send-linewise
+ multi-method method user host
+ (concat "tramp_decode_with_module () {\n"
+ (format tramp-perl-decode-with-module tramp-remote-perl)
+ " 2>/dev/null"
+ "\n}"))
(tramp-wait-for-output))))
;; Find ln(1)
(erase-buffer)
@@ -4467,6 +4593,8 @@ locale to C and sets up the remote shell search path."
nil uudecode-decode-region)
("uuencode xxx" "uudecode -p"
nil uudecode-decode-region)
+ ("tramp_encode_with_module" "tramp_decode_with_module"
+ base64-encode-region base64-decode-region)
("tramp_encode" "tramp_decode"
base64-encode-region base64-decode-region))
"List of coding commands for inline transfer.
@@ -5537,11 +5665,22 @@ TRAMP.
;;; TODO:
-;; * Revise the comments near the beginning of the file.
+;; * Add fallback for inline encodings. This should be used
+;; if the remote end doesn't support mimencode or a similar program.
+;; For reading files from the remote host, we can just parse the output
+;; of `od -b'. For writing files to the remote host, we construct
+;; a shell program which contains only "safe" ascii characters
+;; and which writes the right bytes to the file. We can use printf(1)
+;; or "echo -e" or the printf function in awk and use octal escapes
+;; for the "dangerous" characters. The null byte might be a problem.
+;; On some systems, the octal escape doesn't work. So we try the following
+;; two commands to write a null byte:
+;; dd if=/dev/zero bs=1 count=1
+;; echo | tr '\n' '\000'
;; * Cooperate with PCL-CVS. It uses start-process, which doesn't
;; work for remote files.
;; * Rewrite `tramp-shell-quote-argument' to abstain from using
-;; `shell-quote-argument'.
+;; `shell-quote-argument'.
;; * Completion gets confused when you leave out the method name.
;; * Support `dired-compress-file' filename handler.
;; * In Emacs 21, `insert-directory' shows total number of bytes used