tramp.el 306 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 5
;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
;;   2005 Free Software Foundation, Inc.
Kai Großjohann's avatar
Kai Großjohann committed
6

Michael Albinus's avatar
Michael Albinus committed
7 8
;; Author: Kai Gro,A_(Bjohann <kai.grossjohann@gmx.net>
;;         Michael Albinus <michael.albinus@gmx.de>
Kai Großjohann's avatar
Kai Großjohann committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
;; 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
25 26
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
Kai Großjohann's avatar
Kai Großjohann committed
27 28 29 30 31 32 33 34

;;; 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.
;;
35
;; For more detailed instructions, please see the info file.
Kai Großjohann's avatar
Kai Großjohann committed
36 37 38
;;
;; Notes:
;; -----
39
;;
Kai Großjohann's avatar
Kai Großjohann committed
40 41 42 43 44 45 46 47 48 49 50
;; 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.
;;
51
;; The current version of Tramp can be retrieved from the following URL:
Michael Albinus's avatar
Michael Albinus committed
52
;;            http://ftp.gnu.org/gnu/tramp/
Kai Großjohann's avatar
Kai Großjohann committed
53 54
;;
;; There's a mailing list for this, as well.  Its name is:
Michael Albinus's avatar
Michael Albinus committed
55 56 57
;;            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
58 59 60
;;
;; For the adventurous, the current development sources are available
;; via CVS.  You can find instructions about this at the following URL:
61
;;            http://savannah.gnu.org/projects/tramp/
Kai Großjohann's avatar
Kai Großjohann committed
62 63 64 65 66 67
;; Click on "CVS" in the navigation bar near the top.
;;
;; Don't forget to put on your asbestos longjohns, first!

;;; Code:

68 69
;; The Tramp version number and bug report address, as prepared by configure.
(require 'trampver)
Kai Großjohann's avatar
Kai Großjohann committed
70 71 72

(require 'timer)
(require 'format-spec)                  ;from Gnus 5.8, also in tar ball
73 74 75 76 77 78
;; 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

79 80 81 82 83 84
;; 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
85 86 87
(require 'shell)
(require 'advice)

88 89 90 91 92 93
(autoload 'tramp-uuencode-region "tramp-uu"
  "Implementation of `uuencode' in Lisp.")

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

94 95 96 97 98 99 100 101 102 103 104 105
;; 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.
Nil means to use a separate filename syntax for Tramp.")
Kai Großjohann's avatar
Kai Großjohann committed
106

107 108 109 110 111 112 113
;; 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"
    '(require 'tramp-ftp)))
114 115 116
(when (and tramp-unified-filenames (featurep 'xemacs))
  (eval-after-load "tramp"
    '(require 'tramp-efs)))
117 118 119 120

;; 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
121
;; UNC file names like "//host/share/localname".
122 123 124 125
(unless (memq system-type '(cygwin windows-nt))
  (eval-after-load "tramp"
    '(require 'tramp-smb)))

Kai Großjohann's avatar
Kai Großjohann committed
126 127 128 129 130 131 132 133 134 135
(eval-when-compile
  (require 'cl)
  (require 'custom)
  ;; Emacs 19.34 compatibility hack -- is this needed?
  (or (>= emacs-major-version 20)
      (load "cl-seq")))

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

136
;; Avoid byte-compiler warnings if the byte-compiler supports this.
137 138
;; Currently, XEmacs supports this.
(eval-when-compile
139
  (when (featurep 'xemacs)
140 141 142 143 144 145 146 147 148 149 150
    (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)))

Kai Großjohann's avatar
Kai Großjohann committed
151 152 153 154
;;; User Customizable Internal Variables:

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

Kai Großjohann's avatar
Kai Großjohann committed
158
(defcustom tramp-verbose 9
Kai Großjohann's avatar
Kai Großjohann committed
159 160 161 162 163 164 165 166 167
  "*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)

168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
;; 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."
201
      :type '(repeat
202 203 204 205 206 207 208 209 210
	      (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
211 212 213 214 215 216 217
(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))

218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
(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
236 237 238 239 240 241 242

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

243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
(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
260
(defcustom tramp-multi-sh-program
261
  tramp-encoding-shell
Kai Großjohann's avatar
Kai Großjohann committed
262
  "*Use this program for bootstrapping multi-hop connections.
263
This variable is similar to `tramp-encoding-shell', but it is only used
Kai Großjohann's avatar
Kai Großjohann committed
264 265 266 267 268 269 270 271
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.

272
This variable defaults to the value of `tramp-encoding-shell'."
Kai Großjohann's avatar
Kai Großjohann committed
273 274 275
  :group 'tramp
  :type '(file :must-match t))

Kai Großjohann's avatar
Kai Großjohann committed
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292
;; 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)
293 294
              (tramp-login-program        "rsh")
              (tramp-copy-program         "rcp")
Kai Großjohann's avatar
Kai Großjohann committed
295
              (tramp-remote-sh            "/bin/sh")
296 297
              (tramp-login-args           nil)
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
298 299
              (tramp-copy-keep-date-arg   "-p")
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
300
     ("scp"   (tramp-connection-function  tramp-open-connection-rsh)
301 302
              (tramp-login-program        "ssh")
              (tramp-copy-program         "scp")
Kai Großjohann's avatar
Kai Großjohann committed
303
              (tramp-remote-sh            "/bin/sh")
304
              (tramp-login-args           ("-e" "none"))
305
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
306 307
              (tramp-copy-keep-date-arg   "-p")
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
308
     ("scp1"  (tramp-connection-function  tramp-open-connection-rsh)
309 310
              (tramp-login-program        "ssh")
              (tramp-copy-program         "scp")
Kai Großjohann's avatar
Kai Großjohann committed
311
              (tramp-remote-sh            "/bin/sh")
312 313
              (tramp-login-args           ("-1" "-e" "none"))
              (tramp-copy-args            ("-1"))
Kai Großjohann's avatar
Kai Großjohann committed
314 315
              (tramp-copy-keep-date-arg   "-p")
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
316
     ("scp2"  (tramp-connection-function  tramp-open-connection-rsh)
317 318
              (tramp-login-program        "ssh")
              (tramp-copy-program         "scp")
Kai Großjohann's avatar
Kai Großjohann committed
319
              (tramp-remote-sh            "/bin/sh")
320 321
              (tramp-login-args           ("-2" "-e" "none"))
              (tramp-copy-args            ("-2"))
Kai Großjohann's avatar
Kai Großjohann committed
322 323
              (tramp-copy-keep-date-arg   "-p")
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
324
     ("scp1_old"
Kai Großjohann's avatar
Kai Großjohann committed
325
              (tramp-connection-function  tramp-open-connection-rsh)
326 327
              (tramp-login-program        "ssh1")
              (tramp-copy-program         "scp1")
Kai Großjohann's avatar
Kai Großjohann committed
328
              (tramp-remote-sh            "/bin/sh")
329 330
              (tramp-login-args           ("-e" "none"))
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
331 332
              (tramp-copy-keep-date-arg   "-p")
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
333
     ("scp2_old"
Kai Großjohann's avatar
Kai Großjohann committed
334
              (tramp-connection-function  tramp-open-connection-rsh)
335 336
              (tramp-login-program        "ssh2")
              (tramp-copy-program         "scp2")
Kai Großjohann's avatar
Kai Großjohann committed
337
              (tramp-remote-sh            "/bin/sh")
338 339
              (tramp-login-args           ("-e" "none"))
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
340 341
              (tramp-copy-keep-date-arg   "-p")
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
342
     ("rsync" (tramp-connection-function  tramp-open-connection-rsh)
343 344 345 346 347
              (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
348 349
              (tramp-copy-keep-date-arg   "-t")
	      (tramp-password-end-of-line nil))
350 351 352
     ("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
353
              (tramp-remote-sh            "/bin/sh")
354 355
              (tramp-login-args           nil)
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
356 357
              (tramp-copy-keep-date-arg   "-p")
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
358
     ("rsh"   (tramp-connection-function  tramp-open-connection-rsh)
359 360
              (tramp-login-program        "rsh")
              (tramp-copy-program         nil)
Kai Großjohann's avatar
Kai Großjohann committed
361
              (tramp-remote-sh            "/bin/sh")
362
              (tramp-login-args           nil)
363
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
364 365
              (tramp-copy-keep-date-arg   nil)
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
366
     ("ssh"   (tramp-connection-function  tramp-open-connection-rsh)
367 368
              (tramp-login-program        "ssh")
              (tramp-copy-program         nil)
Kai Großjohann's avatar
Kai Großjohann committed
369
              (tramp-remote-sh            "/bin/sh")
370
              (tramp-login-args           ("-e" "none"))
371
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
372 373
              (tramp-copy-keep-date-arg   nil)
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
374
     ("ssh1"  (tramp-connection-function  tramp-open-connection-rsh)
375 376
              (tramp-login-program        "ssh")
              (tramp-copy-program         nil)
Kai Großjohann's avatar
Kai Großjohann committed
377
              (tramp-remote-sh            "/bin/sh")
378 379
              (tramp-login-args           ("-1" "-e" "none"))
              (tramp-copy-args            ("-1"))
Kai Großjohann's avatar
Kai Großjohann committed
380 381
              (tramp-copy-keep-date-arg   nil)
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
382
     ("ssh2"  (tramp-connection-function  tramp-open-connection-rsh)
383 384
              (tramp-login-program        "ssh")
              (tramp-copy-program         nil)
Kai Großjohann's avatar
Kai Großjohann committed
385
              (tramp-remote-sh            "/bin/sh")
386 387
              (tramp-login-args           ("-2" "-e" "none"))
              (tramp-copy-args            ("-2"))
Kai Großjohann's avatar
Kai Großjohann committed
388 389
              (tramp-copy-keep-date-arg   nil)
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
390
     ("ssh1_old"
Kai Großjohann's avatar
Kai Großjohann committed
391
              (tramp-connection-function  tramp-open-connection-rsh)
392 393
              (tramp-login-program        "ssh1")
              (tramp-copy-program         nil)
Kai Großjohann's avatar
Kai Großjohann committed
394
              (tramp-remote-sh            "/bin/sh")
395 396
              (tramp-login-args           ("-e" "none"))
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
397 398
              (tramp-copy-keep-date-arg   nil)
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
399
     ("ssh2_old"
Kai Großjohann's avatar
Kai Großjohann committed
400
              (tramp-connection-function  tramp-open-connection-rsh)
401 402 403 404 405
              (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
406 407
              (tramp-copy-keep-date-arg   nil)
	      (tramp-password-end-of-line nil))
408 409 410
     ("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
411
              (tramp-remote-sh            "/bin/sh")
412 413
              (tramp-login-args           nil)
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
414 415
              (tramp-copy-keep-date-arg   nil)
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
416 417
     ("telnet"
              (tramp-connection-function  tramp-open-connection-telnet)
418 419
              (tramp-login-program        "telnet")
              (tramp-copy-program         nil)
Kai Großjohann's avatar
Kai Großjohann committed
420
              (tramp-remote-sh            "/bin/sh")
421 422
              (tramp-login-args           nil)
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
423 424
              (tramp-copy-keep-date-arg   nil)
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
425
     ("su"    (tramp-connection-function  tramp-open-connection-su)
426 427
              (tramp-login-program        "su")
              (tramp-copy-program         nil)
Kai Großjohann's avatar
Kai Großjohann committed
428
              (tramp-remote-sh            "/bin/sh")
429 430
              (tramp-login-args           ("-" "%u"))
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
431 432
              (tramp-copy-keep-date-arg   nil)
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
433
     ("sudo"  (tramp-connection-function  tramp-open-connection-su)
434 435
              (tramp-login-program        "sudo")
              (tramp-copy-program         nil)
Kai Großjohann's avatar
Kai Großjohann committed
436
              (tramp-remote-sh            "/bin/sh")
437 438 439
              (tramp-login-args           ("-u" "%u" "-s"
					   "-p" "Password:"))
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
440 441
              (tramp-copy-keep-date-arg   nil)
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
442
     ("multi" (tramp-connection-function  tramp-open-connection-multi)
443 444
              (tramp-login-program        nil)
              (tramp-copy-program         nil)
Kai Großjohann's avatar
Kai Großjohann committed
445
              (tramp-remote-sh            "/bin/sh")
446 447
              (tramp-login-args           nil)
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
448 449
              (tramp-copy-keep-date-arg   nil)
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
450
     ("scpx"  (tramp-connection-function  tramp-open-connection-rsh)
451 452
              (tramp-login-program        "ssh")
              (tramp-copy-program         "scp")
Kai Großjohann's avatar
Kai Großjohann committed
453
              (tramp-remote-sh            "/bin/sh")
454 455
              (tramp-login-args           ("-e" "none" "-t" "-t" "/bin/sh"))
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
456 457
              (tramp-copy-keep-date-arg   "-p")
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
458
     ("sshx"  (tramp-connection-function  tramp-open-connection-rsh)
459 460
              (tramp-login-program        "ssh")
              (tramp-copy-program         nil)
Kai Großjohann's avatar
Kai Großjohann committed
461
              (tramp-remote-sh            "/bin/sh")
462 463
              (tramp-login-args           ("-e" "none" "-t" "-t" "/bin/sh"))
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
464 465
              (tramp-copy-keep-date-arg   nil)
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
466
     ("krlogin"
Kai Großjohann's avatar
Kai Großjohann committed
467
              (tramp-connection-function  tramp-open-connection-rsh)
468 469
	      (tramp-login-program        "krlogin")
	      (tramp-copy-program         nil)
Kai Großjohann's avatar
Kai Großjohann committed
470
	      (tramp-remote-sh            "/bin/sh")
471 472
	      (tramp-login-args           ("-x"))
	      (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
473 474
	      (tramp-copy-keep-date-arg   nil)
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
475
     ("plink"
Kai Großjohann's avatar
Kai Großjohann committed
476
              (tramp-connection-function  tramp-open-connection-rsh)
477 478
	      (tramp-login-program        "plink")
	      (tramp-copy-program         nil)
Kai Großjohann's avatar
Kai Großjohann committed
479
	      (tramp-remote-sh            "/bin/sh")
480 481
	      (tramp-login-args           ("-ssh")) ;optionally add "-v"
	      (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
482 483
	      (tramp-copy-keep-date-arg   nil)
	      (tramp-password-end-of-line "xy")) ;see docstring for "xy"
484 485 486 487 488 489 490
     ("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
491 492
	      (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
493 494
     ("pscp"
              (tramp-connection-function  tramp-open-connection-rsh)
495 496
	      (tramp-login-program        "plink")
	      (tramp-copy-program         "pscp")
Kai Großjohann's avatar
Kai Großjohann committed
497
	      (tramp-remote-sh            "/bin/sh")
498 499
	      (tramp-login-args           ("-ssh"))
	      (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
500 501
	      (tramp-copy-keep-date-arg   "-p")
	      (tramp-password-end-of-line "xy")) ;see docstring for "xy"
502
     ("fcp"
Kai Großjohann's avatar
Kai Großjohann committed
503
	      (tramp-connection-function  tramp-open-connection-rsh)
504 505
              (tramp-login-program        "fsh")
              (tramp-copy-program         "fcp")
Kai Großjohann's avatar
Kai Großjohann committed
506
              (tramp-remote-sh            "/bin/sh -i")
507 508
              (tramp-login-args           ("sh" "-i"))
              (tramp-copy-args            nil)
Kai Großjohann's avatar
Kai Großjohann committed
509 510
              (tramp-copy-keep-date-arg   "-p")
	      (tramp-password-end-of-line nil))
Kai Großjohann's avatar
Kai Großjohann committed
511 512 513 514 515
     )
  "*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:
516
 * `tramp-connection-function'
Kai Großjohann's avatar
Kai Großjohann committed
517 518 519 520 521 522 523 524 525 526 527
    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.
528 529 530 531 532 533 534 535
  * `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
536 537 538 539 540
    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\".
541 542 543 544 545 546 547 548
    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.
  * `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
549
    This specifies the list of parameters to pass to the above mentioned
550 551 552 553
    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
554
    `rsync', use `-t'.
Kai Großjohann's avatar
Kai Großjohann committed
555 556 557 558 559 560 561 562 563
  * `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\".
564 565 566 567 568 569

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
570 571

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

578
So, to summarize: if the method is an out-of-band method, then you
579
must specify `tramp-copy-program' and `tramp-copy-args'.  If it is an
580 581
inline method, then these two parameters should be nil.  Every method,
inline or out of band, must specify `tramp-connection-function' plus
582
the associated arguments (for example, the login program if you chose
Kai Großjohann's avatar
Kai Großjohann committed
583 584 585 586 587 588 589 590
`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
591
host other than `localhost' or the name of the local host."
Kai Großjohann's avatar
Kai Großjohann committed
592 593 594 595
  :group 'tramp
  :type '(repeat
          (cons string
                (set (list (const tramp-connection-function) function)
596
                     (list (const tramp-login-program)
Kai Großjohann's avatar
Kai Großjohann committed
597
			   (choice (const nil) string))
598
                     (list (const tramp-copy-program)
Kai Großjohann's avatar
Kai Großjohann committed
599 600 601
			   (choice (const nil) string))
                     (list (const tramp-remote-sh)
			   (choice (const nil) string))
602 603 604
                     (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
605 606 607 608 609 610 611 612
			   (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
613 614 615
			   (choice (const nil) function))
		     (list (const tramp-password-end-of-line)
			   (choice (const nil) string))))))
Kai Großjohann's avatar
Kai Großjohann committed
616 617 618 619 620 621 622 623 624 625 626

(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")
627
    ("remsh"  tramp-multi-connect-rlogin "remsh %h -l %u%n")
Kai Großjohann's avatar
Kai Großjohann committed
628
    ("ssh"    tramp-multi-connect-rlogin "ssh %h -l %u%n")
629
    ("ssht"   tramp-multi-connect-rlogin "ssh %h -e none -t -t -l %u%n")
Kai Großjohann's avatar
Kai Großjohann committed
630
    ("su"     tramp-multi-connect-su     "su - %u%n")
631
    ("sudo"   tramp-multi-connect-su     "sudo -u %u -s -p Password:%n"))
Kai Großjohann's avatar
Kai Großjohann committed
632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648
  "*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)))

649 650 651 652 653
(defcustom tramp-default-method
  (if (and (fboundp 'executable-find)
	   (executable-find "plink"))
      "plink"
    "ssh")
Kai Großjohann's avatar
Kai Großjohann committed
654
  "*Default method to use for transferring files.
655
See `tramp-methods' for possibilities.
656
Also see `tramp-default-method-alist'."
657 658 659
  :group 'tramp
  :type 'string)

660
(defcustom tramp-default-method-alist
661
  '(("\\`localhost\\'" "\\`root\\'" "su"))
662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677
  "*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"))))

678 679 680 681 682
;; 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")))
683
  "Default list of (FUNCTION FILE) pairs to be examined for rsh methods.")
684 685 686 687

;; Default values for non-Unices seeked
(defconst tramp-completion-function-alist-ssh
  (unless (memq system-type '(windows-nt))
688 689 690 691 692 693 694 695 696 697 698 699
    '((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")))
700
  "Default list of (FUNCTION FILE) pairs to be examined for ssh methods.")
701 702 703 704 705

;; Default values for non-Unices seeked
(defconst tramp-completion-function-alist-telnet
  (unless (memq system-type '(windows-nt))
    '((tramp-parse-hosts "/etc/hosts")))
706
  "Default list of (FUNCTION FILE) pairs to be examined for telnet methods.")
707 708 709 710 711

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

714
(defvar tramp-completion-function-alist nil
715 716 717 718 719 720
  "*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:

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 760 761 762 763 764 765 766 767 768 769 770 771 772
 * `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)
773
     (tramp-set-completion-function
774 775 776 777 778 779 780 781 782 783 784 785 786
      "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)))
787

Kai Großjohann's avatar
Kai Großjohann committed
788 789 790
(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
791
if you need to change this.
Kai Großjohann's avatar
Kai Großjohann committed
792 793
Also see the method parameter `tramp-password-end-of-line' and the normal
variable `tramp-default-password-end-of-line'."
794 795 796
  :group 'tramp
  :type 'string)

Kai Großjohann's avatar
Kai Großjohann committed
797 798
(defcustom tramp-default-password-end-of-line
  tramp-rsh-end-of-line
799
  "*String used for end of line after sending a password.
Kai Großjohann's avatar
Kai Großjohann committed
800 801 802
This variable provides the default value for the method parameter
`tramp-password-end-of-line', see `tramp-methods' for more details.

803 804 805 806 807 808
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
809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824
  :group 'tramp
  :type 'string)

(defcustom tramp-remote-path
  '("/bin" "/usr/bin" "/usr/sbin" "/usr/local/bin" "/usr/ccs/bin"
    "/local/bin" "/local/freeware/bin" "/local/gnu/bin"
    "/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
825
  ".*ogin\\( .*\\)?: *"
Kai Großjohann's avatar
Kai Großjohann committed
826
  "*Regexp matching login-like prompts.
827 828 829
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
830 831 832
  :group 'tramp
  :type 'regexp)

Kai Großjohann's avatar
Kai Großjohann committed
833
(defcustom tramp-shell-prompt-pattern
834
  "^[^#$%>\n]*[#$%>] *\\(\e\\[[0-9;]*[a-zA-Z] *\\)*"
Kai Großjohann's avatar
Kai Großjohann committed
835 836 837 838 839 840
  "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
841
variable is similar to the default value of `shell-prompt-pattern',
Kai Großjohann's avatar
Kai Großjohann committed
842 843 844 845
which should work well in many cases."
  :group 'tramp
  :type 'regexp)

Kai Großjohann's avatar
Kai Großjohann committed
846
(defcustom tramp-password-prompt-regexp
Michael Albinus's avatar
Michael Albinus committed
847
  "^.*\\([pP]assword\\|passphrase\\).*:\^@? *"
Kai Großjohann's avatar
Kai Großjohann committed
848
  "*Regexp matching password-like prompts.
Kai Großjohann's avatar
Kai Großjohann committed
849
The regexp should match at end of buffer.
Kai Großjohann's avatar
Kai Großjohann committed
850 851 852 853 854 855

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
856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871
  (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
872
  "*Regexp matching a `login failed' message.
Kai Großjohann's avatar
Kai Großjohann committed
873 874 875 876 877
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
878 879 880 881
  (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
882
The confirmation should be done with yes or no.
Kai Großjohann's avatar
Kai Großjohann committed
883 884
The regexp should match at end of buffer.
See also `tramp-yn-prompt-regexp'."
Kai Großjohann's avatar
Kai Großjohann committed
885 886 887
  :group 'tramp
  :type 'regexp)

Kai Großjohann's avatar
Kai Großjohann committed
888 889 890 891 892 893 894 895 896
(defcustom tramp-yn-prompt-regexp
  (concat (regexp-opt '("Store key in cache? (y/n)") t)
	  "\\s-*")
  "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
897 898 899 900 901 902 903 904 905 906 907 908

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

Michael Albinus's avatar
Michael Albinus committed
910 911 912 913 914 915 916 917 918
(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)

919
(defcustom tramp-process-alive-regexp
920
  ""
921
  "Regular expression indicating a process has finished.
922 923
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
924 925
The answer will be provided by `tramp-action-process-alive',
`tramp-multi-action-process-alive' and`tramp-action-out-of-band', which see."
926 927 928
  :group 'tramp
  :type 'regexp)

Kai Großjohann's avatar
Kai Großjohann committed
929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944
(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)

945
(defcustom tramp-sh-extra-args '(("/bash\\'" . "-norc -noprofile"))
946 947 948 949 950 951 952 953 954
  "*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
955 956 957 958 959
  ;; 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))))
960

961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013
(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
1014

1015 1016
(defcustom tramp-postfix-multi-hop-format
  (if tramp-unified-filenames ":" "/")
Kai Großjohann's avatar
Kai Großjohann committed
1017
  "*String matching delimeter between host and next method.
1018 1019 1020 1021 1022 1023 1024
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
1025
  "*Regexp matching delimeter between host and next method.
1026 1027 1028 1029 1030 1031
Applicable for multi-hop methods.
Derived from `tramp-postfix-multi-hop-format'."
  :group 'tramp
  :type 'regexp)

(defcustom tramp-user-regexp
Michael Albinus's avatar
Michael Albinus committed
1032
  "[^:/ \t]*"
1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051
  "*Regexp matching user names."
  :group 'tramp
  :type 'regexp)

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

(defcustom tramp-postfix-user-regexp
  (regexp-quote tramp-postfix-user-format)
  "*Regexp matching delimeter between user and host names.
Derived from `tramp-postfix-user-format'."
  :group 'tramp
  :type 'regexp)

(defcustom tramp-host-regexp
Kai Großjohann's avatar
Kai Großjohann committed
1052 1053 1054 1055 1056 1057
  "[a-zA-Z0-9_.-]*"
  "*Regexp matching host names."
  :group 'tramp
  :type 'regexp)

(defcustom tramp-host-with-port-regexp
Kai Großjohann's avatar
Kai Großjohann committed
1058
  "[a-zA-Z0-9_.#-]*"
1059 1060 1061 1062 1063 1064
  "*Regexp matching host names."
  :group 'tramp
  :type 'regexp)

(defcustom tramp-postfix-host-format
  (if tramp-unified-filenames ":" "]")
Kai Großjohann's avatar
Kai Großjohann committed
1065
  "*String matching delimeter between host names and localnames.
1066 1067 1068 1069 1070 1071
Used in `tramp-make-tramp-file-name' and `tramp-make-tramp-multi-file-name'."
  :group 'tramp
  :type 'string)

(defcustom tramp-postfix-host-regexp
  (regexp-quote tramp-postfix-host-format)
Kai Großjohann's avatar
Kai Großjohann committed
1072
  "*Regexp matching delimeter between host names and localnames.
1073 1074 1075 1076
Derived from `tramp-postfix-host-format'."
  :group 'tramp
  :type 'regexp)

Kai Großjohann's avatar
Kai Großjohann committed
1077
(defcustom tramp-localname-regexp
1078
  ".*$"
Kai Großjohann's avatar
Kai Großjohann committed
1079
  "*Regexp matching localnames."
1080 1081 1082 1083
  :group 'tramp
  :type 'regexp)

;; File name format.
1084 1085

(defcustom tramp-file-name-structure
1086 1087 1088 1089
  (list
   (concat
    tramp-prefix-regexp
    "\\(" "\\(" tramp-method-regexp "\\)" tramp-postfix-single-method-regexp "\\)?"
Kai Großjohann's avatar
Kai Großjohann committed
1090 1091
    "\\(" "\\(" tramp-user-regexp "\\)" tramp-postfix-user-regexp   "\\)?"
          "\\(" tramp-host-with-port-regexp "\\)" tramp-postfix-host-regexp
Kai Großjohann's avatar
Kai Großjohann committed
1092
	  "\\(" tramp-localname-regexp "\\)")
1093 1094
   2 4 5 6)

Kai Großjohann's avatar
Kai Großjohann committed
1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108
  "*List of five elements (REGEXP METHOD USER HOST FILE), detailing \
the tramp file name structure.

The first element REGEXP is a regular expression matching a tramp file
name.  The regex should contain parentheses around the method name,
the user name, the host name, and the file name parts.

The second element METHOD is a number, saying which pair of
parentheses matches the method name.  The third element USER is
similar, but for the user name.  The fourth element HOST is similar,
but for the host name.  The fifth element FILE is for the file name.
These numbers are passed directly to `match-string', which see.  That
means the opening parentheses are counted to identify the pair.

1109
See also `tramp-file-name-regexp'."
Kai Großjohann's avatar
Kai Großjohann committed
1110 1111 1112 1113 1114 1115 1116 1117
  :group 'tramp
  :type '(list (regexp :tag "File name regexp")
               (integer :tag "Paren pair for method name")
               (integer :tag "Paren pair for user name  ")
               (integer :tag "Paren pair for host name  ")
               (integer :tag "Paren pair for file name  ")))

;;;###autoload
1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132
(defconst tramp-file-name-regexp-unified
  "\\`/[^/:]+:"
  "Value for `tramp-file-name-regexp' for unified remoting.
Emacs (not XEmacs) uses a unified filename syntax for Ange-FTP and
Tramp.  See `tramp-file-name-structure-unified' for more explanations.")

;;;###autoload
(defconst tramp-file-name-regexp-separate
  "\\`/\\[.*\\]"
  "Value for `tramp-file-name-regexp' for separate remoting.
XEmacs uses a separate filename syntax for Tramp and EFS.
See `tramp-file-name-structure-separate' for more explanations.")

;;;###autoload
(defcustom tramp-file-name-regexp
1133 1134 1135
  (if tramp-unified-filenames
      tramp-file-name-regexp-unified
    tramp-file-name-regexp-separate)
Kai Großjohann's avatar
Kai Großjohann committed
1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148
  "*Regular expression matching file names handled by tramp.
This regexp should match tramp file names but no other file names.
\(When tramp.el is loaded, this regular expression is prepended to
`file-name-handler-alist', and that is searched sequentially.  Thus,
if the tramp entry appears rather early in the `file-name-handler-alist'
and is a bit too general, then some files might be considered tramp
files which are not really tramp files.

Please note that the entry in `file-name-handler-alist' is made when
this file (tramp.el) is loaded.  This means that this variable must be set
before loading tramp.el.  Alternatively, `file-name-handler-alist' can be
updated after changing this variable.

1149
Also see `tramp-file-name-structure'."
Kai Großjohann's avatar
Kai Großjohann committed
1150 1151 1152
  :group 'tramp
  :type 'regexp)

1153 1154
;;;###autoload
(defconst tramp-completion-file-name-regexp-unified
1155
  "^/$\\|^/[^/:][^/]*$"
1156 1157 1158
  "Value for `tramp-completion-file-name-regexp' for unified remoting.
Emacs (not XEmacs) uses a unified filename syntax for Ange-FTP and
Tramp.  See `tramp-file-name-structure-unified' for more explanations.")
Kai Großjohann's avatar
Kai Großjohann committed
1159

1160 1161 1162 1163 1164 1165
;;;###autoload
(defconst tramp-completion-file-name-regexp-separate
  "^/\\([[][^]]*\\)?$"
  "Value for `tramp-completion-file-name-regexp' for separate remoting.
XEmacs uses a separate filename syntax for Tramp and EFS.
See `tramp-file-name-structure-separate' for more explanations.")
Kai Großjohann's avatar
Kai Großjohann committed
1166

1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182
;;;###autoload
(defcustom tramp-completion-file-name-regexp
  (if tramp-unified-filenames
      tramp-completion-file-name-regexp-unified
    tramp-completion-file-name-regexp-separate)
  "*Regular expression matching file names handled by tramp completion.
This regexp should match partial tramp file names only.

Please note that the entry in `file-name-handler-alist' is made when
this file (tramp.el) is loaded.  This means that this variable must be set
before loading tramp.el.  Alternatively, `file-name-handler-alist' can be
updated after changing this variable.

Also see `tramp-file-name-structure'."
  :group 'tramp
  :type 'regexp)
1183 1184

(defcustom tramp-multi-file-name-structure
1185 1186 1187 1188 1189
  (list
   (concat
    tramp-prefix-regexp
    "\\(" "\\(" tramp-method-regexp "\\)" "\\)?"
    "\\(" "\\(" tramp-postfix-multi-hop-regexp "%s" "\\)+" "\\)?"
Kai Großjohann's avatar
Kai Großjohann committed
1190
    tramp-postfix-host-regexp "\\(" tramp-localname-regexp "\\)")
1191
   2 3 -1)
Kai Großjohann's avatar
Kai Großjohann committed
1192 1193
  "*Describes the file name structure of `multi' files.
Multi files allow you to contact a remote host in several hops.
Kai Großjohann's avatar
Kai Großjohann committed
1194
This is a list of four elements (REGEXP METHOD HOP LOCALNAME).
Kai Großjohann's avatar
Kai Großjohann committed
1195 1196 1197 1198 1199 1200 1201 1202 1203 1204

The first element, REGEXP, gives a regular expression to match against
the file name.  In this regular expression, `%s' is replaced with the
value of `tramp-multi-file-name-hop-structure'.  (Note: in order to
allow multiple hops, you normally want to use something like
\"\\\\(\\\\(%s\\\\)+\\\\)\" in the regular expression.  The outer pair
of parentheses is used for the HOP element, see below.)

All remaining elements are numbers.  METHOD gives the number of the
paren pair which matches the method name.  HOP gives the number of the
Kai Großjohann's avatar
Kai Großjohann committed
1205 1206
paren pair which matches the hop sequence.  LOCALNAME gives the number of
the paren pair which matches the localname (pathname) on the remote host.
Kai Großjohann's avatar
Kai Großjohann committed
1207

Kai Großjohann's avatar
Kai Großjohann committed
1208
LOCALNAME can also be negative, which means to count from the end.  Ie, a
Kai Großjohann's avatar
Kai Großjohann committed
1209 1210 1211 1212 1213 1214 1215 1216
value of -1 means the last paren pair.

I think it would be good if the regexp matches the whole of the
string, but I haven't actually tried what happens if it doesn't..."
  :group 'tramp
  :type '(list (regexp :tag "File name regexp")
               (integer :tag "Paren pair for method name")
               (integer :tag "Paren pair for hops")
Kai Großjohann's avatar
Kai Großjohann committed
1217
               (integer :tag "Paren pair to match localname")))
Kai Großjohann's avatar
Kai Großjohann committed
1218

1219
(defcustom tramp-multi-file-name-hop-structure
1220 1221 1222
  (list
   (concat
    "\\(" tramp-method-regexp "\\)" tramp-postfix-multi-method-regexp
Kai Großjohann's avatar
Kai Großjohann committed
1223 1224
    "\\(" tramp-user-regexp "\\)" tramp-postfix-user-regexp
    "\\(" tramp-host-with-port-regexp "\\)")
1225
   1 2 3)
Kai Großjohann's avatar
Kai Großjohann committed
1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238
  "*Describes the structure of a hop in multi files.
This is a list of four elements (REGEXP METHOD USER HOST).  First
element REGEXP is used to match against the hop.  Pair number METHOD
matches the method of one hop, pair number USER matches the user of
one hop, pair number HOST matches the host of one hop.

This regular expression should match exactly all of one hop."
  :group 'tramp
  :type '(list (regexp :tag "Hop regexp")
               (integer :tag "Paren pair for method name")
               (integer :tag "Paren pair for user name")
               (integer :tag "Paren pair for host name")))