tramp.el 301 KB
Newer Older
1
;;; tramp.el --- Transparent Remote Access, Multiple Protocol
Kai Großjohann's avatar
Kai Großjohann committed
2

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

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

Stefan Monnier's avatar
Stefan Monnier committed
8
;; Author: Kai Großjohann <kai.grossjohann@gmx.net>
Michael Albinus's avatar
Michael Albinus committed
9
;;         Michael Albinus <michael.albinus@gmx.de>
Kai Großjohann's avatar
Kai Großjohann committed
10 11 12 13
;; Keywords: comm, processes

;; This file is part of GNU Emacs.

14
;; GNU Emacs is free software: you can redistribute it and/or modify
Kai Großjohann's avatar
Kai Großjohann committed
15
;; it under the terms of the GNU General Public License as published by
16 17
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
Kai Großjohann's avatar
Kai Großjohann committed
18 19 20 21 22 23 24

;; 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
25
;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
Kai Großjohann's avatar
Kai Großjohann committed
26 27 28 29 30 31 32 33

;;; 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.
;;
34
;; For more detailed instructions, please see the info file.
Kai Großjohann's avatar
Kai Großjohann committed
35 36 37
;;
;; Notes:
;; -----
38
;;
39 40 41
;; This package only works for Emacs 21.1 and higher, and for XEmacs 21.4
;; and higher.  For XEmacs 21, you need the package `fsf-compat' for
;; the `with-timeout' macro.)
Kai Großjohann's avatar
Kai Großjohann committed
42 43 44
;;
;; Also see the todo list at the bottom of this file.
;;
45
;; The current version of Tramp can be retrieved from the following URL:
Michael Albinus's avatar
Michael Albinus committed
46
;;            http://ftp.gnu.org/gnu/tramp/
Kai Großjohann's avatar
Kai Großjohann committed
47 48
;;
;; There's a mailing list for this, as well.  Its name is:
Michael Albinus's avatar
Michael Albinus committed
49 50 51
;;            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
52 53 54
;;
;; For the adventurous, the current development sources are available
;; via CVS.  You can find instructions about this at the following URL:
55
;;            http://savannah.gnu.org/projects/tramp/
Kai Großjohann's avatar
Kai Großjohann committed
56 57 58 59 60 61
;; Click on "CVS" in the navigation bar near the top.
;;
;; Don't forget to put on your asbestos longjohns, first!

;;; Code:

62 63 64 65 66 67 68
;; Since Emacs 23.1, loading messages have been disabled during
;; autoload.  However, loading Tramp takes a while, and it could
;; happen while typing a filename in the minibuffer.  Therefore, Tramp
;; shall inform about.
(when (and load-in-progress (null (current-message)))
  (message "Loading tramp..."))

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

