tramp.el 316 KB
Newer Older
Kai Großjohann's avatar
Kai Großjohann committed
1
;;; -*- mode: Emacs-Lisp; coding: iso-2022-7bit; -*-
2
;;; tramp.el --- Transparent Remote Access, Multiple Protocol
Kai Großjohann's avatar
Kai Großjohann committed
3

4
;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
5
;;   2005, 2006, 2007 Free Software Foundation, Inc.
Kai Großjohann's avatar
Kai Großjohann committed
6

7 8
;; (copyright statements below in code to be updated with the above notice)

Michael Albinus's avatar
Michael Albinus committed
9 10
;; Author: Kai Gro,A_(Bjohann <kai.grossjohann@gmx.net>
;;         Michael Albinus <michael.albinus@gmx.de>
Kai Großjohann's avatar
Kai Großjohann committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
;; Keywords: comm, processes

;; This file is part of GNU Emacs.

;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to the
Lute Kamstra's avatar
Lute Kamstra committed
27 28
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
Kai Großjohann's avatar
Kai Großjohann committed
29 30 31 32 33 34 35 36

;;; Commentary:

;; This package provides remote file editing, similar to ange-ftp.
;; The difference is that ange-ftp uses FTP to transfer files between
;; the local and the remote host, whereas tramp.el uses a combination
;; of rsh and rcp or other work-alike programs, such as ssh/scp.
;;
37
;; For more detailed instructions, please see the info file.
Kai Großjohann's avatar
Kai Großjohann committed
38 39 40
;;
;; Notes:
;; -----
41
;;
Kai Großjohann's avatar
Kai Großjohann committed
42 43 44 45 46 47 48 49 50 51 52
;; This package only works for Emacs 20 and higher, and for XEmacs 21
;; and higher.  (XEmacs 20 is missing the `with-timeout' macro.  Emacs
;; 19 is reported to have other problems.  For XEmacs 21, you need the
;; package `fsf-compat' for the `with-timeout' macro.)
;;
;; This version might not work with pre-Emacs 21 VC unless VC is
;; loaded before tramp.el.  Could you please test this and tell me about
;; the result?  Thanks.
;;
;; Also see the todo list at the bottom of this file.
;;
53
;; The current version of Tramp can be retrieved from the following URL:
Michael Albinus's avatar
Michael Albinus committed
54
;;            http://ftp.gnu.org/gnu/tramp/
Kai Großjohann's avatar
Kai Großjohann committed
55 56
;;
;; There's a mailing list for this, as well.  Its name is:
Michael Albinus's avatar
Michael Albinus committed
57 58 59
;;            tramp-devel@gnu.org
;; You can use the Web to subscribe, under the following URL:
;;            http://lists.gnu.org/mailman/listinfo/tramp-devel
Kai Großjohann's avatar
Kai Großjohann committed
60 61 62
;;
;; For the adventurous, the current development sources are available
;; via CVS.  You can find instructions about this at the following URL:
63
;;            http://savannah.gnu.org/projects/tramp/
Kai Großjohann's avatar
Kai Großjohann committed
64 65 66 67 68 69
;; Click on "CVS" in the navigation bar near the top.
;;
;; Don't forget to put on your asbestos longjohns, first!

;;; Code:

70 71
;; The Tramp version number and bug report address, as prepared by configure.
(require 'trampver)
Michael Albinus's avatar
Michael Albinus committed
72 73 74 75 76 77 78 79
(add-hook 'tramp-unload-hook
	  '(lambda ()
	     (when (featurep 'trampver)
	       (unload-feature 'trampver 'force))))

(if (featurep 'xemacs)
    (require 'timer-funcs)
  (require 'timer))
Kai Großjohann's avatar
Kai Großjohann committed
80 81

(require 'format-spec)                  ;from Gnus 5.8, also in tar ball
82 83 84 85 86 87
;; As long as password.el is not part of (X)Emacs, it shouldn't
;; be mandatory
(if (featurep 'xemacs)
    (load "password" 'noerror)
  (require 'password nil 'noerror))     ;from No Gnus, also in tar ball

88 89 90 91 92 93
;; The explicit check is not necessary in Emacs, which provides the
;; feature even if implemented in C, but it appears to be necessary
;; in XEmacs.
(unless (and (fboundp 'base64-encode-region)
	     (fboundp 'base64-decode-region))
  (require 'base64))                       ;for the mimencode methods
Kai Großjohann's avatar
Kai Großjohann committed
94 95 96
(require 'shell)
(require 'advice)

97 98
(autoload 'tramp-uuencode-region "tramp-uu"
  "Implementation of `uuencode' in Lisp.")
Michael Albinus's avatar
Michael Albinus committed
99 100 101 102
(add-hook 'tramp-unload-hook
	  '(lambda ()
	     (when (featurep 'tramp-uu)
	       (unload-feature 'tramp-uu 'force))))
103 104 105 106

(unless (fboundp 'uudecode-decode-region)
  (autoload 'uudecode-decode-region "uudecode"))

107 108 109 110 111 112 113 114 115 116 117
;; XEmacs is distributed with few Lisp packages.  Further packages are
;; installed using EFS.  If we use a unified filename format, then
;; Tramp is required in addition to EFS.  (But why can't Tramp just
;; disable EFS when Tramp is loaded?  Then XEmacs can ship with EFS
;; just like before.)  Another reason for using a separate filename
;; syntax on XEmacs is that EFS hooks into XEmacs in many places, but
;; Tramp only knows how to deal with `file-name-handler-alist', not
;; the other places.
;;;###autoload
(defvar tramp-unified-filenames (not (featurep 'xemacs))
  "Non-nil means to use unified Ange-FTP/Tramp filename syntax.
118
Otherwise, use a separate filename syntax for Tramp.")
Kai Großjohann's avatar
Kai Großjohann committed
119

120 121 122 123 124 125
;; Load foreign methods.  Because they do require Tramp internally, this
;; must be done with the `eval-after-load' trick.

;; tramp-ftp supports Ange-FTP only.  Not suited for XEmacs therefore.
(unless (featurep 'xemacs)
  (eval-after-load "tramp"
Michael Albinus's avatar
Michael Albinus committed
126 127 128 129 130 131
    '(progn
       (require 'tramp-ftp)
       (add-hook 'tramp-unload-hook
		 '(lambda ()
		    (when (featurep 'tramp-ftp)
		      (unload-feature 'tramp-ftp 'force)))))))
132 133
(when (and tramp-unified-filenames (featurep 'xemacs))
  (eval-after-load "tramp"
Michael Albinus's avatar
Michael Albinus committed
134 135 136 137 138 139
    '(progn
       (require 'tramp-efs)
       (add-hook 'tramp-unload-hook
		 '(lambda ()
		    (when (featurep 'tramp-efs)
		      (unload-feature 'tramp-efs 'force)))))))
140 141 142 143

;; tramp-smb uses "smbclient" from Samba.
;; Not available under Cygwin and Windows, because they don't offer
;; "smbclient".  And even not necessary there, because Emacs supports
Kai Großjohann's avatar
Kai Großjohann committed
144
;; UNC file names like "//host/share/localname".
145 146
(unless (memq system-type '(cygwin windows-nt))
  (eval-after-load "tramp"
Michael Albinus's avatar
Michael Albinus committed
147 148 149 150 151 152
    '(progn
       (require 'tramp-smb)
       (add-hook 'tramp-unload-hook
		 '(lambda ()
		    (when (featurep 'tramp-smb)
		      (unload-feature 'tramp-smb 'force)))))))
153

154
(require 'custom)
Kai Großjohann's avatar
Kai Großjohann committed
155 156 157 158

(unless (boundp 'custom-print-functions)
  (defvar custom-print-functions nil))	; not autoloaded before Emacs 20.4

159
;; Avoid byte-compiler warnings if the byte-compiler supports this.
160 161
;; Currently, XEmacs supports this.
(eval-when-compile
162
  (when (featurep 'xemacs)
163 164 165 166 167 168 169 170 171 172 173
    (let (unused-vars) ; Pacify Emacs byte-compiler
      (defalias 'warnings 'identity) ; Pacify Emacs byte-compiler
      (byte-compiler-options (warnings (- unused-vars))))))

;; `directory-sep-char' is an obsolete variable in Emacs.  But it is
;; used in XEmacs, so we set it here and there.  The following is needed
;; to pacify Emacs byte-compiler.
(eval-when-compile
  (when (boundp 'byte-compile-not-obsolete-var)
    (setq byte-compile-not-obsolete-var 'directory-sep-char)))

Michael Albinus's avatar
Michael Albinus committed
174 175 176 177 178
;; `set-buffer-multibyte' comes from Emacs Leim.
(eval-and-compile
  (unless (fboundp 'set-buffer-multibyte)
    (defalias 'set-buffer-multibyte 'ignore)))

Kai Großjohann's avatar
Kai Großjohann committed
179 180 181 182
;;; User Customizable Internal Variables:

(defgroup tramp nil
  "Edit remote files with a combination of rsh and rcp or similar programs."
183
  :group 'files
184
  :version "22.1")
Kai Großjohann's avatar
Kai Großjohann committed
185

Kai Großjohann's avatar
Kai Großjohann committed
186
(defcustom tramp-verbose 9
Kai Großjohann's avatar
Kai Großjohann committed
187 188 189 190 191 192 193 194 195
  "*Verbosity level for tramp.el.  0 means be silent, 10 is most verbose."
  :group 'tramp
  :type 'integer)

(defcustom tramp-debug-buffer nil
  "*Whether to send all commands and responses to a debug buffer."
  :group 'tramp
  :type 'boolean)

196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
;; Emacs case
(eval-and-compile
  (when (boundp 'backup-directory-alist)
    (defcustom tramp-backup-directory-alist nil
      "Alist of filename patterns and backup directory names.
Each element looks like (REGEXP . DIRECTORY), with the same meaning like
in `backup-directory-alist'.  If a Tramp file is backed up, and DIRECTORY
is a local file name, the backup directory is prepended with Tramp file
name prefix \(multi-method, method, user, host\) of file.

\(setq tramp-backup-directory-alist backup-directory-alist\)

gives the same backup policy for Tramp files on their hosts like the
policy for local files."
      :group 'tramp
      :type '(repeat (cons (regexp :tag "Regexp matching filename")
			   (directory :tag "Backup directory name"))))))

;; XEmacs case.  We cannot check for `bkup-backup-directory-info', because
;; the package "backup-dir" might not be loaded yet.
(eval-and-compile
  (when (featurep 'xemacs)
    (defcustom tramp-bkup-backup-directory-info nil
      "*Alist of (FILE-REGEXP BACKUP-DIR OPTIONS ...))
It has the same meaning like `bkup-backup-directory-info' from package
`backup-dir'.  If a Tramp file is backed up, and BACKUP-DIR is a local
file name, the backup directory is prepended with Tramp file name prefix
\(multi-method, method, user, host\) of file.

\(setq tramp-bkup-backup-directory-info bkup-backup-directory-info\)

gives the same backup policy for Tramp files on their hosts like the
policy for local files."
229
      :type '(repeat
230 231 232 233 234 235 236 237 238
	      (list (regexp :tag "File regexp")
		    (string :tag "Backup Dir")
		    (set :inline t
			 (const ok-create)
			 (const full-path)
			 (const prepend-name)
			 (const search-upward))))
      :group 'tramp)))

Kai Großjohann's avatar
Kai Großjohann committed
239 240 241 242 243 244 245
(defcustom tramp-auto-save-directory nil
  "*Put auto-save files in this directory, if set.
The idea is to use a local directory so that auto-saving is faster."
  :group 'tramp
  :type '(choice (const nil)
                 string))

246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263
(defcustom tramp-encoding-shell
  (if (memq system-type '(windows-nt))
      (getenv "COMSPEC")
    "/bin/sh")
  "*Use this program for encoding and decoding commands on the local host.
This shell is used to execute the encoding and decoding command on the
local host, so if you want to use `~' in those commands, you should
choose a shell here which groks tilde expansion.  `/bin/sh' normally
does not understand tilde expansion.

For encoding and deocding, commands like the following are executed:

    /bin/sh -c COMMAND < INPUT > OUTPUT

This variable can be used to change the \"/bin/sh\" part.  See the
variable `tramp-encoding-command-switch' for the \"-c\" part.  Also, see the
variable `tramp-encoding-reads-stdin' to specify whether the commands read
standard input or a file.
Kai Großjohann's avatar
Kai Großjohann committed
264 265 266 267 268 269 270

Note that this variable is not used for remote commands.  There are
mechanisms in tramp.el which automatically determine the right shell to
use for the remote host."
  :group 'tramp
  :type '(file :must-match t))

271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
(defcustom tramp-encoding-command-switch
  (if (string-match "cmd\\.exe" tramp-encoding-shell)
      "/c"
    "-c")
  "*Use this switch together with `tramp-encoding-shell' for local commands.
See the variable `tramp-encoding-shell' for more information."
  :group 'tramp
  :type 'string)

(defcustom tramp-encoding-reads-stdin t
  "*If non-nil, encoding commands read from standard input.
If nil, the filename is the last argument.

Note that the commands always must write to standard output."
  :group 'tramp
  :type 'boolean)

Kai Großjohann's avatar
Kai Großjohann committed
288
(defcustom tramp-multi-sh-program
289
  tramp-encoding-shell
Kai Großjohann's avatar
Kai Großjohann committed
290
  "*Use this program for bootstrapping multi-hop connections.
291
This variable is similar to `tramp-encoding-shell', but it is only used
Kai Großjohann's avatar
Kai Großjohann committed
292 293 294 295 296 297 298 299
when initializing a multi-hop connection.  Therefore, the set of
commands sent to this shell is quite restricted, and if you are
careful it works to use CMD.EXE under Windows (instead of a Bourne-ish
shell which does not normally exist on Windows anyway).

To use multi-hop methods from Windows, you also need suitable entries
in `tramp-multi-connection-function-alist' for the first hop.

300
This variable defaults to the value of `tramp-encoding-shell'."
Kai Großjohann's avatar
Kai Großjohann committed
301 302 303
  :group 'tramp
  :type '(file :must-match t))

Kai Großjohann's avatar
Kai Großjohann committed
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320
;; CCC I have changed all occurrences of comint-quote-filename with
;; tramp-shell-quote-argument, except in tramp-handle-expand-many-files.
;; There, comint-quote-filename was removed altogether.  If it turns
;; out to be necessary there, something will need to be done.
;;-(defcustom tramp-file-name-quote-list
;;-  '(?] ?[ ?\| ?& ?< ?> ?\( ?\) ?\; ?\  ?\* ?\? ?\! ?\" ?\' ?\` ?# ?\@ ?\+ )
;;-  "*Protect these characters from the remote shell.
;;-Any character in this list is quoted (preceded with a backslash)
;;-because it means something special to the shell.  This takes effect
;;-when sending file and directory names to the remote shell.
;;-
;;-See `comint-file-name-quote-list' for details."
;;-  :group 'tramp
;;-  :type '(repeat character))

(defcustom tramp-methods
  '( ("rcp"   (tramp-connection-function  tramp-open-connection-rsh)
321 322
              (tramp-login-program        "rsh")
              (tramp-copy-program         "rcp")
Kai Großjohann's avatar
Kai Großjohann committed
323
              (tramp-remote-sh            "/bin/sh")
324 325
              (tramp-login-args           nil)
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
326 327
              (tramp-copy-keep-date-arg   "-p")
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
328
     ("scp"   (tramp-connection-function  tramp-open-connection-rsh)
329 330
              (tramp-login-program        "ssh")
              (tramp-copy-program         "scp")
Kai Großjohann's avatar
Kai Großjohann committed
331
              (tramp-remote-sh            "/bin/sh")
332 333
              (tramp-login-args           ("-e" "none"))
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
334 335
              (tramp-copy-keep-date-arg   "-p")
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
336
     ("scp1"  (tramp-connection-function  tramp-open-connection-rsh)
337 338
              (tramp-login-program        "ssh")
              (tramp-copy-program         "scp")
Kai Großjohann's avatar
Kai Großjohann committed
339
              (tramp-remote-sh            "/bin/sh")
340 341
              (tramp-login-args           ("-1" "-e" "none"))
              (tramp-copy-args            ("-1"))
Kai Großjohann's avatar
Kai Großjohann committed
342 343
              (tramp-copy-keep-date-arg   "-p")
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
344
     ("scp2"  (tramp-connection-function  tramp-open-connection-rsh)
345 346
              (tramp-login-program        "ssh")
              (tramp-copy-program         "scp")
Kai Großjohann's avatar
Kai Großjohann committed
347
              (tramp-remote-sh            "/bin/sh")
348 349
              (tramp-login-args           ("-2" "-e" "none"))
              (tramp-copy-args            ("-2"))
Kai Großjohann's avatar
Kai Großjohann committed
350 351
              (tramp-copy-keep-date-arg   "-p")
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
352
     ("scp1_old"
Kai Großjohann's avatar
Kai Großjohann committed
353
              (tramp-connection-function  tramp-open-connection-rsh)
354 355
              (tramp-login-program        "ssh1")
              (tramp-copy-program         "scp1")
Kai Großjohann's avatar
Kai Großjohann committed
356
              (tramp-remote-sh            "/bin/sh")
357 358
              (tramp-login-args           ("-e" "none"))
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
359 360
              (tramp-copy-keep-date-arg   "-p")
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
361
     ("scp2_old"
Kai Großjohann's avatar
Kai Großjohann committed
362
              (tramp-connection-function  tramp-open-connection-rsh)
363 364
              (tramp-login-program        "ssh2")
              (tramp-copy-program         "scp2")
Kai Großjohann's avatar
Kai Großjohann committed
365
              (tramp-remote-sh            "/bin/sh")
366 367
              (tramp-login-args           ("-e" "none"))
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
368 369
              (tramp-copy-keep-date-arg   "-p")
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
370
     ("rsync" (tramp-connection-function  tramp-open-connection-rsh)
371 372 373 374 375
              (tramp-login-program        "ssh")
              (tramp-copy-program         "rsync")
              (tramp-remote-sh            "/bin/sh")
              (tramp-login-args           ("-e" "none"))
              (tramp-copy-args            ("-e" "ssh"))
Kai Großjohann's avatar
Kai Großjohann committed
376 377
              (tramp-copy-keep-date-arg   "-t")
	      (tramp-password-end-of-line nil))
378 379 380
     ("remcp" (tramp-connection-function  tramp-open-connection-rsh)
              (tramp-login-program        "remsh")
              (tramp-copy-program         "rcp")
Kai Großjohann's avatar
Kai Großjohann committed
381
              (tramp-remote-sh            "/bin/sh")
382 383
              (tramp-login-args           nil)
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
384 385
              (tramp-copy-keep-date-arg   "-p")
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
386
     ("rsh"   (tramp-connection-function  tramp-open-connection-rsh)
387 388
              (tramp-login-program        "rsh")
              (tramp-copy-program         nil)
Kai Großjohann's avatar
Kai Großjohann committed
389
              (tramp-remote-sh            "/bin/sh")
390
              (tramp-login-args           nil)
391
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
392 393
              (tramp-copy-keep-date-arg   nil)
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
394
     ("ssh"   (tramp-connection-function  tramp-open-connection-rsh)
395 396
              (tramp-login-program        "ssh")
              (tramp-copy-program         nil)
Kai Großjohann's avatar
Kai Großjohann committed
397
              (tramp-remote-sh            "/bin/sh")
398
              (tramp-login-args           ("-e" "none"))
399
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
400 401
              (tramp-copy-keep-date-arg   nil)
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
402
     ("ssh1"  (tramp-connection-function  tramp-open-connection-rsh)
403 404
              (tramp-login-program        "ssh")
              (tramp-copy-program         nil)
Kai Großjohann's avatar
Kai Großjohann committed
405
              (tramp-remote-sh            "/bin/sh")
406 407
              (tramp-login-args           ("-1" "-e" "none"))
              (tramp-copy-args            ("-1"))
Kai Großjohann's avatar
Kai Großjohann committed
408 409
              (tramp-copy-keep-date-arg   nil)
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
410
     ("ssh2"  (tramp-connection-function  tramp-open-connection-rsh)
411 412
              (tramp-login-program        "ssh")
              (tramp-copy-program         nil)
Kai Großjohann's avatar
Kai Großjohann committed
413
              (tramp-remote-sh            "/bin/sh")
414 415
              (tramp-login-args           ("-2" "-e" "none"))
              (tramp-copy-args            ("-2"))
Kai Großjohann's avatar
Kai Großjohann committed
416 417
              (tramp-copy-keep-date-arg   nil)
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
418
     ("ssh1_old"
Kai Großjohann's avatar
Kai Großjohann committed
419
              (tramp-connection-function  tramp-open-connection-rsh)
420 421
              (tramp-login-program        "ssh1")
              (tramp-copy-program         nil)
Kai Großjohann's avatar
Kai Großjohann committed
422
              (tramp-remote-sh            "/bin/sh")
423 424
              (tramp-login-args           ("-e" "none"))
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
425 426
              (tramp-copy-keep-date-arg   nil)
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
427
     ("ssh2_old"
Kai Großjohann's avatar
Kai Großjohann committed
428
              (tramp-connection-function  tramp-open-connection-rsh)
429 430 431 432 433
              (tramp-login-program        "ssh2")
              (tramp-copy-program         nil)
              (tramp-remote-sh            "/bin/sh")
              (tramp-login-args           ("-e" "none"))
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
434 435
              (tramp-copy-keep-date-arg   nil)
	      (tramp-password-end-of-line nil))
436 437 438
     ("remsh" (tramp-connection-function  tramp-open-connection-rsh)
              (tramp-login-program        "remsh")
              (tramp-copy-program         nil)
Kai Großjohann's avatar
Kai Großjohann committed
439
              (tramp-remote-sh            "/bin/sh")
440 441
              (tramp-login-args           nil)
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
442 443
              (tramp-copy-keep-date-arg   nil)
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
444 445
     ("telnet"
              (tramp-connection-function  tramp-open-connection-telnet)
446 447
              (tramp-login-program        "telnet")
              (tramp-copy-program         nil)
Kai Großjohann's avatar
Kai Großjohann committed
448
              (tramp-remote-sh            "/bin/sh")
449 450
              (tramp-login-args           nil)
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
451 452
              (tramp-copy-keep-date-arg   nil)
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
453
     ("su"    (tramp-connection-function  tramp-open-connection-su)
454 455
              (tramp-login-program        "su")
              (tramp-copy-program         nil)
Kai Großjohann's avatar
Kai Großjohann committed
456
              (tramp-remote-sh            "/bin/sh")
457 458
              (tramp-login-args           ("-" "%u"))
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
459 460
              (tramp-copy-keep-date-arg   nil)
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
461
     ("sudo"  (tramp-connection-function  tramp-open-connection-su)
462 463
              (tramp-login-program        "sudo")
              (tramp-copy-program         nil)
Kai Großjohann's avatar
Kai Großjohann committed
464
              (tramp-remote-sh            "/bin/sh")
465 466 467
              (tramp-login-args           ("-u" "%u" "-s"
					   "-p" "Password:"))
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
468 469
              (tramp-copy-keep-date-arg   nil)
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
470
     ("multi" (tramp-connection-function  tramp-open-connection-multi)
471 472
              (tramp-login-program        nil)
              (tramp-copy-program         nil)
Kai Großjohann's avatar
Kai Großjohann committed
473
              (tramp-remote-sh            "/bin/sh")
474 475
              (tramp-login-args           nil)
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
476 477
              (tramp-copy-keep-date-arg   nil)
	      (tramp-password-end-of-line nil))
478 479 480 481 482 483 484 485 486 487 488
     ("scpc"  (tramp-connection-function  tramp-open-connection-rsh)
              (tramp-login-program        "ssh")
              (tramp-copy-program         "scp")
              (tramp-remote-sh            "/bin/sh")
              (tramp-login-args           ("-o" "ControlPath=%t.%%r@%%h:%%p"
					   "-o" "ControlMaster=yes"
					   "-e" "none"))
              (tramp-copy-args            ("-o" "ControlPath=%t.%%r@%%h:%%p"
					   "-o" "ControlMaster=auto"))
              (tramp-copy-keep-date-arg   "-p")
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
489
     ("scpx"  (tramp-connection-function  tramp-open-connection-rsh)
490 491
              (tramp-login-program        "ssh")
              (tramp-copy-program         "scp")
Kai Großjohann's avatar
Kai Großjohann committed
492
              (tramp-remote-sh            "/bin/sh")
493 494
              (tramp-login-args           ("-e" "none" "-t" "-t" "/bin/sh"))
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
495 496
              (tramp-copy-keep-date-arg   "-p")
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
497
     ("sshx"  (tramp-connection-function  tramp-open-connection-rsh)
498 499
              (tramp-login-program        "ssh")
              (tramp-copy-program         nil)
Kai Großjohann's avatar
Kai Großjohann committed
500
              (tramp-remote-sh            "/bin/sh")
501 502
              (tramp-login-args           ("-e" "none" "-t" "-t" "/bin/sh"))
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
503 504
              (tramp-copy-keep-date-arg   nil)
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
505
     ("krlogin"
Kai Großjohann's avatar
Kai Großjohann committed
506
              (tramp-connection-function  tramp-open-connection-rsh)
507 508
	      (tramp-login-program        "krlogin")
	      (tramp-copy-program         nil)
Kai Großjohann's avatar
Kai Großjohann committed
509
	      (tramp-remote-sh            "/bin/sh")
510 511
	      (tramp-login-args           ("-x"))
	      (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
512 513
	      (tramp-copy-keep-date-arg   nil)
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
514
     ("plink"
Kai Großjohann's avatar
Kai Großjohann committed
515
              (tramp-connection-function  tramp-open-connection-rsh)
516 517
	      (tramp-login-program        "plink")
	      (tramp-copy-program         nil)
Kai Großjohann's avatar
Kai Großjohann committed
518
	      (tramp-remote-sh            "/bin/sh")
519 520
	      (tramp-login-args           ("-ssh")) ;optionally add "-v"
	      (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
521 522
	      (tramp-copy-keep-date-arg   nil)
	      (tramp-password-end-of-line "xy")) ;see docstring for "xy"
523 524 525 526 527 528 529
     ("plink1"
              (tramp-connection-function  tramp-open-connection-rsh)
	      (tramp-login-program        "plink")
	      (tramp-copy-program         nil)
	      (tramp-remote-sh            "/bin/sh")
	      (tramp-login-args           ("-1" "-ssh")) ;optionally add "-v"
	      (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
530 531
	      (tramp-copy-keep-date-arg   nil)
	      (tramp-password-end-of-line "xy")) ;see docstring for "xy"
Kai Großjohann's avatar
Kai Großjohann committed
532 533
     ("pscp"
              (tramp-connection-function  tramp-open-connection-rsh)
534 535
	      (tramp-login-program        "plink")
	      (tramp-copy-program         "pscp")
Kai Großjohann's avatar
Kai Großjohann committed
536
	      (tramp-remote-sh            "/bin/sh")
537 538
	      (tramp-login-args           ("-ssh"))
	      (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
539 540
	      (tramp-copy-keep-date-arg   "-p")
	      (tramp-password-end-of-line "xy")) ;see docstring for "xy"
541
     ("fcp"
Kai Großjohann's avatar
Kai Großjohann committed
542
	      (tramp-connection-function  tramp-open-connection-rsh)
543 544
              (tramp-login-program        "fsh")
              (tramp-copy-program         "fcp")
Kai Großjohann's avatar
Kai Großjohann committed
545
              (tramp-remote-sh            "/bin/sh -i")
546 547
              (tramp-login-args           ("sh" "-i"))
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
548 549
              (tramp-copy-keep-date-arg   "-p")
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
550 551 552 553 554
     )
  "*Alist of methods for remote files.
This is a list of entries of the form (NAME PARAM1 PARAM2 ...).
Each NAME stands for a remote access method.  Each PARAM is a
pair of the form (KEY VALUE).  The following KEYs are defined:
555
 * `tramp-connection-function'
Kai Großjohann's avatar
Kai Großjohann committed
556 557 558 559 560 561 562 563 564 565 566
    This specifies the function to use to connect to the remote host.
    Currently, `tramp-open-connection-rsh', `tramp-open-connection-telnet'
    and `tramp-open-connection-su' are defined.  See the documentation
    of these functions for more details.
  * `tramp-remote-sh'
    This specifies the Bourne shell to use on the remote host.  This
    MUST be a Bourne-like shell.  It is normally not necessary to set
    this to any value other than \"/bin/sh\": tramp wants to use a shell
    which groks tilde expansion, but it can search for it.  Also note
    that \"/bin/sh\" exists on all Unixen, this might not be true for
    the value that you decide to use.  You Have Been Warned.
567 568 569 570 571 572 573 574
  * `tramp-login-program'
    This specifies the name of the program to use for logging in to the
    remote host.  Depending on `tramp-connection-function', this may be
    the name of rsh or a workalike program (when
    `tramp-connection-function' is `tramp-open-connection-rsh'), or the
    name of telnet or a workalike (for `tramp-open-connection-telnet'),
    or the name of su or a workalike (for `tramp-open-connection-su').
  * `tramp-login-args'
Kai Großjohann's avatar
Kai Großjohann committed
575 576 577 578 579
    This specifies the list of arguments to pass to the above
    mentioned program.  Please note that this is a list of arguments,
    that is, normally you don't want to put \"-a -b\" or \"-f foo\"
    here.  Instead, you want two list elements, one for \"-a\" and one
    for \"-b\", or one for \"-f\" and one for \"foo\".
580 581 582
    If `tramp-connection-function' is `tramp-open-connection-su', then
    \"%u\" in this list is replaced by the user name, and \"%%\" can
    be used to obtain a literal percent character.
583
    \"%t\" is replaced by the temporary file name for `scp'-like methods.
584 585 586 587 588
  * `tramp-copy-program'
    This specifies the name of the program to use for remotely copying
    the file; this might be the absolute filename of rcp or the name of
    a workalike program.
  * `tramp-copy-args'
Kai Großjohann's avatar
Kai Großjohann committed
589
    This specifies the list of parameters to pass to the above mentioned
590 591 592 593
    program, the hints for `tramp-login-args' also apply here.
  * `tramp-copy-keep-date-arg'
    This specifies the parameter to use for the copying program when the
    timestamp of the original file should be kept.  For `rcp', use `-p', for
Kai Großjohann's avatar
Kai Großjohann committed
594
    `rsync', use `-t'.
Kai Großjohann's avatar
Kai Großjohann committed
595 596 597 598 599 600 601 602 603
  * `tramp-password-end-of-line'
    This specifies the string to use for terminating the line after
    submitting the password.  If this method parameter is nil, then the
    value of the normal variable `tramp-default-password-end-of-line'
    is used.  This parameter is necessary because the \"plink\" program
    requires any two characters after sending the password.  These do
    not have to be newline or carriage return characters.  Other login
    programs are happy with just one character, the newline character.
    We use \"xy\" as the value for methods using \"plink\".
604 605 606 607 608 609

What does all this mean?  Well, you should specify `tramp-login-program'
for all methods; this program is used to log in to the remote site.  Then,
there are two ways to actually transfer the files between the local and the
remote side.  One way is using an additional rcp-like program.  If you want
to do this, set `tramp-copy-program' in the method.
Kai Großjohann's avatar
Kai Großjohann committed
610 611

Another possibility for file transfer is inline transfer, i.e. the
612
file is passed through the same buffer used by `tramp-login-program'.  In
Kai Großjohann's avatar
Kai Großjohann committed
613
this case, the file contents need to be protected since the
614
`tramp-login-program' might use escape codes or the connection might not
Kai Großjohann's avatar
Kai Großjohann committed
615
be eight-bit clean.  Therefore, file contents are encoded for transit.
616
See the variable `tramp-coding-commands' for details.
Kai Großjohann's avatar
Kai Großjohann committed
617

618
So, to summarize: if the method is an out-of-band method, then you
619
must specify `tramp-copy-program' and `tramp-copy-args'.  If it is an
620 621
inline method, then these two parameters should be nil.  Every method,
inline or out of band, must specify `tramp-connection-function' plus
622
the associated arguments (for example, the login program if you chose
Kai Großjohann's avatar
Kai Großjohann committed
623 624 625 626 627 628 629 630
`tramp-open-connection-telnet').

Notes:

When using `tramp-open-connection-su' the phrase `open connection to a
remote host' sounds strange, but it is used nevertheless, for
consistency.  No connection is opened to a remote host, but `su' is
started on the local host.  You are not allowed to specify a remote
631
host other than `localhost' or the name of the local host."
Kai Großjohann's avatar
Kai Großjohann committed
632 633 634 635
  :group 'tramp
  :type '(repeat
          (cons string
                (set (list (const tramp-connection-function) function)
636
                     (list (const tramp-login-program)
Kai Großjohann's avatar
Kai Großjohann committed
637
			   (choice (const nil) string))
638
                     (list (const tramp-copy-program)
Kai Großjohann's avatar
Kai Großjohann committed
639 640 641
			   (choice (const nil) string))
                     (list (const tramp-remote-sh)
			   (choice (const nil) string))
642 643 644
                     (list (const tramp-login-args) (repeat string))
                     (list (const tramp-copy-args) (repeat string))
                     (list (const tramp-copy-keep-date-arg)
Kai Großjohann's avatar
Kai Großjohann committed
645 646 647 648 649 650 651 652
			   (choice (const nil) string))
                     (list (const tramp-encoding-command)
			   (choice (const nil) string))
                     (list (const tramp-decoding-command)
			   (choice (const nil) string))
                     (list (const tramp-encoding-function)
			   (choice (const nil) function))
                     (list (const tramp-decoding-function)
Kai Großjohann's avatar
Kai Großjohann committed
653 654 655
			   (choice (const nil) function))
		     (list (const tramp-password-end-of-line)
			   (choice (const nil) string))))))
Kai Großjohann's avatar
Kai Großjohann committed
656 657 658 659 660 661 662 663 664 665 666

(defcustom tramp-multi-methods '("multi" "multiu")
  "*List of multi-hop methods.
Each entry in this list should be a method name as mentioned in the
variable `tramp-methods'."
  :group 'tramp
  :type '(repeat string))

(defcustom tramp-multi-connection-function-alist
  '(("telnet" tramp-multi-connect-telnet "telnet %h%n")
    ("rsh"    tramp-multi-connect-rlogin "rsh %h -l %u%n")
667
    ("remsh"  tramp-multi-connect-rlogin "remsh %h -l %u%n")
Kai Großjohann's avatar
Kai Großjohann committed
668
    ("ssh"    tramp-multi-connect-rlogin "ssh %h -l %u%n")
669
    ("ssht"   tramp-multi-connect-rlogin "ssh %h -e none -t -t -l %u%n")
Kai Großjohann's avatar
Kai Großjohann committed
670
    ("su"     tramp-multi-connect-su     "su - %u%n")
671
    ("sudo"   tramp-multi-connect-su     "sudo -u %u -s -p Password:%n"))
Kai Großjohann's avatar
Kai Großjohann committed
672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688
  "*List of connection functions for multi-hop methods.
Each list item is a list of three items (METHOD FUNCTION COMMAND),
where METHOD is the name as used in the file name, FUNCTION is the
function to be executed, and COMMAND is the shell command used for
connecting.

COMMAND may contain percent escapes.  `%u' will be replaced with the
user name, `%h' will be replaced with the host name, and `%n' will be
replaced with an end-of-line character, as specified in the variable
`tramp-rsh-end-of-line'.  Use `%%' for a literal percent character.
Note that the interpretation of the percent escapes also depends on
the FUNCTION.  For example, the `%u' escape is forbidden with the
function `tramp-multi-connect-telnet'.  See the documentation of the
various functions for details."
  :group 'tramp
  :type '(repeat (list string function string)))

689
(defcustom tramp-default-method
690 691 692 693 694 695 696 697 698
  ;; An external copy method seems to be preferred, because it is much
  ;; more performant for large files, and it hasn't too serious delays
  ;; for small files.  But it must be ensured that there aren't
  ;; permanent password queries.  Either a password agent like
  ;; "ssh-agent" or "Pageant" shall run, or the optional password.el
  ;; package shall be active for password caching.  "scpc" would be
  ;; another good choice because of the "ControlMaster" option, but
  ;; this is a more modern alternative in OpenSSH 4, which cannot be
  ;; taken as default.
699
  (let ((e-f (fboundp 'executable-find)))
700 701
    (cond
     ;; PuTTY is installed.
702
     ((and e-f (funcall 'executable-find "pscp"))
703 704 705
      (if (or (fboundp 'password-read)
	      ;; Pageant is running.
	      (and (fboundp 'w32-window-exists-p)
706
		   (funcall 'w32-window-exists-p "Pageant" "Pageant")))
707 708 709
	  "pscp"
	"plink"))
     ;; There is an ssh installation.
710
     ((and e-f (funcall 'executable-find "scp"))
711 712 713 714 715 716 717 718 719 720 721 722
      (if (or (fboundp 'password-read)
	      ;; ssh-agent is running.
	      (getenv "SSH_AUTH_SOCK")
	      (getenv "SSH_AGENT_PID"))
	  "scp"
	"ssh"))
     ;; Under Emacs 20, `executable-find' does not exists.  So we
     ;; couldn't check whether there is an ssh implementation.  Let's
     ;; hope the best.
     ((not e-f) "ssh")
     ;; Fallback.
     (t "ftp")))
Kai Großjohann's avatar
Kai Großjohann committed
723
  "*Default method to use for transferring files.
724
See `tramp-methods' for possibilities.
725
Also see `tramp-default-method-alist'."
726 727 728
  :group 'tramp
  :type 'string)

729
(defcustom tramp-default-method-alist
730
  '(("\\`localhost\\'" "\\`root\\'" "su"))
731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746
  "*Default method to use for specific user/host pairs.
This is an alist of items (HOST USER METHOD).  The first matching item
specifies the method to use for a file name which does not specify a
method.  HOST and USER are regular expressions or nil, which is
interpreted as a regular expression which always matches.  If no entry
matches, the variable `tramp-default-method' takes effect.

If the file name does not specify the user, lookup is done using the
empty string for the user name.

See `tramp-methods' for a list of possibilities for METHOD."
  :group 'tramp
  :type '(repeat (list (regexp :tag "Host regexp")
		       (regexp :tag "User regexp")
		       (string :tag "Method"))))

747 748 749 750 751
;; Default values for non-Unices seeked
(defconst tramp-completion-function-alist-rsh
  (unless (memq system-type '(windows-nt))
    '((tramp-parse-rhosts "/etc/hosts.equiv")
      (tramp-parse-rhosts "~/.rhosts")))
752
  "Default list of (FUNCTION FILE) pairs to be examined for rsh methods.")
753 754 755 756

;; Default values for non-Unices seeked
(defconst tramp-completion-function-alist-ssh
  (unless (memq system-type '(windows-nt))
757 758 759 760 761 762 763 764 765 766 767 768
    '((tramp-parse-rhosts      "/etc/hosts.equiv")
      (tramp-parse-rhosts      "/etc/shosts.equiv")
      (tramp-parse-shosts      "/etc/ssh_known_hosts")
      (tramp-parse-sconfig     "/etc/ssh_config")
      (tramp-parse-shostkeys   "/etc/ssh2/hostkeys")
      (tramp-parse-sknownhosts "/etc/ssh2/knownhosts")
      (tramp-parse-rhosts      "~/.rhosts")
      (tramp-parse-rhosts      "~/.shosts")
      (tramp-parse-shosts      "~/.ssh/known_hosts")
      (tramp-parse-sconfig     "~/.ssh/config")
      (tramp-parse-shostkeys   "~/.ssh2/hostkeys")
      (tramp-parse-sknownhosts "~/.ssh2/knownhosts")))
769
  "Default list of (FUNCTION FILE) pairs to be examined for ssh methods.")
770 771 772 773 774

;; Default values for non-Unices seeked
(defconst tramp-completion-function-alist-telnet
  (unless (memq system-type '(windows-nt))
    '((tramp-parse-hosts "/etc/hosts")))
775
  "Default list of (FUNCTION FILE) pairs to be examined for telnet methods.")
776 777 778 779 780

;; Default values for non-Unices seeked
(defconst tramp-completion-function-alist-su
  (unless (memq system-type '(windows-nt))
    '((tramp-parse-passwd "/etc/passwd")))
781
  "Default list of (FUNCTION FILE) pairs to be examined for su methods.")
Kai Großjohann's avatar
Kai Großjohann committed
782

783
(defvar tramp-completion-function-alist nil
784 785 786 787 788 789
  "*Alist of methods for remote files.
This is a list of entries of the form (NAME PAIR1 PAIR2 ...).
Each NAME stands for a remote access method.  Each PAIR is of the form
\(FUNCTION FILE).  FUNCTION is responsible to extract user names and host
names from FILE for completion.  The following predefined FUNCTIONs exists:

790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841
 * `tramp-parse-rhosts'      for \"~/.rhosts\" like files,
 * `tramp-parse-shosts'      for \"~/.ssh/known_hosts\" like files,
 * `tramp-parse-sconfig'     for \"~/.ssh/config\" like files,
 * `tramp-parse-shostkeys'   for \"~/.ssh2/hostkeys/*\" like files,
 * `tramp-parse-sknownhosts' for \"~/.ssh2/knownhosts/*\" like files,
 * `tramp-parse-hosts'       for \"/etc/hosts\" like files,
 * `tramp-parse-passwd'      for \"/etc/passwd\" like files.
 * `tramp-parse-netrc'       for \"~/.netrc\" like files.

FUNCTION can also be a customer defined function.  For more details see
the info pages.")

(eval-after-load "tramp"
  '(progn
     (tramp-set-completion-function
      "rcp" tramp-completion-function-alist-rsh)
     (tramp-set-completion-function
      "scp" tramp-completion-function-alist-ssh)
     (tramp-set-completion-function
      "scp1" tramp-completion-function-alist-ssh)
     (tramp-set-completion-function
      "scp2" tramp-completion-function-alist-ssh)
     (tramp-set-completion-function
      "scp1_old" tramp-completion-function-alist-ssh)
     (tramp-set-completion-function
      "scp2_old" tramp-completion-function-alist-ssh)
     (tramp-set-completion-function
      "rsync" tramp-completion-function-alist-rsh)
     (tramp-set-completion-function
      "remcp" tramp-completion-function-alist-rsh)
     (tramp-set-completion-function
      "rsh" tramp-completion-function-alist-rsh)
     (tramp-set-completion-function
      "ssh" tramp-completion-function-alist-ssh)
     (tramp-set-completion-function
      "ssh1" tramp-completion-function-alist-ssh)
     (tramp-set-completion-function
      "ssh2" tramp-completion-function-alist-ssh)
     (tramp-set-completion-function
      "ssh1_old" tramp-completion-function-alist-ssh)
     (tramp-set-completion-function
      "ssh2_old" tramp-completion-function-alist-ssh)
     (tramp-set-completion-function
      "remsh" tramp-completion-function-alist-rsh)
     (tramp-set-completion-function
      "telnet" tramp-completion-function-alist-telnet)
     (tramp-set-completion-function
      "su" tramp-completion-function-alist-su)
     (tramp-set-completion-function
      "sudo" tramp-completion-function-alist-su)
     (tramp-set-completion-function
      "multi" nil)
842
     (tramp-set-completion-function
843 844 845 846 847 848 849 850 851 852 853 854 855
      "scpx" tramp-completion-function-alist-ssh)
     (tramp-set-completion-function
      "sshx" tramp-completion-function-alist-ssh)
     (tramp-set-completion-function
      "krlogin" tramp-completion-function-alist-rsh)
     (tramp-set-completion-function
      "plink" tramp-completion-function-alist-ssh)
     (tramp-set-completion-function
      "plink1" tramp-completion-function-alist-ssh)
     (tramp-set-completion-function
      "pscp" tramp-completion-function-alist-ssh)
     (tramp-set-completion-function
      "fcp" tramp-completion-function-alist-ssh)))
856

Kai Großjohann's avatar
Kai Großjohann committed
857 858 859
(defcustom tramp-rsh-end-of-line "\n"
  "*String used for end of line in rsh connections.
I don't think this ever needs to be changed, so please tell me about it
860
if you need to change this.
Kai Großjohann's avatar
Kai Großjohann committed
861 862
Also see the method parameter `tramp-password-end-of-line' and the normal
variable `tramp-default-password-end-of-line'."
863 864 865
  :group 'tramp
  :type 'string)

Kai Großjohann's avatar
Kai Großjohann committed
866 867
(defcustom tramp-default-password-end-of-line
  tramp-rsh-end-of-line
868
  "*String used for end of line after sending a password.
Kai Großjohann's avatar
Kai Großjohann committed
869 870 871
This variable provides the default value for the method parameter
`tramp-password-end-of-line', see `tramp-methods' for more details.

872 873 874 875 876 877
It seems that people using plink under Windows need to send
\"\\r\\n\" (carriage-return, then newline) after a password, but just
\"\\n\" after all other lines.  This variable can be used for the
password, see `tramp-rsh-end-of-line' for the other cases.

The default value is to use the same value as `tramp-rsh-end-of-line'."
Kai Großjohann's avatar
Kai Großjohann committed
878 879 880 881
  :group 'tramp
  :type 'string)

(defcustom tramp-remote-path
882 883 884 885
  ;; "/usr/xpg4/bin" has been placed first, because on Solaris a POSIX
  ;; compatible "id" is needed.
  '("/usr/xpg4/bin" "/bin" "/usr/bin" "/usr/sbin" "/usr/local/bin"
    "/usr/ccs/bin" "/local/bin" "/local/freeware/bin" "/local/gnu/bin"
Kai Großjohann's avatar
Kai Großjohann committed
886 887 888 889 890 891 892 893 894 895
    "/usr/freeware/bin" "/usr/pkg/bin" "/usr/contrib/bin")
  "*List of directories to search for executables on remote host.
Please notify me about other semi-standard directories to include here.

You can use `~' in this list, but when searching for a shell which groks
tilde expansion, all directory names starting with `~' will be ignored."
  :group 'tramp
  :type '(repeat string))

(defcustom tramp-login-prompt-regexp
896
  ".*ogin\\( .*\\)?: *"
Kai Großjohann's avatar
Kai Großjohann committed
897
  "*Regexp matching login-like prompts.
898 899 900
The regexp should match at end of buffer.

Sometimes the prompt is reported to look like \"login as:\"."
Kai Großjohann's avatar
Kai Großjohann committed
901 902 903
  :group 'tramp
  :type 'regexp)

Kai Großjohann's avatar
Kai Großjohann committed
904
(defcustom tramp-shell-prompt-pattern
905
  "^[^#$%>\n]*[#$%>] *\\(\e\\[[0-9;]*[a-zA-Z] *\\)*"
Kai Großjohann's avatar
Kai Großjohann committed
906 907 908 909 910 911
  "Regexp to match prompts from remote shell.
Normally, Tramp expects you to configure `shell-prompt-pattern'
correctly, but sometimes it happens that you are connecting to a
remote host which sends a different kind of shell prompt.  Therefore,
Tramp recognizes things matched by `shell-prompt-pattern' as prompt,
and also things matched by this variable.  The default value of this
912
variable is similar to the default value of `shell-prompt-pattern',
Kai Großjohann's avatar
Kai Großjohann committed
913 914 915 916
which should work well in many cases."
  :group 'tramp
  :type 'regexp)

Kai Großjohann's avatar
Kai Großjohann committed
917
(defcustom tramp-password-prompt-regexp
Michael Albinus's avatar
Michael Albinus committed
918
  "^.*\\([pP]assword\\|passphrase\\).*:\^@? *"
Kai Großjohann's avatar
Kai Großjohann committed
919
  "*Regexp matching password-like prompts.
Kai Großjohann's avatar
Kai Großjohann committed
920
The regexp should match at end of buffer.
Kai Großjohann's avatar
Kai Großjohann committed
921 922 923 924 925 926

The `sudo' program appears to insert a `^@' character into the prompt."
  :group 'tramp
  :type 'regexp)

(defcustom tramp-wrong-passwd-regexp
Kai Großjohann's avatar
Kai Großjohann committed
927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942
  (concat "^.*"
	  ;; These strings should be on the last line
	  (regexp-opt '("Permission denied."
			"Login incorrect"
			"Login Incorrect"
			"Connection refused"
			"Connection closed"
			"Sorry, try again."
			"Name or service not known"
			"Host key verification failed.") t)
	  ".*"
	  "\\|"
	  "^.*\\("
	  ;; Here comes a list of regexes, separated by \\|
	  "Received signal [0-9]+"
	  "\\).*")
Kai Großjohann's avatar
Kai Großjohann committed
943
  "*Regexp matching a `login failed' message.
Kai Großjohann's avatar
Kai Großjohann committed
944 945 946 947 948
The regexp should match at end of buffer."
  :group 'tramp
  :type 'regexp)

(defcustom tramp-yesno-prompt-regexp
Kai Großjohann's avatar
Kai Großjohann committed
949 950 951 952
  (concat
   (regexp-opt '("Are you sure you want to continue connecting (yes/no)?") t)
   "\\s-*")
  "Regular expression matching all yes/no queries which need to be confirmed.
Kai Großjohann's avatar
Kai Großjohann committed
953
The confirmation should be done with yes or no.
Kai Großjohann's avatar
Kai Großjohann committed
954 955
The regexp should match at end of buffer.
See also `tramp-yn-prompt-regexp'."
Kai Großjohann's avatar
Kai Großjohann committed
956 957 958
  :group 'tramp
  :type 'regexp)

Kai Großjohann's avatar
Kai Großjohann committed
959
(defcustom tramp-yn-prompt-regexp
Michael Albinus's avatar
Michael Albinus committed
960 961 962 963
  (concat
   (regexp-opt '("Store key in cache? (y/n)"
		 "Update cached key? (y/n, Return cancels connection)") t)
   "\\s-*")
Kai Großjohann's avatar
Kai Großjohann committed
964 965 966 967 968 969
  "Regular expression matching all y/n queries which need to be confirmed.
The confirmation should be done with y or n.
The regexp should match at end of buffer.
See also `tramp-yesno-prompt-regexp'."
  :group 'tramp
  :type 'regexp)
Kai Großjohann's avatar
Kai Großjohann committed
970 971 972 973 974 975 976 977 978 979 980 981

(defcustom tramp-terminal-prompt-regexp
  (concat "\\("
	  "TERM = (.*)"
	  "\\|"
	  "Terminal type\\? \\[.*\\]"
	  "\\)\\s-*")
  "Regular expression matching all terminal setting prompts.
The regexp should match at end of buffer.
The answer will be provided by `tramp-action-terminal', which see."
  :group 'tramp
  :type 'regexp)
Kai Großjohann's avatar
Kai Großjohann committed
982

Michael Albinus's avatar
Michael Albinus committed
983 984 985 986 987 988 989 990 991
(defcustom tramp-operation-not-permitted-regexp
  (concat "\\(" "preserving times.*" "\\|" "set mode" "\\)" ":\\s-*"
	  (regexp-opt '("Operation not permitted") t))
  "Regular expression matching keep-date problems in (s)cp operations.
Copying has been performed successfully already, so this message can
be ignored safely."
  :group 'tramp
  :type 'regexp)

992 993 994 995 996 997 998 999 1000 1001 1002
(defcustom tramp-copy-failed-regexp
  (concat "\\(.+: "
          (regexp-opt '("Permission denied"
                        "not a regular file"
                        "is a directory"
                        "No such file or directory") t)
          "\\)\\s-*")
  "Regular expression matching copy problems in (s)cp operations."
  :group 'tramp
  :type 'regexp)

1003
(defcustom tramp-process-alive-regexp
1004
  ""
1005
  "Regular expression indicating a process has finished.
1006 1007
In fact this expression is empty by intention, it will be used only to
check regularly the status of the associated process.
Kai Großjohann's avatar
Kai Großjohann committed
1008 1009
The answer will be provided by `tramp-action-process-alive',
`tramp-multi-action-process-alive' and`tramp-action-out-of-band', which see."
1010 1011 1012
  :group 'tramp
  :type 'regexp)

Kai Großjohann's avatar
Kai Großjohann committed
1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028
(defcustom tramp-temp-name-prefix "tramp."
  "*Prefix to use for temporary files.
If this is a relative file name (such as \"tramp.\"), it is considered
relative to the directory name returned by the function
`tramp-temporary-file-directory' (which see).  It may also be an
absolute file name; don't forget to include a prefix for the filename
part, though."
  :group 'tramp
  :type 'string)

(defcustom tramp-discard-garbage nil
  "*If non-nil, try to discard garbage sent by remote shell.
Some shells send such garbage upon connection setup."
  :group 'tramp
  :type 'boolean)

1029
(defcustom tramp-sh-extra-args '(("/bash\\'" . "-norc -noprofile"))
1030 1031 1032 1033 1034 1035 1036 1037 1038
  "*Alist specifying extra arguments to pass to the remote shell.
Entries are (REGEXP . ARGS) where REGEXP is a regular expression
matching the shell file name and ARGS is a string specifying the
arguments.

This variable is only used when Tramp needs to start up another shell
for tilde expansion.  The extra arguments should typically prevent the
shell from reading its init file."
  :group 'tramp
Kai Großjohann's avatar
Kai Großjohann committed
1039 1040 1041 1042 1043
  ;; This might be the wrong way to test whether the widget type
  ;; `alist' is available.  Who knows the right way to test it?
  :type (if (get 'alist 'widget-type)
	    '(alist :key-type string :value-type string)
	  '(repeat (cons string string))))
1044

1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097
(defcustom tramp-prefix-format
  (if tramp-unified-filenames "/" "/[")
  "*String matching the very beginning of tramp file names.
Used in `tramp-make-tramp-file-name' and `tramp-make-tramp-multi-file-name'."
  :group 'tramp
  :type 'string)

(defcustom tramp-prefix-regexp
  (concat "^" (regexp-quote tramp-prefix-format))
  "*Regexp matching the very beginning of tramp file names.
Should always start with \"^\". Derived from `tramp-prefix-format'."
  :group 'tramp
  :type 'regexp)

(defcustom tramp-method-regexp
  "[a-zA-Z_0-9-]+"
  "*Regexp matching methods identifiers."
  :group 'tramp
  :type 'regexp)

;; It is a little bit annoying that in XEmacs case this delimeter is different
;; for single-hop and multi-hop cases.
(defcustom tramp-postfix-single-method-format
  (if tramp-unified-filenames ":" "/")
  "*String matching delimeter between method and user or host names.
Applicable for single-hop methods.
Used in `tramp-make-tramp-file-name'."
  :group 'tramp
  :type 'string)

(defcustom tramp-postfix-single-method-regexp
  (regexp-quote tramp-postfix-single-method-format)
  "*Regexp matching delimeter between method and user or host names.
Applicable for single-hop methods.
Derived from `tramp-postfix-single-method-format'."
  :group 'tramp
  :type 'regexp)

(defcustom tramp-postfix-multi-method-format
  ":"
  "*String matching delimeter between method and user or host names.
Applicable for multi-hop methods.
Used in `tramp-make-tramp-multi-file-name'."
  :group 'tramp
  :type 'string)

(defcustom tramp-postfix-multi-method-regexp
  (regexp-quote tramp-postfix-multi-method-format)
  "*Regexp matching delimeter between method and user or host names.
Applicable for multi-hop methods.
Derived from `tramp-postfix-multi-method-format'."
  :group 'tramp
  :type 'regexp)
Kai Großjohann's avatar
Kai Großjohann committed
1098

1099 1100
(defcustom tramp-postfix-multi-hop-format
  (if tramp-unified-filenames ":" "/")
Kai Großjohann's avatar
Kai Großjohann committed
1101
  "*String matching delimeter between host and next method.
1102 1103 1104 1105 1106 1107 1108
Applicable for multi-hop methods.
Used in `tramp-make-tramp-multi-file-name'."
  :group 'tramp
  :type 'string)

(defcustom tramp-postfix-multi-hop-regexp
  (regexp-quote tramp-postfix-multi-hop-format)
Kai Großjohann's avatar
Kai Großjohann committed
1109
  "*Regexp matching delimeter between host and next method.
1110 1111 1112 1113 1114 1115
Applicable for multi-hop methods.
Derived from `tramp-postfix-multi-hop-format'."
  :group 'tramp
  :type 'regexp)

(defcustom tramp-user-regexp
</