comparison lisp/net/tramp.el @ 62344:5a19ff64befb

Sync with Tramp 2.0.49.
author Michael Albinus <michael.albinus@gmx.de>
date Sat, 14 May 2005 15:39:15 +0000
parents 3ba8f94e9cfa
children df55e63482c4
comparison
equal deleted inserted replaced
62343:4a68f3c340ab 62344:5a19ff64befb
1350 :group 'tramp 1350 :group 'tramp
1351 :type '(repeat string)) 1351 :type '(repeat string))
1352 1352
1353 ;; Chunked sending kluge. We set this to 500 for black-listed constellations 1353 ;; Chunked sending kluge. We set this to 500 for black-listed constellations
1354 ;; known to have a bug in `process-send-string'; some ssh connections appear 1354 ;; known to have a bug in `process-send-string'; some ssh connections appear
1355 ;; to drop bytes when data is sent too quickly. 1355 ;; to drop bytes when data is sent too quickly. There is also a connection
1356 ;; buffer local variable, which is computed depending on remote host properties
1357 ;; when `tramp-chunksize' is zero or nil.
1356 (defcustom tramp-chunksize 1358 (defcustom tramp-chunksize
1357 (when (and (not (featurep 'xemacs)) 1359 (when (and (not (featurep 'xemacs))
1358 (memq system-type '(hpux))) 1360 (memq system-type '(hpux)))
1359 500) 1361 500)
1360 "*If non-nil, chunksize for sending input to local process. 1362 "*If non-nil, chunksize for sending input to local process.
3229 (tramp-send-command 3231 (tramp-send-command
3230 multi-method method user host 3232 multi-method method user host
3231 (mapconcat #'tramp-shell-quote-argument (cons program arguments) " ")) 3233 (mapconcat #'tramp-shell-quote-argument (cons program arguments) " "))
3232 (tramp-wait-for-output)) 3234 (tramp-wait-for-output))
3233 (unless discard 3235 (unless discard
3234 (insert-buffer (tramp-get-buffer multi-method method user host))) 3236 ;; We cannot use `insert-buffer' because the tramp buffer
3237 ;; changes its contents before insertion due to calling
3238 ;; `expand-file' and alike.
3239 (insert
3240 (with-current-buffer
3241 (tramp-get-buffer multi-method method user host)
3242 (buffer-string))))
3235 (save-excursion 3243 (save-excursion
3236 (prog1 3244 (prog1
3237 (tramp-send-command-and-check multi-method method user host nil) 3245 (tramp-send-command-and-check multi-method method user host nil)
3238 (tramp-send-command multi-method method user host "cd") 3246 (tramp-send-command multi-method method user host "cd")
3239 (tramp-wait-for-output))))) 3247 (tramp-wait-for-output)))))
3358 (format "%s %s %s" 3366 (format "%s %s %s"
3359 (tramp-get-ls-command multi-method method user host) 3367 (tramp-get-ls-command multi-method method user host)
3360 switches 3368 switches
3361 (if wildcard 3369 (if wildcard
3362 localname 3370 localname
3363 (tramp-shell-quote-argument 3371 (if (zerop (length (file-name-nondirectory localname)))
3364 (file-name-nondirectory localname)))))) 3372 ""
3373 (tramp-shell-quote-argument
3374 (file-name-nondirectory localname)))))))
3365 (sit-for 1) ;needed for rsh but not ssh? 3375 (sit-for 1) ;needed for rsh but not ssh?
3366 (tramp-wait-for-output)) 3376 (tramp-wait-for-output))
3367 ;; The following let-binding is used by code that's commented 3377 ;; The following let-binding is used by code that's commented
3368 ;; out. Let's leave the let-binding in for a while to see 3378 ;; out. Let's leave the let-binding in for a while to see
3369 ;; that the commented-out code is really not needed. Commenting-out 3379 ;; that the commented-out code is really not needed. Commenting-out
3370 ;; happened on 2003-03-13. 3380 ;; happened on 2003-03-13.
3371 (let ((old-pos (point))) 3381 (let ((old-pos (point)))
3372 (insert-buffer-substring 3382 ;; We cannot use `insert-buffer' because the tramp buffer
3373 (tramp-get-buffer multi-method method user host)) 3383 ;; changes its contents before insertion due to calling
3384 ;; `expand-file' and alike.
3385 (insert
3386 (with-current-buffer
3387 (tramp-get-buffer multi-method method user host)
3388 (buffer-string)))
3374 ;; On XEmacs, we want to call (exchange-point-and-mark t), but 3389 ;; On XEmacs, we want to call (exchange-point-and-mark t), but
3375 ;; that doesn't exist on Emacs, so we use this workaround instead. 3390 ;; that doesn't exist on Emacs, so we use this workaround instead.
3376 ;; Since zmacs-region-stays doesn't exist in Emacs, this ought to 3391 ;; Since zmacs-region-stays doesn't exist in Emacs, this ought to
3377 ;; be safe. Thanks to Daniel Pittman <daniel@danann.net>. 3392 ;; be safe. Thanks to Daniel Pittman <daniel@danann.net>.
3378 ;; (let ((zmacs-region-stays t)) 3393 ;; (let ((zmacs-region-stays t))
3559 command) 3574 command)
3560 (format "%s; tramp_old_status=$?" command))) 3575 (format "%s; tramp_old_status=$?" command)))
3561 (unless asynchronous 3576 (unless asynchronous
3562 (tramp-wait-for-output))) 3577 (tramp-wait-for-output)))
3563 (unless asynchronous 3578 (unless asynchronous
3564 (insert-buffer (tramp-get-buffer multi-method method user host))) 3579 ;; We cannot use `insert-buffer' because the tramp buffer
3580 ;; changes its contents before insertion due to calling
3581 ;; `expand-file' and alike.
3582 (insert
3583 (with-current-buffer
3584 (tramp-get-buffer multi-method method user host)
3585 (buffer-string))))
3565 (when error-buffer 3586 (when error-buffer
3566 (save-excursion 3587 (save-excursion
3567 (unless (bufferp error-buffer) 3588 (unless (bufferp error-buffer)
3568 (setq error-buffer (get-buffer-create error-buffer))) 3589 (setq error-buffer (get-buffer-create error-buffer)))
3569 (tramp-send-command 3590 (tramp-send-command
3570 multi-method method user host 3591 multi-method method user host
3571 "cat /tmp/tramp.$$.err") 3592 "cat /tmp/tramp.$$.err")
3572 (tramp-wait-for-output) 3593 (tramp-wait-for-output)
3573 (set-buffer error-buffer) 3594 (set-buffer error-buffer)
3574 (insert-buffer (tramp-get-buffer multi-method method user host)) 3595 ;; Same comment as above
3596 (insert
3597 (with-current-buffer
3598 (tramp-get-buffer multi-method method user host)
3599 (buffer-string)))
3575 (tramp-send-command-and-check 3600 (tramp-send-command-and-check
3576 multi-method method user host "rm -f /tmp/tramp.$$.err"))) 3601 multi-method method user host "rm -f /tmp/tramp.$$.err")))
3577 (save-excursion 3602 (save-excursion
3578 (tramp-send-command multi-method method user host "cd") 3603 (tramp-send-command multi-method method user host "cd")
3579 (unless asynchronous 3604 (unless asynchronous
4832 (tramp-message 5 (concat "Sending the Perl script `" name "'...done."))))))) 4857 (tramp-message 5 (concat "Sending the Perl script `" name "'...done.")))))))
4833 4858
4834 (defun tramp-set-auto-save () 4859 (defun tramp-set-auto-save ()
4835 (when (and (buffer-file-name) 4860 (when (and (buffer-file-name)
4836 (tramp-tramp-file-p (buffer-file-name)) 4861 (tramp-tramp-file-p (buffer-file-name))
4862 ;; ange-ftp has its own auto-save mechanism
4863 (eq (tramp-find-foreign-file-name-handler (buffer-file-name))
4864 'tramp-sh-file-name-handler)
4837 auto-save-default) 4865 auto-save-default)
4838 (auto-save-mode 1))) 4866 (auto-save-mode 1)))
4839 (add-hook 'find-file-hooks 'tramp-set-auto-save t) 4867 (add-hook 'find-file-hooks 'tramp-set-auto-save t)
4840 4868
4841 (defun tramp-run-test (switch filename) 4869 (defun tramp-run-test (switch filename)
5415 (when (tramp-method-out-of-band-p multi-method method user host) 5443 (when (tramp-method-out-of-band-p multi-method method user host)
5416 (error "Cannot use out-of-band method `%s' with telnet connection method" 5444 (error "Cannot use out-of-band method `%s' with telnet connection method"
5417 method)) 5445 method))
5418 (when multi-method 5446 (when multi-method
5419 (error "Cannot multi-connect using telnet connection method")) 5447 (error "Cannot multi-connect using telnet connection method"))
5420 (tramp-pre-connection multi-method method user host) 5448 (tramp-pre-connection multi-method method user host tramp-chunksize)
5421 (tramp-message 7 "Opening connection for %s@%s using %s..." 5449 (tramp-message 7 "Opening connection for %s@%s using %s..."
5422 (or user (user-login-name)) host method) 5450 (or user (user-login-name)) host method)
5423 (let ((process-environment (copy-sequence process-environment))) 5451 (let ((process-environment (copy-sequence process-environment)))
5424 (setenv "TERM" tramp-terminal-type) 5452 (setenv "TERM" tramp-terminal-type)
5425 (let* ((default-directory (tramp-temporary-file-directory)) 5453 (let* ((default-directory (tramp-temporary-file-directory))
5473 * Actually, the rsh program to be used can be specified in the 5501 * Actually, the rsh program to be used can be specified in the
5474 method parameters, see the variable `tramp-methods'." 5502 method parameters, see the variable `tramp-methods'."
5475 (save-match-data 5503 (save-match-data
5476 (when multi-method 5504 (when multi-method
5477 (error "Cannot multi-connect using rsh connection method")) 5505 (error "Cannot multi-connect using rsh connection method"))
5478 (tramp-pre-connection multi-method method user host) 5506 (tramp-pre-connection multi-method method user host tramp-chunksize)
5479 (if (and user (not (string= user ""))) 5507 (if (and user (not (string= user "")))
5480 (tramp-message 7 "Opening connection for %s@%s using %s..." 5508 (tramp-message 7 "Opening connection for %s@%s using %s..."
5481 user host method) 5509 user host method)
5482 (tramp-message 7 "Opening connection at %s using %s..." host method)) 5510 (tramp-message 7 "Opening connection at %s using %s..." host method))
5483 (let ((process-environment (copy-sequence process-environment)) 5511 (let ((process-environment (copy-sequence process-environment))
5542 (string= "localhost" host) 5570 (string= "localhost" host)
5543 (string= "" host)) 5571 (string= "" host))
5544 (error 5572 (error
5545 "Cannot connect to different host `%s' with `su' connection method" 5573 "Cannot connect to different host `%s' with `su' connection method"
5546 host)) 5574 host))
5547 (tramp-pre-connection multi-method method user host) 5575 (tramp-pre-connection multi-method method user host tramp-chunksize)
5548 (tramp-message 7 "Opening connection for `%s' using `%s'..." 5576 (tramp-message 7 "Opening connection for `%s' using `%s'..."
5549 (or user "<root>") method) 5577 (or user "<root>") method)
5550 (let ((process-environment (copy-sequence process-environment))) 5578 (let ((process-environment (copy-sequence process-environment)))
5551 (setenv "TERM" tramp-terminal-type) 5579 (setenv "TERM" tramp-terminal-type)
5552 (let* ((default-directory (tramp-temporary-file-directory)) 5580 (let* ((default-directory (tramp-temporary-file-directory))
5607 (unless (and (arrayp host) (not (stringp host))) 5635 (unless (and (arrayp host) (not (stringp host)))
5608 (error "HOST must be an array of strings for multi methods")) 5636 (error "HOST must be an array of strings for multi methods"))
5609 (unless (and (= (length method) (length user)) 5637 (unless (and (= (length method) (length user))
5610 (= (length method) (length host))) 5638 (= (length method) (length host)))
5611 (error "Arrays METHOD, USER, HOST must have equal length")) 5639 (error "Arrays METHOD, USER, HOST must have equal length"))
5612 (tramp-pre-connection multi-method method user host) 5640 (tramp-pre-connection multi-method method user host tramp-chunksize)
5613 (tramp-message 7 "Opening `%s' connection..." multi-method) 5641 (tramp-message 7 "Opening `%s' connection..." multi-method)
5614 (let ((process-environment (copy-sequence process-environment))) 5642 (let ((process-environment (copy-sequence process-environment)))
5615 (setenv "TERM" tramp-terminal-type) 5643 (setenv "TERM" tramp-terminal-type)
5616 (let* ((default-directory (tramp-temporary-file-directory)) 5644 (let* ((default-directory (tramp-temporary-file-directory))
5617 ;; If we omit the conditional, we use `undecided-dos' in 5645 ;; If we omit the conditional, we use `undecided-dos' in
5808 tramp-default-password-end-of-line))))) 5836 tramp-default-password-end-of-line)))))
5809 5837
5810 ;; HHH: Not Changed. This might handle the case where USER is not 5838 ;; HHH: Not Changed. This might handle the case where USER is not
5811 ;; given in the "File name" very poorly. Then, the local 5839 ;; given in the "File name" very poorly. Then, the local
5812 ;; variable tramp-current-user will be set to nil. 5840 ;; variable tramp-current-user will be set to nil.
5813 (defun tramp-pre-connection (multi-method method user host) 5841 (defun tramp-pre-connection (multi-method method user host chunksize)
5814 "Do some setup before actually logging in. 5842 "Do some setup before actually logging in.
5815 METHOD, USER and HOST specify the connection." 5843 METHOD, USER and HOST specify the connection."
5816 (set-buffer (tramp-get-buffer multi-method method user host)) 5844 (set-buffer (tramp-get-buffer multi-method method user host))
5817 (set (make-local-variable 'tramp-current-multi-method) multi-method) 5845 (set (make-local-variable 'tramp-current-multi-method) multi-method)
5818 (set (make-local-variable 'tramp-current-method) method) 5846 (set (make-local-variable 'tramp-current-method) method)
5819 (set (make-local-variable 'tramp-current-user) user) 5847 (set (make-local-variable 'tramp-current-user) user)
5820 (set (make-local-variable 'tramp-current-host) host) 5848 (set (make-local-variable 'tramp-current-host) host)
5849 (set (make-local-variable 'tramp-chunksize) chunksize)
5821 (set (make-local-variable 'inhibit-eol-conversion) nil) 5850 (set (make-local-variable 'inhibit-eol-conversion) nil)
5822 (erase-buffer)) 5851 (erase-buffer))
5823 5852
5824 (defun tramp-open-connection-setup-interactive-shell 5853 (defun tramp-open-connection-setup-interactive-shell
5825 (p multi-method method user host) 5854 (p multi-method method user host)
5867 (tramp-send-command-internal multi-method method user host 5896 (tramp-send-command-internal multi-method method user host
5868 "echo foo") 5897 "echo foo")
5869 (erase-buffer) 5898 (erase-buffer)
5870 (tramp-send-command-internal multi-method method user host 5899 (tramp-send-command-internal multi-method method user host
5871 "TERM=dumb; export TERM") 5900 "TERM=dumb; export TERM")
5901 (erase-buffer)
5902 ;; Check whether the remote host suffers from buggy `send-process-string'.
5903 ;; This is known for FreeBSD (see comment in `send_process', file process.c).
5904 ;; I've tested sending 624 bytes successfully, sending 625 bytes failed.
5905 ;; Emacs makes a hack when this host type is detected locally. It cannot
5906 ;; handle remote hosts, though.
5907 (when (or (not tramp-chunksize) (zerop tramp-chunksize))
5908 (tramp-message 9 "Checking remote host type for `send-process-string' bug")
5909 (tramp-send-command-internal multi-method method user host
5910 "(uname -sr) 2>/dev/null")
5911 (goto-char (point-min))
5912 (when (looking-at "FreeBSD")
5913 (setq tramp-chunksize 500)))
5914
5872 ;; Try to set up the coding system correctly. 5915 ;; Try to set up the coding system correctly.
5873 ;; CCC this can't be the right way to do it. Hm. 5916 ;; CCC this can't be the right way to do it. Hm.
5874 (save-excursion 5917 (save-excursion
5875 (erase-buffer) 5918 (erase-buffer)
5876 (tramp-message 9 "Determining coding system") 5919 (tramp-message 9 "Determining coding system")
6946 (unless (file-exists-p buffer-auto-save-file-name) 6989 (unless (file-exists-p buffer-auto-save-file-name)
6947 (write-region "" nil buffer-auto-save-file-name)) 6990 (write-region "" nil buffer-auto-save-file-name))
6948 ;; Permissions should be set always, because there might be an old 6991 ;; Permissions should be set always, because there might be an old
6949 ;; auto-saved file belonging to another original file. This could 6992 ;; auto-saved file belonging to another original file. This could
6950 ;; be a security threat. 6993 ;; be a security threat.
6951 (set-file-modes buffer-auto-save-file-name (file-modes bfn))))) 6994 (set-file-modes buffer-auto-save-file-name
6995 (or (file-modes bfn) ?\600)))))
6952 6996
6953 (unless (or (> emacs-major-version 21) 6997 (unless (or (> emacs-major-version 21)
6954 (and (featurep 'xemacs) 6998 (and (featurep 'xemacs)
6955 (= emacs-major-version 21) 6999 (= emacs-major-version 21)
6956 (> emacs-minor-version 4))) 7000 (> emacs-minor-version 4)))
7224 tramp-password-prompt-regexp 7268 tramp-password-prompt-regexp
7225 tramp-wrong-passwd-regexp 7269 tramp-wrong-passwd-regexp
7226 tramp-yesno-prompt-regexp 7270 tramp-yesno-prompt-regexp
7227 tramp-yn-prompt-regexp 7271 tramp-yn-prompt-regexp
7228 tramp-terminal-prompt-regexp 7272 tramp-terminal-prompt-regexp
7229 tramp-out-of-band-prompt-regexp
7230 tramp-temp-name-prefix 7273 tramp-temp-name-prefix
7231 tramp-file-name-structure 7274 tramp-file-name-structure
7232 tramp-file-name-regexp 7275 tramp-file-name-regexp
7233 tramp-multi-file-name-structure 7276 tramp-multi-file-name-structure
7234 tramp-multi-file-name-hop-structure 7277 tramp-multi-file-name-hop-structure
7284 ")))) 7327 "))))
7285 7328
7286 (defun tramp-append-tramp-buffers () 7329 (defun tramp-append-tramp-buffers ()
7287 "Append Tramp buffers into the bug report." 7330 "Append Tramp buffers into the bug report."
7288 7331
7289 ;; We load mml.el from Gnus. 7332 ;; We load message.el and mml.el from Gnus.
7290 (if (featurep 'xemacs) 7333 (if (featurep 'xemacs)
7291 (load "mml" 'noerror) 7334 (progn
7335 (load "message" 'noerror)
7336 (load "mml" 'noerror))
7337 (require 'message nil 'noerror)
7292 (require 'mml nil 'noerror)) 7338 (require 'mml nil 'noerror))
7339 (when (functionp 'message-mode)
7340 (funcall 'message-mode))
7341 (when (functionp 'mml-mode)
7342 (funcall 'mml-mode t))
7293 7343
7294 (when (and 7344 (when (and
7295 ;; We don't want to add another dependency. 7345 (eq major-mode 'message-mode)
7296 (functionp 'mml-insert-empty-tag) 7346 (boundp 'mml-mode)
7297 ;; 2nd parameter since Emacs 22. 7347 (symbol-value 'mml-mode))
7298 (condition-case nil 7348
7299 (list-buffers-noselect nil nil) 7349 (let* ((tramp-buf-regexp "\\*\\(debug \\)?tramp/")
7300 (t nil))) 7350 (buffer-list
7301 (let ((buffer-list 7351 (delq nil
7302 (delq nil 7352 (mapcar '(lambda (b)
7303 (mapcar '(lambda (b) 7353 (when (string-match tramp-buf-regexp (buffer-name b)) b))
7304 (when (string-match "^\\*\\(debug \\)?tramp/" (buffer-name b)) b)) 7354 (buffer-list))))
7305 (buffer-list)))) 7355 (curbuf (current-buffer)))
7306 (curbuf (current-buffer)))
7307 7356
7308 ;; There is at least one Tramp buffer. 7357 ;; There is at least one Tramp buffer.
7309 (when buffer-list 7358 (when buffer-list
7310 (switch-to-buffer (list-buffers-noselect nil buffer-list)) 7359 (switch-to-buffer (list-buffers-noselect nil))
7311 (delete-other-windows) 7360 (delete-other-windows)
7312 (setq buffer-read-only nil) 7361 (setq buffer-read-only nil)
7313 (goto-char (point-max)) 7362 (goto-char (point-min))
7363 (while (not (eobp))
7364 (if (re-search-forward tramp-buf-regexp (tramp-point-at-eol) t)
7365 (forward-line 1)
7366 (forward-line 0)
7367 (let ((start (point)))
7368 (forward-line 1)
7369 (kill-region start (point)))))
7314 (insert " 7370 (insert "
7315 The buffer(s) above will be appended to this message. If you don't want 7371 The buffer(s) above will be appended to this message. If you don't want
7316 to append a buffer because it contains sensible data, or because the buffer 7372 to append a buffer because it contains sensible data, or because the buffer
7317 is too large, you should delete the respective buffer. The buffer(s) will 7373 is too large, you should delete the respective buffer. The buffer(s) will
7318 contain user and host names. Passwords will never be included there.") 7374 contain user and host names. Passwords will never be included there.")