• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.9.5/emacs-92/emacs/lisp/net/

Lines Matching +refs:tramp +refs:password +refs:prompt +refs:regexp

2 ;;; tramp.el --- Transparent Remote Access, Multiple Protocol
34 ;; the local and the remote host, whereas tramp.el uses a combination
48 ;; loaded before tramp.el. Could you please test this and tell me about
54 ;; http://ftp.gnu.org/gnu/tramp/
57 ;; tramp-devel@gnu.org
59 ;; http://lists.gnu.org/mailman/listinfo/tramp-devel
63 ;; http://savannah.gnu.org/projects/tramp/
72 (add-hook 'tramp-unload-hook
82 ;; As long as password.el is not part of (X)Emacs, it shouldn't
85 (load "password" 'noerror)
86 (require 'password nil 'noerror)) ;from No Gnus, also in tar ball
97 (autoload 'tramp-uuencode-region "tramp-uu"
99 (add-hook 'tramp-unload-hook
101 (when (featurep 'tramp-uu)
102 (unload-feature 'tramp-uu 'force))))
116 (defvar tramp-unified-filenames (not (featurep 'xemacs))
123 ;; tramp-ftp supports Ange-FTP only. Not suited for XEmacs therefore.
125 (eval-after-load "tramp"
127 (require 'tramp-ftp)
128 (add-hook 'tramp-unload-hook
130 (when (featurep 'tramp-ftp)
131 (unload-feature 'tramp-ftp 'force)))))))
132 (when (and tramp-unified-filenames (featurep 'xemacs))
133 (eval-after-load "tramp"
135 (require 'tramp-efs)
136 (add-hook 'tramp-unload-hook
138 (when (featurep 'tramp-efs)
139 (unload-feature 'tramp-efs 'force)))))))
141 ;; tramp-smb uses "smbclient" from Samba.
146 (eval-after-load "tramp"
148 (require 'tramp-smb)
149 (add-hook 'tramp-unload-hook
151 (when (featurep 'tramp-smb)
152 (unload-feature 'tramp-smb 'force)))))))
180 (defgroup tramp nil
185 (defcustom tramp-verbose 9
186 "*Verbosity level for tramp.el. 0 means be silent, 10 is most verbose."
187 :group 'tramp
190 (defcustom tramp-debug-buffer nil
192 :group 'tramp
198 (defcustom tramp-backup-directory-alist nil
205 \(setq tramp-backup-directory-alist backup-directory-alist\)
209 :group 'tramp
210 :type '(repeat (cons (regexp :tag "Regexp matching filename")
217 (defcustom tramp-bkup-backup-directory-info nil
224 \(setq tramp-bkup-backup-directory-info bkup-backup-directory-info\)
229 (list (regexp :tag "File regexp")
236 :group 'tramp)))
238 (defcustom tramp-auto-save-directory nil
241 :group 'tramp
245 (defcustom tramp-encoding-shell
260 variable `tramp-encoding-command-switch' for the \"-c\" part. Also, see the
261 variable `tramp-encoding-reads-stdin' to specify whether the commands read
265 mechanisms in tramp.el which automatically determine the right shell to
267 :group 'tramp
270 (defcustom tramp-encoding-command-switch
271 (if (string-match "cmd\\.exe" tramp-encoding-shell)
274 "*Use this switch together with `tramp-encoding-shell' for local commands.
275 See the variable `tramp-encoding-shell' for more information."
276 :group 'tramp
279 (defcustom tramp-encoding-reads-stdin t
284 :group 'tramp
287 (defcustom tramp-multi-sh-program
288 tramp-encoding-shell
290 This variable is similar to `tramp-encoding-shell', but it is only used
297 in `tramp-multi-connection-function-alist' for the first hop.
299 This variable defaults to the value of `tramp-encoding-shell'."
300 :group 'tramp
304 ;; tramp-shell-quote-argument, except in tramp-handle-expand-many-files.
307 ;;-(defcustom tramp-file-name-quote-list
315 ;;- :group 'tramp
318 (defcustom tramp-methods
319 '( ("rcp" (tramp-connection-function tramp-open-connection-rsh)
320 (tramp-login-program "rsh")
321 (tramp-copy-program "rcp")
322 (tramp-remote-sh "/bin/sh")
323 (tramp-login-args nil)
324 (tramp-copy-args nil)
325 (tramp-copy-keep-date-arg "-p")
326 (tramp-password-end-of-line nil))
327 ("scp" (tramp-connection-function tramp-open-connection-rsh)
328 (tramp-login-program "ssh")
329 (tramp-copy-program "scp")
330 (tramp-remote-sh "/bin/sh")
331 (tramp-login-args ("-e" "none"))
332 (tramp-copy-args nil)
333 (tramp-copy-keep-date-arg "-p")
334 (tramp-password-end-of-line nil))
335 ("scp1" (tramp-connection-function tramp-open-connection-rsh)
336 (tramp-login-program "ssh")
337 (tramp-copy-program "scp")
338 (tramp-remote-sh "/bin/sh")
339 (tramp-login-args ("-1" "-e" "none"))
340 (tramp-copy-args ("-1"))
341 (tramp-copy-keep-date-arg "-p")
342 (tramp-password-end-of-line nil))
343 ("scp2" (tramp-connection-function tramp-open-connection-rsh)
344 (tramp-login-program "ssh")
345 (tramp-copy-program "scp")
346 (tramp-remote-sh "/bin/sh")
347 (tramp-login-args ("-2" "-e" "none"))
348 (tramp-copy-args ("-2"))
349 (tramp-copy-keep-date-arg "-p")
350 (tramp-password-end-of-line nil))
352 (tramp-connection-function tramp-open-connection-rsh)
353 (tramp-login-program "ssh1")
354 (tramp-copy-program "scp1")
355 (tramp-remote-sh "/bin/sh")
356 (tramp-login-args ("-e" "none"))
357 (tramp-copy-args nil)
358 (tramp-copy-keep-date-arg "-p")
359 (tramp-password-end-of-line nil))
361 (tramp-connection-function tramp-open-connection-rsh)
362 (tramp-login-program "ssh2")
363 (tramp-copy-program "scp2")
364 (tramp-remote-sh "/bin/sh")
365 (tramp-login-args ("-e" "none"))
366 (tramp-copy-args nil)
367 (tramp-copy-keep-date-arg "-p")
368 (tramp-password-end-of-line nil))
369 ("rsync" (tramp-connection-function tramp-open-connection-rsh)
370 (tramp-login-program "ssh")
371 (tramp-copy-program "rsync")
372 (tramp-remote-sh "/bin/sh")
373 (tramp-login-args ("-e" "none"))
374 (tramp-copy-args ("-e" "ssh"))
375 (tramp-copy-keep-date-arg "-t")
376 (tramp-password-end-of-line nil))
377 ("remcp" (tramp-connection-function tramp-open-connection-rsh)
378 (tramp-login-program "remsh")
379 (tramp-copy-program "rcp")
380 (tramp-remote-sh "/bin/sh")
381 (tramp-login-args nil)
382 (tramp-copy-args nil)
383 (tramp-copy-keep-date-arg "-p")
384 (tramp-password-end-of-line nil))
385 ("rsh" (tramp-connection-function tramp-open-connection-rsh)
386 (tramp-login-program "rsh")
387 (tramp-copy-program nil)
388 (tramp-remote-sh "/bin/sh")
389 (tramp-login-args nil)
390 (tramp-copy-args nil)
391 (tramp-copy-keep-date-arg nil)
392 (tramp-password-end-of-line nil))
393 ("ssh" (tramp-connection-function tramp-open-connection-rsh)
394 (tramp-login-program "ssh")
395 (tramp-copy-program nil)
396 (tramp-remote-sh "/bin/sh")
397 (tramp-login-args ("-e" "none"))
398 (tramp-copy-args nil)
399 (tramp-copy-keep-date-arg nil)
400 (tramp-password-end-of-line nil))
401 ("ssh1" (tramp-connection-function tramp-open-connection-rsh)
402 (tramp-login-program "ssh")
403 (tramp-copy-program nil)
404 (tramp-remote-sh "/bin/sh")
405 (tramp-login-args ("-1" "-e" "none"))
406 (tramp-copy-args ("-1"))
407 (tramp-copy-keep-date-arg nil)
408 (tramp-password-end-of-line nil))
409 ("ssh2" (tramp-connection-function tramp-open-connection-rsh)
410 (tramp-login-program "ssh")
411 (tramp-copy-program nil)
412 (tramp-remote-sh "/bin/sh")
413 (tramp-login-args ("-2" "-e" "none"))
414 (tramp-copy-args ("-2"))
415 (tramp-copy-keep-date-arg nil)
416 (tramp-password-end-of-line nil))
418 (tramp-connection-function tramp-open-connection-rsh)
419 (tramp-login-program "ssh1")
420 (tramp-copy-program nil)
421 (tramp-remote-sh "/bin/sh")
422 (tramp-login-args ("-e" "none"))
423 (tramp-copy-args nil)
424 (tramp-copy-keep-date-arg nil)
425 (tramp-password-end-of-line nil))
427 (tramp-connection-function tramp-open-connection-rsh)
428 (tramp-login-program "ssh2")
429 (tramp-copy-program nil)
430 (tramp-remote-sh "/bin/sh")
431 (tramp-login-args ("-e" "none"))
432 (tramp-copy-args nil)
433 (tramp-copy-keep-date-arg nil)
434 (tramp-password-end-of-line nil))
435 ("remsh" (tramp-connection-function tramp-open-connection-rsh)
436 (tramp-login-program "remsh")
437 (tramp-copy-program nil)
438 (tramp-remote-sh "/bin/sh")
439 (tramp-login-args nil)
440 (tramp-copy-args nil)
441 (tramp-copy-keep-date-arg nil)
442 (tramp-password-end-of-line nil))
444 (tramp-connection-function tramp-open-connection-telnet)
445 (tramp-login-program "telnet")
446 (tramp-copy-program nil)
447 (tramp-remote-sh "/bin/sh")
448 (tramp-login-args nil)
449 (tramp-copy-args nil)
450 (tramp-copy-keep-date-arg nil)
451 (tramp-password-end-of-line nil))
452 ("su" (tramp-connection-function tramp-open-connection-su)
453 (tramp-login-program "su")
454 (tramp-copy-program nil)
455 (tramp-remote-sh "/bin/sh")
456 (tramp-login-args ("-" "%u"))
457 (tramp-copy-args nil)
458 (tramp-copy-keep-date-arg nil)
459 (tramp-password-end-of-line nil))
460 ("sudo" (tramp-connection-function tramp-open-connection-su)
461 (tramp-login-program "sudo")
462 (tramp-copy-program nil)
463 (tramp-remote-sh "/bin/sh")
464 (tramp-login-args ("-u" "%u" "-s"
466 (tramp-copy-args nil)
467 (tramp-copy-keep-date-arg nil)
468 (tramp-password-end-of-line nil))
469 ("multi" (tramp-connection-function tramp-open-connection-multi)
470 (tramp-login-program nil)
471 (tramp-copy-program nil)
472 (tramp-remote-sh "/bin/sh")
473 (tramp-login-args nil)
474 (tramp-copy-args nil)
475 (tramp-copy-keep-date-arg nil)
476 (tramp-password-end-of-line nil))
477 ("scpc" (tramp-connection-function tramp-open-connection-rsh)
478 (tramp-login-program "ssh")
479 (tramp-copy-program "scp")
480 (tramp-remote-sh "/bin/sh")
481 (tramp-login-args ("-o" "ControlPath=%t.%%r@%%h:%%p"
484 (tramp-copy-args ("-o" "ControlPath=%t.%%r@%%h:%%p"
486 (tramp-copy-keep-date-arg "-p")
487 (tramp-password-end-of-line nil))
488 ("scpx" (tramp-connection-function tramp-open-connection-rsh)
489 (tramp-login-program "ssh")
490 (tramp-copy-program "scp")
491 (tramp-remote-sh "/bin/sh")
492 (tramp-login-args ("-e" "none" "-t" "-t" "/bin/sh"))
493 (tramp-copy-args nil)
494 (tramp-copy-keep-date-arg "-p")
495 (tramp-password-end-of-line nil))
496 ("sshx" (tramp-connection-function tramp-open-connection-rsh)
497 (tramp-login-program "ssh")
498 (tramp-copy-program nil)
499 (tramp-remote-sh "/bin/sh")
500 (tramp-login-args ("-e" "none" "-t" "-t" "/bin/sh"))
501 (tramp-copy-args nil)
502 (tramp-copy-keep-date-arg nil)
503 (tramp-password-end-of-line nil))
505 (tramp-connection-function tramp-open-connection-rsh)
506 (tramp-login-program "krlogin")
507 (tramp-copy-program nil)
508 (tramp-remote-sh "/bin/sh")
509 (tramp-login-args ("-x"))
510 (tramp-copy-args nil)
511 (tramp-copy-keep-date-arg nil)
512 (tramp-password-end-of-line nil))
514 (tramp-connection-function tramp-open-connection-rsh)
515 (tramp-login-program "plink")
516 (tramp-copy-program nil)
517 (tramp-remote-sh "/bin/sh")
518 (tramp-login-args ("-ssh")) ;optionally add "-v"
519 (tramp-copy-args nil)
520 (tramp-copy-keep-date-arg nil)
521 (tramp-password-end-of-line "xy")) ;see docstring for "xy"
523 (tramp-connection-function tramp-open-connection-rsh)
524 (tramp-login-program "plink")
525 (tramp-copy-program nil)
526 (tramp-remote-sh "/bin/sh")
527 (tramp-login-args ("-1" "-ssh")) ;optionally add "-v"
528 (tramp-copy-args nil)
529 (tramp-copy-keep-date-arg nil)
530 (tramp-password-end-of-line "xy")) ;see docstring for "xy"
532 (tramp-connection-function tramp-open-connection-rsh)
533 (tramp-login-program "plink")
534 (tramp-copy-program "pscp")
535 (tramp-remote-sh "/bin/sh")
536 (tramp-login-args ("-ssh"))
537 (tramp-copy-args nil)
538 (tramp-copy-keep-date-arg "-p")
539 (tramp-password-end-of-line "xy")) ;see docstring for "xy"
541 (tramp-connection-function tramp-open-connection-rsh)
542 (tramp-login-program "fsh")
543 (tramp-copy-program "fcp")
544 (tramp-remote-sh "/bin/sh -i")
545 (tramp-login-args ("sh" "-i"))
546 (tramp-copy-args nil)
547 (tramp-copy-keep-date-arg "-p")
548 (tramp-password-end-of-line nil))
554 * `tramp-connection-function'
556 Currently, `tramp-open-connection-rsh', `tramp-open-connection-telnet'
557 and `tramp-open-connection-su' are defined. See the documentation
559 * `tramp-remote-sh'
562 this to any value other than \"/bin/sh\": tramp wants to use a shell
566 * `tramp-login-program'
568 remote host. Depending on `tramp-connection-function', this may be
570 `tramp-connection-function' is `tramp-open-connection-rsh'), or the
571 name of telnet or a workalike (for `tramp-open-connection-telnet'),
572 or the name of su or a workalike (for `tramp-open-connection-su').
573 * `tramp-login-args'
579 If `tramp-connection-function' is `tramp-open-connection-su', then
583 * `tramp-copy-program'
587 * `tramp-copy-args'
589 program, the hints for `tramp-login-args' also apply here.
590 * `tramp-copy-keep-date-arg'
594 * `tramp-password-end-of-line'
596 submitting the password. If this method parameter is nil, then the
597 value of the normal variable `tramp-default-password-end-of-line'
599 requires any two characters after sending the password. These do
604 What does all this mean? Well, you should specify `tramp-login-program'
608 to do this, set `tramp-copy-program' in the method.
611 file is passed through the same buffer used by `tramp-login-program'. In
613 `tramp-login-program' might use escape codes or the connection might not
615 See the variable `tramp-coding-commands' for details.
618 must specify `tramp-copy-program' and `tramp-copy-args'. If it is an
620 inline or out of band, must specify `tramp-connection-function' plus
622 `tramp-open-connection-telnet').
626 When using `tramp-open-connection-su' the phrase `open connection to a
631 :group 'tramp
634 (set (list (const tramp-connection-function) function)
635 (list (const tramp-login-program)
637 (list (const tramp-copy-program)
639 (list (const tramp-remote-sh)
641 (list (const tramp-login-args) (repeat string))
642 (list (const tramp-copy-args) (repeat string))
643 (list (const tramp-copy-keep-date-arg)
645 (list (const tramp-encoding-command)
647 (list (const tramp-decoding-command)
649 (list (const tramp-encoding-function)
651 (list (const tramp-decoding-function)
653 (list (const tramp-password-end-of-line)
656 (defcustom tramp-multi-methods '("multi" "multiu")
659 variable `tramp-methods'."
660 :group 'tramp
663 (defcustom tramp-multi-connection-function-alist
664 '(("telnet" tramp-multi-connect-telnet "telnet %h%n")
665 ("rsh" tramp-multi-connect-rlogin "rsh %h -l %u%n")
666 ("remsh" tramp-multi-connect-rlogin "remsh %h -l %u%n")
667 ("ssh" tramp-multi-connect-rlogin "ssh %h -l %u%n")
668 ("ssht" tramp-multi-connect-rlogin "ssh %h -e none -t -t -l %u%n")
669 ("su" tramp-multi-connect-su "su - %u%n")
670 ("sudo" tramp-multi-connect-su "sudo -u %u -s -p Password:%n"))
680 `tramp-rsh-end-of-line'. Use `%%' for a literal percent character.
683 function `tramp-multi-connect-telnet'. See the documentation of the
685 :group 'tramp
688 (defcustom tramp-default-method
692 ;; permanent password queries. Either a password agent like
693 ;; "ssh-agent" or "Pageant" shall run, or the optional password.el
694 ;; package shall be active for password caching. "scpc" would be
702 (if (or (fboundp 'password-read)
710 (if (or (fboundp 'password-read)
723 See `tramp-methods' for possibilities.
724 Also see `tramp-default-method-alist'."
725 :group 'tramp
728 (defcustom tramp-default-method-alist
735 matches, the variable `tramp-default-method' takes effect.
740 See `tramp-methods' for a list of possibilities for METHOD."
741 :group 'tramp
742 :type '(repeat (list (regexp :tag "Host regexp")
743 (regexp :tag "User regexp")
747 (defconst tramp-completion-function-alist-rsh
749 '((tramp-parse-rhosts "/etc/hosts.equiv")
750 (tramp-parse-rhosts "~/.rhosts")))
754 (defconst tramp-completion-function-alist-ssh
756 '((tramp-parse-rhosts "/etc/hosts.equiv")
757 (tramp-parse-rhosts "/etc/shosts.equiv")
758 (tramp-parse-shosts "/etc/ssh_known_hosts")
759 (tramp-parse-sconfig "/etc/ssh_config")
760 (tramp-parse-shostkeys "/etc/ssh2/hostkeys")
761 (tramp-parse-sknownhosts "/etc/ssh2/knownhosts")
762 (tramp-parse-rhosts "~/.rhosts")
763 (tramp-parse-rhosts "~/.shosts")
764 (tramp-parse-shosts "~/.ssh/known_hosts")
765 (tramp-parse-sconfig "~/.ssh/config")
766 (tramp-parse-shostkeys "~/.ssh2/hostkeys")
767 (tramp-parse-sknownhosts "~/.ssh2/knownhosts")))
771 (defconst tramp-completion-function-alist-telnet
773 '((tramp-parse-hosts "/etc/hosts")))
777 (defconst tramp-completion-function-alist-su
779 '((tramp-parse-passwd "/etc/passwd")))
782 (defvar tramp-completion-function-alist nil
789 * `tramp-parse-rhosts' for \"~/.rhosts\" like files,
790 * `tramp-parse-shosts' for \"~/.ssh/known_hosts\" like files,
791 * `tramp-parse-sconfig' for \"~/.ssh/config\" like files,
792 * `tramp-parse-shostkeys' for \"~/.ssh2/hostkeys/*\" like files,
793 * `tramp-parse-sknownhosts' for \"~/.ssh2/knownhosts/*\" like files,
794 * `tramp-parse-hosts' for \"/etc/hosts\" like files,
795 * `tramp-parse-passwd' for \"/etc/passwd\" like files.
796 * `tramp-parse-netrc' for \"~/.netrc\" like files.
801 (eval-after-load "tramp"
803 (tramp-set-completion-function
804 "rcp" tramp-completion-function-alist-rsh)
805 (tramp-set-completion-function
806 "scp" tramp-completion-function-alist-ssh)
807 (tramp-set-completion-function
808 "scp1" tramp-completion-function-alist-ssh)
809 (tramp-set-completion-function
810 "scp2" tramp-completion-function-alist-ssh)
811 (tramp-set-completion-function
812 "scp1_old" tramp-completion-function-alist-ssh)
813 (tramp-set-completion-function
814 "scp2_old" tramp-completion-function-alist-ssh)
815 (tramp-set-completion-function
816 "rsync" tramp-completion-function-alist-rsh)
817 (tramp-set-completion-function
818 "remcp" tramp-completion-function-alist-rsh)
819 (tramp-set-completion-function
820 "rsh" tramp-completion-function-alist-rsh)
821 (tramp-set-completion-function
822 "ssh" tramp-completion-function-alist-ssh)
823 (tramp-set-completion-function
824 "ssh1" tramp-completion-function-alist-ssh)
825 (tramp-set-completion-function
826 "ssh2" tramp-completion-function-alist-ssh)
827 (tramp-set-completion-function
828 "ssh1_old" tramp-completion-function-alist-ssh)
829 (tramp-set-completion-function
830 "ssh2_old" tramp-completion-function-alist-ssh)
831 (tramp-set-completion-function
832 "remsh" tramp-completion-function-alist-rsh)
833 (tramp-set-completion-function
834 "telnet" tramp-completion-function-alist-telnet)
835 (tramp-set-completion-function
836 "su" tramp-completion-function-alist-su)
837 (tramp-set-completion-function
838 "sudo" tramp-completion-function-alist-su)
839 (tramp-set-completion-function
841 (tramp-set-completion-function
842 "scpx" tramp-completion-function-alist-ssh)
843 (tramp-set-completion-function
844 "sshx" tramp-completion-function-alist-ssh)
845 (tramp-set-completion-function
846 "krlogin" tramp-completion-function-alist-rsh)
847 (tramp-set-completion-function
848 "plink" tramp-completion-function-alist-ssh)
849 (tramp-set-completion-function
850 "plink1" tramp-completion-function-alist-ssh)
851 (tramp-set-completion-function
852 "pscp" tramp-completion-function-alist-ssh)
853 (tramp-set-completion-function
854 "fcp" tramp-completion-function-alist-ssh)))
856 (defcustom tramp-rsh-end-of-line "\n"
860 Also see the method parameter `tramp-password-end-of-line' and the normal
861 variable `tramp-default-password-end-of-line'."
862 :group 'tramp
865 (defcustom tramp-default-password-end-of-line
866 tramp-rsh-end-of-line
867 "*String used for end of line after sending a password.
869 `tramp-password-end-of-line', see `tramp-methods' for more details.
872 \"\\r\\n\" (carriage-return, then newline) after a password, but just
874 password, see `tramp-rsh-end-of-line' for the other cases.
876 The default value is to use the same value as `tramp-rsh-end-of-line'."
877 :group 'tramp
880 (defcustom tramp-remote-path
891 :group 'tramp
894 (defcustom tramp-login-prompt-regexp
897 The regexp should match at end of buffer.
899 Sometimes the prompt is reported to look like \"login as:\"."
900 :group 'tramp
901 :type 'regexp)
903 (defcustom tramp-shell-prompt-pattern
906 Normally, Tramp expects you to configure `shell-prompt-pattern'
908 remote host which sends a different kind of shell prompt. Therefore,
909 Tramp recognizes things matched by `shell-prompt-pattern' as prompt,
911 variable is similar to the default value of `shell-prompt-pattern',
913 :group 'tramp
914 :type 'regexp)
916 (defcustom tramp-password-prompt-regexp
918 "*Regexp matching password-like prompts.
919 The regexp should match at end of buffer.
921 The `sudo' program appears to insert a `^@' character into the prompt."
922 :group 'tramp
923 :type 'regexp)
925 (defcustom tramp-wrong-passwd-regexp
928 (regexp-opt '("Permission denied."
943 The regexp should match at end of buffer."
944 :group 'tramp
945 :type 'regexp)
947 (defcustom tramp-yesno-prompt-regexp
949 (regexp-opt '("Are you sure you want to continue connecting (yes/no)?") t)
953 The regexp should match at end of buffer.
954 See also `tramp-yn-prompt-regexp'."
955 :group 'tramp
956 :type 'regexp)
958 (defcustom tramp-yn-prompt-regexp
960 (regexp-opt '("Store key in cache? (y/n)"
965 The regexp should match at end of buffer.
966 See also `tramp-yesno-prompt-regexp'."
967 :group 'tramp
968 :type 'regexp)
970 (defcustom tramp-terminal-prompt-regexp
977 The regexp should match at end of buffer.
978 The answer will be provided by `tramp-action-terminal', which see."
979 :group 'tramp
980 :type 'regexp)
982 (defcustom tramp-operation-not-permitted-regexp
984 (regexp-opt '("Operation not permitted") t))
988 :group 'tramp
989 :type 'regexp)
991 (defcustom tramp-copy-failed-regexp
993 (regexp-opt '("Permission denied"
999 :group 'tramp
1000 :type 'regexp)
1002 (defcustom tramp-process-alive-regexp
1007 The answer will be provided by `tramp-action-process-alive',
1008 `tramp-multi-action-process-alive' and`tramp-action-out-of-band', which see."
1009 :group 'tramp
1010 :type 'regexp)
1012 (defcustom tramp-temp-name-prefix "tramp."
1014 If this is a relative file name (such as \"tramp.\"), it is considered
1016 `tramp-temporary-file-directory' (which see). It may also be an
1019 :group 'tramp
1022 (defcustom tramp-discard-garbage nil
1025 :group 'tramp
1028 (defcustom tramp-sh-extra-args '(("/bash\\'" . "-norc -noprofile"))
1037 :group 'tramp
1044 (defcustom tramp-prefix-format
1045 (if tramp-unified-filenames "/" "/[")
1046 "*String matching the very beginning of tramp file names.
1047 Used in `tramp-make-tramp-file-name' and `tramp-make-tramp-multi-file-name'."
1048 :group 'tramp
1051 (defcustom tramp-prefix-regexp
1052 (concat "^" (regexp-quote tramp-prefix-format))
1053 "*Regexp matching the very beginning of tramp file names.
1054 Should always start with \"^\". Derived from `tramp-prefix-format'."
1055 :group 'tramp
1056 :type 'regexp)
1058 (defcustom tramp-method-regexp
1061 :group 'tramp
1062 :type 'regexp)
1066 (defcustom tramp-postfix-single-method-format
1067 (if tramp-unified-filenames ":" "/")
1070 Used in `tramp-make-tramp-file-name'."
1071 :group 'tramp
1074 (defcustom tramp-postfix-single-method-regexp
1075 (regexp-quote tramp-postfix-single-method-format)
1078 Derived from `tramp-postfix-single-method-format'."
1079 :group 'tramp
1080 :type 'regexp)
1082 (defcustom tramp-postfix-multi-method-format
1086 Used in `tramp-make-tramp-multi-file-name'."
1087 :group 'tramp
1090 (defcustom tramp-postfix-multi-method-regexp
1091 (regexp-quote tramp-postfix-multi-method-format)
1094 Derived from `tramp-postfix-multi-method-format'."
1095 :group 'tramp
1096 :type 'regexp)
1098 (defcustom tramp-postfix-multi-hop-format
1099 (if tramp-unified-filenames ":" "/")
1102 Used in `tramp-make-tramp-multi-file-name'."
1103 :group 'tramp
1106 (defcustom tramp-postfix-multi-hop-regexp
1107 (regexp-quote tramp-postfix-multi-hop-format)
1110 Derived from `tramp-postfix-multi-hop-format'."
1111 :group 'tramp
1112 :type 'regexp)
1114 (defcustom tramp-user-regexp
1117 :group 'tramp
1118 :type 'regexp)
1120 (defcustom tramp-postfix-user-format
1123 Used in `tramp-make-tramp-file-name' and `tramp-make-tramp-multi-file-name'."
1124 :group 'tramp
1127 (defcustom tramp-postfix-user-regexp
1128 (regexp-quote tramp-postfix-user-format)
1130 Derived from `tramp-postfix-user-format'."
1131 :group 'tramp
1132 :type 'regexp)
1134 (defcustom tramp-host-regexp
1137 :group 'tramp
1138 :type 'regexp)
1140 (defcustom tramp-host-with-port-regexp
1143 :group 'tramp
1144 :type 'regexp)
1146 (defcustom tramp-postfix-host-format
1147 (if tramp-unified-filenames ":" "]")
1149 Used in `tramp-make-tramp-file-name' and `tramp-make-tramp-multi-file-name'."
1150 :group 'tramp
1153 (defcustom tramp-postfix-host-regexp
1154 (regexp-quote tramp-postfix-host-format)
1156 Derived from `tramp-postfix-host-format'."
1157 :group 'tramp
1158 :type 'regexp)
1160 (defcustom tramp-localname-regexp
1163 :group 'tramp
1164 :type 'regexp)
1168 (defcustom tramp-file-name-structure
1171 tramp-prefix-regexp
1172 "\\(" "\\(" tramp-method-regexp "\\)" tramp-postfix-single-method-regexp "\\)?"
1173 "\\(" "\\(" tramp-user-regexp "\\)" tramp-postfix-user-regexp "\\)?"
1174 "\\(" tramp-host-with-port-regexp "\\)" tramp-postfix-host-regexp
1175 "\\(" tramp-localname-regexp "\\)")
1179 the tramp file name structure.
1181 The first element REGEXP is a regular expression matching a tramp file
1192 See also `tramp-file-name-regexp'."
1193 :group 'tramp
1194 :type '(list (regexp :tag "File name regexp")
1201 (defconst tramp-file-name-regexp-unified
1203 "Value for `tramp-file-name-regexp' for unified remoting.
1205 Tramp. See `tramp-file-name-structure-unified' for more explanations.")
1208 (defconst tramp-file-name-regexp-separate
1210 "Value for `tramp-file-name-regexp' for separate remoting.
1212 See `tramp-file-name-structure-separate' for more explanations.")
1215 (defcustom tramp-file-name-regexp
1216 (if tramp-unified-filenames
1217 tramp-file-name-regexp-unified
1218 tramp-file-name-regexp-separate)
1219 "*Regular expression matching file names handled by tramp.
1220 This regexp should match tramp file names but no other file names.
1221 \(When tramp.el is loaded, this regular expression is prepended to
1223 if the tramp entry appears rather early in the `file-name-handler-alist'
1224 and is a bit too general, then some files might be considered tramp
1225 files which are not really tramp files.
1228 this file (tramp.el) is loaded. This means that this variable must be set
1229 before loading tramp.el. Alternatively, `file-name-handler-alist' can be
1232 Also see `tramp-file-name-structure'."
1233 :group 'tramp
1234 :type 'regexp)
1237 (defconst tramp-completion-file-name-regexp-unified
1239 "Value for `tramp-completion-file-name-regexp' for unified remoting.
1241 Tramp. See `tramp-file-name-structure-unified' for more explanations.")
1244 (defconst tramp-completion-file-name-regexp-separate
1246 "Value for `tramp-completion-file-name-regexp' for separate remoting.
1248 See `tramp-file-name-structure-separate' for more explanations.")
1251 (defcustom tramp-completion-file-name-regexp
1252 (if tramp-unified-filenames
1253 tramp-completion-file-name-regexp-unified
1254 tramp-completion-file-name-regexp-separate)
1255 "*Regular expression matching file names handled by tramp completion.
1256 This regexp should match partial tramp file names only.
1259 this file (tramp.el) is loaded. This means that this variable must be set
1260 before loading tramp.el. Alternatively, `file-name-handler-alist' can be
1263 Also see `tramp-file-name-structure'."
1264 :group 'tramp
1265 :type 'regexp)
1267 (defcustom tramp-multi-file-name-structure
1270 tramp-prefix-regexp
1271 "\\(" "\\(" tramp-method-regexp "\\)" "\\)?"
1272 "\\(" "\\(" tramp-postfix-multi-hop-regexp "%s" "\\)+" "\\)?"
1273 tramp-postfix-host-regexp "\\(" tramp-localname-regexp "\\)")
1281 value of `tramp-multi-file-name-hop-structure'. (Note: in order to
1294 I think it would be good if the regexp matches the whole of the
1296 :group 'tramp
1297 :type '(list (regexp :tag "File name regexp")
1302 (defcustom tramp-multi-file-name-hop-structure
1305 "\\(" tramp-method-regexp "\\)" tramp-postfix-multi-method-regexp
1306 "\\(" tramp-user-regexp "\\)" tramp-postfix-user-regexp
1307 "\\(" tramp-host-with-port-regexp "\\)")
1316 :group 'tramp
1317 :type '(list (regexp :tag "Hop regexp")
1322 (defcustom tramp-make-multi-tramp-file-format
1324 (concat tramp-prefix-format "%m")
1325 (concat tramp-postfix-multi-hop-format
1326 "%m" tramp-postfix-multi-method-format
1327 "%u" tramp-postfix-user-format
1329 (concat tramp-postfix-host-format "%p"))
1351 :group 'tramp
1354 (defcustom tramp-terminal-type "dumb"
1359 :group 'tramp
1362 (defcustom tramp-completion-without-shell-p nil
1369 :group 'tramp
1372 (defcustom tramp-actions-before-shell
1373 '((tramp-password-prompt-regexp tramp-action-password)
1374 (tramp-login-prompt-regexp tramp-action-login)
1375 (shell-prompt-pattern tramp-action-succeed)
1376 (tramp-shell-prompt-pattern tramp-action-succeed)
1377 (tramp-wrong-passwd-regexp tramp-action-permission-denied)
1378 (tramp-yesno-prompt-regexp tramp-action-yesno)
1379 (tramp-yn-prompt-regexp tramp-action-yn)
1380 (tramp-terminal-prompt-regexp tramp-action-terminal)
1381 (tramp-process-alive-regexp tramp-action-process-alive))
1388 regexp must match at the end of the buffer, \"\\'\" is implicitly
1393 :group 'tramp
1396 (defcustom tramp-actions-copy-out-of-band
1397 '((tramp-password-prompt-regexp tramp-action-password)
1398 (tramp-wrong-passwd-regexp tramp-action-permission-denied)
1399 (tramp-copy-failed-regexp tramp-action-copy-failed)
1400 (tramp-process-alive-regexp tramp-action-out-of-band))
1403 See `tramp-actions-before-shell' for more info."
1404 :group 'tramp
1407 (defcustom tramp-multi-actions
1408 '((tramp-password-prompt-regexp tramp-multi-action-password)
1409 (tramp-login-prompt-regexp tramp-multi-action-login)
1410 (shell-prompt-pattern tramp-multi-action-succeed)
1411 (tramp-shell-prompt-pattern tramp-multi-action-succeed)
1412 (tramp-wrong-passwd-regexp tramp-multi-action-permission-denied)
1413 (tramp-process-alive-regexp tramp-multi-action-process-alive))
1416 See `tramp-actions-before-shell' for more info."
1417 :group 'tramp
1420 (defcustom tramp-initial-commands
1433 :group 'tramp
1440 ;; when `tramp-chunksize' is zero or nil.
1441 (defcustom tramp-chunksize
1475 (message \"You should set `tramp-chunksize' to a maximum of %s\"
1486 \"ssh\" to run without password query, see ssh-agent(1).
1493 about the value `tramp-chunksize' should be set. Maybe you could just
1497 When it is necessary to set `tramp-chunksize', you might consider to
1499 \(like \"ssh\"), because setting `tramp-chunksize' to non-nil decreases
1502 Please raise a bug report via \"M-x tramp-bug\" if your system needs
1504 :group 'tramp
1511 (defcustom tramp-process-connection-type t
1515 :group 'tramp
1520 (defvar tramp-buffer-file-attributes nil
1525 (make-variable-buffer-local 'tramp-buffer-file-attributes)
1527 (defvar tramp-md5-function
1535 (defvar tramp-end-of-output
1537 (funcall tramp-md5-function
1545 ;; (tramp-temporary-file-directory)))
1550 ;; (tramp-temporary-file-directory))
1555 (defvar tramp-connection-function nil
1556 "This internal variable holds a parameter for `tramp-methods'.
1558 method parameter, as specified in `tramp-methods' (which see).")
1560 (defvar tramp-remote-sh nil
1561 "This internal variable holds a parameter for `tramp-methods'.
1563 method parameter, as specified in `tramp-methods' (which see).")
1565 (defvar tramp-login-program nil
1566 "This internal variable holds a parameter for `tramp-methods'.
1568 method parameter, as specified in `tramp-methods' (which see).")
1570 (defvar tramp-login-args nil
1571 "This internal variable holds a parameter for `tramp-methods'.
1573 method parameter, as specified in `tramp-methods' (which see).")
1575 (defvar tramp-copy-program nil
1576 "This internal variable holds a parameter for `tramp-methods'.
1578 method parameter, as specified in `tramp-methods' (which see).")
1580 (defvar tramp-copy-args nil
1581 "This internal variable holds a parameter for `tramp-methods'.
1583 method parameter, as specified in `tramp-methods' (which see).")
1585 (defvar tramp-copy-keep-date-arg nil
1586 "This internal variable holds a parameter for `tramp-methods'.
1588 method parameter, as specified in `tramp-methods' (which see).")
1590 (defvar tramp-encoding-command nil
1591 "This internal variable holds a parameter for `tramp-methods'.
1593 method parameter, as specified in `tramp-methods' (which see).")
1595 (defvar tramp-decoding-command nil
1596 "This internal variable holds a parameter for `tramp-methods'.
1598 method parameter, as specified in `tramp-methods' (which see).")
1600 (defvar tramp-encoding-function nil
1601 "This internal variable holds a parameter for `tramp-methods'.
1603 method parameter, as specified in `tramp-methods' (which see).")
1605 (defvar tramp-decoding-function nil
1606 "This internal variable holds a parameter for `tramp-methods'.
1608 method parameter, as specified in `tramp-methods' (which see).")
1610 (defvar tramp-password-end-of-line nil
1611 "This internal variable holds a parameter for `tramp-methods'.
1613 method parameter, as specified in `tramp-methods' (which see).")
1616 (defvar tramp-ls-command nil
1621 (defvar tramp-current-multi-method nil
1622 "Name of `multi' connection method for this *tramp* buffer, or nil if not multi.
1626 (defvar tramp-current-method nil
1627 "Connection method for this *tramp* buffer.
1631 (defvar tramp-current-user nil
1632 "Remote login name for this *tramp* buffer.
1636 (defvar tramp-current-host nil
1637 "Remote host for this *tramp* buffer.
1641 (defvar tramp-test-groks-nt nil
1647 (defvar tramp-file-exists-command nil
1652 (defconst tramp-uudecode "\
1654 \(echo begin 600 /tmp/tramp.$$; tail +2) | uudecode
1655 cat /tmp/tramp.$$
1656 rm -f /tmp/tramp.$$
1668 ;; device number set in `tramp-handle-file-attributes'
1669 (defconst tramp-perl-file-attributes "\
1706 (defconst tramp-perl-directory-files-and-attributes "\
1757 ;; (defvar tramp-perl-encode "%s -e'\
1770 ;; (defvar tramp-perl-decode "%s -ne '
1777 (defvar tramp-perl-encode-with-module
1785 (defvar tramp-perl-decode-with-module
1793 (defvar tramp-perl-encode
1836 (defvar tramp-perl-decode
1882 (defconst tramp-file-mode-type-map '((0 . "-") ; Normal file (SVID-v2 and XPG2)
1900 (defvar tramp-dos-coding-system
1907 (defvar tramp-last-cmd nil
1910 (make-variable-buffer-local 'tramp-last-cmd)
1912 (defvar tramp-process-echoes nil
1915 (defvar tramp-last-cmd-time nil
1918 (make-variable-buffer-local 'tramp-last-cmd-time)
1922 (defvar tramp-feature-write-region-fix
1935 (defconst tramp-file-name-handler-alist
1937 (load . tramp-handle-load)
1938 (make-symbolic-link . tramp-handle-make-symbolic-link)
1939 (file-name-directory . tramp-handle-file-name-directory)
1940 (file-name-nondirectory . tramp-handle-file-name-nondirectory)
1941 (file-truename . tramp-handle-file-truename)
1942 (file-exists-p . tramp-handle-file-exists-p)
1943 (file-directory-p . tramp-handle-file-directory-p)
1944 (file-executable-p . tramp-handle-file-executable-p)
1945 (file-accessible-directory-p . tramp-handle-file-accessible-directory-p)
1946 (file-readable-p . tramp-handle-file-readable-p)
1947 (file-regular-p . tramp-handle-file-regular-p)
1948 (file-symlink-p . tramp-handle-file-symlink-p)
1949 (file-writable-p . tramp-handle-file-writable-p)
1950 (file-ownership-preserved-p . tramp-handle-file-ownership-preserved-p)
1951 (file-newer-than-file-p . tramp-handle-file-newer-than-file-p)
1952 (file-attributes . tramp-handle-file-attributes)
1953 (file-modes . tramp-handle-file-modes)
1954 (directory-files . tramp-handle-directory-files)
1955 (directory-files-and-attributes . tramp-handle-directory-files-and-attributes)
1956 (file-name-all-completions . tramp-handle-file-name-all-completions)
1957 (file-name-completion . tramp-handle-file-name-completion)
1958 (add-name-to-file . tramp-handle-add-name-to-file)
1959 (copy-file . tramp-handle-copy-file)
1960 (rename-file . tramp-handle-rename-file)
1961 (set-file-modes . tramp-handle-set-file-modes)
1962 (make-directory . tramp-handle-make-directory)
1963 (delete-directory . tramp-handle-delete-directory)
1964 (delete-file . tramp-handle-delete-file)
1965 (directory-file-name . tramp-handle-directory-file-name)
1966 (shell-command . tramp-handle-shell-command)
1967 (process-file . tramp-handle-process-file)
1968 (insert-directory . tramp-handle-insert-directory)
1969 (expand-file-name . tramp-handle-expand-file-name)
1970 (file-local-copy . tramp-handle-file-local-copy)
1971 (file-remote-p . tramp-handle-file-remote-p)
1972 (insert-file-contents . tramp-handle-insert-file-contents)
1973 (write-region . tramp-handle-write-region)
1974 (find-backup-file-name . tramp-handle-find-backup-file-name)
1975 (make-auto-save-file-name . tramp-handle-make-auto-save-file-name)
1976 (unhandled-file-name-directory . tramp-handle-unhandled-file-name-directory)
1977 (dired-compress-file . tramp-handle-dired-compress-file)
1978 (dired-call-process . tramp-handle-dired-call-process)
1980 . tramp-handle-dired-recursive-delete-directory)
1981 (set-visited-file-modtime . tramp-handle-set-visited-file-modtime)
1982 (verify-visited-file-modtime . tramp-handle-verify-visited-file-modtime))
1986 ;; Handlers for partial tramp file names. For Emacs just
1989 (defconst tramp-completion-file-name-handler-alist
1990 '((file-name-all-completions . tramp-completion-handle-file-name-all-completions)
1991 (file-name-completion . tramp-completion-handle-file-name-completion))
1993 Used for file names matching `tramp-file-name-regexp'. Operations not
1994 mentioned here will be handled by `tramp-file-name-handler-alist' or the
1998 (defvar tramp-foreign-file-name-handler-alist
1999 ;; (identity . tramp-sh-file-name-handler) should always be the last
2001 '((identity . tramp-sh-file-name-handler))
2008 (defsubst tramp-message (level fmt-string &rest args)
2010 First arg LEVEL says to be quiet if `tramp-verbose' is less than LEVEL. The
2011 message is emitted only if `tramp-verbose' is greater than or equal to LEVEL.
2015 This function expects to be called from the tramp buffer only!"
2016 (when (<= level tramp-verbose)
2017 (apply #'message (concat "tramp: " fmt-string) args)
2018 (when tramp-debug-buffer
2021 (tramp-get-debug-buffer
2022 tramp-current-multi-method tramp-current-method
2023 tramp-current-user tramp-current-host))
2027 (tramp-insert-with-face
2031 (defun tramp-message-for-buffer
2033 "Like `tramp-message' but temporarily switches to the tramp buffer.
2034 First three args METHOD, USER, and HOST identify the tramp buffer to use,
2035 remaining args passed to `tramp-message'."
2037 (set-buffer (tramp-get-buffer multi-method method user host))
2038 (apply 'tramp-message level fmt-string args)))
2040 (defsubst tramp-line-end-position nil
2049 (defmacro with-parsed-tramp-file-name (filename var &rest body)
2065 `(let* ((,(or var 'v) (tramp-dissect-file-name ,filename))
2067 (tramp-file-name-multi-method ,(or var 'v)))
2069 (tramp-file-name-method ,(or var 'v)))
2071 (tramp-file-name-user ,(or var 'v)))
2073 (tramp-file-name-host ,(or var 'v)))
2075 (tramp-file-name-localname ,(or var 'v))))
2078 (put 'with-parsed-tramp-file-name 'lisp-indent-function 2)
2080 (def-edebug-spec with-parsed-tramp-file-name (form symbolp body))
2084 'emacs-lisp-mode '("\\<with-parsed-tramp-file-name\\>")))
2086 (defmacro tramp-let-maybe (variable value &rest body)
2094 (put 'tramp-let-maybe 'lisp-indent-function 2)
2095 (put 'tramp-let-maybe 'edebug-form-spec t)
2099 (defun tramp-set-completion-function (method function-list)
2104 Predefined FUNCTIONs are `tramp-parse-rhosts', `tramp-parse-shosts',
2105 `tramp-parse-sconfig',`tramp-parse-hosts', `tramp-parse-passwd',
2106 and `tramp-parse-netrc'.
2110 (tramp-set-completion-function
2112 '((tramp-parse-sconfig \"/etc/ssh_config\")
2113 (tramp-parse-sconfig \"~/.ssh/config\")))"
2117 (setq tramp-completion-function-alist
2118 (delete (assoc method tramp-completion-function-alist)
2119 tramp-completion-function-alist))
2132 (add-to-list 'tramp-completion-function-alist
2135 (defun tramp-get-completion-function (method)
2137 For definition of that list see `tramp-set-completion-function'."
2138 (cdr (assoc method tramp-completion-function-alist)))
2142 (defun tramp-handle-make-symbolic-link
2144 "Like `make-symbolic-link' for tramp files.
2153 (with-parsed-tramp-file-name linkname l
2154 (let ((ln (tramp-get-remote-ln l-multi-method l-method l-user l-host))
2174 (when (tramp-tramp-file-p filename)
2175 (setq filename (tramp-file-name-localname
2176 (tramp-dissect-file-name
2183 (tramp-send-command-and-check
2192 (defun tramp-handle-load (file &optional noerror nomessage nosuffix must-suffix)
2193 "Like `load' for tramp files. Not implemented!"
2196 (with-parsed-tramp-file-name file nil
2225 (defun tramp-handle-file-name-directory (file)
2228 (with-parsed-tramp-file-name file nil
2230 (tramp-make-tramp-file-name
2233 (defun tramp-handle-file-name-nondirectory (file)
2235 (with-parsed-tramp-file-name file nil
2238 (defun tramp-handle-file-truename (filename &optional counter prev-dirs)
2239 "Like `file-truename' for tramp files."
2240 (with-parsed-tramp-file-name (expand-file-name filename) nil
2241 (let* ((steps (tramp-split-string localname "/"))
2242 (localnamedir (tramp-let-maybe directory-sep-char ?/ ;for XEmacs
2254 (tramp-message-for-buffer
2259 (tramp-message-for-buffer
2267 (tramp-make-tramp-file-name
2275 (tramp-message-for-buffer multi-method method user host
2278 (tramp-message-for-buffer multi-method method user host
2283 (tramp-message-for-buffer
2292 (when (tramp-tramp-file-p symlink-target)
2293 (with-parsed-tramp-file-name symlink-target sym
2301 (append (tramp-split-string symlink-target "/") steps)))
2316 (tramp-message-for-buffer
2319 (tramp-make-tramp-file-name
2324 (defun tramp-handle-file-exists-p (filename)
2325 "Like `file-exists-p' for tramp files."
2326 (with-parsed-tramp-file-name filename nil
2328 (zerop (tramp-send-command-and-check
2331 (tramp-get-file-exists-command multi-method method user host)
2332 (tramp-shell-quote-argument localname)))))))
2339 (defvar tramp-devices nil
2345 (defun tramp-handle-file-attributes (filename &optional id-format)
2346 "Like `file-attributes' for tramp files."
2350 (with-parsed-tramp-file-name filename nil
2352 (tramp-convert-file-attributes
2354 (if (tramp-get-remote-perl multi-method method user host)
2355 (tramp-handle-file-attributes-with-perl multi-method method user host
2357 (tramp-handle-file-attributes-with-ls multi-method method user host
2360 (defun tramp-handle-file-attributes-with-ls
2362 "Implement `file-attributes' for tramp files using the ls(1) command."
2366 (tramp-message-for-buffer multi-method method user host 10
2368 (tramp-make-tramp-file-name
2370 (tramp-send-command
2373 (tramp-get-ls-command multi-method method user host)
2375 (tramp-shell-quote-argument localname)))
2376 (tramp-wait-for-output)
2414 (tramp-line-end-position))))
2437 ;; recreated. Will be set in `tramp-convert-file-attributes'
2445 (defun tramp-handle-file-attributes-with-perl
2447 "Implement `file-attributes' for tramp files using a Perl script."
2448 (tramp-message-for-buffer multi-method method user host 10
2450 (tramp-make-tramp-file-name
2452 (tramp-maybe-send-perl-script multi-method method user host
2453 tramp-perl-file-attributes
2455 (tramp-send-command multi-method method user host
2457 (tramp-shell-quote-argument localname) id-format))
2458 (tramp-wait-for-output)
2461 (defun tramp-handle-set-visited-file-modtime (&optional time-list)
2462 "Like `set-visited-file-modtime' for tramp files."
2467 (tramp-run-real-handler 'set-visited-file-modtime (list time-list))
2470 (with-parsed-tramp-file-name f nil
2477 ;; `tramp-handle-file-attributes-with-ls'.
2479 (tramp-run-real-handler 'set-visited-file-modtime (list modtime))
2481 (tramp-send-command
2484 (tramp-get-ls-command multi-method method user host)
2485 (tramp-shell-quote-argument localname)))
2486 (tramp-wait-for-output)
2489 (setq tramp-buffer-file-attributes attr))
2497 ;; `tramp-handle-set-visited-file-modtime'.
2498 (defun tramp-handle-verify-visited-file-modtime (buf)
2499 "Like `verify-visited-file-modtime' for tramp files.
2512 (with-parsed-tramp-file-name f nil
2520 (< (abs (tramp-time-diff
2532 (tramp-send-command
2535 (tramp-get-ls-command multi-method method user host)
2536 (tramp-shell-quote-argument localname)))
2537 (tramp-wait-for-output)
2540 (equal tramp-buffer-file-attributes attr))
2545 (defun tramp-handle-set-file-modes (filename mode)
2546 "Like `set-file-modes' for tramp files."
2547 (with-parsed-tramp-file-name filename nil
2549 (unless (zerop (tramp-send-command-and-check
2552 (tramp-decimal-to-octal mode)
2553 (tramp-shell-quote-argument localname))))
2562 (defun tramp-handle-file-executable-p (filename)
2563 "Like `file-executable-p' for tramp files."
2564 (with-parsed-tramp-file-name filename nil
2565 (zerop (tramp-run-test "-x" filename))))
2567 (defun tramp-handle-file-readable-p (filename)
2568 "Like `file-readable-p' for tramp files."
2569 (with-parsed-tramp-file-name filename nil
2570 (zerop (tramp-run-test "-r" filename))))
2572 (defun tramp-handle-file-accessible-directory-p (filename)
2573 "Like `file-accessible-directory-p' for tramp files."
2574 (with-parsed-tramp-file-name filename nil
2575 (and (zerop (tramp-run-test "-d" filename))
2576 (zerop (tramp-run-test "-r" filename))
2577 (zerop (tramp-run-test "-x" filename)))))
2584 (defun tramp-handle-file-newer-than-file-p (file1 file2)
2585 "Like `file-newer-than-file-p' for tramp files."
2600 (> 0 (tramp-time-diff (nth 5 fa2) (nth 5 fa1)))
2606 (unless (and (tramp-tramp-file-p file1)
2607 (tramp-tramp-file-p file2))
2613 (with-parsed-tramp-file-name file1 v1
2614 (with-parsed-tramp-file-name file2 v2
2622 (unless (and (tramp-tramp-file-p file1)
2623 (tramp-tramp-file-p file2))
2625 (list "Files must be tramp files on same host"
2627 (if (tramp-get-test-groks-nt
2629 (zerop (tramp-run-test2 "test" file1 file2 "-nt"))
2630 (zerop (tramp-run-test2
2635 (defun tramp-handle-file-modes (filename)
2636 "Like `file-modes' for tramp files."
2637 (with-parsed-tramp-file-name filename nil
2639 (tramp-mode-string-to-int
2642 (defun tramp-handle-file-directory-p (filename)
2643 "Like `file-directory-p' for tramp files."
2652 (with-parsed-tramp-file-name filename nil
2655 (tramp-send-command-and-check
2658 (tramp-shell-quote-argument localname))
2661 (defun tramp-handle-file-regular-p (filename)
2662 "Like `file-regular-p' for tramp files."
2663 (with-parsed-tramp-file-name filename nil
2667 (defun tramp-handle-file-symlink-p (filename)
2668 "Like `file-symlink-p' for tramp files."
2669 (with-parsed-tramp-file-name filename nil
2675 (tramp-make-tramp-file-name
2679 (defun tramp-handle-file-writable-p (filename)
2680 "Like `file-writable-p' for tramp files."
2681 (with-parsed-tramp-file-name filename nil
2684 (zerop (tramp-run-test "-w" filename))
2686 (and (zerop (tramp-run-test
2688 (zerop (tramp-run-test
2691 (defun tramp-handle-file-ownership-preserved-p (filename)
2692 "Like `file-ownership-preserved-p' for tramp files."
2693 (with-parsed-tramp-file-name filename nil
2699 (tramp-get-remote-uid multi-method method user host))))))
2704 ;; (defun tramp-handle-directory-file-name (directory)
2705 ;; "Like `directory-file-name' for tramp files."
2712 ;; (defun tramp-handle-directory-file-name (directory)
2713 ;; "Like `directory-file-name' for tramp files."
2714 ;; (with-parsed-tramp-file-name directory nil
2718 ;; (eq (string-match tramp-file-name-regexp directory) 0)
2723 (defun tramp-handle-directory-file-name (directory)
2724 "Like `directory-file-name' for tramp files."
2729 (with-parsed-tramp-file-name directory nil
2738 (defun tramp-handle-directory-files (directory
2740 "Like `directory-files' for tramp files."
2741 (with-parsed-tramp-file-name directory nil
2744 (tramp-barf-unless-okay
2746 (concat "cd " (tramp-shell-quote-argument localname))
2749 "tramp-handle-directory-files: couldn't `cd %s'"
2750 (tramp-shell-quote-argument localname))
2751 (tramp-send-command
2753 (concat (tramp-get-ls-command multi-method method user host)
2755 (tramp-wait-for-output)
2759 (tramp-line-end-position)))
2766 (tramp-send-command multi-method method user host "cd")
2767 (tramp-wait-for-output)
2771 ;; tramp-handle-file-name-all-completions.
2789 (defun tramp-handle-directory-files-and-attributes
2791 "Like `directory-files-and-attributes' for tramp files."
2792 (when (tramp-handle-file-exists-p directory)
2794 (setq directory (tramp-handle-expand-file-name directory))
2795 (with-parsed-tramp-file-name directory nil
2796 (tramp-maybe-send-perl-script multi-method method user host
2797 tramp-perl-directory-files-and-attributes
2799 (tramp-send-command multi-method method user host
2801 (tramp-shell-quote-argument localname)
2803 (tramp-wait-for-output)
2816 (tramp-convert-file-attributes multi-method method user host
2828 (defun tramp-handle-file-name-all-completions (filename directory)
2829 "Like `file-name-all-completions' for tramp files."
2830 (with-parsed-tramp-file-name directory nil
2832 (let* ((nowild tramp-completion-without-shell-p)
2835 (tramp-barf-unless-okay
2837 (format "cd %s" (tramp-shell-quote-argument localname))
2839 "tramp-handle-file-name-all-completions: Couldn't `cd %s'"
2840 (tramp-shell-quote-argument localname))
2845 (tramp-send-command
2850 (tramp-get-ls-command multi-method method user host)
2854 (tramp-shell-quote-argument filename)))))
2857 (tramp-wait-for-output)
2861 (tramp-line-end-position))
2864 (tramp-send-command multi-method method user host "cd")
2865 (tramp-wait-for-output)
2874 (defun tramp-handle-file-name-completion
2876 "Like `file-name-completion' for tramp files."
2877 (unless (tramp-tramp-file-p directory)
2879 "tramp-handle-file-name-completion invoked on non-tramp directory `%s'"
2889 (defun tramp-handle-add-name-to-file
2891 "Like `add-name-to-file' for tramp files."
2892 (with-parsed-tramp-file-name filename v1
2893 (with-parsed-tramp-file-name newname v2
2894 (let ((ln (when v1 (tramp-get-remote-ln
2911 (tramp-barf-unless-okay
2913 (format "%s %s %s" ln (tramp-shell-quote-argument v1-localname)
2914 (tramp-shell-quote-argument v2-localname))
2919 (defun tramp-handle-copy-file
2921 "Like `copy-file' for tramp files."
2923 ;; Otherwise, use tramp from local system.
2926 ;; At least one file a tramp file?
2927 (if (or (tramp-tramp-file-p filename)
2928 (tramp-tramp-file-p newname))
2929 (tramp-do-copy-or-rename-file
2931 (tramp-run-real-handler
2935 (defun tramp-handle-rename-file
2937 "Like `rename-file' for tramp files."
2939 ;; Otherwise, use tramp from local system.
2942 ;; At least one file a tramp file?
2943 (if (or (tramp-tramp-file-p filename)
2944 (tramp-tramp-file-p newname))
2945 (tramp-do-copy-or-rename-file
2947 (tramp-run-real-handler 'rename-file
2950 (defun tramp-do-copy-or-rename-file
2960 This function is invoked by `tramp-handle-copy-file' and
2961 `tramp-handle-rename-file'. It is an error if OP is neither of `copy'
2969 (let ((t1 (tramp-tramp-file-p filename))
2970 (t2 (tramp-tramp-file-p newname))
2975 ;; We cannot invoke `with-parsed-tramp-file-name';
2978 (with-parsed-tramp-file-name filename l
2986 (with-parsed-tramp-file-name newname l
3005 (tramp-do-copy-or-rename-file-directly
3016 (tramp-method-out-of-band-p
3020 (tramp-do-copy-or-rename-file-out-of-band
3032 (tramp-do-copy-or-rename-file-via-buffer
3041 (or (and t1 (tramp-method-out-of-band-p
3043 (and t2 (tramp-method-out-of-band-p
3045 (tramp-do-copy-or-rename-file-out-of-band
3048 (tramp-do-copy-or-rename-file-via-buffer
3055 (defun tramp-do-copy-or-rename-file-via-buffer (op filename newname keep-date)
3060 (let ((trampbuf (get-buffer-create "*tramp output*"))
3063 (tramp-message
3078 (tramp-touch newname modtime)))
3085 (defun tramp-do-copy-or-rename-file-directly
3100 (tramp-send-command
3104 (tramp-shell-quote-argument localname1)
3105 (tramp-shell-quote-argument localname2)))
3106 (tramp-wait-for-output)
3112 (re-search-forward tramp-operation-not-permitted-regexp nil t))
3113 (zerop (tramp-send-command-and-check
3124 (tramp-make-tramp-file-name multi-method method user host localname2)
3126 (tramp-make-tramp-file-name
3129 (defun tramp-do-copy-or-rename-file-out-of-band (op filename newname keep-date)
3133 (let ((t1 (tramp-tramp-file-p filename))
3134 (t2 (tramp-tramp-file-p newname))
3141 ;; We cannot invoke `with-parsed-tramp-file-name';
3144 (with-parsed-tramp-file-name filename l
3151 method (tramp-find-method
3155 copy-program (tramp-get-method-parameter
3157 v1-user v1-host 'tramp-copy-program)
3158 copy-args (tramp-get-method-parameter
3160 v1-user v1-host 'tramp-copy-args)))
3164 (with-parsed-tramp-file-name newname l
3171 method (tramp-find-method
3175 copy-program (tramp-get-method-parameter
3177 v2-user v2-host 'tramp-copy-program)
3178 copy-args (tramp-get-method-parameter
3180 v2-user v2-host 'tramp-copy-args)))
3191 (tramp-make-copy-program-file-name
3193 (tramp-shell-quote-argument v1-localname))))
3201 (tramp-make-copy-program-file-name
3203 (tramp-shell-quote-argument v2-localname))))
3210 x `((?t . ,(format "/tmp/%s" tramp-temp-name-prefix)))))
3217 (cons (tramp-get-method-parameter
3219 v1-user v1-host 'tramp-copy-keep-date-arg)
3222 (cons (tramp-get-method-parameter
3224 v2-user v2-host 'tramp-copy-keep-date-arg)
3229 (tramp-buffer-name multi-method method user host)))
3231 ;; Use an asynchronous process. By this, password can be handled.
3240 (setq tramp-current-multi-method multi-method
3241 tramp-current-method method
3242 tramp-current-user user
3243 tramp-current-host host)
3252 (tramp-temporary-file-directory)))
3255 (tramp-set-process-query-on-exit-flag p nil)
3256 (tramp-process-actions p multi-method method user host
3257 tramp-actions-copy-out-of-band))
3270 (defun tramp-handle-make-directory (dir &optional parents)
3271 "Like `make-directory' for tramp files."
3273 (with-parsed-tramp-file-name dir nil
3275 (tramp-barf-unless-okay
3279 (tramp-shell-quote-argument localname))
3284 (defun tramp-handle-delete-directory (directory)
3285 "Like `delete-directory' for tramp files."
3287 (with-parsed-tramp-file-name directory nil
3289 (tramp-send-command
3292 (tramp-shell-quote-argument localname)))
3293 (tramp-wait-for-output))))
3295 (defun tramp-handle-delete-file (filename)
3296 "Like `delete-file' for tramp files."
3298 (with-parsed-tramp-file-name filename nil
3300 (unless (zerop (tramp-send-command-and-check
3303 (tramp-shell-quote-argument localname))))
3310 (defun tramp-handle-dired-recursive-delete-directory (filename)
3312 This is like `dired-recursive-delete-directory' for tramp files."
3313 (with-parsed-tramp-file-name filename nil
3321 (tramp-send-command multi-method method user host
3322 (format "rm -r %s" (tramp-shell-quote-argument localname)))
3325 (tramp-wait-for-output 120)
3330 (defun tramp-handle-dired-call-process (program discard &rest arguments)
3331 "Like `dired-call-process' for tramp files."
3332 (with-parsed-tramp-file-name default-directory nil
3334 (tramp-barf-unless-okay
3336 (format "cd %s" (tramp-shell-quote-argument localname))
3338 "tramp-handle-dired-call-process: Couldn't `cd %s'"
3339 (tramp-shell-quote-argument localname))
3340 (tramp-send-command
3342 (mapconcat #'tramp-shell-quote-argument (cons program arguments) " "))
3343 (tramp-wait-for-output))
3345 ;; We cannot use `insert-buffer' because the tramp buffer
3350 (tramp-get-buffer multi-method method user host)
3354 (tramp-send-command-and-check multi-method method user host nil)
3355 (tramp-send-command multi-method method user host "cd")
3356 (tramp-wait-for-output)))))
3358 (defun tramp-handle-dired-compress-file (file &rest ok-flag)
3359 "Like `dired-compress-file' for tramp files."
3362 (with-parsed-tramp-file-name file nil
3372 (list (concat (regexp-quote (nth 1 x)) "\\'")
3389 (when (zerop (tramp-send-command-and-check
3401 (when (zerop (tramp-send-command-and-check
3426 (defun tramp-handle-insert-directory
3428 "Like `insert-directory' for tramp files."
3431 (tramp-run-real-handler 'insert-directory
3439 (with-parsed-tramp-file-name filename nil
3440 (tramp-message-for-buffer
3458 (tramp-send-command
3461 (tramp-get-ls-command multi-method method user host)
3465 (tramp-shell-quote-argument (concat localname ".")))))
3466 (tramp-barf-unless-okay
3468 (format "cd %s" (tramp-shell-quote-argument
3472 (tramp-shell-quote-argument (file-name-directory localname)))
3473 (tramp-send-command
3476 (tramp-get-ls-command multi-method method user host)
3482 (tramp-shell-quote-argument
3485 (tramp-wait-for-output))
3491 ;; We cannot use `insert-buffer' because the tramp buffer
3496 (tramp-get-buffer multi-method method user host)
3505 (tramp-send-command multi-method method user host "cd")
3506 (tramp-wait-for-output))
3524 (defun tramp-handle-unhandled-file-name-directory (filename)
3525 "Like `unhandled-file-name-directory' for tramp files."
3526 (with-parsed-tramp-file-name filename nil
3531 (defun tramp-drop-volume-letter (name)
3533 The function `tramp-handle-expand-file-name' calls `expand-file-name'
3547 (defun tramp-handle-expand-file-name (name &optional dir)
3548 "Like `expand-file-name' for tramp files.
3556 ;; If NAME is not a tramp file, run the real handler
3557 (if (not (tramp-tramp-file-p name))
3558 (tramp-run-real-handler 'expand-file-name
3561 (with-parsed-tramp-file-name name nil
3566 ;; groks tilde expansion! The function `tramp-find-shell' is
3581 (tramp-find-method multi-method method user host)))
3584 (set-buffer (tramp-get-buffer multi-method method user host))
3586 (tramp-send-command
3590 (tramp-wait-for-output)
3592 (setq uname (buffer-substring (point) (tramp-line-end-position)))
3605 (tramp-let-maybe directory-sep-char ?/
3607 (tramp-make-tramp-file-name
3608 multi-method (or method (tramp-find-default-method user host))
3610 (tramp-drop-volume-letter
3611 (tramp-run-real-handler 'expand-file-name
3625 ;; (tramp-make-tramp-file-name
3627 ;; (tramp-drop-volume-letter
3628 ;; (tramp-run-real-handler 'expand-file-name
3633 (defvar tramp-async-proc nil
3635 Used in `tramp-handle-shell-command'")
3637 (defvar tramp-display-shell-command-buffer t
3641 (defun tramp-handle-shell-command (command &optional output-buffer error-buffer)
3642 "Like `shell-command' for tramp files.
3644 `tramp-end-of-output', followed by another newline."
3647 (if (tramp-tramp-file-p default-directory)
3648 (with-parsed-tramp-file-name default-directory nil
3670 tramp-async-proc (start-process (buffer-name output-buffer)
3673 (tramp-barf-unless-okay
3675 (format "cd %s" (tramp-shell-quote-argument localname))
3677 "tramp-handle-shell-command: Couldn't `cd %s'"
3678 (tramp-shell-quote-argument localname))
3683 (tramp-get-buffer multi-method method user host))
3693 (regexp-quote tramp-end-of-output) string)))
3697 (process-send-string tramp-async-proc string)
3700 (process-send-eof tramp-async-proc))))))
3702 (tramp-send-command
3705 (format "( %s ) 2>/tmp/tramp.$$.err; tramp_old_status=$?"
3709 (tramp-wait-for-output)))
3711 ;; We cannot use `insert-buffer' because the tramp buffer
3716 (tramp-get-buffer multi-method method user host)
3722 (tramp-send-command
3724 "cat /tmp/tramp.$$.err")
3725 (tramp-wait-for-output)
3730 (tramp-get-buffer multi-method method user host)
3732 (tramp-send-command-and-check
3733 multi-method method user host "rm -f /tmp/tramp.$$.err")))
3735 (tramp-send-command multi-method method user host "cd")
3737 (tramp-wait-for-output))
3738 (tramp-send-command
3743 (tramp-wait-for-output)
3750 (when tramp-display-shell-command-buffer
3756 (message "tramp-handle-shell-command called with non-tramp directory: `%s'"
3758 (tramp-run-real-handler 'shell-command
3761 (defun tramp-handle-process-file (program &optional infile buffer display &rest args)
3767 (let ((tramp-display-shell-command-buffer display))
3769 (mapconcat 'tramp-shell-quote-argument (cons program args) " ")
3774 (defsubst tramp-make-temp-file (filename)
3777 (expand-file-name tramp-temp-name-prefix
3778 (tramp-temporary-file-directory)))
3781 (defun tramp-handle-file-local-copy (filename)
3782 "Like `file-local-copy' for tramp files."
3783 (with-parsed-tramp-file-name filename nil
3784 (let ((tramp-buf (tramp-get-buffer multi-method method user host))
3788 ;; tramp-get-* might invoke the "are you awake" check in
3789 ;; tramp-maybe-open-connection, which is an unfortunate time
3791 (rem-enc (tramp-get-remote-encoding multi-method method user host))
3792 (rem-dec (tramp-get-remote-decoding multi-method method user host))
3793 (loc-enc (tramp-get-local-encoding multi-method method user host))
3794 (loc-dec (tramp-get-local-decoding multi-method method user host))
3799 (setq tmpfil (tramp-make-temp-file filename))
3801 (cond ((tramp-method-out-of-band-p multi-method method user host)
3808 ;; Following line for setting tramp-current-method,
3809 ;; tramp-current-user, tramp-current-host.
3810 (set-buffer tramp-buf)
3811 (tramp-message 5 "Encoding remote file %s..." filename)
3812 (tramp-barf-unless-okay
3814 (concat rem-enc " < " (tramp-shell-quote-argument localname))
3817 tramp-buf)
3822 (tramp-message 5 "Decoding remote file %s..." filename)
3830 (let ((tmpbuf (get-buffer-create " *tramp tmp*")))
3834 (insert-buffer-substring tramp-buf)
3835 (tramp-message-for-buffer
3849 ;; If tramp-decoding-function is not defined for this
3850 ;; method, we invoke tramp-decoding-command instead.
3851 (let ((tmpfil2 (tramp-make-temp-file filename)))
3853 (tramp-message
3856 (tramp-call-local-coding-command
3859 (tramp-message-for-buffer
3868 (defun tramp-handle-file-remote-p (filename)
3869 "Like `file-remote-p' for tramp files."
3870 (when (tramp-tramp-file-p filename)
3871 (with-parsed-tramp-file-name filename nil
3872 (make-tramp-file-name
3879 (defun tramp-handle-insert-file-contents
3881 "Like `insert-file-contents' for tramp files."
3884 (with-parsed-tramp-file-name filename nil
3908 (tramp-message-for-buffer
3915 (tramp-message-for-buffer
3925 (defun tramp-handle-find-backup-file-name (filename)
3926 "Like `find-backup-file-name' for tramp files."
3927 (with-parsed-tramp-file-name filename nil
3933 (if (boundp 'tramp-backup-directory-alist)
3940 (not (tramp-file-name-p (cdr x))))
3941 (tramp-make-tramp-file-name
3944 (symbol-value 'tramp-backup-directory-alist))
3950 (if (boundp 'tramp-bkup-backup-directory-info)
3958 (not (tramp-file-name-p (car (cdr x)))))
3959 (tramp-make-tramp-file-name
3963 (symbol-value 'tramp-bkup-backup-directory-info))
3966 (tramp-run-real-handler 'find-backup-file-name (list filename)))))
3968 (defun tramp-handle-make-auto-save-file-name ()
3969 "Like `make-auto-save-file-name' for tramp files.
3970 Returns a file name in `tramp-auto-save-directory' for autosaving this file."
3971 (let ((tramp-auto-save-directory tramp-auto-save-directory))
3980 (setq tramp-auto-save-directory
3981 (or tramp-auto-save-directory temporary-file-directory))))
3984 (when tramp-auto-save-directory
3985 (unless (file-exists-p tramp-auto-save-directory)
3986 (make-directory tramp-auto-save-directory t)))
3991 (if tramp-auto-save-directory
3993 (tramp-subst-strs-in-string
4001 tramp-auto-save-directory)
4007 (tramp-run-real-handler
4012 (tramp-run-real-handler
4018 (defun tramp-handle-write-region
4020 "Like `write-region' for tramp files."
4022 (error "Cannot append to file using tramp (`%s')" filename))
4032 ;; "tramp-handle-write-region: LOCKNAME must be nil or equal FILENAME"))
4039 (with-parsed-tramp-file-name filename nil
4041 (rem-enc (tramp-get-remote-encoding multi-method method user host))
4042 (rem-dec (tramp-get-remote-decoding multi-method method user host))
4043 (loc-enc (tramp-get-local-encoding multi-method method user host))
4044 (loc-dec (tramp-get-local-decoding multi-method method user host))
4045 (trampbuf (get-buffer-create "*tramp output*"))
4058 (setq tmpfil (tramp-make-temp-file filename))
4065 (tramp-run-real-handler
4084 (cond ((tramp-method-out-of-band-p multi-method method user host)
4090 (let ((tmpbuf (get-buffer-create " *tramp file transfer*")))
4093 (tramp-message-for-buffer multi-method method user host
4100 (tramp-message-for-buffer
4115 (tramp-temporary-file-directory)))
4120 (tramp-message-for-buffer
4123 (unless (equal 0 (tramp-call-local-coding-command
4132 (tramp-message-for-buffer
4135 (tramp-send-command
4139 (tramp-shell-quote-argument localname)))
4141 (tramp-message-for-buffer
4144 (tramp-send-string multi-method method user host
4147 (tramp-message-for-buffer
4150 (tramp-send-command
4152 (tramp-message-for-buffer
4155 (set-buffer (tramp-get-buffer multi-method method user host))
4156 (tramp-wait-for-output)
4157 (tramp-barf-unless-okay
4162 (tramp-message 5 "Decoding region into remote file %s...done"
4189 ;; TRAMP file name) it is needed to disable efs as well as tramp for the
4204 ;; (defun tramp-run-real-handler (operation args)
4206 ;; This inhibits EFS and Ange-FTP, too, because they conflict with tramp.
4210 ;; (list 'tramp-file-name-handler
4219 (progn (defun tramp-run-real-handler (operation args)
4224 `(tramp-file-name-handler
4225 tramp-completion-file-name-handler
4234 ;; This function is used from `tramp-completion-file-name-handler' functions
4235 ;; only, if `tramp-completion-mode' is true. But this cannot be checked here
4239 (progn (defun tramp-completion-run-real-handler (operation args)
4240 "Invoke `tramp-file-name-handler' for OPERATION.
4244 `(tramp-completion-file-name-handler
4259 ;; function as well but regexp only.
4260 (defun tramp-file-name-for-operation (operation &rest args)
4302 ((string-match tramp-file-name-regexp (nth 0 args)) (nth 0 args))
4303 ((string-match tramp-file-name-regexp (nth 1 args)) (nth 1 args))
4329 (defun tramp-find-foreign-file-name-handler (filename)
4331 (when (tramp-tramp-file-p filename)
4334 (handler-alist tramp-foreign-file-name-handler-alist))
4345 (defun tramp-file-name-handler (operation &rest args)
4347 Falls back to normal file name handler if no tramp file name handler exists."
4351 (let* ((filename (apply 'tramp-file-name-for-operation operation args))
4352 (completion (tramp-completion-mode filename))
4353 (foreign (tramp-find-foreign-file-name-handler filename)))
4354 (with-parsed-tramp-file-name filename nil
4359 (tramp-run-real-handler operation args))
4366 (t (tramp-run-real-handler operation args)))))))
4376 ;; `tramp-locked' and `tramp-locker'. `tramp-locked' is set to true
4379 ;; recursive calls. That's where the `tramp-locker' variable comes in
4381 ;; handler. So if `tramp-locked' is t and `tramp-locker' is also t,
4383 ;; recursively. But if `tramp-locker' is nil, then we are a timer
4386 (defvar tramp-locked nil
4388 Together with `tramp-locker', this implements a locking mechanism
4391 (defvar tramp-locker nil
4393 Together with `tramp-locked', this implements a locking mechanism
4396 (defun tramp-sh-file-name-handler (operation &rest args)
4399 (when (and tramp-locked (not tramp-locker))
4401 (let ((tl tramp-locked))
4404 (setq tramp-locked t)
4405 (let ((tramp-locker t))
4407 (let ((fn (assoc operation tramp-file-name-handler-alist)))
4410 (tramp-run-real-handler operation args))))))
4411 (setq tramp-locked tl))))
4414 (progn (defun tramp-completion-file-name-handler (operation &rest args)
4415 "Invoke tramp file name completion handler.
4416 Falls back to normal file name handler if no tramp file name handler exists."
4419 (let ((fn (assoc operation tramp-completion-file-name-handler-alist)))
4422 (tramp-completion-run-real-handler operation args)))))
4425 (defsubst tramp-register-file-name-handler ()
4426 "Add tramp file name handler to `file-name-handler-alist'."
4428 (cons tramp-file-name-regexp 'tramp-file-name-handler))
4437 (defsubst tramp-register-completion-file-name-handler ()
4438 "Add tramp completion file name handler to `file-name-handler-alist'."
4446 (cons tramp-completion-file-name-regexp
4447 'tramp-completion-file-name-handler))
4448 (put 'tramp-completion-file-name-handler 'safe-magic t))
4456 ;; `tramp-file-name-handler' must be registered before evaluation of
4459 ;;;###autoload(tramp-register-file-name-handler)
4462 ;; `tramp-completion-file-name-handler' will be delayed.
4465 ;;;###autoload '(lambda () (tramp-register-completion-file-name-handler)))
4466 (tramp-register-file-name-handler)
4467 (tramp-register-completion-file-name-handler)
4470 (defun tramp-unload-file-name-handlers ()
4472 (delete (rassoc 'tramp-file-name-handler
4474 (delete (rassoc 'tramp-completion-file-name-handler
4478 (add-hook 'tramp-unload-hook 'tramp-unload-file-name-handlers)
4486 (defun tramp-handle-expand-many-files (name)
4487 "Like `PC-expand-many-files' for tramp files."
4488 (with-parsed-tramp-file-name name nil
4500 ;;- (set-difference tramp-file-name-quote-list
4502 ;;- (tramp-send-command
4505 ;;- (tramp-wait-for-output))
4506 (tramp-send-command multi-method method user host
4508 (tramp-wait-for-output)
4510 (tramp-line-end-position)))
4524 (tramp-make-tramp-file-name multi-method method
4532 (around tramp-advice-PC-expand-many-files (name) activate)
4533 "Invoke `tramp-handle-expand-many-files' for tramp files."
4534 (if (tramp-tramp-file-p name)
4535 (setq ad-return-value (tramp-handle-expand-many-files name))
4537 (add-hook 'tramp-unload-hook
4542 (defvar tramp-completion-mode nil
4545 ;; Necessary because `tramp-file-name-regexp-unified' and
4546 ;; `tramp-completion-file-name-regexp-unified' aren't different.
4547 ;; If nil, `tramp-completion-run-real-handler' is called (i.e. forwarding to
4548 ;; `tramp-file-name-handler'). Otherwise, it takes `tramp-run-real-handler'.
4552 ;; shouldn't have partial tramp file name syntax. Maybe another variable should
4553 ;; be introduced overwriting this check in such cases. Or we change tramp
4556 ;; necessary, because there are different regexp).
4557 (defun tramp-completion-mode (file)
4560 (tramp-completion-mode t)
4563 (concat tramp-prefix-regexp
4564 "\\(" tramp-method-regexp "\\)" tramp-postfix-single-method-regexp "$")
4566 (member (match-string 1 file) (mapcar 'car tramp-methods)))
4593 ;; `tramp-completion-dissect-file-name' returns a list of
4594 ;; tramp-file-name structures. For all of them we return possible completions.
4596 (defun tramp-completion-handle-file-name-all-completions (filename directory)
4597 "Like `file-name-all-completions' for partial tramp files."
4600 ;; We need to reset `tramp-completion-mode'.
4602 (setq tramp-completion-mode t)
4606 (v (tramp-completion-dissect-file-name fullname))
4611 (multi-method (tramp-file-name-multi-method car))
4612 (method (tramp-file-name-method car))
4613 (user (tramp-file-name-user car))
4614 (host (tramp-file-name-host car))
4615 (localname (tramp-file-name-localname car))
4616 (m (tramp-find-method multi-method method user host))
4617 (tramp-current-user user) ; see `tramp-parse-passwd'
4632 (tramp-get-completion-function m))
4637 (tramp-get-completion-user-host
4643 (append result (tramp-get-completion-methods m)))))
4660 (tramp-run-real-handler
4663 (tramp-completion-run-real-handler
4667 (setq tramp-completion-mode nil)))
4671 (defun tramp-completion-handle-file-name-completion
4673 "Like `file-name-completion' for tramp files."
4680 ;; I misuse a little bit the tramp-file-name structure in order to handle
4682 ;; Return value is a list of tramp-file-name structures according to possible
4703 (defun tramp-completion-dissect-file-name (name)
4704 "Returns a list of `tramp-file-name' structures.
4705 They are collected by `tramp-completion-dissect-file-name1'."
4710 (tramp-completion-file-name-structure1
4711 (list (concat tramp-prefix-regexp "\\(" tramp-method-regexp x-nil "\\)$")
4714 (tramp-completion-file-name-structure2
4715 (list (concat tramp-prefix-regexp "\\(" tramp-user-regexp x-nil "\\)$")
4718 (tramp-completion-file-name-structure3
4719 (list (concat tramp-prefix-regexp "\\(" tramp-host-regexp x-nil "\\)$")
4722 (tramp-completion-file-name-structure4
4723 (list (concat tramp-prefix-regexp
4724 "\\(" tramp-user-regexp "\\)" tramp-postfix-user-regexp
4725 "\\(" tramp-host-regexp x-nil "\\)$")
4728 (tramp-completion-file-name-structure5
4729 (list (concat tramp-prefix-regexp
4730 "\\(" tramp-method-regexp "\\)" tramp-postfix-single-method-regexp
4731 "\\(" tramp-user-regexp x-nil "\\)$")
4734 (tramp-completion-file-name-structure6
4735 (list (concat tramp-prefix-regexp
4736 "\\(" tramp-method-regexp "\\)" tramp-postfix-single-method-regexp
4737 "\\(" tramp-host-regexp x-nil "\\)$")
4740 (tramp-completion-file-name-structure7
4741 (list (concat tramp-prefix-regexp
4742 "\\(" tramp-method-regexp "\\)" tramp-postfix-single-method-regexp
4743 "\\(" tramp-user-regexp "\\)" tramp-postfix-user-regexp
4744 "\\(" tramp-host-regexp x-nil "\\)$")
4747 (mapcar (lambda (regexp)
4749 (tramp-completion-dissect-file-name1 regexp name)))
4751 tramp-completion-file-name-structure1
4752 tramp-completion-file-name-structure2
4753 tramp-completion-file-name-structure3
4754 tramp-completion-file-name-structure4
4755 tramp-completion-file-name-structure5
4756 tramp-completion-file-name-structure6
4757 tramp-completion-file-name-structure7
4758 tramp-file-name-structure))
4762 (defun tramp-completion-dissect-file-name1 (structure name)
4763 "Returns a `tramp-file-name' structure matching STRUCTURE.
4772 (if (and method (member method tramp-multi-methods))
4774 (make-tramp-file-name
4786 (make-tramp-file-name
4795 (defun tramp-get-completion-methods (partial-method)
4800 (string-match (concat "^" (regexp-quote partial-method)) method)
4801 (tramp-make-tramp-file-name nil method nil nil nil)))
4802 (delete "multi" (mapcar 'car tramp-methods))))
4805 (defun tramp-get-completion-user-host (method partial-user partial-host user host)
4812 (string-match (concat "^" (regexp-quote partial-host)) host)
4821 (and user (string-match (concat "^" (regexp-quote partial-user)) user))
4827 (and host (string-match (concat "^" (regexp-quote partial-host)) host))
4834 (tramp-make-tramp-file-name nil method user host nil)))
4836 (defun tramp-parse-rhosts (filename)
4846 (push (tramp-parse-rhosts-group) res))))
4851 (defalias 'tramp-point-at-eol
4856 (defun tramp-parse-rhosts-group ()
4861 (regexp
4863 "^\\(" tramp-host-regexp "\\)"
4864 "\\([ \t]+" "\\(" tramp-user-regexp "\\)" "\\)?")))
4866 (narrow-to-region (point) (tramp-point-at-eol))
4867 (when (re-search-forward regexp nil t)
4873 (defun tramp-parse-shosts (filename)
4883 (push (tramp-parse-shosts-group) res))))
4886 (defun tramp-parse-shosts-group ()
4891 (regexp (concat "^\\(" tramp-host-regexp "\\)")))
4893 (narrow-to-region (point) (tramp-point-at-eol))
4894 (when (re-search-forward regexp nil t)
4902 (defun tramp-parse-sconfig (filename)
4912 (push (tramp-parse-sconfig-group) res))))
4915 (defun tramp-parse-sconfig-group ()
4920 (regexp (concat "^[ \t]*Host[ \t]+" "\\(" tramp-host-regexp "\\)")))
4922 (narrow-to-region (point) (tramp-point-at-eol))
4923 (when (re-search-forward regexp nil t)
4931 (defun tramp-parse-shostkeys (dirname)
4935 (let ((regexp (concat "^key_[0-9]+_\\(" tramp-host-regexp "\\)\\.pub$"))
4940 (when (string-match regexp (car files))
4945 (defun tramp-parse-sknownhosts (dirname)
4949 (let ((regexp (concat "^\\(" tramp-host-regexp
4955 (when (string-match regexp (car files))
4960 (defun tramp-parse-hosts (filename)
4970 (push (tramp-parse-hosts-group) res))))
4973 (defun tramp-parse-hosts-group ()
4978 (regexp (concat "^\\(" tramp-host-regexp "\\)")))
4980 (narrow-to-region (point) (tramp-point-at-eol))
4981 (when (re-search-forward regexp nil t)
4992 ;; has been typed already. So we (mis-)use tramp-current-user as indication,
4993 ;; assuming it is set in `tramp-completion-handle-file-name-all-completions'.
4994 (defun tramp-parse-passwd (filename)
4999 (if (zerop (length tramp-current-user))
5006 (push (tramp-parse-passwd-group) res))))
5009 (defun tramp-parse-passwd-group ()
5014 (regexp (concat "^\\(" tramp-user-regexp "\\):")))
5016 (narrow-to-region (point) (tramp-point-at-eol))
5017 (when (re-search-forward regexp nil t)
5023 (defun tramp-parse-netrc (filename)
5033 (push (tramp-parse-netrc-group) res))))
5036 (defun tramp-parse-netrc-group ()
5041 (regexp
5043 "^[ \t]*machine[ \t]+" "\\(" tramp-host-regexp "\\)"
5044 "\\([ \t]+login[ \t]+" "\\(" tramp-user-regexp "\\)" "\\)?")))
5046 (narrow-to-region (point) (tramp-point-at-eol))
5047 (when (re-search-forward regexp nil t)
5055 (defun tramp-maybe-send-perl-script (multi-method method user host script name)
5059 (let ((remote-perl (tramp-get-remote-perl multi-method method user host)))
5061 (let ((perl-scripts (tramp-get-connection-property "perl-scripts" nil
5064 (with-current-buffer (tramp-get-buffer multi-method method user host)
5065 (tramp-message 5 (concat "Sending the Perl script `" name "'..."))
5066 (tramp-send-string multi-method method user host
5073 (tramp-wait-for-output)
5074 (tramp-set-connection-property "perl-scripts" (cons name perl-scripts)
5076 (tramp-message 5 (concat "Sending the Perl script `" name "'...done.")))))))
5078 (defun tramp-set-auto-save ()
5080 (tramp-tramp-file-p (buffer-file-name))
5082 (eq (tramp-find-foreign-file-name-handler (buffer-file-name))
5083 'tramp-sh-file-name-handler)
5086 (add-hook 'find-file-hooks 'tramp-set-auto-save t)
5087 (add-hook 'tramp-unload-hook
5089 (remove-hook 'find-file-hooks 'tramp-set-auto-save)))
5091 (defun tramp-run-test (switch filename)
5094 (let ((v (tramp-dissect-file-name filename)))
5096 (tramp-send-command-and-check
5097 (tramp-file-name-multi-method v) (tramp-file-name-method v)
5098 (tramp-file-name-user v) (tramp-file-name-host v)
5100 (tramp-shell-quote-argument (tramp-file-name-localname v)))))))
5102 (defun tramp-run-test2 (program file1 file2 &optional switch)
5107 (let* ((v1 (tramp-dissect-file-name file1))
5108 (v2 (tramp-dissect-file-name file2))
5109 (mmethod1 (tramp-file-name-multi-method v1))
5110 (mmethod2 (tramp-file-name-multi-method v2))
5111 (method1 (tramp-file-name-method v1))
5112 (method2 (tramp-file-name-method v2))
5113 (user1 (tramp-file-name-user v1))
5114 (user2 (tramp-file-name-user v2))
5115 (host1 (tramp-file-name-host v1))
5116 (host2 (tramp-file-name-host v2))
5117 (localname1 (tramp-file-name-localname v1))
5118 (localname2 (tramp-file-name-localname v2)))
5124 (error "tramp-run-test2: %s"
5127 (tramp-send-command-and-check
5131 (tramp-shell-quote-argument localname1)
5133 (tramp-shell-quote-argument localname2))))))
5135 (defun tramp-touch (file time)
5148 (if (tramp-tramp-file-p file)
5149 (with-parsed-tramp-file-name file nil
5150 (let ((buf (tramp-get-buffer multi-method method user host)))
5151 (unless (zerop (tramp-send-command-and-check
5156 (tramp-shell-quote-argument localname))
5159 (error "tramp-touch: touch failed, see buffer `%s' for details"
5166 (error "tramp-touch: touch failed"))))))
5168 (defun tramp-buffer-name (multi-method method user host)
5171 (tramp-buffer-name-multi-method "tramp" multi-method method user host)
5172 (let ((method (tramp-find-method multi-method method user host)))
5174 (format "*tramp/%s %s@%s*" method user host)
5175 (format "*tramp/%s %s*" method host)))))
5177 (defun tramp-buffer-name-multi-method (prefix multi-method method user host)
5199 (defun tramp-get-buffer (multi-method method user host)
5202 (get-buffer-create (tramp-buffer-name multi-method method user host))
5206 (defun tramp-debug-buffer-name (multi-method method user host)
5209 (tramp-buffer-name-multi-method "debug tramp"
5211 (let ((method (tramp-find-method multi-method method user host)))
5213 (format "*debug tramp/%s %s@%s*" method user host)
5214 (format "*debug tramp/%s %s*" method host)))))
5216 (defun tramp-get-debug-buffer (multi-method method user host)
5220 (tramp-debug-buffer-name multi-method method user host))
5224 (defun tramp-find-executable (multi-method method user host
5234 This function expects to be in the right *tramp* buffer."
5246 (tramp-send-command
5254 (tramp-send-command multi-method method user host d))
5256 (tramp-send-command multi-method method user host "EOF")
5257 (tramp-wait-for-output)
5262 (buffer-substring (point) (tramp-line-end-position)))))
5264 (defun tramp-set-remote-path (multi-method method user host var dirlist)
5273 (tramp-make-tramp-file-name multi-method method user host x))
5275 (tramp-make-tramp-file-name multi-method method user host x)))
5278 (tramp-send-command
5283 (tramp-wait-for-output)))
5287 (defun tramp-find-file-exists-command (multi-method method user host)
5291 (make-local-variable 'tramp-file-exists-command)
5292 (tramp-message 9 "Finding command to check if file exists")
5294 (tramp-make-tramp-file-name
5298 (tramp-make-tramp-file-name
5319 (and (setq tramp-file-exists-command "test -e %s")
5322 (and (setq tramp-file-exists-command "/bin/test -e %s")
5325 (and (setq tramp-file-exists-command "/usr/bin/test -e %s")
5328 (and (setq tramp-file-exists-command "ls -d %s")
5335 (defun tramp-find-shell (multi-method method user host)
5338 (tramp-send-command multi-method method user host "echo ~root")
5339 (tramp-wait-for-output)
5343 (or (tramp-find-executable multi-method method user host
5344 "bash" tramp-remote-path t)
5345 (tramp-find-executable multi-method method user host
5346 "ksh" tramp-remote-path t)))
5350 (let ((alist tramp-sh-extra-args)
5357 (tramp-message
5359 (tramp-send-command
5362 (tramp-barf-if-no-shell-prompt
5364 60 "Couldn't find remote `%s' prompt" shell)
5365 (tramp-message
5366 9 "Setting remote shell prompt...")
5368 ;; must use "\n" here, not tramp-rsh-end-of-line. Kai left the
5369 ;; last tramp-rsh-end-of-line, Douglas wanted to replace that,
5372 tramp-rsh-end-of-line
5373 tramp-end-of-output
5374 tramp-rsh-end-of-line
5375 tramp-rsh-end-of-line))
5376 (tramp-wait-for-output)
5377 (tramp-message
5378 9 "Setting remote shell prompt...done")
5380 (t (tramp-message 5 "Remote `%s' groks tilde expansion, good"
5381 (tramp-get-method-parameter
5382 multi-method method user host 'tramp-remote-sh))))))
5384 (defun tramp-check-ls-command (multi-method method user host cmd)
5389 (tramp-message 9 "Checking remote `%s' command for `-n' option" cmd)
5391 (tramp-make-tramp-file-name multi-method method user host cmd))
5393 (tramp-message 7 "Testing remote command `%s' for -n..." cmd)
5395 (tramp-send-command-and-check
5399 (tramp-message 7 "Testing remote command `%s' for -n...%s"
5404 (defun tramp-check-ls-commands (multi-method method user host cmd dirlist)
5409 (tramp-let-maybe directory-sep-char ?/ ;for XEmacs
5414 (when (tramp-check-ls-command multi-method method user host x)
5419 (defun tramp-find-ls-command (multi-method method user host)
5422 (tramp-message 9 "Finding a suitable `ls' command")
5424 (tramp-check-ls-commands multi-method method user host "ls" tramp-remote-path)
5425 (tramp-check-ls-commands multi-method method user host "gnuls" tramp-remote-path)
5426 (tramp-check-ls-commands multi-method method user host "gls" tramp-remote-path)))
5434 ;; `tramp-actions-before-shell' for usage of these functions.
5436 (defun tramp-action-login (p multi-method method user host)
5438 (tramp-message 9 "Sending login name `%s'"
5442 tramp-rsh-end-of-line)))
5444 (defun tramp-action-password (p multi-method method user host)
5445 "Query the user for a password."
5446 (let ((pw-prompt
5448 (tramp-make-tramp-file-name
5450 (tramp-message 9 "Sending password")
5451 (tramp-enter-password p pw-prompt user host)))
5453 (defun tramp-action-succeed (p multi-method method user host)
5454 "Signal success in finding shell prompt."
5455 (tramp-message 9 "Found remote shell prompt.")
5457 (throw 'tramp-action 'ok))
5459 (defun tramp-action-permission-denied (p multi-method method user host)
5461 (pop-to-buffer (tramp-get-buffer multi-method method user host))
5462 (tramp-message 9 "Permission denied by remote host.")
5464 (throw 'tramp-action 'permission-denied))
5466 (defun tramp-action-copy-failed (p multi-method method user host)
5471 (defun tramp-action-yesno (p multi-method method user host)
5474 See also `tramp-action-yn'."
5476 (pop-to-buffer (tramp-get-buffer multi-method method user host))
5480 (throw 'tramp-action 'permission-denied))
5481 (process-send-string p (concat "yes" tramp-rsh-end-of-line))
5484 (defun tramp-action-yn (p multi-method method user host)
5487 See also `tramp-action-yesno'."
5489 (pop-to-buffer (tramp-get-buffer multi-method method user host))
5492 (throw 'tramp-action 'permission-denied))
5494 (process-send-string p (concat "y" tramp-rsh-end-of-line))))
5496 (defun tramp-action-terminal (p multi-method method user host)
5498 The terminal type can be configured with `tramp-terminal-type'."
5499 (tramp-message 9 "Setting `%s' as terminal type."
5500 tramp-terminal-type)
5502 (process-send-string nil (concat tramp-terminal-type
5503 tramp-rsh-end-of-line)))
5505 (defun tramp-action-process-alive (p multi-method method user host)
5508 (throw 'tramp-action 'process-died)))
5510 (defun tramp-action-out-of-band (p multi-method method user host)
5514 (tramp-message 9 "Process has finished.")
5515 (throw 'tramp-action 'ok))
5522 (if (re-search-forward tramp-operation-not-permitted-regexp nil t)
5524 (tramp-message 10 "'set mode' error ignored.")
5525 (tramp-message 9 "Process has finished.")
5526 (throw 'tramp-action 'ok))
5527 (tramp-message 9 "Process has died.")
5528 (throw 'tramp-action 'process-died)))
5533 (defun tramp-multi-action-login (p method user host)
5535 (tramp-message 9 "Sending login name `%s'" user)
5537 (process-send-string p (concat user tramp-rsh-end-of-line)))
5539 (defun tramp-multi-action-password (p method user host)
5540 "Query the user for a password."
5541 (let ((pw-prompt
5543 (tramp-make-tramp-file-name
5545 (tramp-message 9 "Sending password")
5546 (tramp-enter-password p pw-prompt user host)))
5548 (defun tramp-multi-action-succeed (p method user host)
5549 "Signal success in finding shell prompt."
5550 (tramp-message 9 "Found shell prompt on `%s'" host)
5552 (throw 'tramp-action 'ok))
5554 (defun tramp-multi-action-permission-denied (p method user host)
5556 (tramp-message 9 "Permission denied by remote host `%s'" host)
5559 (throw 'tramp-action 'permission-denied))
5561 (defun tramp-multi-action-process-alive (p method user host)
5564 (throw 'tramp-action 'process-died)))
5568 (defun tramp-process-one-action (p multi-method method user host actions)
5572 (tramp-message 9 "Waiting 60s for prompt from remote shell")
5574 (tramp-accept-process-output p 1)
5582 (tramp-message 10 "Looking for regexp \"%s\" from remote shell"
5588 (defun tramp-process-actions
5591 (tramp-message 10 "%s" (mapconcat 'identity (process-command p) " "))
5594 (tramp-message 9 "Waiting for prompts from remote shell")
5596 (catch 'tramp-action
5599 (tramp-process-one-action
5601 (tramp-process-one-action
5605 (tramp-clear-passwd user host)
5610 (defun tramp-process-one-multi-action (p method user host actions)
5614 (tramp-message 9 "Waiting 60s for prompt from remote shell")
5615 (with-timeout (60 (throw 'tramp-action 'timeout))
5617 (tramp-accept-process-output p 1)
5625 (tramp-message 10 "Looking for regexp \"%s\" from remote shell"
5631 (defun tramp-process-multi-actions (p method user host actions)
5635 (tramp-message 9 "Waiting for prompts from remote shell")
5637 (catch 'tramp-action
5638 (tramp-process-one-multi-action p method user host actions)
5641 (tramp-clear-passwd user host)
5644 ;; Functions to execute when we have seen the remote shell prompt but
5651 (defun tramp-process-initial-commands (p
5659 (tramp-message 10 "Sending command to remote shell: %s"
5661 (tramp-send-command multi-method method user host cmd nil t)
5662 (tramp-barf-if-no-shell-prompt
5668 (defun tramp-open-connection-telnet (multi-method method user host)
5671 login prompt, then sends the user name USER, then waits for a remote
5672 password prompt. It queries the user for the password, then sends the
5673 password to the remote host.
5677 Recognition of the remote shell prompt is based on the variables
5678 `shell-prompt-pattern' and `tramp-shell-prompt-pattern' which must be
5688 specified in the method parameters, see the variable `tramp-methods'."
5690 (when (tramp-method-out-of-band-p multi-method method user host)
5695 (tramp-pre-connection multi-method method user host tramp-chunksize)
5696 (tramp-message 7 "Opening connection for %s@%s using %s..."
5699 (setenv "TERM" tramp-terminal-type)
5701 (let* ((default-directory (tramp-temporary-file-directory))
5707 tramp-dos-coding-system))
5709 (tramp-buffer-name multi-method method user host)
5710 (tramp-get-buffer multi-method method user host)
5711 (tramp-get-method-parameter
5713 (tramp-find-method multi-method method user host)
5714 user host 'tramp-login-program)
5716 (tramp-get-method-parameter
5718 (tramp-find-method multi-method method user host)
5719 user host 'tramp-login-args)))
5722 (tramp-set-process-query-on-exit-flag p nil)
5723 (set-buffer (tramp-get-buffer multi-method method user host))
5725 (tramp-process-actions p multi-method method user host
5726 tramp-actions-before-shell 60)
5727 (tramp-open-connection-setup-interactive-shell
5729 (tramp-post-connection multi-method method user host)))))
5732 (defun tramp-open-connection-rsh (multi-method method user host)
5735 password or shell prompt. If a password prompt is seen, the user is
5736 queried for a password, this function sends the password to the remote
5737 host and waits for a shell prompt.
5741 Recognition of the remote shell prompt is based on the variables
5742 `shell-prompt-pattern' and `tramp-shell-prompt-pattern' which must be
5750 method parameters, see the variable `tramp-methods'."
5754 (tramp-pre-connection multi-method method user host tramp-chunksize)
5756 (tramp-message 7 "Opening connection for %s@%s using %s..."
5758 (tramp-message 7 "Opening connection at %s using %s..." host method))
5760 (bufnam (tramp-buffer-name multi-method method user host))
5761 (buf (tramp-get-buffer multi-method method user host))
5762 (login-program (tramp-get-method-parameter
5764 (tramp-find-method multi-method method user host)
5765 user host 'tramp-login-program))
5769 x `((?t . ,(format "/tmp/%s" tramp-temp-name-prefix)))))
5770 (tramp-get-method-parameter
5772 (tramp-find-method multi-method method user host)
5773 user host 'tramp-login-args)))
5780 (setenv "TERM" tramp-terminal-type)
5782 (let* ((default-directory (tramp-temporary-file-directory))
5788 tramp-dos-coding-system))
5795 (tramp-set-process-query-on-exit-flag p nil)
5798 (tramp-process-actions p multi-method method user host
5799 tramp-actions-before-shell 60)
5800 (tramp-message 7 "Initializing remote shell")
5801 (tramp-open-connection-setup-interactive-shell
5803 (tramp-post-connection multi-method method user host)))))
5805 (defun tramp-open-connection-su (multi-method method user host)
5807 This starts `su - USER', then waits for a password prompt. The HOST
5812 Recognition of the remote shell prompt is based on the variables
5813 `shell-prompt-pattern' and `tramp-shell-prompt-pattern' which must be
5815 prompt than you do, so it is not at all unlikely that the variable
5816 `shell-prompt-pattern' is set up wrongly!"
5818 (when (tramp-method-out-of-band-p multi-method method user host)
5821 (unless (or (string-match (concat "^" (regexp-quote host))
5828 (tramp-pre-connection multi-method method user host tramp-chunksize)
5829 (tramp-message 7 "Opening connection for `%s' using `%s'..."
5832 (setenv "TERM" tramp-terminal-type)
5834 (let* ((default-directory (tramp-temporary-file-directory))
5840 tramp-dos-coding-system))
5842 (tramp-buffer-name multi-method method user host)
5843 (tramp-get-buffer multi-method method user host)
5844 (tramp-get-method-parameter
5846 (tramp-find-method multi-method method user host)
5847 user host 'tramp-login-program)
5851 (tramp-get-method-parameter
5853 (tramp-find-method multi-method method user host)
5854 user host 'tramp-login-args))))
5857 (tramp-set-process-query-on-exit-flag p nil)
5858 (set-buffer (tramp-get-buffer multi-method method user host))
5859 (tramp-process-actions p multi-method method user host
5860 tramp-actions-before-shell 60)
5861 (tramp-open-connection-setup-interactive-shell
5863 (tramp-post-connection multi-method method
5874 (defun tramp-open-connection-multi (multi-method method user host)
5883 (when (tramp-method-out-of-band-p multi-method method user host)
5894 (tramp-pre-connection multi-method method user host tramp-chunksize)
5895 (tramp-message 7 "Opening `%s' connection..." multi-method)
5897 (setenv "TERM" tramp-terminal-type)
5899 (let* ((default-directory (tramp-temporary-file-directory))
5905 tramp-dos-coding-system))
5906 (p (start-process (tramp-buffer-name multi-method method user host)
5907 (tramp-get-buffer multi-method method user host)
5908 tramp-multi-sh-program))
5911 (tramp-set-process-query-on-exit-flag p nil)
5912 (tramp-message 9 "Waiting 60s for local shell to come up...")
5913 (unless (tramp-wait-for-regexp
5915 shell-prompt-pattern tramp-shell-prompt-pattern))
5918 (error "Couldn't find local shell prompt"))
5924 (entry (assoc m tramp-multi-connection-function-alist))
5932 (tramp-open-connection-setup-interactive-shell
5934 (tramp-post-connection multi-method method user host)))))
5940 (defun tramp-multi-connect-telnet (p method user host command)
5945 set in `tramp-rsh-end-of-line'. Use `%%' if you want a literal percent
5950 `((?h . ,host) (?n . ,tramp-rsh-end-of-line))))
5954 (tramp-message 9 "Sending telnet command `%s'" cmd1)
5956 (tramp-process-multi-actions p method user host
5957 tramp-multi-actions)))
5963 (defun tramp-multi-connect-rlogin (p method user host command)
5968 will be replaced with the value of `tramp-rsh-end-of-line'. You can use
5974 (?n . ,tramp-rsh-end-of-line))))
5980 (tramp-message 9 "Sending rlogin command `%s'" cmd1)
5982 (tramp-process-multi-actions p method user host
5983 tramp-multi-actions)))
5989 (defun tramp-multi-connect-su (p method user host command)
5999 `tramp-rsh-end-of-line'. Use `%%' if you want a literal percent
6002 (?n . ,tramp-rsh-end-of-line))))
6007 (tramp-message 9 "Sending su command `%s'" cmd1)
6009 (tramp-process-multi-actions p method user host
6010 tramp-multi-actions)))
6014 (defun tramp-accept-process-output
6022 (defun tramp-wait-for-regexp (proc timeout regexp)
6034 (< (tramp-time-diff (current-time) start-time)
6038 (tramp-accept-process-output proc 1)
6042 (setq found (re-search-forward regexp nil t))))))
6045 (tramp-accept-process-output proc 1)
6049 (setq found (re-search-forward regexp nil t)))))
6050 (when tramp-debug-buffer
6052 (tramp-get-debug-buffer tramp-current-multi-method tramp-current-method
6053 tramp-current-user tramp-current-host)
6058 (tramp-get-debug-buffer tramp-current-multi-method tramp-current-method
6059 tramp-current-user tramp-current-host))
6061 (insert "[[Regexp `" regexp "' not found"
6066 (defun tramp-wait-for-shell-prompt (proc timeout)
6067 "Wait for the shell prompt to appear from process PROC within TIMEOUT seconds.
6068 See `tramp-wait-for-regexp' for more details.
6069 Shell prompt pattern is determined by variables `shell-prompt-pattern'
6070 and `tramp-shell-prompt-pattern'."
6071 (tramp-wait-for-regexp
6074 shell-prompt-pattern tramp-shell-prompt-pattern)))
6076 (defun tramp-barf-if-no-shell-prompt (proc timeout &rest error-args)
6077 "Wait for shell prompt and barf if none appears.
6078 Looks at process PROC to see if a shell prompt appears in TIMEOUT
6080 (unless (tramp-wait-for-shell-prompt proc timeout)
6084 (defun tramp-enter-password (p prompt user host)
6085 "Prompt for a password and send it to the remote end.
6086 Uses PROMPT as a prompt and sends the password to process P."
6087 (let ((pw (tramp-read-passwd user host prompt)))
6091 (or (tramp-get-method-parameter
6092 tramp-current-multi-method
6093 tramp-current-method
6094 tramp-current-user
6095 tramp-current-host
6096 'tramp-password-end-of-line)
6097 tramp-default-password-end-of-line)))))
6101 ;; variable tramp-current-user will be set to nil.
6102 (defun tramp-pre-connection (multi-method method user host chunksize)
6105 (set-buffer (tramp-get-buffer multi-method method user host))
6106 (set (make-local-variable 'tramp-current-multi-method) multi-method)
6107 (set (make-local-variable 'tramp-current-method) method)
6108 (set (make-local-variable 'tramp-current-user) user)
6109 (set (make-local-variable 'tramp-current-host) host)
6110 (set (make-local-variable 'tramp-chunksize) chunksize)
6114 (defun tramp-open-connection-setup-interactive-shell
6117 Mainly sets the prompt and the echo correctly. P is the shell process
6123 (tramp-discard-garbage-erase-buffer p multi-method method user host)
6124 (tramp-process-initial-commands p multi-method method user host
6125 tramp-initial-commands)
6126 ;; It is useful to set the prompt in the following command because
6128 ;; about and thus /bin/sh will display a strange prompt. For
6138 (tramp-send-command-internal
6141 (tramp-get-method-parameter
6142 multi-method method user host 'tramp-remote-sh))
6144 (tramp-get-method-parameter
6145 multi-method method user host 'tramp-remote-sh)))
6146 (tramp-barf-if-no-shell-prompt
6149 (tramp-get-method-parameter multi-method method user host 'tramp-remote-sh)
6151 (tramp-message 8 "Setting up remote shell environment")
6152 (tramp-discard-garbage-erase-buffer p multi-method method user host)
6153 (tramp-send-command-internal multi-method method user host
6157 (tramp-send-command-internal multi-method method user host
6160 (tramp-send-command-internal multi-method method user host
6168 (when (or (not tramp-chunksize) (zerop tramp-chunksize))
6169 (tramp-message 9 "Checking remote host type for `send-process-string' bug")
6170 (tramp-send-command-internal multi-method method user host
6174 (setq tramp-chunksize 500)))
6180 (tramp-message 9 "Determining coding system")
6181 (tramp-send-command-internal multi-method method user host
6194 (setq cs-encode (tramp-coding-system-change-eol-conversion
6197 (setq cs-decode (tramp-coding-system-change-eol-conversion
6206 (tramp-message 9 "Trying `stty -onlcr'")
6207 (tramp-send-command-internal multi-method method user host
6210 (tramp-message
6212 (tramp-send-command-internal
6216 (tramp-message 9 "Waiting 30s for `set +o vi +o emacs'")
6217 (tramp-send-command-internal multi-method method user host
6220 (tramp-message 9 "Waiting 30s for `unset MAIL MAILCHECK MAILPATH'")
6221 (tramp-send-command-internal
6225 (tramp-message 9 "Waiting 30s for `unset CDPATH'")
6226 (tramp-send-command-internal multi-method method user host
6229 (tramp-message 9 "Setting shell prompt")
6231 ;; use "\n" here, not tramp-rsh-end-of-line. We also manually frob
6232 ;; the last time we sent a command, to avoid tramp-send-command to send
6234 (setq tramp-last-cmd-time (current-time))
6235 (tramp-send-command
6238 tramp-rsh-end-of-line
6239 tramp-end-of-output
6240 tramp-rsh-end-of-line))
6241 (tramp-wait-for-output))
6243 (defun tramp-post-connection (multi-method method user host)
6257 (tramp-find-shell multi-method method user host)
6260 ;; output of (tramp-find-shell) to show up along with the output of
6261 ;; (tramp-find-ls-command) testing.
6263 ;; I can't work out why this is a problem though. The (tramp-wait-for-output)
6264 ;; call in (tramp-find-shell) *should* make this not happen, I thought.
6272 (tramp-find-file-exists-command multi-method method user host)
6273 (make-local-variable 'tramp-ls-command)
6274 (setq tramp-ls-command (tramp-find-ls-command multi-method method user host))
6275 (unless tramp-ls-command
6276 (tramp-message
6279 (setq tramp-ls-command
6280 (tramp-find-executable multi-method method user host
6281 "ls" tramp-remote-path nil)))
6282 (unless tramp-ls-command
6284 (tramp-message 5 "Using remote command `%s' for getting directory listings"
6285 tramp-ls-command)
6286 (tramp-send-command multi-method method user host
6287 (concat "tramp_set_exit_status () {" tramp-rsh-end-of-line
6288 "return $1" tramp-rsh-end-of-line
6290 (tramp-wait-for-output)
6292 (tramp-set-remote-path multi-method method user host "PATH" tramp-remote-path)
6295 (tramp-send-command multi-method method user host
6297 (tramp-wait-for-output)
6298 (tramp-send-command multi-method method user host
6300 (tramp-wait-for-output)
6301 (tramp-send-command multi-method method user host
6303 (tramp-wait-for-output)
6306 (tramp-send-command multi-method method user host
6308 (tramp-wait-for-output)
6313 (make-local-variable 'tramp-test-groks-nt)
6314 (tramp-send-command multi-method method user host
6316 (tramp-wait-for-output)
6318 (setq tramp-test-groks-nt
6319 (looking-at (format "\n%s\r?\n" (regexp-quote tramp-end-of-output))))
6320 (unless tramp-test-groks-nt
6321 (tramp-send-command
6323 (concat "tramp_test_nt () {" tramp-rsh-end-of-line
6324 "test -n \"`find $1 -prune -newer $2 -print`\"" tramp-rsh-end-of-line
6326 (tramp-wait-for-output)
6329 (tramp-send-string multi-method method user host tramp-uudecode)
6330 (tramp-wait-for-output)
6333 (tramp-set-connection-property "perl-scripts" nil multi-method method user host)
6334 (let ((tramp-remote-perl
6335 (or (tramp-find-executable multi-method method user host
6336 "perl5" tramp-remote-path nil)
6337 (tramp-find-executable multi-method method user host
6338 "perl" tramp-remote-path nil))))
6339 (when tramp-remote-perl
6340 (tramp-set-connection-property "perl" tramp-remote-perl
6342 (unless (tramp-method-out-of-band-p multi-method method user host)
6343 (tramp-message 5 "Sending the Perl `mime-encode' implementations.")
6344 (tramp-send-string
6347 (format tramp-perl-encode tramp-remote-perl)
6350 (tramp-wait-for-output)
6351 (tramp-send-string
6354 (format tramp-perl-encode-with-module tramp-remote-perl)
6357 (tramp-wait-for-output)
6358 (tramp-message 5 "Sending the Perl `mime-decode' implementations.")
6359 (tramp-send-string
6362 (format tramp-perl-decode tramp-remote-perl)
6365 (tramp-wait-for-output)
6366 (tramp-send-string
6369 (format tramp-perl-decode-with-module tramp-remote-perl)
6372 (tramp-wait-for-output))))
6375 (let ((ln (tramp-find-executable multi-method method user host
6376 "ln" tramp-remote-path nil)))
6378 (tramp-set-connection-property "ln" ln multi-method method user host)))
6381 (tramp-send-command multi-method method user host "id -u; id -g")
6382 (tramp-wait-for-output)
6384 (tramp-set-connection-property
6386 (tramp-set-connection-property
6390 (unless (tramp-method-out-of-band-p multi-method method user host)
6391 (tramp-find-inline-encoding multi-method method user host))
6395 (let ((rem-enc (tramp-get-remote-encoding multi-method method user host))
6396 (rem-dec (tramp-get-remote-decoding multi-method method user host))
6399 (tramp-kill-process multi-method method user host)
6404 (tramp-message
6407 (tramp-send-command
6410 (tramp-shell-quote-argument magic-string) rem-enc rem-dec))
6411 (tramp-wait-for-output)
6412 (unless (looking-at (regexp-quote magic-string))
6413 (tramp-kill-process multi-method method user host)
6417 (tramp-message
6425 ;; Old text from documentation of tramp-methods:
6438 (defvar tramp-coding-commands
6446 tramp-uuencode-region uudecode-decode-region)
6448 tramp-uuencode-region uudecode-decode-region)
6450 tramp-uuencode-region uudecode-decode-region)
6452 tramp-uuencode-region uudecode-decode-region)
6479 (defun tramp-find-inline-encoding (multi-method method user host)
6481 Goes through the list `tramp-coding-commands'."
6482 (let ((commands tramp-coding-commands)
6500 (tramp-message-for-buffer
6503 (unless (zerop (tramp-send-command-and-check
6507 (tramp-message-for-buffer
6510 (unless (zerop (tramp-send-command-and-check
6517 (unless (looking-at (regexp-quote magic))
6522 (tramp-message-for-buffer
6525 (unless (zerop (tramp-call-local-coding-command
6529 (tramp-message-for-buffer
6532 (unless (zerop (tramp-call-local-coding-command
6548 (tramp-message 10 "Using remote encoding %s" rem-enc)
6549 (tramp-set-remote-encoding multi-method method user host rem-enc)
6550 (tramp-message 10 "Using remote decoding %s" rem-dec)
6551 (tramp-set-remote-decoding multi-method method user host rem-dec)
6552 (tramp-message 10 "Using local encoding %s" loc-enc)
6553 (tramp-set-local-encoding multi-method method user host loc-enc)
6554 (tramp-message 10 "Using local decoding %s" loc-dec)
6555 (tramp-set-local-decoding multi-method method user host loc-dec))))
6557 (defun tramp-call-local-coding-command (cmd input output)
6566 tramp-encoding-shell ;program
6571 tramp-encoding-command-switch
6577 (defun tramp-maybe-open-connection (multi-method method user host)
6582 (tramp-get-buffer multi-method method user host)))
6592 (set-buffer (tramp-get-buffer multi-method method user host))
6593 (when (and tramp-last-cmd-time
6594 (> (tramp-time-diff (current-time) tramp-last-cmd-time) 60)
6596 (tramp-send-command
6599 (tramp-wait-for-output 10))
6606 (let ((process-connection-type tramp-process-connection-type))
6607 (funcall (tramp-get-method-parameter
6609 (tramp-find-method multi-method method user host)
6610 user host 'tramp-connection-function)
6613 (defun tramp-send-command
6620 `tramp-maybe-open-connection' only."
6622 (tramp-maybe-open-connection multi-method method user host))
6623 (setq tramp-last-cmd-time (current-time))
6624 (setq tramp-last-cmd command)
6625 (when tramp-debug-buffer
6627 (set-buffer (tramp-get-debug-buffer multi-method method user host))
6629 (tramp-insert-with-face 'bold (format "$ %s\n" command))))
6631 (set-buffer (tramp-get-buffer multi-method method user host))
6635 (concat command tramp-rsh-end-of-line))))
6637 (defun tramp-send-command-internal
6640 Sends COMMAND, then waits 30 seconds for shell prompt."
6641 (tramp-send-command multi-method method user host command t t)
6643 (tramp-message 9 "Waiting 30s for %s..." msg))
6644 (tramp-barf-if-no-shell-prompt
6648 (defun tramp-wait-for-output (&optional timeout)
6655 (regexp-quote tramp-end-of-output)
6668 (< (tramp-time-diff (current-time) start-time)
6672 (tramp-accept-process-output proc 1)
6680 (tramp-accept-process-output proc 1)
6693 (when tramp-process-echoes
6696 (when (looking-at (regexp-quote tramp-last-cmd))
6699 (when tramp-debug-buffer
6701 (tramp-get-debug-buffer tramp-current-multi-method tramp-current-method
6702 tramp-current-user tramp-current-host)
6707 (tramp-get-debug-buffer tramp-current-multi-method tramp-current-method
6708 tramp-current-user tramp-current-host))
6710 (insert "[[Remote prompt `" end-of-output "' not found"
6717 (defun tramp-send-command-and-check (multi-method method user host command
6726 (tramp-send-command multi-method method user host
6732 (tramp-wait-for-output)
6739 (defun tramp-barf-unless-okay (multi-method method user host command subshell
6742 Similar to `tramp-send-command-and-check' but accepts two more arguments
6744 (unless (zerop (tramp-send-command-and-check
6755 (defun tramp-send-string
6761 `tramp-rsh-end-of-line'."
6763 (tramp-get-buffer multi-method method user host))))
6767 (when tramp-debug-buffer
6769 (set-buffer (tramp-get-debug-buffer multi-method method user host))
6771 (tramp-insert-with-face 'bold (format "$ %s\n" string))))
6772 ;; replace "\n" by `tramp-rsh-end-of-line'
6776 tramp-rsh-end-of-line))
6778 (string-equal (substring string -1) tramp-rsh-end-of-line))
6779 (setq string (concat string tramp-rsh-end-of-line)))
6781 (if (and tramp-chunksize (not (zerop tramp-chunksize)))
6785 (tramp-message-for-buffer
6788 pos (min (+ pos tramp-chunksize) end))
6790 proc (substring string pos (min (+ pos tramp-chunksize) end)))
6791 (setq pos (+ pos tramp-chunksize))
6795 (defun tramp-send-eof (multi-method method user host)
6799 (tramp-get-buffer multi-method method user host))))
6805 (defun tramp-kill-process (multi-method method user host)
6809 (tramp-get-buffer multi-method method user host))))
6812 (defun tramp-discard-garbage-erase-buffer (p multi-method method user host)
6814 If `tramp-discard-garbage' is nil, just erase buffer."
6815 (if (not tramp-discard-garbage)
6817 (while (prog1 (erase-buffer) (tramp-accept-process-output p 0.25))
6818 (when tramp-debug-buffer
6820 (set-buffer (tramp-get-debug-buffer multi-method method user host))
6822 (tramp-insert-with-face
6825 (defun tramp-mode-string-to-int (mode-string)
6840 (?r (tramp-octal-to-decimal "00400")) (?- 0)
6843 (?w (tramp-octal-to-decimal "00200")) (?- 0)
6846 (?x (tramp-octal-to-decimal "00100"))
6847 (?S (tramp-octal-to-decimal "04000"))
6848 (?s (tramp-octal-to-decimal "04100"))
6853 (?r (tramp-octal-to-decimal "00040")) (?- 0)
6856 (?w (tramp-octal-to-decimal "00020")) (?- 0)
6859 (?x (tramp-octal-to-decimal "00010"))
6860 (?S (tramp-octal-to-decimal "02000"))
6861 (?s (tramp-octal-to-decimal "02010"))
6866 (?r (tramp-octal-to-decimal "00004")) (?- 0)
6869 (?w (tramp-octal-to-decimal "00002")) (?- 0)
6872 (?x (tramp-octal-to-decimal "00001"))
6873 (?T (tramp-octal-to-decimal "01000"))
6874 (?t (tramp-octal-to-decimal "01001"))
6879 (defun tramp-convert-file-attributes (multi-method method user host attr)
6885 (setcar (nthcdr 8 attr) (tramp-file-mode-from-int (nth 8 attr))))
6890 (tramp-get-remote-gid multi-method method user host)))))
6893 (tramp-get-device multi-method method user host))
6896 (defun tramp-get-device (multi-method method user host)
6899 (let ((string (tramp-make-tramp-file-name multi-method method user host "")))
6900 (unless (assoc string tramp-devices)
6901 (add-to-list 'tramp-devices
6902 (list string (length tramp-devices))))
6903 (list -1 (nth 1 (assoc string tramp-devices)))))
6905 (defun tramp-file-mode-from-int (mode)
6907 (let ((type (cdr (assoc (logand (lsh mode -12) 15) tramp-file-mode-type-map)))
6914 (setq user (tramp-file-mode-permissions user suid "s"))
6915 (setq group (tramp-file-mode-permissions group sgid "s"))
6916 (setq other (tramp-file-mode-permissions other sticky "t"))
6920 (defun tramp-file-mode-permissions (perm suid suid-text)
6922 This is used internally by `tramp-file-mode-from-int'."
6933 (defun tramp-decimal-to-octal (i)
6939 (t (concat (tramp-decimal-to-octal (/ i 8))
6943 ;;(defun tramp-octal-to-decimal (ostr)
6952 ;; (+ (- last ?0) (* 8 (tramp-octal-to-decimal rest)))))))
6954 (defun tramp-octal-to-decimal (ostr)
6957 ;; `save-match' is in `tramp-mode-string-to-int' which calls this.
6962 (defun tramp-shell-case-fold (string)
6980 (defstruct tramp-file-name multi-method method user host localname)
6982 (defun tramp-tramp-file-p (name)
6983 "Return t iff NAME is a tramp file."
6985 (string-match tramp-file-name-regexp name)))
6990 (defun tramp-dissect-file-name (name)
6991 "Return an `tramp-file-name' structure.
6995 (let* ((match (string-match (nth 0 tramp-file-name-structure) name))
6998 (if match (match-string (nth 1 tramp-file-name-structure) name)
7001 (format (nth 0 tramp-multi-file-name-structure)
7002 (nth 0 tramp-multi-file-name-hop-structure)) name)
7003 (match-string (nth 1 tramp-multi-file-name-structure) name))))
7004 (if (and method (member method tramp-multi-methods))
7007 (tramp-dissect-multi-file-name name)
7009 (unless match (error "Not a tramp file name: %s" name))
7010 (let ((user (match-string (nth 2 tramp-file-name-structure) name))
7011 (host (match-string (nth 3 tramp-file-name-structure) name))
7012 (localname (match-string (nth 4 tramp-file-name-structure) name)))
7013 (make-tramp-file-name
7020 (defun tramp-find-default-method (user host)
7021 "Look up the right method to use in `tramp-default-method-alist'."
7022 (let ((choices tramp-default-method-alist)
7023 (method tramp-default-method)
7033 (defun tramp-find-method (multi-method method user host)
7037 `tramp-default-method-alist'."
7038 (or multi-method method (tramp-find-default-method user host)))
7042 (defun tramp-dissect-multi-file-name (name)
7044 (let ((regexp (nth 0 tramp-multi-file-name-structure))
7045 (method-index (nth 1 tramp-multi-file-name-structure))
7046 (hops-index (nth 2 tramp-multi-file-name-structure))
7047 (localname-index (nth 3 tramp-multi-file-name-structure))
7048 (hop-regexp (nth 0 tramp-multi-file-name-hop-structure))
7049 (hop-method-index (nth 1 tramp-multi-file-name-hop-structure))
7050 (hop-user-index (nth 2 tramp-multi-file-name-hop-structure))
7051 (hop-host-index (nth 3 tramp-multi-file-name-hop-structure))
7053 (unless (string-match (format regexp hop-regexp) name)
7054 (error "Not a multi tramp file name: %s" name))
7061 (while (string-match hop-regexp hops index)
7069 (make-tramp-file-name
7076 (defun tramp-make-tramp-file-name (multi-method method user host localname)
7077 "Constructs a tramp file name from METHOD, USER, HOST and LOCALNAME."
7079 (tramp-make-tramp-multi-file-name multi-method method user host localname)
7081 (concat tramp-prefix-format
7082 (when method (concat "%m" tramp-postfix-single-method-format))
7083 (when user (concat "%u" tramp-postfix-user-format))
7084 (when host (concat "%h" tramp-postfix-host-format))
7090 (defun tramp-make-tramp-multi-file-name (multi-method method user host localname)
7091 "Constructs a tramp file name for a multi-hop method."
7092 (unless tramp-make-multi-tramp-file-format
7093 (error "`tramp-make-multi-tramp-file-format' is nil"))
7094 (let* ((prefix-format (nth 0 tramp-make-multi-tramp-file-format))
7095 (hop-format (nth 1 tramp-make-multi-tramp-file-format))
7096 (localname-format (nth 2 tramp-make-multi-tramp-file-format))
7109 (defun tramp-make-copy-program-file-name (user host localname)
7115 (defun tramp-method-out-of-band-p (multi-method method user host)
7117 (tramp-get-method-parameter
7119 (tramp-find-method multi-method method user host)
7120 user host 'tramp-copy-program))
7124 (defun tramp-get-ls-command (multi-method method user host)
7127 (tramp-maybe-open-connection multi-method method user host)
7128 (set-buffer (tramp-get-buffer multi-method method user host))
7129 tramp-ls-command)
7132 (defun tramp-get-test-groks-nt (multi-method method user host)
7134 (tramp-maybe-open-connection multi-method method user host)
7135 (set-buffer (tramp-get-buffer multi-method method user host))
7136 tramp-test-groks-nt))
7138 (defun tramp-get-file-exists-command (multi-method method user host)
7141 (tramp-maybe-open-connection multi-method method user host)
7142 (set-buffer (tramp-get-buffer multi-method method user host))
7143 tramp-file-exists-command)
7146 (defun tramp-get-remote-perl (multi-method method user host)
7147 (tramp-get-connection-property "perl" nil multi-method method user host))
7149 (defun tramp-get-remote-ln (multi-method method user host)
7151 (tramp-get-connection-property "ln" nil multi-method method user host)
7154 (defun tramp-get-remote-uid (multi-method method user host)
7155 (tramp-get-connection-property "uid" nil multi-method method user host))
7157 (defun tramp-get-remote-gid (multi-method method user host)
7158 (tramp-get-connection-property "gid" nil multi-method method user host))
7161 (defun tramp-get-connection-property
7165 (tramp-maybe-open-connection multi-method method user host)
7166 (with-current-buffer (tramp-get-buffer multi-method method user host)
7169 (symbol-value (intern (concat "tramp-connection-property-" property)))
7173 (defun tramp-set-connection-property
7176 (tramp-maybe-open-connection multi-method method user host)
7177 (with-current-buffer (tramp-get-buffer multi-method method user host)
7179 (intern (concat "tramp-connection-property-" property)))
7183 (defun tramp-set-remote-encoding (multi-method method user host rem-enc)
7184 (tramp-set-connection-property "remote-encoding" rem-enc
7186 (defun tramp-get-remote-encoding (multi-method method user host)
7187 (tramp-get-connection-property "remote-encoding" nil
7190 (defun tramp-set-remote-decoding (multi-method method user host rem-dec)
7191 (tramp-set-connection-property "remote-decoding" rem-dec
7193 (defun tramp-get-remote-decoding (multi-method method user host)
7194 (tramp-get-connection-property "remote-decoding" nil
7197 (defun tramp-set-local-encoding (multi-method method user host loc-enc)
7198 (tramp-set-connection-property "local-encoding" loc-enc
7200 (defun tramp-get-local-encoding (multi-method method user host)
7201 (tramp-get-connection-property "local-encoding" nil
7204 (defun tramp-set-local-decoding (multi-method method user host loc-dec)
7205 (tramp-set-connection-property "local-decoding" loc-dec
7207 (defun tramp-get-local-decoding (multi-method method user host)
7208 (tramp-get-connection-property "local-decoding" nil
7211 (defun tramp-get-method-parameter (multi-method method user host param)
7213 If the `tramp-methods' entry does not exist, use the variable PARAM
7218 (assoc (tramp-find-method multi-method method user host)
7219 tramp-methods))))
7227 (defun tramp-exists-file-name-handler (operation &rest args)
7242 (unless (tramp-exists-file-name-handler 'make-auto-save-file-name)
7244 (around tramp-advice-make-auto-save-file-name () activate)
7245 "Invoke `tramp-handle-make-auto-save-file-name' for tramp files."
7246 (if (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name)))
7247 (setq ad-return-value (tramp-handle-make-auto-save-file-name))
7249 (add-hook 'tramp-unload-hook
7255 (defun tramp-set-auto-save-file-modes ()
7259 (tramp-tramp-file-p bfn)
7268 (or (file-modes bfn) (tramp-octal-to-decimal "0600"))))))
7274 (add-hook 'auto-save-hook 'tramp-set-auto-save-file-modes)
7275 (add-hook 'tramp-unload-hook
7277 (remove-hook 'auto-save-hook 'tramp-set-auto-save-file-modes))))
7279 (defun tramp-subst-strs-in-string (alist string)
7287 (while (string-match (regexp-quote from) string)
7292 (defun tramp-insert-with-face (face string)
7302 (defun tramp-temporary-file-directory ()
7321 (defun tramp-read-passwd (user host prompt)
7322 "Read a password from user (compat function).
7323 Invokes `password-read' if available, `read-passwd' else."
7324 (if (functionp 'password-read)
7326 (password (apply #'password-read (list prompt key))))
7327 (apply #'password-cache-add (list key password))
7328 password)
7329 (read-passwd prompt)))
7331 (defun tramp-clear-passwd (&optional user host)
7332 "Clear password cache for connection related to current-buffer."
7335 (when (and (functionp 'password-cache-remove)
7336 (or (and user host) (tramp-tramp-file-p filename)))
7337 (let* ((v (when (tramp-tramp-file-p filename)
7338 (tramp-dissect-file-name filename)))
7339 (luser (or user (tramp-file-name-user v) (user-login-name)))
7340 (lhost (or host (tramp-file-name-host v) (system-name)))
7342 (apply #'password-cache-remove (list key))))))
7344 (defun tramp-time-diff (t1 t2)
7370 (defun tramp-coding-system-change-eol-conversion (coding-system eol-type)
7389 (defun tramp-split-string (string pattern)
7395 Note: this function has been written for `tramp-handle-file-truename'.
7400 (defun tramp-set-process-query-on-exit-flag (process flag)
7440 (defun tramp-shell-quote-argument (s)
7446 (nl (regexp-quote (format "\\%s" tramp-rsh-end-of-line))))
7451 (setq result (replace-match (format "'%s'" tramp-rsh-end-of-line)
7457 ;; ;; away from tramp.el file names.
7472 ;; (defadvice efs-ftp-path (around dont-match-tramp-localname activate protect)
7474 ;; (if (tramp-tramp-file-p (ad-get-arg 0))
7487 (when (string-match "\\[" tramp-prefix-format)
7488 (defadvice file-expand-wildcards (around tramp-fix activate)
7490 (if (tramp-tramp-file-p name)
7493 (let ((v (tramp-dissect-file-name name)))
7494 (if (string-match "[[*?]" (tramp-file-name-localname v))
7501 (add-hook 'tramp-unload-hook
7506 (defun tramp-version (arg)
7507 "Print version number of tramp.el in minibuffer or current buffer."
7509 (if arg (insert tramp-version) (message tramp-version)))
7517 (defun tramp-bug ()
7522 (let ((reporter-prompt-for-summary-p t))
7524 tramp-bug-report-address ; to-address
7525 (format "tramp (%s)" tramp-version) ; package name and version
7528 tramp-ls-command
7529 tramp-test-groks-nt
7530 tramp-file-exists-command
7531 tramp-current-multi-method
7532 tramp-current-method
7533 tramp-current-user
7534 tramp-current-host
7537 tramp-auto-save-directory ; vars to dump
7538 tramp-default-method
7539 tramp-rsh-end-of-line
7540 tramp-default-password-end-of-line
7541 tramp-remote-path
7542 tramp-login-prompt-regexp
7544 (tramp-password-prompt-regexp . tramp-reporter-dump-variable)
7545 tramp-wrong-passwd-regexp
7546 tramp-yesno-prompt-regexp
7547 tramp-yn-prompt-regexp
7548 tramp-terminal-prompt-regexp
7549 tramp-temp-name-prefix
7550 tramp-file-name-structure
7551 tramp-file-name-regexp
7552 tramp-multi-file-name-structure
7553 tramp-multi-file-name-hop-structure
7554 tramp-multi-methods
7555 tramp-multi-connection-function-alist
7556 tramp-methods
7557 tramp-end-of-output
7558 tramp-coding-commands
7559 tramp-actions-before-shell
7560 tramp-actions-copy-out-of-band
7561 tramp-multi-actions
7562 tramp-terminal-type
7564 (tramp-shell-prompt-pattern . tramp-reporter-dump-variable)
7565 tramp-chunksize
7566 ,(when (boundp 'tramp-backup-directory-alist)
7567 'tramp-backup-directory-alist)
7568 ,(when (boundp 'tramp-bkup-backup-directory-info)
7569 'tramp-bkup-backup-directory-info)
7571 ;; Non-tramp variables of interest
7573 (shell-prompt-pattern . tramp-reporter-dump-variable)
7579 ,(when (boundp 'password-cache)
7580 'password-cache)
7581 ,(when (boundp 'password-cache-expiry)
7582 'password-cache-expiry)
7589 'tramp-load-report-modules ; pre-hook
7590 'tramp-append-tramp-buffers ; post-hook
7600 Another useful thing to do is to put (setq tramp-debug-buffer t) in
7602 of the *tramp/foo* buffer and the *debug tramp/foo* buffer in your bug
7608 (defun tramp-reporter-dump-variable (varsym mailbuf)
7643 (defun tramp-load-report-modules ()
7658 (defun tramp-append-tramp-buffers ()
7666 (let* ((tramp-buf-regexp "\\*\\(debug \\)?tramp/")
7670 (when (string-match tramp-buf-regexp (buffer-name b)) b))
7681 (if (re-search-forward tramp-buf-regexp (tramp-point-at-eol) t)
7693 (when (and tramp-debug-buffer (> tramp-verbose 9))
7697 Please note that you have set `tramp-verbose' to a value greater than 9.
7725 (defalias 'tramp-submit-bug 'tramp-bug)
7727 ;; Checklist for `tramp-unload-hook'
7728 ;; - Unload all `tramp-*' packages
7734 (defun tramp-unload-tramp ()
7738 (tramp-unload-file-name-handlers)
7740 (when (functionp 'tramp-ftp-enable-ange-ftp)
7741 (funcall (symbol-function 'tramp-ftp-enable-ange-ftp)))
7742 ;; `tramp-util' unloads also `tramp'.
7744 (unload-feature (if (featurep 'tramp-util) 'tramp-util 'tramp) 'force)
7747 (provide 'tramp)
7751 ;; This must come after (provide 'tramp) because tramp-vc.el
7752 ;; requires tramp.
7755 (require 'tramp-vc)
7756 (add-hook 'tramp-unload-hook
7758 (when (featurep 'tramp-vc)
7759 (unload-feature 'tramp-vc 'force))))))
7784 ;; * Separate local `tramp-coding-commands' from remote ones. Connect
7789 ;; * Rewrite `tramp-shell-quote-argument' to abstain from using
7815 ;; * Test remote ksh or bash for tilde expansion in `tramp-find-shell'?
7817 ;; * grok ~ in tramp-remote-path (Henrik Holm <henrikh@tele.ntnu.no>)
7836 ;; * Change applicable functions to pass a struct tramp-file-name rather
7839 ;; * Clean up unused *tramp/foo* buffers after a while. (Pete Forman)
7858 ;; ** Try to avoid usage of `last-input-event' in `tramp-completion-mode'.
7859 ;; ** Extend `tramp-get-completion-su' for NIS and shadow passwords.
7860 ;; ** Unify `tramp-parse-{rhosts,shosts,sconfig,hosts,passwd,netrc}'.
7863 ;; operating system (windows-nt) in `tramp-completion-function-alist'.
7878 ;;; tramp.el ends here