76
(require 'tramp-compat)
77 78 79 80
(add-hook 'tramp-unload-hook
	  '(lambda ()
	     (when (featurep 'tramp-compat)
	       (unload-feature 'tramp-compat 'force))))
Kai Großjohann's avatar
Kai Großjohann committed
81

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

Kai Großjohann's avatar
Kai Großjohann committed
90 91 92
(require 'shell)
(require 'advice)

93 94 95 96
(eval-and-compile
  (if (featurep 'xemacs)
      (load "auth-source" 'noerror)
    (require 'auth-source nil 'noerror)))
97

98 99 100 101 102 103 104 105 106 107 108 109 110 111
;; Requiring 'tramp-cache results in an endless loop.
(autoload 'tramp-get-file-property "tramp-cache")
(autoload 'tramp-set-file-property "tramp-cache")
(autoload 'tramp-flush-file-property "tramp-cache")
(autoload 'tramp-flush-directory-property "tramp-cache")
(autoload 'tramp-get-connection-property "tramp-cache")
(autoload 'tramp-set-connection-property "tramp-cache")
(autoload 'tramp-flush-connection-property "tramp-cache")
(autoload 'tramp-parse-connection-properties "tramp-cache")
(add-hook 'tramp-unload-hook
	  '(lambda ()
	     (when (featurep 'tramp-cache)
	       (unload-feature 'tramp-cache 'force))))

112 113
(autoload 'tramp-uuencode-region "tramp-uu"
  "Implementation of `uuencode' in Lisp.")
Michael Albinus's avatar
Michael Albinus committed
114 115 116 117
(add-hook 'tramp-unload-hook
	  '(lambda ()
	     (when (featurep 'tramp-uu)
	       (unload-feature 'tramp-uu 'force))))
118

119
(autoload 'uudecode-decode-region "uudecode")
120

121 122
;; The following Tramp packages must be loaded after tramp.el, because
;; they require it as well.
123
(eval-after-load "tramp"
124 125 126 127
  '(dolist
       (feature
	(list

128
	 ;; Tramp interactive commands.
129 130 131 132 133 134 135 136 137 138 139 140 141
	 'tramp-cmds

	 ;; Load foreign FTP method.
	 (if (featurep 'xemacs) 'tramp-efs 'tramp-ftp)

	 ;; 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 UNC file names like "//host/share/localname".
	 (unless (memq system-type '(cygwin windows-nt)) 'tramp-smb)

	 ;; Load foreign FISH method.
	 'tramp-fish
142

143 144 145 146 147 148
	 ;; tramp-gvfs needs D-Bus messages.  Available since Emacs 23
	 ;; on some system types.
	 (when (and (featurep 'dbusbind)
		    (tramp-compat-process-running-p "gvfs-fuse-daemon"))
	   'tramp-gvfs)

149 150 151 152
	 ;; Load gateways.  It needs `make-network-process' from Emacs 22.
	 (when (functionp 'make-network-process) 'tramp-gw)))

     (when feature
153 154 155 156 157 158 159 160 161 162 163
       ;; We have used just some basic tests, whether a package shall
       ;; be added.  There might still be other errors during loading,
       ;; which we will catch here.
       (catch 'tramp-loading
	 (require feature)
	 (add-hook 'tramp-unload-hook
		   `(lambda ()
		      (when (featurep (quote ,feature))
			(unload-feature (quote ,feature) 'force)))))
       (unless (featurep feature)
	 (message "Loading %s failed, ignoring this package" feature)))))
Kai Großjohann's avatar
Kai Großjohann committed
164 165 166 167 168

;;; User Customizable Internal Variables:

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

172 173 174 175 176 177 178 179
;; Maybe we need once a real Tramp mode, with key bindings etc.
;;;###autoload
(defcustom tramp-mode t
  "*Whether Tramp is enabled.
If it is set to nil, all remote file names are used literally."
  :group 'tramp
  :type 'boolean)

180
(defcustom tramp-verbose 3
181
  "*Verbosity level for Tramp.
182 183 184 185 186 187 188 189 190 191 192 193
Any level x includes messages for all levels 1 .. x-1.  The levels are

 0  silent (no tramp messages at all)
 1  errors
 2  warnings
 3  connection to remote hosts (default level)
 4  activities
 5  internal
 6  sent and received strings
 7  file caching
 8  connection properties
10  traces (huge)."
Kai Großjohann's avatar
Kai Großjohann committed
194 195 196
  :group 'tramp
  :type 'integer)

197 198 199 200 201 202 203 204
;; 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
205
name prefix \(method, user, host\) of file.
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223

\(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
224
\(method, user, host\) of file.
225 226 227 228 229

\(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."
230
      :type '(repeat
231 232 233 234 235 236 237 238 239
	      (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
240 241 242 243
(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
244
  :type '(choice (const nil) string))
Kai Großjohann's avatar
Kai Großjohann committed
245

246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
(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
261
variable `tramp-encoding-command-switch' for the \"-c\" part.
Kai Großjohann's avatar
Kai Großjohann committed
262 263 264 265 266 267 268

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))

269 270 271 272 273 274 275 276 277
(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)

278 279
(defcustom tramp-copy-size-limit 10240
  "*The maximum file size where inline copying is preferred over an out-of-the-band copy."
280
  :group 'tramp
281
  :type 'integer)
Kai Großjohann's avatar
Kai Großjohann committed
282

283 284 285 286 287
(defcustom tramp-terminal-type "dumb"
  "*Value of TERM environment variable for logging in to remote host.
Because Tramp wants to parse the output of the remote shell, it is easily
confused by ANSI color escape sequences and suchlike.  Often, shell init
files conditionalize this setup based on the TERM environment variable."
Kai Großjohann's avatar
Kai Großjohann committed
288
  :group 'tramp
289
  :type 'string)
Kai Großjohann's avatar
Kai Großjohann committed
290

291 292 293 294 295 296 297 298 299
(defvar tramp-methods
  `(("rcp"   (tramp-login-program        "rsh")
             (tramp-login-args           (("%h") ("-l" "%u")))
	     (tramp-remote-sh            "/bin/sh")
	     (tramp-copy-program         "rcp")
	     (tramp-copy-args            (("-p" "%k")))
	     (tramp-copy-keep-date       t)
	     (tramp-password-end-of-line nil))
    ("scp"   (tramp-login-program        "ssh")
300
             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
301 302 303 304 305 306 307 308 309 310 311 312
					  ("-e" "none")))
	     (tramp-remote-sh            "/bin/sh")
	     (tramp-copy-program         "scp")
	     (tramp-copy-args            (("-P" "%p") ("-p" "%k") ("-q")))
	     (tramp-copy-keep-date       t)
	     (tramp-password-end-of-line nil)
	     (tramp-gw-args              (("-o"
					   "GlobalKnownHostsFile=/dev/null")
					  ("-o" "UserKnownHostsFile=/dev/null")
					  ("-o" "StrictHostKeyChecking=no")))
	     (tramp-default-port         22))
    ("scp1"  (tramp-login-program        "ssh")
313
             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
314 315 316 317 318 319 320 321 322 323 324 325 326
					  ("-1" "-e" "none")))
	     (tramp-remote-sh            "/bin/sh")
	     (tramp-copy-program         "scp")
	     (tramp-copy-args            (("-1") ("-P" "%p") ("-p" "%k")
					  ("-q")))
	     (tramp-copy-keep-date       t)
	     (tramp-password-end-of-line nil)
	     (tramp-gw-args              (("-o"
					   "GlobalKnownHostsFile=/dev/null")
					  ("-o" "UserKnownHostsFile=/dev/null")
					  ("-o" "StrictHostKeyChecking=no")))
	     (tramp-default-port         22))
    ("scp2"  (tramp-login-program        "ssh")
327
             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388
					  ("-2" "-e" "none")))
	     (tramp-remote-sh            "/bin/sh")
	     (tramp-copy-program         "scp")
	     (tramp-copy-args            (("-2") ("-P" "%p") ("-p" "%k")
					  ("-q")))
	     (tramp-copy-keep-date       t)
	     (tramp-password-end-of-line nil)
	     (tramp-gw-args              (("-o"
					   "GlobalKnownHostsFile=/dev/null")
					  ("-o" "UserKnownHostsFile=/dev/null")
					  ("-o" "StrictHostKeyChecking=no")))
	     (tramp-default-port         22))
    ("scp1_old"
             (tramp-login-program        "ssh1")
	     (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
					  ("-e" "none")))
	     (tramp-remote-sh            "/bin/sh")
	     (tramp-copy-program         "scp1")
	     (tramp-copy-args            (("-p" "%k")))
	     (tramp-copy-keep-date       t)
	     (tramp-password-end-of-line nil))
    ("scp2_old"
             (tramp-login-program        "ssh2")
	     (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
					  ("-e" "none")))
	     (tramp-remote-sh            "/bin/sh")
	     (tramp-copy-program         "scp2")
	     (tramp-copy-args            (("-p" "%k")))
	     (tramp-copy-keep-date       t)
	     (tramp-password-end-of-line nil))
    ("sftp"  (tramp-login-program        "ssh")
             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
					  ("-e" "none")))
	     (tramp-remote-sh            "/bin/sh")
	     (tramp-copy-program         "sftp")
	     (tramp-copy-args            nil)
	     (tramp-copy-keep-date       nil)
	     (tramp-password-end-of-line nil))
    ("rsync" (tramp-login-program        "ssh")
             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
					  ("-e" "none")))
	     (tramp-remote-sh            "/bin/sh")
	     (tramp-copy-program         "rsync")
	     (tramp-copy-args            (("-e" "ssh") ("-t" "%k")))
	     (tramp-copy-keep-date       t)
	     (tramp-password-end-of-line nil))
    ("remcp" (tramp-login-program        "remsh")
             (tramp-login-args           (("%h") ("-l" "%u")))
	     (tramp-remote-sh            "/bin/sh")
	     (tramp-copy-program         "rcp")
	     (tramp-copy-args            (("-p" "%k")))
	     (tramp-copy-keep-date       t)
	     (tramp-password-end-of-line nil))
    ("rsh"   (tramp-login-program        "rsh")
             (tramp-login-args           (("%h") ("-l" "%u")))
	     (tramp-remote-sh            "/bin/sh")
	     (tramp-copy-program         nil)
	     (tramp-copy-args            nil)
	     (tramp-copy-keep-date       nil)
	     (tramp-password-end-of-line nil))
    ("ssh"   (tramp-login-program        "ssh")
389
             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
390 391 392 393 394 395 396 397 398 399 400 401
					  ("-e" "none")))
	     (tramp-remote-sh            "/bin/sh")
	     (tramp-copy-program         nil)
	     (tramp-copy-args            nil)
	     (tramp-copy-keep-date       nil)
	     (tramp-password-end-of-line nil)
	     (tramp-gw-args              (("-o"
					   "GlobalKnownHostsFile=/dev/null")
					  ("-o" "UserKnownHostsFile=/dev/null")
					  ("-o" "StrictHostKeyChecking=no")))
	     (tramp-default-port         22))
    ("ssh1"  (tramp-login-program        "ssh")
402
             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
403 404 405 406 407 408 409 410 411 412 413 414
					  ("-1" "-e" "none")))
	     (tramp-remote-sh            "/bin/sh")
	     (tramp-copy-program         nil)
	     (tramp-copy-args            nil)
	     (tramp-copy-keep-date       nil)
	     (tramp-password-end-of-line nil)
	     (tramp-gw-args              (("-o"
					   "GlobalKnownHostsFile=/dev/null")
					  ("-o" "UserKnownHostsFile=/dev/null")
					  ("-o" "StrictHostKeyChecking=no")))
	     (tramp-default-port         22))
    ("ssh2"  (tramp-login-program        "ssh")
415
             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469
					  ("-2" "-e" "none")))
	     (tramp-remote-sh            "/bin/sh")
	     (tramp-copy-program         nil)
	     (tramp-copy-args            nil)
	     (tramp-copy-keep-date       nil)
	     (tramp-password-end-of-line nil)
	     (tramp-gw-args              (("-o"
					   "GlobalKnownHostsFile=/dev/null")
					  ("-o" "UserKnownHostsFile=/dev/null")
					  ("-o" "StrictHostKeyChecking=no")))
	     (tramp-default-port         22))
    ("ssh1_old"
             (tramp-login-program        "ssh1")
	     (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
					  ("-e" "none")))
	     (tramp-remote-sh            "/bin/sh")
	     (tramp-copy-program         nil)
	     (tramp-copy-args            nil)
	     (tramp-copy-keep-date       nil)
	     (tramp-password-end-of-line nil))
    ("ssh2_old"
             (tramp-login-program        "ssh2")
	     (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
					  ("-e" "none")))
	     (tramp-remote-sh            "/bin/sh")
	     (tramp-copy-program         nil)
	     (tramp-copy-args            nil)
	     (tramp-copy-keep-date       nil)
	     (tramp-password-end-of-line nil))
    ("remsh" (tramp-login-program        "remsh")
             (tramp-login-args           (("%h") ("-l" "%u")))
	     (tramp-remote-sh            "/bin/sh")
	     (tramp-copy-program         nil)
	     (tramp-copy-args            nil)
	     (tramp-copy-keep-date       nil)
	     (tramp-password-end-of-line nil))
    ("telnet"
             (tramp-login-program        "telnet")
	     (tramp-login-args           (("%h") ("%p")))
	     (tramp-remote-sh            "/bin/sh")
	     (tramp-copy-program         nil)
	     (tramp-copy-args            nil)
	     (tramp-copy-keep-date       nil)
	     (tramp-password-end-of-line nil)
	     (tramp-default-port         23))
    ("su"    (tramp-login-program        "su")
             (tramp-login-args           (("-") ("%u")))
	     (tramp-remote-sh            "/bin/sh")
	     (tramp-copy-program         nil)
	     (tramp-copy-args            nil)
	     (tramp-copy-keep-date       nil)
	     (tramp-password-end-of-line nil))
    ("sudo"  (tramp-login-program        "sudo")
             (tramp-login-args           (("-u" "%u")
470
					  ("-s") ("-H") ("-p" "Password:")))
471 472 473 474 475 476
	     (tramp-remote-sh            "/bin/sh")
	     (tramp-copy-program         nil)
	     (tramp-copy-args            nil)
	     (tramp-copy-keep-date       nil)
	     (tramp-password-end-of-line nil))
    ("scpc"  (tramp-login-program        "ssh")
477
             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493
					  ("-o" "ControlPath=%t.%%r@%%h:%%p")
					  ("-o" "ControlMaster=yes")
					  ("-e" "none")))
	     (tramp-remote-sh            "/bin/sh")
	     (tramp-copy-program         "scp")
	     (tramp-copy-args            (("-P" "%p") ("-p" "%k") ("-q")
					  ("-o" "ControlPath=%t.%%r@%%h:%%p")
					  ("-o" "ControlMaster=auto")))
	     (tramp-copy-keep-date       t)
	     (tramp-password-end-of-line nil)
	     (tramp-gw-args              (("-o"
					   "GlobalKnownHostsFile=/dev/null")
					  ("-o" "UserKnownHostsFile=/dev/null")
					  ("-o" "StrictHostKeyChecking=no")))
	     (tramp-default-port         22))
    ("scpx"  (tramp-login-program        "ssh")
494
             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
495 496 497 498 499 500 501 502 503 504 505 506
					  ("-e" "none" "-t" "-t" "/bin/sh")))
	     (tramp-remote-sh            "/bin/sh")
	     (tramp-copy-program         "scp")
	     (tramp-copy-args            (("-p" "%k")))
	     (tramp-copy-keep-date       t)
	     (tramp-password-end-of-line nil)
	     (tramp-gw-args              (("-o"
					   "GlobalKnownHostsFile=/dev/null")
					  ("-o" "UserKnownHostsFile=/dev/null")
					  ("-o" "StrictHostKeyChecking=no")))
	     (tramp-default-port         22))
    ("sshx"  (tramp-login-program        "ssh")
507
             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547
					  ("-e" "none" "-t" "-t" "/bin/sh")))
	     (tramp-remote-sh            "/bin/sh")
	     (tramp-copy-program         nil)
	     (tramp-copy-args            nil)
	     (tramp-copy-keep-date       nil)
	     (tramp-password-end-of-line nil)
	     (tramp-gw-args              (("-o"
					   "GlobalKnownHostsFile=/dev/null")
					  ("-o" "UserKnownHostsFile=/dev/null")
					  ("-o" "StrictHostKeyChecking=no")))
	     (tramp-default-port         22))
    ("krlogin"
	     (tramp-login-program        "krlogin")
	     (tramp-login-args           (("%h") ("-l" "%u") ("-x")))
	     (tramp-remote-sh            "/bin/sh")
	     (tramp-copy-program         nil)
	     (tramp-copy-args            nil)
	     (tramp-copy-keep-date       nil)
	     (tramp-password-end-of-line nil))
    ("plink" (tramp-login-program        "plink")
	     (tramp-login-args           (("%h") ("-l" "%u") ("-P" "%p")
					  ("-ssh")))
	     (tramp-remote-sh            "/bin/sh")
	     (tramp-copy-program         nil)
	     (tramp-copy-args            nil)
	     (tramp-copy-keep-date       nil)
	     (tramp-password-end-of-line "xy") ;see docstring for "xy"
	     (tramp-default-port         22))
    ("plink1"
	     (tramp-login-program        "plink")
	     (tramp-login-args           (("%h") ("-l" "%u") ("-P" "%p")
					  ("-1" "-ssh")))
	     (tramp-remote-sh            "/bin/sh")
	     (tramp-copy-program         nil)
	     (tramp-copy-args            nil)
	     (tramp-copy-keep-date       nil)
	     (tramp-password-end-of-line "xy") ;see docstring for "xy"
	     (tramp-default-port         22))
    ("plinkx"
             (tramp-login-program        "plink")
548 549 550
	     ;; ("%h") must be a single element, see
	     ;; `tramp-compute-multi-hops'.
	     (tramp-login-args           (("-load") ("%h") ("-t")
551 552 553
					  (,(format
					     "env 'TERM=%s' 'PROMPT_COMMAND=' 'PS1=$ '"
					     tramp-terminal-type))
554 555 556 557 558 559 560 561 562 563 564
					  ("/bin/sh")))
	     (tramp-remote-sh            "/bin/sh")
	     (tramp-copy-program         nil)
	     (tramp-copy-args            nil)
	     (tramp-copy-keep-date       nil)
	     (tramp-password-end-of-line nil))
    ("pscp"  (tramp-login-program        "plink")
	     (tramp-login-args           (("%h") ("-l" "%u") ("-P" "%p")
					  ("-ssh")))
	     (tramp-remote-sh            "/bin/sh")
	     (tramp-copy-program         "pscp")
565
	     (tramp-copy-args            (("-P" "%p") ("-scp") ("-p" "%k")))
566 567 568 569 570 571 572 573
	     (tramp-copy-keep-date       t)
	     (tramp-password-end-of-line "xy") ;see docstring for "xy"
	     (tramp-default-port         22))
    ("psftp" (tramp-login-program        "plink")
	     (tramp-login-args           (("%h") ("-l" "%u") ("-P" "%p")
					  ("-ssh")))
	     (tramp-remote-sh            "/bin/sh")
	     (tramp-copy-program         "pscp")
574
	     (tramp-copy-args            (("-P" "%p") ("-sftp") ("-p" "%k")))
575 576 577 578 579 580 581 582 583
	     (tramp-copy-keep-date       t)
	     (tramp-password-end-of-line "xy")) ;see docstring for "xy"
    ("fcp"   (tramp-login-program        "fsh")
             (tramp-login-args           (("%h") ("-l" "%u") ("sh" "-i")))
	     (tramp-remote-sh            "/bin/sh -i")
	     (tramp-copy-program         "fcp")
	     (tramp-copy-args            (("-p" "%k")))
	     (tramp-copy-keep-date       t)
	     (tramp-password-end-of-line nil)))
Kai Großjohann's avatar
Kai Großjohann committed
584 585 586 587 588 589 590
  "*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:
  * `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
591
    this to any value other than \"/bin/sh\": Tramp wants to use a shell
Kai Großjohann's avatar
Kai Großjohann committed
592 593 594
    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.
595 596
  * `tramp-login-program'
    This specifies the name of the program to use for logging in to the
597 598
    remote host.  This may be the name of rsh or a workalike program,
    or the name of telnet or a workalike, or the name of su or a workalike.
599
  * `tramp-login-args'
Kai Großjohann's avatar
Kai Großjohann committed
600
    This specifies the list of arguments to pass to the above
601
    mentioned program.  Please note that this is a list of list of arguments,
Kai Großjohann's avatar
Kai Großjohann committed
602
    that is, normally you don't want to put \"-a -b\" or \"-f foo\"
603 604 605 606 607 608 609 610 611 612
    here.  Instead, you want a list (\"-a\" \"-b\"), or (\"-f\" \"foo\").
    There are some patterns: \"%h\" in this list is replaced by the host
    name, \"%u\" is replaced by the user name, \"%p\" is replaced by the
    port number, and \"%%\" can be used to obtain a literal percent character.
    If a list containing \"%h\", \"%u\" or \"%p\" is unchanged during
    expansion (i.e. no host or no user specified), this list is not used as
    argument.  By this, arguments like (\"-l\" \"%u\") are optional.
    \"%t\" is replaced by the temporary file name produced with
    `tramp-make-tramp-temp-file'.  \"%k\" indicates the keep-date
    parameter of a program, if exists.
613 614 615 616 617
  * `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
618
    This specifies the list of parameters to pass to the above mentioned
619
    program, the hints for `tramp-login-args' also apply here.
620 621 622 623 624 625 626 627 628 629
  * `tramp-copy-keep-date'
    This specifies whether the copying program when the preserves the
    timestamp of the original file.
  * `tramp-default-port'
    The default port of a method is needed in case of gateway connections.
    Additionally, it is used as indication which method is prepared for
    passing gateways.
  * `tramp-gw-args'
    As the attribute name says, additional arguments are specified here
    when a method is applied via a gateway.
Kai Großjohann's avatar
Kai Großjohann committed
630 631 632 633 634 635 636 637 638
  * `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\".
639 640 641 642 643 644

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
645 646

Another possibility for file transfer is inline transfer, i.e. the
647
file is passed through the same buffer used by `tramp-login-program'.  In
Kai Großjohann's avatar
Kai Großjohann committed
648
this case, the file contents need to be protected since the
649
`tramp-login-program' might use escape codes or the connection might not
Kai Großjohann's avatar
Kai Großjohann committed
650
be eight-bit clean.  Therefore, file contents are encoded for transit.
651 652
See the variables `tramp-local-coding-commands' and
`tramp-remote-coding-commands' for details.
Kai Großjohann's avatar
Kai Großjohann committed
653

654
So, to summarize: if the method is an out-of-band method, then you
655
must specify `tramp-copy-program' and `tramp-copy-args'.  If it is an
656 657
inline method, then these two parameters should be nil.  Methods which
are fit for gateways must have `tramp-default-port' at least.
Kai Großjohann's avatar
Kai Großjohann committed
658 659 660

Notes:

661 662 663 664 665 666
When using `su' or `sudo' 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' or `sudo' is
started on the local host.  You should specify a remote host
`localhost' or the name of the local host.  Another host name is
useful only in combination with `tramp-default-proxies-alist'.")
Kai Großjohann's avatar
Kai Großjohann committed
667

668
(defcustom tramp-default-method
669 670 671 672 673 674 675 676 677
  ;; 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.
678 679 680 681 682
  (cond
   ;; PuTTY is installed.
   ((executable-find "pscp")
    (if	(or (fboundp 'password-read)
	    ;; Pageant is running.
683
	    (tramp-compat-process-running-p "Pageant"))
684 685 686 687 688 689 690 691 692 693 694 695
	"pscp"
      "plink"))
   ;; There is an ssh installation.
   ((executable-find "scp")
    (if	(or (fboundp 'password-read)
	    ;; ssh-agent is running.
	    (getenv "SSH_AUTH_SOCK")
	    (getenv "SSH_AGENT_PID"))
	"scp"
      "ssh"))
   ;; Fallback.
   (t "ftp"))
Kai Großjohann's avatar
Kai Großjohann committed
696
  "*Default method to use for transferring files.
697
See `tramp-methods' for possibilities.
698
Also see `tramp-default-method-alist'."
699 700 701
  :group 'tramp
  :type 'string)

702
(defcustom tramp-default-method-alist
703
  '(("\\`localhost\\'" "\\`root\\'" "su"))
704
  "*Default method to use for specific host/user pairs.
705 706 707 708 709 710 711 712 713 714 715 716 717 718 719
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"))))

720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759
(defcustom tramp-default-user
  nil
  "*Default user to use for transferring files.
It is nil by default; otherwise settings in configuration files like
\"~/.ssh/config\" would be overwritten.  Also see `tramp-default-user-alist'.

This variable is regarded as obsolete, and will be removed soon."
  :group 'tramp
  :type '(choice (const nil) string))

(defcustom tramp-default-user-alist
  `(("\\`su\\(do\\)?\\'" nil "root")
    ("\\`r\\(em\\)?\\(cp\\|sh\\)\\|telnet\\|plink1?\\'"
     nil ,(user-login-name)))
  "*Default user to use for specific method/host pairs.
This is an alist of items (METHOD HOST USER).  The first matching item
specifies the user to use for a file name which does not specify a
user.  METHOD 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-user' takes effect.

If the file name does not specify the method, lookup is done using the
empty string for the method name."
  :group 'tramp
  :type '(repeat (list (regexp :tag "Method regexp")
		       (regexp :tag "Host regexp")
		       (string :tag "User"))))

(defcustom tramp-default-host
  (system-name)
  "*Default host to use for transferring files.
Useful for su and sudo methods mostly."
  :group 'tramp
  :type 'string)

(defcustom tramp-default-proxies-alist nil
  "*Route to be followed for specific host/user pairs.
This is an alist of items (HOST USER PROXY).  The first matching
item specifies the proxy to be passed for a file name located on
a remote target matching USER@HOST.  HOST and USER are regular
760 761 762 763 764 765 766 767 768
expressions.  PROXY must be a Tramp filename without a localname
part.  Method and user name on PROXY are optional, which is
interpreted with the default values.  PROXY can contain the
patterns %h and %u, which are replaced by the strings matching
HOST or USER, respectively.

HOST, USER or PROXY could also be Lisp forms, which will be
evaluated.  The result must be a string or nil, which is
interpreted as a regular expression which always matches."
769
  :group 'tramp
770 771 772
  :type '(repeat (list (choice :tag "Host regexp" regexp sexp)
		       (choice :tag "User regexp" regexp sexp)
		       (choice :tag "Proxy remote name" string (const nil)))))
773

774 775 776 777 778
(defconst tramp-local-host-regexp
  (concat
   "^" (regexp-opt (list "localhost" (system-name) "127\.0\.0\.1" "::1") t) "$")
  "*Host names which are regarded as local host.")

779
(defconst tramp-completion-function-alist-rsh
780 781
  '((tramp-parse-rhosts "/etc/hosts.equiv")
    (tramp-parse-rhosts "~/.rhosts"))
782
  "Default list of (FUNCTION FILE) pairs to be examined for rsh methods.")
783 784

(defconst tramp-completion-function-alist-ssh
785 786 787 788 789 790 791 792 793 794 795 796
  '((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"))
797
  "Default list of (FUNCTION FILE) pairs to be examined for ssh methods.")
798 799

(defconst tramp-completion-function-alist-telnet
800
  '((tramp-parse-hosts "/etc/hosts"))
801
  "Default list of (FUNCTION FILE) pairs to be examined for telnet methods.")
802 803

(defconst tramp-completion-function-alist-su
804
  '((tramp-parse-passwd "/etc/passwd"))
805
  "Default list of (FUNCTION FILE) pairs to be examined for su methods.")
Kai Großjohann's avatar
Kai Großjohann committed
806

807 808 809 810 811
(defconst tramp-completion-function-alist-putty
  '((tramp-parse-putty
     "HKEY_CURRENT_USER\\Software\\SimonTatham\\PuTTY\\Sessions"))
  "Default list of (FUNCTION REGISTRY) pairs to be examined for putty methods.")

812
(defvar tramp-completion-function-alist nil
813 814 815 816 817 818
  "*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:

819 820 821 822 823 824 825 826
 * `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.
827
 * `tramp-parse-putty'       for PuTTY registry keys.
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846

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
847
      "rsync" tramp-completion-function-alist-ssh)
848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869
     (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)
870
     (tramp-set-completion-function
871 872 873 874 875 876 877 878 879
      "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)
880 881
     (tramp-set-completion-function
      "plinkx" tramp-completion-function-alist-putty)
882 883 884 885
     (tramp-set-completion-function
      "pscp" tramp-completion-function-alist-ssh)
     (tramp-set-completion-function
      "fcp" tramp-completion-function-alist-ssh)))
886

887 888 889
(defconst tramp-echo-mark-marker "_echo"
  "String marker to surround echoed commands.")

890 891 892 893 894 895
(defconst tramp-echo-mark "_echo\b\b\b\b\b"
  "String mark to be transmitted around shell commands.
Used to separate their echo from the output they produce.  This
will only be used if we cannot disable remote echo via stty.
This string must have no effect on the remote shell except for
producing some echo which can later be detected by
896 897 898
`tramp-echoed-echo-mark-regexp'.  Using `tramp-echo-mark-marker',
followed by an equal number of backspaces to erase them will
usually suffice.")
899 900 901 902 903

(defconst tramp-echoed-echo-mark-regexp "_echo\\(\b\\( \b\\)?\\)\\{5\\}"
  "Regexp which matches `tramp-echo-mark' as it gets echoed by
the remote shell.")

Kai Großjohann's avatar
Kai Großjohann committed
904 905 906
(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
907
if you need to change this.
Kai Großjohann's avatar
Kai Großjohann committed
908 909
Also see the method parameter `tramp-password-end-of-line' and the normal
variable `tramp-default-password-end-of-line'."
910 911 912
  :group 'tramp
  :type 'string)

Kai Großjohann's avatar
Kai Großjohann committed
913 914
(defcustom tramp-default-password-end-of-line
  tramp-rsh-end-of-line
915
  "*String used for end of line after sending a password.
Kai Großjohann's avatar
Kai Großjohann committed
916 917 918
This variable provides the default value for the method parameter
`tramp-password-end-of-line', see `tramp-methods' for more details.

919 920 921 922 923 924
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
925 926 927
  :group 'tramp
  :type 'string)

928 929 930
;; "getconf PATH" yields:
;; HP-UX: /usr/bin:/usr/ccs/bin:/opt/ansic/bin:/opt/langtools/bin:/opt/fortran/bin
;; Solaris: /usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/opt/SUNWspro/bin
931
;; GNU/Linux (Debian, Suse): /bin:/usr/bin
932
;; FreeBSD: /usr/bin:/bin:/usr/sbin:/sbin: - beware trailing ":"!
Kai Großjohann's avatar
Kai Großjohann committed
933
(defcustom tramp-remote-path
934 935
  '(tramp-default-remote-path "/usr/sbin" "/usr/local/bin"
    "/local/bin" "/local/freeware/bin" "/local/gnu/bin"
Kai Großjohann's avatar
Kai Großjohann committed
936 937
    "/usr/freeware/bin" "/usr/pkg/bin" "/usr/contrib/bin")
  "*List of directories to search for executables on remote host.
938 939
For every remote host, this variable will be set buffer local,
keeping the list of existing directories on that host.
Kai Großjohann's avatar
Kai Großjohann committed
940 941

You can use `~' in this list, but when searching for a shell which groks
942 943 944 945 946
tilde expansion, all directory names starting with `~' will be ignored.

`Default Directories' represent the list of directories given by
the command \"getconf PATH\".  It is recommended to use this
entry on top of this list, because these are the default
947 948 949 950
directories for POSIX compatible commands.

`Private Directories' are the settings of the $PATH environment,
as given in your `~/.profile'."
951 952 953
  :group 'tramp
  :type '(repeat (choice
		  (const :tag "Default Directories" tramp-default-remote-path)
954
		  (const :tag "Private Directories" tramp-own-remote-path)
955 956 957
		  (string :tag "Directory"))))

(defcustom tramp-remote-process-environment
958
  `("HISTFILE=$HOME/.tramp_history" "HISTSIZE=1" "LC_ALL=C"
959
    ,(concat "TERM=" tramp-terminal-type)
960 961
    "EMACS=t" ;; Deprecated.
    ,(format "INSIDE_EMACS=%s,tramp:%s" emacs-version tramp-version)
962 963 964 965 966 967 968 969 970 971 972
    "CDPATH=" "HISTORY=" "MAIL=" "MAILCHECK=" "MAILPATH="
    "autocorrect=" "correct=")

  "*List of environment variables to be set on the remote host.

Each element should be a string of the form ENVVARNAME=VALUE.  An
entry ENVVARNAME= diables the corresponding environment variable,
which might have been set in the init files like ~/.profile.

Special handling is applied to the PATH environment, which should
not be set here. Instead of, it should be set via `tramp-remote-path'."
Kai Großjohann's avatar
Kai Großjohann committed
973 974 975 976
  :group 'tramp
  :type '(repeat string))

(defcustom tramp-login-prompt-regexp
977
  ".*ogin\\( .*\\)?: *"
Kai Großjohann's avatar
Kai Großjohann committed
978
  "*Regexp matching login-like prompts.
979 980 981
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
982 983 984
  :group 'tramp
  :type 'regexp)

Kai Großjohann's avatar
Kai Großjohann committed
985
(defcustom tramp-shell-prompt-pattern
986
  "^[^#$%>\n]*[#$%>] *\\(\e\\[[0-9;]*[a-zA-Z] *\\)*"
Kai Großjohann's avatar
Kai Großjohann committed
987 988 989 990 991 992
  "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
993
variable is similar to the default value of `shell-prompt-pattern',
Kai Großjohann's avatar
Kai Großjohann committed
994 995 996 997
which should work well in many cases."
  :group 'tramp
  :type 'regexp)

Kai Großjohann's avatar
Kai Großjohann committed
998
(defcustom tramp-password-prompt-regexp
999
  "^.*\\([pP]assword\\|[pP]assphrase\\).*:\^@? *"
Kai Großjohann's avatar
Kai Großjohann committed
1000
  "*Regexp matching password-like prompts.
Kai Großjohann's avatar
Kai Großjohann committed
1001
The regexp should match at end of buffer.
Kai Großjohann's avatar
Kai Großjohann committed
1002 1003 1004 1005 1006 1007

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
1008 1009
  (concat "^.*"
	  ;; These strings should be on the last line
1010
	  (regexp-opt '("Permission denied"
Kai Großjohann's avatar
Kai Großjohann committed
1011 1012 1013
			"Login incorrect"
			"Login Incorrect"
			"Connection refused"
1014
			"Connection closed"
Kai Großjohann's avatar
Kai Großjohann committed
1015 1016
			"Sorry, try again."
			"Name or service not known"
1017
			"Host key verification failed."
1018
			"No supported authentication methods left to try!") t)
Kai Großjohann's avatar
Kai Großjohann committed
1019 1020 1021 1022 1023 1024
	  ".*"
	  "\\|"
	  "^.*\\("
	  ;; Here comes a list of regexes, separated by \\|
	  "Received signal [0-9]+"
	  "\\).*")
Kai Großjohann's avatar
Kai Großjohann committed
1025
  "*Regexp matching a `login failed' message.
Kai Großjohann's avatar
Kai Großjohann committed
1026 1027 1028 1029 1030
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
1031 1032 1033 1034
  (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
1035
The confirmation should be done with yes or no.
Kai Großjohann's avatar
Kai Großjohann committed
1036 1037
The regexp should match at end of buffer.
See also `tramp-yn-prompt-regexp'."
Kai Großjohann's avatar
Kai Großjohann committed
1038 1039 1040
  :group 'tramp
  :type 'regexp)

Kai Großjohann's avatar
Kai Großjohann committed
1041
(defcustom tramp-yn-prompt-regexp
Michael Albinus's avatar
Michael Albinus committed
1042 1043 1044 1045
  (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
1046 1047 1048 1049 1050 1051
  "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
1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063

(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
1064

Michael Albinus's avatar
Michael Albinus committed
1065 1066 1067 1068 1069 1070 1071 1072 1073
(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)

1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084
(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)

1085
(defcustom tramp-process-alive-regexp
1086
  ""
1087
  "Regular expression indicating a process has finished.
1088 1089
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
1090
The answer will be provided by `tramp-action-process-alive',
1091
`tramp-action-out-of-band', which see."
1092 1093 1094
  :group 'tramp
  :type 'regexp)

Kai Großjohann's avatar
Kai Großjohann committed
1095 1096 1097 1098
(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
1099
`tramp-compat-temporary-file-directory' (which see).  It may also be an
Kai Großjohann's avatar
Kai Großjohann committed
1100 1101 1102 1103 1104
absolute file name; don't forget to include a prefix for the filename
part, though."
  :group 'tramp
  :type 'string)

1105 1106 1107 1108
(defconst tramp-temp-buffer-name " *tramp temp*"
  "Buffer name for a temporary buffer.
It shall be used in combination with `generate-new-buffer-name'.")

1109
(defcustom tramp-sh-extra-args '(("/bash\\'" . "-norc -noprofile"))
1110 1111 1112 1113 1114 1115 1116 1117 1118
  "*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
1119 1120 1121 1122 1123
  ;; 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))))
1124

1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144
;; 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.

;; Currently, we have the choice between 'ftp, 'sep, and 'url.
;;;###autoload
(defcustom tramp-syntax
  (if (featurep 'xemacs) 'sep 'ftp)
  "Tramp filename syntax to be used.

It can have the following values:

  'ftp -- Ange-FTP respective EFS like syntax (GNU Emacs default)
  'sep -- Syntax as defined for XEmacs (not available yet for GNU Emacs)
  'url -- URL-like syntax."
1145
  :group 'tramp
1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157
  :type (if (featurep 'xemacs)
	    '(choice (const :tag "EFS"    ftp)
		     (const :tag "XEmacs" sep)
		     (const :tag "URL"    url))
	  '(choice (const :tag "Ange-FTP" ftp)
		   (const :tag "URL"      url))))

(defconst tramp-prefix-format
  (cond ((equal tramp-syntax 'ftp) "/")
	((equal tramp-syntax 'sep) "/[")
	((equal tramp-syntax 'url) "/")
	(t (error "Wrong `tramp-syntax' defined")))
1158
  "*String matching the very beginning of Tramp file names.
1159
Used in `tramp-make-tramp-file-name'.")
1160

1161
(defconst tramp-prefix-regexp
1162
  (concat "^" (regexp-quote tramp-prefix-format))
1163
  "*Regexp matching the very beginning of Tramp file names.
1164
Should always start with \"^\". Derived from `tramp-prefix-format'.")
1165

1166
(defconst tramp-method-regexp
1167
  "[a-zA-Z_0-9-]+"
1168
  "*Regexp matching methods identifiers.")
1169

1170 1171 1172 1173 1174
(defconst tramp-postfix-method-format
  (cond ((equal tramp-syntax 'ftp) ":")
	((equal tramp-syntax 'sep) "/")
	((equal tramp-syntax 'url) "://")
	(t (error "Wrong `tramp-syntax' defined")))
1175
  "*String matching delimeter between method and user or host names.
1176
Used in `tramp-make-tramp-file-name'.")
1177

1178 1179
(defconst tramp-postfix-method-regexp
  (regexp-quote tramp-postfix-method-format)
1180
  "*Regexp matching delimeter between method and user or host names.
1181
Derived from `tramp-postfix-method-format'.")
1182

1183 1184 1185
(defconst tramp-user-regexp
  "[^:/ \t]+"
  "*Regexp matching user names.")
1186

1187 1188 1189 1190 1191 1192 1193 1194 1195
(defconst tramp-prefix-domain-format "%"
  "*String matching delimeter between user and domain names.")

(defconst tramp-prefix-domain-regexp
  (regexp-quote tramp-prefix-domain-format)
  "*Regexp matching delimeter between user and domain names.
Derived from `tramp-prefix-domain-format'.")

(defconst tramp-domain-regexp
1196
  "[-a-zA-Z0-9_.]+"
1197 1198 1199 1200 1201 1202 1203 1204
  "*Regexp matching domain names.")

(defconst tramp-user-with-domain-regexp
  (concat "\\(" tramp-user-regexp "\\)"
	        tramp-prefix-domain-regexp
	  "\\(" tramp-domain-regexp "\\)")
  "*Regexp matching user names with domain names.")

1205
(defconst tramp-postfix-user-format
1206 1207
  "@"
  "*String matching delimeter between user and host names.
1208
Used in `tramp-make-tramp-file-name'.")
1209

1210
(defconst tramp-postfix-user-regexp
1211 1212
  (regexp-quote tramp-postfix-user-format)
  "*Regexp matching delimeter between user and host names.
1213 1214 1215 1216 1217 1218
Derived from `tramp-postfix-user-format'.")

(defconst tramp-host-regexp
  "[a-zA-Z0-9_.-]+"
  "*Regexp matching host names.")

1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231
(defconst tramp-prefix-ipv6-format
  (cond ((equal tramp-syntax 'ftp) "[")
	((equal tramp-syntax 'sep) "")
	((equal tramp-syntax 'url) "[")
	(t (error "Wrong `tramp-syntax' defined")))
  "*String matching left hand side of IPv6 addresses.
Used in `tramp-make-tramp-file-name'.")

(defconst tramp-prefix-ipv6-regexp
  (regexp-quote tramp-prefix-ipv6-format)
  "*Regexp matching left hand side of IPv6 addresses.
Derived from `tramp-prefix-ipv6-format'.")

1232 1233 1234
;; The following regexp is a bit sloppy.  But it shall serve our
;; purposes.  It covers also IPv4 mapped IPv6 addresses, like in
;; "::ffff:192.168.0.1".
1235
(defconst tramp-ipv6-regexp
1236
  "\\(?:\\(?:[a-zA-Z0-9]+\\)?:\\)+[a-zA-Z0-9.]+"
1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251
  "*Regexp matching IPv6 addresses.")

(defconst tramp-postfix-ipv6-format
  (cond ((equal tramp-syntax 'ftp) "]")
	((equal tramp-syntax 'sep) "")
	((equal tramp-syntax 'url) "]")
	(t (error "Wrong `tramp-syntax' defined")))
  "*String matching right hand side of IPv6 addresses.
Used in `tramp-make-tramp-file-name'.")

(defconst tramp-postfix-ipv6-regexp
  (regexp-quote tramp-postfix-ipv6-format)
  "*Regexp matching right hand side of IPv6 addresses.
Derived from `tramp-postfix-ipv6-format'.")

1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278
(defconst tramp-prefix-port-format
  (cond ((equal tramp-syntax 'ftp) "#")
	((equal tramp-syntax 'sep) "#")
	((equal tramp-syntax 'url) ":")
	(t (error "Wrong `tramp-syntax' defined")))
  "*String matching delimeter between host names and port numbers.")

(defconst tramp-prefix-port-regexp
  (regexp-quote tramp-prefix-port-format)
  "*Regexp matching delimeter between host names and port numbers.
Derived from `tramp-prefix-port-format'.")

(defconst tramp-port-regexp
  "[0-9]+"
  "*Regexp matching port numbers.")

(defconst tramp-host-with-port-regexp
  (concat "\\(" tramp-host-regexp "\\)"
	        tramp-prefix-port-regexp
	  "\\(" tramp-port-regexp "\\)")
  "*Regexp matching host names with port numbers.")

(defconst tramp-postfix-host-format
  (cond ((equal tramp-syntax 'ftp) ":")
	((equal tramp-syntax 'sep) "]")
	((equal tramp-syntax 'url) "")
	(t (error "Wrong `tramp-syntax' defined")))
Kai Großjohann's avatar
Kai Großjohann committed
1279
  "*String matching delimeter between host names and localnames.
1280
Used in `tramp-make-tramp-file-name'.")
1281

1282
(defconst tramp-postfix-host-regexp
1283
  (regexp-quote tramp-postfix-host-format)
Kai Großjohann's avatar
Kai Großjohann committed
1284
  "*Regexp matching delimeter between host names and localnames.
1285
Derived from `tramp-postfix-host-format'.")
1286

1287
(defconst tramp-localname-regexp
1288
  ".*$"
1289
  "*Regexp matching localnames.")
1290 1291

;; File name format.
1292

1293
(defconst tramp-file-name-structure
1294 1295 1296
  (list
   (concat
    tramp-prefix-regexp
1297 1298
    "\\(" "\\(" tramp-method-regexp "\\)" tramp-postfix-method-regexp "\\)?"
    "\\(" "\\(" tramp-user-regexp "\\)"   tramp-postfix-user-regexp   "\\)?"
1299 1300 1301 1302 1303
    "\\(" "\\(" tramp-host-regexp
		"\\|"
		tramp-prefix-ipv6-regexp  tramp-ipv6-regexp
					  tramp-postfix-ipv6-regexp "\\)"
	  "\\(" tramp-prefix-port-regexp  tramp-port-regexp "\\)?" "\\)?"
1304 1305
    tramp-postfix-host-regexp
    "\\(" tramp-localname-regexp "\\)")
1306
   2 4 5 8)
1307

Kai Großjohann's avatar
Kai Großjohann committed
1308
  "*List of five elements (REGEXP METHOD USER HOST FILE), detailing \
1309
the Tramp file name structure.