comparison lisp/net/tramp.el @ 107021:b38ac2be4408

Fix some busybox annoyances. * net/tramp.el (tramp-wrong-passwd-regexp): Add "Timeout, server not responding." string. (tramp-open-connection-setup-interactive-shell): Dump stty settings. Enable "neveropen" arg for all `tramp-send-command' calls. Handle "=" in variable values properly. (tramp-find-inline-encoding): Raise an error, when no encoding is found. (tramp-wait-for-output): Check, whether PROC buffer is available. Remove spurious " ^H" sequences, sent by busybox. (tramp-get-ls-command): Suppress coloring, if possible.
author Michael Albinus <albinus@detlef>
date Thu, 28 Jan 2010 07:06:41 +0100
parents 181539c8b6a4
children 5555e86608c1
comparison
equal deleted inserted replaced
107020:e59c65208b1c 107021:b38ac2be4408
1083 (regexp-opt '("Permission denied" 1083 (regexp-opt '("Permission denied"
1084 "Login incorrect" 1084 "Login incorrect"
1085 "Login Incorrect" 1085 "Login Incorrect"
1086 "Connection refused" 1086 "Connection refused"
1087 "Connection closed" 1087 "Connection closed"
1088 "Timeout, server not responding."
1088 "Sorry, try again." 1089 "Sorry, try again."
1089 "Name or service not known" 1090 "Name or service not known"
1090 "Host key verification failed." 1091 "Host key verification failed."
1091 "No supported authentication methods left to try!") t) 1092 "No supported authentication methods left to try!") t)
1092 ".*" 1093 ".*"
6730 (when (search-forward "\r" nil t) 6731 (when (search-forward "\r" nil t)
6731 ;; We have found a ^M but cannot frob the process coding system 6732 ;; We have found a ^M but cannot frob the process coding system
6732 ;; because we're running on a non-MULE Emacs. Let's try 6733 ;; because we're running on a non-MULE Emacs. Let's try
6733 ;; stty, instead. 6734 ;; stty, instead.
6734 (tramp-send-command vec "stty -onlcr" t)))) 6735 (tramp-send-command vec "stty -onlcr" t))))
6736 ;; Dump stty settings in the traces.
6737 (when (>= tramp-verbose 10)
6738 (tramp-send-command vec "stty -a" t))
6735 (tramp-send-command vec "set +o vi +o emacs" t) 6739 (tramp-send-command vec "set +o vi +o emacs" t)
6736 6740
6737 ;; Check whether the output of "uname -sr" has been changed. If 6741 ;; Check whether the output of "uname -sr" has been changed. If
6738 ;; yes, this is a strong indication that we must expire all 6742 ;; yes, this is a strong indication that we must expire all
6739 ;; connection properties. We start again with 6743 ;; connection properties. We start again with
6799 6803
6800 ;; On OpenSolaris, there is a bug when HISTFILE is changed in place 6804 ;; On OpenSolaris, there is a bug when HISTFILE is changed in place
6801 ;; <http://bugs.opensolaris.org/view_bug.do?bug_id=6834184>. We 6805 ;; <http://bugs.opensolaris.org/view_bug.do?bug_id=6834184>. We
6802 ;; apply the workaround. 6806 ;; apply the workaround.
6803 (if (string-equal (tramp-get-connection-property vec "uname" "") "SunOS 5.11") 6807 (if (string-equal (tramp-get-connection-property vec "uname" "") "SunOS 5.11")
6804 (tramp-send-command vec "unset HISTFILE")) 6808 (tramp-send-command vec "unset HISTFILE" t))
6805 6809
6806 (let ((env (copy-sequence tramp-remote-process-environment)) 6810 (let ((env (copy-sequence tramp-remote-process-environment))
6807 unset item) 6811 unset item)
6808 (while env 6812 (while env
6809 (setq item (tramp-compat-split-string (car env) "=")) 6813 (setq item (tramp-compat-split-string (car env) "="))
6810 (if (and (stringp (cadr item)) (not (string-equal (cadr item) ""))) 6814 (setcdr item (mapconcat 'identity (cdr item) "="))
6815 (if (and (stringp (cdr item)) (not (string-equal (cdr item) "")))
6811 (tramp-send-command 6816 (tramp-send-command
6812 vec (format "%s=%s; export %s" (car item) (cadr item) (car item)) t) 6817 vec (format "%s=%s; export %s" (car item) (cdr item) (car item)) t)
6813 (push (car item) unset)) 6818 (push (car item) unset))
6814 (setq env (cdr env))) 6819 (setq env (cdr env)))
6815 (when unset 6820 (when unset
6816 (tramp-send-command 6821 (tramp-send-command
6817 vec (format "unset %s" (mapconcat 'identity unset " "))))) t) 6822 vec (format "unset %s" (mapconcat 'identity unset " "))))) t)
6979 (setq rem-dec (nth 2 ritem)) 6984 (setq rem-dec (nth 2 ritem))
6980 (setq found t))))))) 6985 (setq found t)))))))
6981 6986
6982 ;; Did we find something? 6987 ;; Did we find something?
6983 (unless found 6988 (unless found
6984 (tramp-message vec 2 "Couldn't find an inline transfer encoding")) 6989 (tramp-error
6990 vec 'file-error "Couldn't find an inline transfer encoding"))
6985 6991
6986 ;; Set connection properties. 6992 ;; Set connection properties.
6987 (tramp-message vec 5 "Using local encoding `%s'" loc-enc) 6993 (tramp-message vec 5 "Using local encoding `%s'" loc-enc)
6988 (tramp-set-connection-property vec "local-encoding" loc-enc) 6994 (tramp-set-connection-property vec "local-encoding" loc-enc)
6989 (tramp-message vec 5 "Using local decoding `%s'" loc-dec) 6995 (tramp-message vec 5 "Using local decoding `%s'" loc-dec)
7299 (tramp-message vec 6 "%s" command) 7305 (tramp-message vec 6 "%s" command)
7300 (tramp-send-string vec command) 7306 (tramp-send-string vec command)
7301 (unless nooutput (tramp-wait-for-output p)))) 7307 (unless nooutput (tramp-wait-for-output p))))
7302 7308
7303 (defun tramp-wait-for-output (proc &optional timeout) 7309 (defun tramp-wait-for-output (proc &optional timeout)
7304 "Wait for output from remote rsh command." 7310 "Wait for output from remote command."
7311 (unless (buffer-live-p (process-buffer proc))
7312 (delete-process proc)
7313 (tramp-error proc 'file-error "Process `%s' not available, try again" proc))
7305 (with-current-buffer (process-buffer proc) 7314 (with-current-buffer (process-buffer proc)
7306 (let* (;; Initially, `tramp-end-of-output' is "#$ ". There might 7315 (let* (;; Initially, `tramp-end-of-output' is "#$ ". There might
7307 ;; be leading escape sequences, which must be ignored. 7316 ;; be leading escape sequences, which must be ignored.
7308 (regexp (format "[^#$\n]*%s\r?$" (regexp-quote tramp-end-of-output))) 7317 (regexp (format "[^#$\n]*%s\r?$" (regexp-quote tramp-end-of-output)))
7309 ;; Sometimes, the commands do not return a newline but a 7318 ;; Sometimes, the commands do not return a newline but a
7311 ;; ls-files -c -z ...". 7320 ;; ls-files -c -z ...".
7312 (regexp1 (format "\\(^\\|\000\\)%s" regexp)) 7321 (regexp1 (format "\\(^\\|\000\\)%s" regexp))
7313 (found (tramp-wait-for-regexp proc timeout regexp1))) 7322 (found (tramp-wait-for-regexp proc timeout regexp1)))
7314 (if found 7323 (if found
7315 (let (buffer-read-only) 7324 (let (buffer-read-only)
7325 ;; A simple-minded busybox has sent " ^H" sequences.
7326 ;; Delete them.
7327 (goto-char (point-min))
7328 (when (re-search-forward
7329 "^\\(.\b\\)+$" (tramp-compat-line-end-position) t)
7330 (forward-line 1)
7331 (delete-region (point-min) (point)))
7332 ;; Delete the prompt.
7316 (goto-char (point-max)) 7333 (goto-char (point-max))
7317 (re-search-backward regexp nil t) 7334 (re-search-backward regexp nil t)
7318 (delete-region (point) (point-max))) 7335 (delete-region (point) (point-max)))
7319 (if timeout 7336 (if timeout
7320 (tramp-error 7337 (tramp-error
8000 (catch 'ls-found 8017 (catch 'ls-found
8001 (dolist (cmd '("ls" "gnuls" "gls")) 8018 (dolist (cmd '("ls" "gnuls" "gls"))
8002 (let ((dl (tramp-get-remote-path vec)) 8019 (let ((dl (tramp-get-remote-path vec))
8003 result) 8020 result)
8004 (while (and dl (setq result (tramp-find-executable vec cmd dl t t))) 8021 (while (and dl (setq result (tramp-find-executable vec cmd dl t t)))
8005 ;; Check parameter. 8022 ;; Check parameters. On busybox, "ls" output coloring is
8023 ;; enabled by default sometimes. So we try to disable it
8024 ;; when possible. $LS_COLORING is not supported there.
8006 (when (zerop (tramp-send-command-and-check 8025 (when (zerop (tramp-send-command-and-check
8007 vec (format "%s -lnd /" result))) 8026 vec (format "%s -lnd /" result)))
8027 (when (zerop (tramp-send-command-and-check
8028 vec (format "%s --color=never /" result)))
8029 (setq result (concat result " --color=never")))
8008 (throw 'ls-found result)) 8030 (throw 'ls-found result))
8009 (setq dl (cdr dl)))))) 8031 (setq dl (cdr dl))))))
8010 (tramp-error vec 'file-error "Couldn't find a proper `ls' command")))) 8032 (tramp-error vec 'file-error "Couldn't find a proper `ls' command"))))
8011 8033
8012 (defun tramp-get-ls-command-with-dired (vec) 8034 (defun tramp-get-ls-command-with-dired (vec)
8479 ;; * Make ffap.el grok Tramp filenames. (Eli Tziperman) 8501 ;; * Make ffap.el grok Tramp filenames. (Eli Tziperman)
8480 ;; * Case-insensitive filename completion. (Norbert Goevert.) 8502 ;; * Case-insensitive filename completion. (Norbert Goevert.)
8481 ;; * Don't use globbing for directories with many files, as this is 8503 ;; * Don't use globbing for directories with many files, as this is
8482 ;; likely to produce long command lines, and some shells choke on 8504 ;; likely to produce long command lines, and some shells choke on
8483 ;; long command lines. 8505 ;; long command lines.
8484 ;; * `vc-directory' does not work. It never displays any files, even
8485 ;; if it does show files when run locally.
8486 ;; * How to deal with MULE in `insert-file-contents' and `write-region'? 8506 ;; * How to deal with MULE in `insert-file-contents' and `write-region'?
8487 ;; * Test remote ksh or bash for tilde expansion in `tramp-find-shell'? 8507 ;; * Test remote ksh or bash for tilde expansion in `tramp-find-shell'?
8488 ;; * abbreviate-file-name 8508 ;; * abbreviate-file-name
8489 ;; * Better error checking. At least whenever we see something 8509 ;; * Better error checking. At least whenever we see something
8490 ;; strange when doing zerop, we should kill the process and start 8510 ;; strange when doing zerop, we should kill the process and start
8527 ;; way of passing credentials, like by using an SSL socket or 8547 ;; way of passing credentials, like by using an SSL socket or
8528 ;; something. (David Kastrup) 8548 ;; something. (David Kastrup)
8529 ;; * Reconnect directly to a compliant shell without first going 8549 ;; * Reconnect directly to a compliant shell without first going
8530 ;; through the user's default shell. (Pete Forman) 8550 ;; through the user's default shell. (Pete Forman)
8531 ;; * Make `tramp-default-user' obsolete. 8551 ;; * Make `tramp-default-user' obsolete.
8532 ;; * Tramp shall reconnect automatically to its ssh connection when it
8533 ;; detects that the process "has died". (David Reitter)
8534 ;; * How can I interrupt the remote process with a signal 8552 ;; * How can I interrupt the remote process with a signal
8535 ;; (interrupt-process seems not to work)? (Markus Triska) 8553 ;; (interrupt-process seems not to work)? (Markus Triska)
8536 ;; * Avoid the local shell entirely for starting remote processes. If 8554 ;; * Avoid the local shell entirely for starting remote processes. If
8537 ;; so, I think even a signal, when delivered directly to the local 8555 ;; so, I think even a signal, when delivered directly to the local
8538 ;; SSH instance, would correctly be propagated to the remote process 8556 ;; SSH instance, would correctly be propagated to the remote process
8550 ;; * Optimize out-of-band copying, when both methods are scp-like (not 8568 ;; * Optimize out-of-band copying, when both methods are scp-like (not
8551 ;; rsync). 8569 ;; rsync).
8552 ;; * Keep a second connection open for out-of-band methods like scp or 8570 ;; * Keep a second connection open for out-of-band methods like scp or
8553 ;; rsync. 8571 ;; rsync.
8554 ;; * Support ptys in `tramp-handle-start-file-process'. 8572 ;; * Support ptys in `tramp-handle-start-file-process'.
8573 ;; * IMHO, it's a drawback that currently Tramp doesn't support
8574 ;; Unicode in Dired file names by default. Is it possible to
8575 ;; improve Tramp to set LC_ALL to "C" only for commands where Tramp
8576 ;; expects English? Or just to set LC_MESSAGES to "C" if Tramp
8577 ;; expects only English messages? (Juri Linkov)
8578 ;; * Make shadowfile.el grok Tramp filenames. (Bug#4526, Bug#4846)
8579 ;; * Do not handle files with drive letter as remote. (Bug#5447)
8580 ;; * Load Tramp subpackages only when needed. (Bug#1529, Bug#5448)
8581 ;; * Try telnet+curl as new method. It might be useful for busybox,
8582 ;; without built-in uuencode/uudecode.
8555 8583
8556 ;; Functions for file-name-handler-alist: 8584 ;; Functions for file-name-handler-alist:
8557 ;; diff-latest-backup-file -- in diff.el 8585 ;; diff-latest-backup-file -- in diff.el
8558 8586
8559 ;; arch-tag: 3a21a994-182b-48fa-b0cd-c1d9fede424a 8587 ;; arch-tag: 3a21a994-182b-48fa-b0cd-c1d9fede424a