/[emacs]/emacs/lisp/net/tramp.el
ViewVC logotype

Diff of /emacs/lisp/net/tramp.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11 by kai, Sun Jul 21 13:49:05 2002 UTC revision 1.12 by kai, Tue Jul 30 20:24:27 2002 UTC
# Line 69  Line 69 
69    
70  ;;; Code:  ;;; Code:
71    
72  (defconst tramp-version "2.0.2"  (defconst tramp-version "2.0.5"
73    "This version of tramp.")    "This version of tramp.")
74    
75  (defconst tramp-bug-report-address "tramp-devel@mail.freesoftware.fsf.org"  (defconst tramp-bug-report-address "tramp-devel@mail.freesoftware.fsf.org"
76    "Email address to send bug reports to.")    "Email address to send bug reports to.")
77    
# Line 175  This variable defaults to CMD.EXE on Win Line 176  This variable defaults to CMD.EXE on Win
176                (tramp-rcp-keep-date-arg    "-p")                (tramp-rcp-keep-date-arg    "-p")
177                (tramp-su-program           nil)                (tramp-su-program           nil)
178                (tramp-su-args              nil)                (tramp-su-args              nil)
               (tramp-encoding-command     nil)  
               (tramp-decoding-command     nil)  
               (tramp-encoding-function    nil)  
               (tramp-decoding-function    nil)  
179                (tramp-telnet-program       nil)                (tramp-telnet-program       nil)
180                (tramp-telnet-args          nil))                (tramp-telnet-args          nil))
181       ("scp"   (tramp-connection-function  tramp-open-connection-rsh)       ("scp"   (tramp-connection-function  tramp-open-connection-rsh)
# Line 190  This variable defaults to CMD.EXE on Win Line 187  This variable defaults to CMD.EXE on Win
187                (tramp-rcp-keep-date-arg    "-p")                (tramp-rcp-keep-date-arg    "-p")
188                (tramp-su-program           nil)                (tramp-su-program           nil)
189                (tramp-su-args              nil)                (tramp-su-args              nil)
               (tramp-encoding-command     nil)  
               (tramp-decoding-command     nil)  
               (tramp-encoding-function    nil)  
               (tramp-decoding-function    nil)  
190                (tramp-telnet-program       nil)                (tramp-telnet-program       nil)
191                (tramp-telnet-args          nil))                (tramp-telnet-args          nil))
192       ("scp1"  (tramp-connection-function  tramp-open-connection-rsh)       ("scp1"  (tramp-connection-function  tramp-open-connection-rsh)
# Line 205  This variable defaults to CMD.EXE on Win Line 198  This variable defaults to CMD.EXE on Win
198                (tramp-rcp-keep-date-arg    "-p")                (tramp-rcp-keep-date-arg    "-p")
199                (tramp-su-program           nil)                (tramp-su-program           nil)
200                (tramp-su-args              nil)                (tramp-su-args              nil)
               (tramp-encoding-command     nil)  
               (tramp-decoding-command     nil)  
               (tramp-encoding-function    nil)  
               (tramp-decoding-function    nil)  
201                (tramp-telnet-program       nil)                (tramp-telnet-program       nil)
202                (tramp-telnet-args          nil))                (tramp-telnet-args          nil))
203       ("scp2"  (tramp-connection-function  tramp-open-connection-rsh)       ("scp2"  (tramp-connection-function  tramp-open-connection-rsh)
# Line 220  This variable defaults to CMD.EXE on Win Line 209  This variable defaults to CMD.EXE on Win
209                (tramp-rcp-keep-date-arg    "-p")                (tramp-rcp-keep-date-arg    "-p")
210                (tramp-su-program           nil)                (tramp-su-program           nil)
211                (tramp-su-args              nil)                (tramp-su-args              nil)
               (tramp-encoding-command     nil)  
               (tramp-decoding-command     nil)  
               (tramp-encoding-function    nil)  
               (tramp-decoding-function    nil)  
212                (tramp-telnet-program       nil)                (tramp-telnet-program       nil)
213                (tramp-telnet-args          nil))                (tramp-telnet-args          nil))
214       ("scp-ssh1" (tramp-connection-function  tramp-open-connection-rsh)       ("scp1-old"
215                  (tramp-connection-function  tramp-open-connection-rsh)
216                (tramp-rsh-program          "ssh1")                (tramp-rsh-program          "ssh1")
217                (tramp-rcp-program          "scp1")                (tramp-rcp-program          "scp1")
218                (tramp-remote-sh            "/bin/sh")                (tramp-remote-sh            "/bin/sh")
# Line 235  This variable defaults to CMD.EXE on Win Line 221  This variable defaults to CMD.EXE on Win
221                (tramp-rcp-keep-date-arg    "-p")                (tramp-rcp-keep-date-arg    "-p")
222                (tramp-su-program           nil)                (tramp-su-program           nil)
223                (tramp-su-args              nil)                (tramp-su-args              nil)
               (tramp-encoding-command     nil)  
               (tramp-decoding-command     nil)  
               (tramp-encoding-function    nil)  
               (tramp-decoding-function    nil)  
224                (tramp-telnet-program       nil)                (tramp-telnet-program       nil)
225                (tramp-telnet-args          nil))                (tramp-telnet-args          nil))
226       ("scp-ssh2"  (tramp-connection-function  tramp-open-connection-rsh)       ("scp2-old"
227                  (tramp-connection-function  tramp-open-connection-rsh)
228                (tramp-rsh-program          "ssh2")                (tramp-rsh-program          "ssh2")
229                (tramp-rcp-program          "scp2")                (tramp-rcp-program          "scp2")
230                (tramp-remote-sh            "/bin/sh")                (tramp-remote-sh            "/bin/sh")
# Line 250  This variable defaults to CMD.EXE on Win Line 233  This variable defaults to CMD.EXE on Win
233                (tramp-rcp-keep-date-arg    "-p")                (tramp-rcp-keep-date-arg    "-p")
234                (tramp-su-program           nil)                (tramp-su-program           nil)
235                (tramp-su-args              nil)                (tramp-su-args              nil)
               (tramp-encoding-command     nil)  
               (tramp-decoding-command     nil)  
               (tramp-encoding-function    nil)  
               (tramp-decoding-function    nil)  
236                (tramp-telnet-program       nil)                (tramp-telnet-program       nil)
237                (tramp-telnet-args          nil))                (tramp-telnet-args          nil))
238       ("rsync" (tramp-connection-function  tramp-open-connection-rsh)       ("rsync" (tramp-connection-function  tramp-open-connection-rsh)
# Line 265  This variable defaults to CMD.EXE on Win Line 244  This variable defaults to CMD.EXE on Win
244                (tramp-rcp-keep-date-arg    "-t")                (tramp-rcp-keep-date-arg    "-t")
245                (tramp-su-program           nil)                (tramp-su-program           nil)
246                (tramp-su-args              nil)                (tramp-su-args              nil)
               (tramp-encoding-command     nil)  
               (tramp-decoding-command     nil)  
               (tramp-encoding-function    nil)  
               (tramp-decoding-function    nil)  
247                (tramp-telnet-program       nil)                (tramp-telnet-program       nil)
248                (tramp-telnet-args          nil))                (tramp-telnet-args          nil))
249       ("ru"    (tramp-connection-function  tramp-open-connection-rsh)       ("rsh"   (tramp-connection-function  tramp-open-connection-rsh)
250                (tramp-rsh-program          "rsh")                (tramp-rsh-program          "rsh")
251                (tramp-rcp-program          nil)                (tramp-rcp-program          nil)
252                (tramp-remote-sh            "/bin/sh")                (tramp-remote-sh            "/bin/sh")
# Line 280  This variable defaults to CMD.EXE on Win Line 255  This variable defaults to CMD.EXE on Win
255                (tramp-rcp-keep-date-arg    nil)                (tramp-rcp-keep-date-arg    nil)
256                (tramp-su-program           nil)                (tramp-su-program           nil)
257                (tramp-su-args              nil)                (tramp-su-args              nil)
               (tramp-encoding-command     "uuencode xxx")  
               (tramp-decoding-command  
                "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )")  
               (tramp-encoding-function    nil)  
               (tramp-decoding-function    uudecode-decode-region)  
258                (tramp-telnet-program       nil)                (tramp-telnet-program       nil)
259                (tramp-telnet-args          nil))                (tramp-telnet-args          nil))
260       ("su"    (tramp-connection-function  tramp-open-connection-rsh)       ("ssh"   (tramp-connection-function  tramp-open-connection-rsh)
261                (tramp-rsh-program          "ssh")                (tramp-rsh-program          "ssh")
262                (tramp-rcp-program          nil)                (tramp-rcp-program          nil)
263                (tramp-remote-sh            "/bin/sh")                (tramp-remote-sh            "/bin/sh")
# Line 296  This variable defaults to CMD.EXE on Win Line 266  This variable defaults to CMD.EXE on Win
266                (tramp-rcp-keep-date-arg    nil)                (tramp-rcp-keep-date-arg    nil)
267                (tramp-su-program           nil)                (tramp-su-program           nil)
268                (tramp-su-args              nil)                (tramp-su-args              nil)
               (tramp-encoding-command     "uuencode xxx")  
               (tramp-decoding-command  
                "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )")  
               (tramp-encoding-function    nil)  
               (tramp-decoding-function    uudecode-decode-region)  
269                (tramp-telnet-program       nil)                (tramp-telnet-program       nil)
270                (tramp-telnet-args          nil))                (tramp-telnet-args          nil))
271       ("su1"   (tramp-connection-function  tramp-open-connection-rsh)       ("ssh1"  (tramp-connection-function  tramp-open-connection-rsh)
272                (tramp-rsh-program          "ssh")                (tramp-rsh-program          "ssh")
273                (tramp-rcp-program          nil)                (tramp-rcp-program          nil)
274                (tramp-remote-sh            "/bin/sh")                (tramp-remote-sh            "/bin/sh")
# Line 312  This variable defaults to CMD.EXE on Win Line 277  This variable defaults to CMD.EXE on Win
277                (tramp-rcp-keep-date-arg    nil)                (tramp-rcp-keep-date-arg    nil)
278                (tramp-su-program           nil)                (tramp-su-program           nil)
279                (tramp-su-args              nil)                (tramp-su-args              nil)
               (tramp-encoding-command     "uuencode xxx")  
               (tramp-decoding-command  
                "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )")  
               (tramp-encoding-function    nil)  
               (tramp-decoding-function    uudecode-decode-region)  
280                (tramp-telnet-program       nil)                (tramp-telnet-program       nil)
281                (tramp-telnet-args          nil))                (tramp-telnet-args          nil))
282       ("su2"   (tramp-connection-function  tramp-open-connection-rsh)       ("ssh2"  (tramp-connection-function  tramp-open-connection-rsh)
283                (tramp-rsh-program          "ssh")                (tramp-rsh-program          "ssh")
284                (tramp-rcp-program          nil)                (tramp-rcp-program          nil)
285                (tramp-remote-sh            "/bin/sh")                (tramp-remote-sh            "/bin/sh")
# Line 328  This variable defaults to CMD.EXE on Win Line 288  This variable defaults to CMD.EXE on Win
288                (tramp-rcp-keep-date-arg    nil)                (tramp-rcp-keep-date-arg    nil)
289                (tramp-su-program           nil)                (tramp-su-program           nil)
290                (tramp-su-args              nil)                (tramp-su-args              nil)
               (tramp-encoding-command     "uuencode xxx")  
               (tramp-decoding-command  
                "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )")  
               (tramp-encoding-function    nil)  
               (tramp-decoding-function    uudecode-decode-region)  
291                (tramp-telnet-program       nil)                (tramp-telnet-program       nil)
292                (tramp-telnet-args          nil))                (tramp-telnet-args          nil))
293       ("su-ssh1"   (tramp-connection-function  tramp-open-connection-rsh)       ("ssh1-old"
294                  (tramp-connection-function  tramp-open-connection-rsh)
295                (tramp-rsh-program          "ssh1")                (tramp-rsh-program          "ssh1")
296                (tramp-rcp-program          nil)                (tramp-rcp-program          nil)
297                (tramp-remote-sh            "/bin/sh")                (tramp-remote-sh            "/bin/sh")
# Line 344  This variable defaults to CMD.EXE on Win Line 300  This variable defaults to CMD.EXE on Win
300                (tramp-rcp-keep-date-arg    nil)                (tramp-rcp-keep-date-arg    nil)
301                (tramp-su-program           nil)                (tramp-su-program           nil)
302                (tramp-su-args              nil)                (tramp-su-args              nil)
               (tramp-encoding-command     "uuencode xxx")  
               (tramp-decoding-command  
                "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )")  
               (tramp-encoding-function    nil)  
               (tramp-decoding-function    uudecode-decode-region)  
303                (tramp-telnet-program       nil)                (tramp-telnet-program       nil)
304                (tramp-telnet-args          nil))                (tramp-telnet-args          nil))
305       ("su-ssh2"   (tramp-connection-function  tramp-open-connection-rsh)       ("ssh2-old"
306                  (tramp-connection-function  tramp-open-connection-rsh)
307                (tramp-rsh-program          "ssh2")                (tramp-rsh-program          "ssh2")
308                (tramp-rcp-program          nil)                (tramp-rcp-program          nil)
309                (tramp-remote-sh            "/bin/sh")                (tramp-remote-sh            "/bin/sh")
# Line 360  This variable defaults to CMD.EXE on Win Line 312  This variable defaults to CMD.EXE on Win
312                (tramp-rcp-keep-date-arg    nil)                (tramp-rcp-keep-date-arg    nil)
313                (tramp-su-program           nil)                (tramp-su-program           nil)
314                (tramp-su-args              nil)                (tramp-su-args              nil)
               (tramp-encoding-command     "uuencode xxx")  
               (tramp-decoding-command  
                "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )")  
               (tramp-encoding-function    nil)  
               (tramp-decoding-function    uudecode-decode-region)  
               (tramp-telnet-program       nil)  
               (tramp-telnet-args          nil))  
      ("rm"    (tramp-connection-function  tramp-open-connection-rsh)  
               (tramp-rsh-program          "rsh")  
               (tramp-rcp-program          nil)  
               (tramp-remote-sh            "/bin/sh")  
               (tramp-rsh-args             nil)  
               (tramp-rcp-args             nil)  
               (tramp-rcp-keep-date-arg    nil)  
               (tramp-su-program           nil)  
               (tramp-su-args              nil)  
               (tramp-encoding-command     "mimencode -b")  
               (tramp-decoding-command     "mimencode -u -b")  
               (tramp-encoding-function    base64-encode-region)  
               (tramp-decoding-function    base64-decode-region)  
               (tramp-telnet-program       nil)  
               (tramp-telnet-args          nil))  
      ("sm"    (tramp-connection-function  tramp-open-connection-rsh)  
               (tramp-rsh-program          "ssh")  
               (tramp-rcp-program          nil)  
               (tramp-remote-sh            "/bin/sh")  
               (tramp-rsh-args             ("-e" "none"))  
               (tramp-rcp-args             nil)  
               (tramp-rcp-keep-date-arg    nil)  
               (tramp-su-program           nil)  
               (tramp-su-args              nil)  
               (tramp-encoding-command     "mimencode -b")  
               (tramp-decoding-command     "mimencode -u -b")  
               (tramp-encoding-function    base64-encode-region)  
               (tramp-decoding-function    base64-decode-region)  
               (tramp-telnet-program       nil)  
               (tramp-telnet-args          nil))  
      ("smp"   (tramp-connection-function  tramp-open-connection-rsh)  
               (tramp-rsh-program          "ssh")  
               (tramp-rcp-program          nil)  
               (tramp-remote-sh            "/bin/sh")  
               (tramp-rsh-args             ("-e" "none"))  
               (tramp-rcp-args             nil)  
               (tramp-rcp-keep-date-arg    nil)  
               (tramp-su-program           nil)  
               (tramp-su-args              nil)  
               (tramp-encoding-command     "tramp_mimencode")  
               (tramp-decoding-command     "tramp_mimedecode")  
               (tramp-encoding-function    base64-encode-region)  
               (tramp-decoding-function    base64-decode-region)  
               (tramp-telnet-program       nil))  
      ("sm1"   (tramp-connection-function  tramp-open-connection-rsh)  
               (tramp-rsh-program          "ssh")  
               (tramp-rcp-program          nil)  
               (tramp-remote-sh            "/bin/sh")  
               (tramp-rsh-args             ("-1" "-e" "none"))  
               (tramp-rcp-args             ("-1"))  
               (tramp-rcp-keep-date-arg    nil)  
               (tramp-su-program           nil)  
               (tramp-su-args              nil)  
               (tramp-encoding-command     "mimencode -b")  
               (tramp-decoding-command     "mimencode -u -b")  
               (tramp-encoding-function    base64-encode-region)  
               (tramp-decoding-function    base64-decode-region)  
               (tramp-telnet-program       nil)  
               (tramp-telnet-args          nil))  
      ("sm2"   (tramp-connection-function  tramp-open-connection-rsh)  
               (tramp-rsh-program          "ssh")  
               (tramp-rcp-program          nil)  
               (tramp-remote-sh            "/bin/sh")  
               (tramp-rsh-args             ("-2" "-e" "none"))  
               (tramp-rcp-args             ("-2"))  
               (tramp-rcp-keep-date-arg    nil)  
               (tramp-su-program           nil)  
               (tramp-su-args              nil)  
               (tramp-encoding-command     "mimencode -b")  
               (tramp-decoding-command     "mimencode -u -b")  
               (tramp-encoding-function    base64-encode-region)  
               (tramp-decoding-function    base64-decode-region)  
315                (tramp-telnet-program       nil)                (tramp-telnet-program       nil)
316                (tramp-telnet-args          nil))                (tramp-telnet-args          nil))
317       ("sm-ssh1"   (tramp-connection-function  tramp-open-connection-rsh)       ("ssh1-old"
318                  (tramp-connection-function  tramp-open-connection-rsh)
319                (tramp-rsh-program          "ssh1")                (tramp-rsh-program          "ssh1")
320                (tramp-rcp-program          nil)                (tramp-rcp-program          nil)
321                (tramp-remote-sh            "/bin/sh")                (tramp-remote-sh            "/bin/sh")
# Line 450  This variable defaults to CMD.EXE on Win Line 324  This variable defaults to CMD.EXE on Win
324                (tramp-rcp-keep-date-arg    nil)                (tramp-rcp-keep-date-arg    nil)
325                (tramp-su-program           nil)                (tramp-su-program           nil)
326                (tramp-su-args              nil)                (tramp-su-args              nil)
               (tramp-encoding-command     "mimencode -b")  
               (tramp-decoding-command     "mimencode -u -b")  
               (tramp-encoding-function    base64-encode-region)  
               (tramp-decoding-function    base64-decode-region)  
327                (tramp-telnet-program       nil)                (tramp-telnet-program       nil)
328                (tramp-telnet-args          nil))                (tramp-telnet-args          nil))
329       ("sm-ssh2"   (tramp-connection-function  tramp-open-connection-rsh)       ("ssh2-old"
330                  (tramp-connection-function  tramp-open-connection-rsh)
331                (tramp-rsh-program          "ssh2")                (tramp-rsh-program          "ssh2")
332                (tramp-rcp-program          nil)                (tramp-rcp-program          nil)
333                (tramp-remote-sh            "/bin/sh")                (tramp-remote-sh            "/bin/sh")
# Line 465  This variable defaults to CMD.EXE on Win Line 336  This variable defaults to CMD.EXE on Win
336                (tramp-rcp-keep-date-arg    nil)                (tramp-rcp-keep-date-arg    nil)
337                (tramp-su-program           nil)                (tramp-su-program           nil)
338                (tramp-su-args              nil)                (tramp-su-args              nil)
               (tramp-encoding-command     "mimencode -b")  
               (tramp-decoding-command     "mimencode -u -b")  
               (tramp-encoding-function    base64-encode-region)  
               (tramp-decoding-function    base64-decode-region)  
339                (tramp-telnet-program       nil)                (tramp-telnet-program       nil)
340                (tramp-telnet-args          nil))                (tramp-telnet-args          nil))
341       ("tm"    (tramp-connection-function  tramp-open-connection-telnet)       ("telnet"
342                  (tramp-connection-function  tramp-open-connection-telnet)
343                (tramp-rsh-program          nil)                (tramp-rsh-program          nil)
344                (tramp-rcp-program          nil)                (tramp-rcp-program          nil)
345                (tramp-remote-sh            "/bin/sh")                (tramp-remote-sh            "/bin/sh")
# Line 480  This variable defaults to CMD.EXE on Win Line 348  This variable defaults to CMD.EXE on Win
348                (tramp-rcp-keep-date-arg    nil)                (tramp-rcp-keep-date-arg    nil)
349                (tramp-su-program           nil)                (tramp-su-program           nil)
350                (tramp-su-args              nil)                (tramp-su-args              nil)
               (tramp-encoding-command     "mimencode -b")  
               (tramp-decoding-command     "mimencode -u -b")  
               (tramp-encoding-function    base64-encode-region)  
               (tramp-decoding-function    base64-decode-region)  
351                (tramp-telnet-program       "telnet")                (tramp-telnet-program       "telnet")
352                (tramp-telnet-args          nil))                (tramp-telnet-args          nil))
353       ("tu"    (tramp-connection-function  tramp-open-connection-telnet)       ("su"    (tramp-connection-function  tramp-open-connection-su)
               (tramp-rsh-program          nil)  
               (tramp-rcp-program          nil)  
               (tramp-remote-sh            "/bin/sh")  
               (tramp-rsh-args             nil)  
               (tramp-rcp-args             nil)  
               (tramp-rcp-keep-date-arg    nil)  
               (tramp-su-program           nil)  
               (tramp-su-args              nil)  
               (tramp-encoding-command     "uuencode xxx")  
               (tramp-decoding-command  
                "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )")  
               (tramp-encoding-function    nil)  
               (tramp-decoding-function    uudecode-decode-region)  
               (tramp-telnet-program       "telnet")  
               (tramp-telnet-args          nil))  
      ("sum"   (tramp-connection-function  tramp-open-connection-su)  
               (tramp-rsh-program          nil)  
               (tramp-rcp-program          nil)  
               (tramp-remote-sh            "/bin/sh")  
               (tramp-rsh-args             nil)  
               (tramp-rcp-args             nil)  
               (tramp-rcp-keep-date-arg    nil)  
               (tramp-su-program           "su")  
               (tramp-su-args              ("-" "%u"))  
               (tramp-encoding-command     "mimencode -b")  
               (tramp-decoding-command     "mimencode -u -b")  
               (tramp-encoding-function    base64-encode-region)  
               (tramp-decoding-function    base64-decode-region)  
               (tramp-telnet-program       nil)  
               (tramp-telnet-args          nil))  
      ("suu"   (tramp-connection-function  tramp-open-connection-su)  
354                (tramp-rsh-program          nil)                (tramp-rsh-program          nil)
355                (tramp-rcp-program          nil)                (tramp-rcp-program          nil)
356                (tramp-remote-sh            "/bin/sh")                (tramp-remote-sh            "/bin/sh")
# Line 526  This variable defaults to CMD.EXE on Win Line 359  This variable defaults to CMD.EXE on Win
359                (tramp-rcp-keep-date-arg    nil)                (tramp-rcp-keep-date-arg    nil)
360                (tramp-su-program           "su")                (tramp-su-program           "su")
361                (tramp-su-args              ("-" "%u"))                (tramp-su-args              ("-" "%u"))
               (tramp-encoding-command     "uuencode xxx")  
               (tramp-decoding-command  
                "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )")  
               (tramp-encoding-function    nil)  
               (tramp-decoding-function    uudecode-decode-region)  
               (tramp-telnet-program       nil)  
               (tramp-telnet-args          nil))  
      ("sudm"  (tramp-connection-function  tramp-open-connection-su)  
               (tramp-rsh-program          nil)  
               (tramp-rcp-program          nil)  
               (tramp-remote-sh            "/bin/sh")  
               (tramp-rsh-args             nil)  
               (tramp-rcp-args             nil)  
               (tramp-rcp-keep-date-arg    nil)  
               (tramp-su-program           "sudo")  
               (tramp-su-args              ("-u" "%u" "-s"))  
               (tramp-encoding-command     "mimencode -b")  
               (tramp-decoding-command     "mimencode -u -b")  
               (tramp-encoding-function    base64-encode-region)  
               (tramp-decoding-function    base64-decode-region)  
362                (tramp-telnet-program       nil)                (tramp-telnet-program       nil)
363                (tramp-telnet-args          nil))                (tramp-telnet-args          nil))
364       ("sudu"  (tramp-connection-function  tramp-open-connection-su)       ("sudo"  (tramp-connection-function  tramp-open-connection-su)
365                (tramp-rsh-program          nil)                (tramp-rsh-program          nil)
366                (tramp-rcp-program          nil)                (tramp-rcp-program          nil)
367                (tramp-remote-sh            "/bin/sh")                (tramp-remote-sh            "/bin/sh")
# Line 557  This variable defaults to CMD.EXE on Win Line 370  This variable defaults to CMD.EXE on Win
370                (tramp-rcp-keep-date-arg    nil)                (tramp-rcp-keep-date-arg    nil)
371                (tramp-su-program           "sudo")                (tramp-su-program           "sudo")
372                (tramp-su-args              ("-u" "%u" "-s"))                (tramp-su-args              ("-u" "%u" "-s"))
               (tramp-encoding-command     "uuencode xxx")  
               (tramp-decoding-command  
                "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )")  
               (tramp-encoding-function    nil)  
               (tramp-decoding-function    uudecode-decode-region)  
373                (tramp-telnet-program       nil)                (tramp-telnet-program       nil)
374                (tramp-telnet-args          nil))                (tramp-telnet-args          nil))
375       ("multi" (tramp-connection-function  tramp-open-connection-multi)       ("multi" (tramp-connection-function  tramp-open-connection-multi)
# Line 573  This variable defaults to CMD.EXE on Win Line 381  This variable defaults to CMD.EXE on Win
381                (tramp-rcp-keep-date-arg    nil)                (tramp-rcp-keep-date-arg    nil)
382                (tramp-su-program           nil)                (tramp-su-program           nil)
383                (tramp-su-args              nil)                (tramp-su-args              nil)
               (tramp-encoding-command     "mimencode -b")  
               (tramp-decoding-command     "mimencode -u -b")  
               (tramp-encoding-function    base64-encode-region)  
               (tramp-decoding-function    base64-decode-region)  
               (tramp-telnet-program       nil)  
               (tramp-telnet-args          nil))  
      ("multiu" (tramp-connection-function  tramp-open-connection-multi)  
               (tramp-rsh-program          nil)  
               (tramp-rcp-program          nil)  
               (tramp-remote-sh            "/bin/sh")  
               (tramp-rsh-args             nil)  
               (tramp-rcp-args             nil)  
               (tramp-rcp-keep-date-arg    nil)  
               (tramp-su-program           nil)  
               (tramp-su-args              nil)  
               (tramp-encoding-command     "uuencode xxx")  
               (tramp-decoding-command  
                "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )")  
               (tramp-encoding-function    nil)  
               (tramp-decoding-function    uudecode-decode-region)  
384                (tramp-telnet-program       nil)                (tramp-telnet-program       nil)
385                (tramp-telnet-args          nil))                (tramp-telnet-args          nil))
386       ("scpx"  (tramp-connection-function  tramp-open-connection-rsh)       ("scpx"  (tramp-connection-function  tramp-open-connection-rsh)
# Line 602  This variable defaults to CMD.EXE on Win Line 390  This variable defaults to CMD.EXE on Win
390                (tramp-rsh-args             ("-e" "none" "-t" "-t" "/bin/sh"))                (tramp-rsh-args             ("-e" "none" "-t" "-t" "/bin/sh"))
391                (tramp-rcp-args             nil)                (tramp-rcp-args             nil)
392                (tramp-rcp-keep-date-arg    "-p")                (tramp-rcp-keep-date-arg    "-p")
               (tramp-encoding-command     nil)  
               (tramp-decoding-command     nil)  
               (tramp-encoding-function    nil)  
               (tramp-decoding-function    nil)  
393                (tramp-telnet-program       nil)                (tramp-telnet-program       nil)
394                (tramp-telnet-args          nil))                (tramp-telnet-args          nil))
395       ("smx"   (tramp-connection-function  tramp-open-connection-rsh)       ("sshx"  (tramp-connection-function  tramp-open-connection-rsh)
396                (tramp-rsh-program          "ssh")                (tramp-rsh-program          "ssh")
397                (tramp-rcp-program          nil)                (tramp-rcp-program          nil)
398                (tramp-remote-sh            "/bin/sh")                (tramp-remote-sh            "/bin/sh")
# Line 617  This variable defaults to CMD.EXE on Win Line 401  This variable defaults to CMD.EXE on Win
401                (tramp-rcp-keep-date-arg    nil)                (tramp-rcp-keep-date-arg    nil)
402                (tramp-su-program           nil)                (tramp-su-program           nil)
403                (tramp-su-args              nil)                (tramp-su-args              nil)
               (tramp-encoding-command     "mimencode -b")  
               (tramp-decoding-command     "mimencode -u -b")  
               (tramp-encoding-function    base64-encode-region)  
               (tramp-decoding-function    base64-decode-region)  
404                (tramp-telnet-program       nil)                (tramp-telnet-program       nil)
405                (tramp-telnet-args          nil))                (tramp-telnet-args          nil))
406       ("km"       ("krlogin"
407                (tramp-connection-function  tramp-open-connection-rsh)                (tramp-connection-function  tramp-open-connection-rsh)
408                (tramp-rsh-program          "krlogin")                (tramp-rsh-program          "krlogin")
409                (tramp-rcp-program          nil)                (tramp-rcp-program          nil)
# Line 633  This variable defaults to CMD.EXE on Win Line 413  This variable defaults to CMD.EXE on Win
413                (tramp-rcp-keep-date-arg    nil)                (tramp-rcp-keep-date-arg    nil)
414                (tramp-su-program           nil)                (tramp-su-program           nil)
415                (tramp-su-args              nil)                (tramp-su-args              nil)
               (tramp-encoding-command     "mimencode -b")  
               (tramp-decoding-command     "mimencode -u -b")  
               (tramp-encoding-function    base64-encode-region)  
               (tramp-decoding-function    base64-decode-region)  
416                (tramp-telnet-program       nil)                (tramp-telnet-program       nil)
417                (tramp-telnet-args          nil))                (tramp-telnet-args          nil))
418       ("plinku"       ("plink"
419                (tramp-connection-function  tramp-open-connection-rsh)                (tramp-connection-function  tramp-open-connection-rsh)
420                (tramp-rsh-program          "plink")                (tramp-rsh-program          "plink")
421                (tramp-rcp-program          nil)                (tramp-rcp-program          nil)
# Line 649  This variable defaults to CMD.EXE on Win Line 425  This variable defaults to CMD.EXE on Win
425                (tramp-rcp-keep-date-arg    nil)                (tramp-rcp-keep-date-arg    nil)
426                (tramp-su-program           nil)                (tramp-su-program           nil)
427                (tramp-su-args              nil)                (tramp-su-args              nil)
               (tramp-encoding-command     "uuencode xxx")  
               (tramp-decoding-command  
                "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )")  
               (tramp-encoding-function    nil)  
               (tramp-decoding-function    uudecode-decode-region)  
               (tramp-telnet-program       nil)  
               (tramp-telnet-args          nil))  
      ("plinkm"  
               (tramp-connection-function  tramp-open-connection-rsh)  
               (tramp-rsh-program          "plink")  
               (tramp-rcp-program          nil)  
               (tramp-remote-sh            "/bin/sh")  
               (tramp-rsh-args             ("-ssh")) ;optionally add "-v"  
               (tramp-rcp-args             nil)  
               (tramp-rcp-keep-date-arg    nil)  
               (tramp-su-program           nil)  
               (tramp-su-args              nil)  
               (tramp-encoding-command     "mimencode -b")  
               (tramp-decoding-command     "mimencode -u -b")  
               (tramp-encoding-function    base64-encode-region)  
               (tramp-decoding-function    base64-decode-region)  
428                (tramp-telnet-program       nil)                (tramp-telnet-program       nil)
429                (tramp-telnet-args          nil))                (tramp-telnet-args          nil))
430       ("pscp"       ("pscp"
# Line 682  This variable defaults to CMD.EXE on Win Line 437  This variable defaults to CMD.EXE on Win
437                (tramp-rcp-keep-date-arg    "-p")                (tramp-rcp-keep-date-arg    "-p")
438                (tramp-su-program           nil)                (tramp-su-program           nil)
439                (tramp-su-args              nil)                (tramp-su-args              nil)
               (tramp-encoding-command     nil)  
               (tramp-decoding-command     nil)  
               (tramp-encoding-function    nil)  
               (tramp-decoding-function    nil)  
440                (tramp-telnet-program       nil)                (tramp-telnet-program       nil)
441                (tramp-telnet-args          nil))                (tramp-telnet-args          nil))
442       ("fcp"         ("fcp"  
# Line 698  This variable defaults to CMD.EXE on Win Line 449  This variable defaults to CMD.EXE on Win
449                (tramp-rcp-keep-date-arg    "-p")                (tramp-rcp-keep-date-arg    "-p")
450                (tramp-su-program           nil)                (tramp-su-program           nil)
451                (tramp-su-args              nil)                (tramp-su-args              nil)
               (tramp-encoding-command     nil)  
               (tramp-decoding-command     nil)  
               (tramp-encoding-function    nil)  
               (tramp-decoding-function    nil)  
452                (tramp-telnet-program       nil)                (tramp-telnet-program       nil)
453                (tramp-telnet-args          nil))                (tramp-telnet-args          nil))
454       )       )
# Line 944  tilde expansion, all directory names sta Line 691  tilde expansion, all directory names sta
691    :type '(repeat string))    :type '(repeat string))
692    
693  (defcustom tramp-login-prompt-regexp  (defcustom tramp-login-prompt-regexp
694    ".*ogin: *$"    ".*ogin: *"
695    "*Regexp matching login-like prompts.    "*Regexp matching login-like prompts.
696  The regexp should match the whole line."  The regexp should match at end of buffer."
697    :group 'tramp    :group 'tramp
698    :type 'regexp)    :type 'regexp)
699    
700  (defcustom tramp-password-prompt-regexp  (defcustom tramp-password-prompt-regexp
701    "^.*\\([pP]assword\\|passphrase.*\\):\^@? *$"    "^.*\\([pP]assword\\|passphrase.*\\):\^@? *"
702    "*Regexp matching password-like prompts.    "*Regexp matching password-like prompts.
703  The regexp should match the whole line.  The regexp should match at end of buffer.
704    
705  The `sudo' program appears to insert a `^@' character into the prompt."  The `sudo' program appears to insert a `^@' character into the prompt."
706    :group 'tramp    :group 'tramp
# Line 962  The `sudo' program appears to insert a ` Line 709  The `sudo' program appears to insert a `
709  (defcustom tramp-wrong-passwd-regexp  (defcustom tramp-wrong-passwd-regexp
710    (concat "^.*\\(Permission denied.\\|Login [Ii]ncorrect\\|"    (concat "^.*\\(Permission denied.\\|Login [Ii]ncorrect\\|"
711            "Received signal [0-9]+\\|Connection \\(refused\\|closed\\)\\|"            "Received signal [0-9]+\\|Connection \\(refused\\|closed\\)\\|"
712            "Sorry, try again.\\|Name or service not known\\).*$")            "Sorry, try again.\\|Name or service not known\\).*")
713    "*Regexp matching a `login failed' message.    "*Regexp matching a `login failed' message.
714  The regexp should match the whole line."  The regexp should match at end of buffer."
715      :group 'tramp
716      :type 'regexp)
717    
718    (defcustom tramp-yesno-prompt-regexp
719      "Are you sure you want to continue connecting (yes/no)\\? *"
720      "Regular expression matching all queries which need to be confirmed.
721    The confirmation should be done with yes or no.
722    The regexp should match at end of buffer."
723    :group 'tramp    :group 'tramp
724    :type 'regexp)    :type 'regexp)
725    
# Line 999  shell from reading its init file." Line 754  shell from reading its init file."
754  ;; File name format.  ;; File name format.
755    
756  (defconst tramp-file-name-structure-unified  (defconst tramp-file-name-structure-unified
757    (list (concat "\\`/\\(\\([a-zA-Z0-9]+\\):\\)?" ;method    (list (concat "\\`/\\(\\([a-zA-Z0-9-]+\\):\\)?" ;method
758                        "\\(\\([^:@/]+\\)@\\)?" ;user                        "\\(\\([^:@/]+\\)@\\)?" ;user
759                        "\\([^:/]+\\):"   ;host                        "\\([^:/]+\\):"   ;host
760                        "\\(.*\\)\\'")    ;path                        "\\(.*\\)\\'")    ;path
# Line 1009  On Emacs (not XEmacs), the Tramp and Ang Line 764  On Emacs (not XEmacs), the Tramp and Ang
764  filename space.  This value is used for this unified namespace.")  filename space.  This value is used for this unified namespace.")
765    
766  (defconst tramp-file-name-structure-separate  (defconst tramp-file-name-structure-separate
767    (list (concat "\\`/\\[\\(\\([a-zA-Z0-9]+\\)/\\)?" ;method    (list (concat "\\`/\\[\\(\\([a-zA-Z0-9-]+\\)/\\)?" ;method
768                  "\\(\\([-a-zA-Z0-9_#/:]+\\)@\\)?" ;user                  "\\(\\([-a-zA-Z0-9_#/:]+\\)@\\)?" ;user
769                  "\\([-a-zA-Z0-9_#/:@.]+\\)\\]" ;host                  "\\([-a-zA-Z0-9_#/:@.]+\\)\\]" ;host
770                  "\\(.*\\)\\'")          ;path                  "\\(.*\\)\\'")          ;path
# Line 1282  but it might be slow on large directorie Line 1037  but it might be slow on large directorie
1037    :group 'tramp    :group 'tramp
1038    :type 'boolean)    :type 'boolean)
1039    
1040    (defcustom tramp-actions-before-shell
1041      '((tramp-password-prompt-regexp tramp-action-password)
1042        (tramp-login-prompt-regexp tramp-action-login)
1043        (shell-prompt-pattern tramp-action-succeed)
1044        (tramp-wrong-passwd-regexp tramp-action-permission-denied)
1045        (tramp-yesno-prompt-regexp tramp-action-yesno))
1046      "List of pattern/action pairs.
1047    Whenever a pattern matches, the corresponding action is performed.
1048    Each item looks like (PATTERN ACTION).
1049    
1050    The PATTERN should be a symbol, a variable.  The value of this
1051    variable gives the regular expression to search for.  Note that the
1052    regexp must match at the end of the buffer, \"\\'\" is implicitly
1053    appended to it.
1054    
1055    The ACTION should also be a symbol, but a function.  When the
1056    corresponding PATTERN matches, the ACTION function is called."
1057      :group 'tramp
1058      :type '(repeat (list variable function)))
1059    
1060    (defcustom tramp-multi-actions
1061      '((tramp-password-prompt-regexp tramp-multi-action-password)
1062        (tramp-login-prompt-regexp tramp-multi-action-login)
1063        (shell-prompt-pattern tramp-multi-action-succeed)
1064        (tramp-wrong-passwd-regexp tramp-multi-action-permission-denied))
1065      "List of pattern/action pairs.
1066    This list is used for each hop in multi-hop connections.
1067    See `tramp-actions-before-shell' for more info."
1068      :group 'tramp
1069      :type '(repeat (list variable function)))
1070    
1071  ;;; Internal Variables:  ;;; Internal Variables:
1072    
1073  (defvar tramp-buffer-file-attributes nil  (defvar tramp-buffer-file-attributes nil
# Line 1413  $s[7], $s[2], $s[1] >> 16 & 0xffff, $s[1 Line 1199  $s[7], $s[2], $s[1] >> 16 & 0xffff, $s[1
1199    "Perl script to produce output suitable for use with `file-attributes'    "Perl script to produce output suitable for use with `file-attributes'
1200  on the remote file system.")  on the remote file system.")
1201    
1202  ;; Perl script to implement `mime-encode'  ;; ;; These two use uu encoding.
1203  (defvar tramp-perl-mime-encode (concat  ;; (defvar tramp-perl-encode "%s -e'\
1204   "sub encode_base64 ($);  ;; print qq(begin 644 xxx\n);
1205    my $buf;  ;; my $s = q();
1206    while(read(STDIN, $buf, 60*57)) { print encode_base64($buf) }  ;; my $res = q();
1207    sub encode_base64 ($) {  ;; while (read(STDIN, $s, 45)) {
1208      my $res = \"\";  ;;     print pack(q(u), $s);
1209      my $eol = \"\n\";  ;; }
1210      pos($_[0]) = 0;                          # ensure start at the beginning  ;; print qq(`\n);
1211      while ($_[0] =~ /(.{1,45})/gs) {  ;; print qq(end\n);
1212          $res .= substr(pack(\"u\", $1), 1);  ;; '"
1213          chop($res);  ;;   "Perl program to use for encoding a file.
1214      }  ;; Escape sequence %s is replaced with name of Perl binary.")
1215      $res =~ tr|` -_|AA-Za-z0-9+/|;               # `# help emacs  
1216      # fix padding at the end  ;; (defvar tramp-perl-decode "%s -ne '
1217      my $padding = (3 - length($_[0]) % 3) % 3;  ;; print unpack q(u), $_;
1218      $res =~ s/.{$padding}$/\"=\" x $padding/e if $padding;  ;; '"
1219      # break encoded string into lines of no more than 76 characters each  ;;   "Perl program to use for decoding a file.
1220      if (length $eol) {  ;; Escape sequence %s is replaced with name of Perl binary.")
1221          $res =~ s/(.{1,76})/$1$eol/g;  
1222      }  ;; These two use base64 encoding.
1223      $res;}"))  (defvar tramp-perl-encode
1224      "perl -MMIME::Base64 -0777 -ne 'print encode_base64($_)'"
1225  ;; Perl script to implement `mime-decode'    "Perl program to use for encoding a file.
1226  (defvar tramp-perl-mime-decode (concat  Escape sequence %s is replaced with name of Perl binary.")
1227   "sub decode_base64 ($);  
1228    my $buf;  (defvar tramp-perl-decode
1229    while(read(STDIN, $buf, 60*57)) { print decode_base64($buf) }    "perl -MMIME::Base64 -0777 -ne 'print decode_base64($_)'"
1230    sub decode_base64 ($) {    "Perl program to use for decoding a file.
1231      local($^W) = 0; # unpack(\"u\",...) gives bogus warning in 5.00[123]  Escape sequence %s is replaced with name of Perl binary.")
   
     my $str = shift;  
     my $res = \"\";  
   
     $str =~ tr|A-Za-z0-9+=/||cd;            # remove non-base64 chars  
     if (length($str) % 4) {  
         warn(\"Length of base64 data not a multiple of 4\")  
     }  
     $str =~ s/=+$//;                        # remove padding  
     $str =~ tr|A-Za-z0-9+/| -_|;            # convert to uuencoded format  
     while ($str =~ /(.{1,60})/gs) {  
         my $len = chr(32 + length($1)*3/4); # compute length byte  
         $res .= unpack(\"u\", $len . $1 );    # uudecode  
     }  
     $res;}"))  
1232    
1233  ; These values conform to `file-attributes' from XEmacs 21.2.  ; These values conform to `file-attributes' from XEmacs 21.2.
1234  ; GNU Emacs and other tools not checked.  ; GNU Emacs and other tools not checked.
# Line 1486  This is used to map a mode number to a p Line 1257  This is used to map a mode number to a p
1257      'undecided-dos)      'undecided-dos)
1258    "Some Emacsen know the `dos' coding system, others need `undecided-dos'.")    "Some Emacsen know the `dos' coding system, others need `undecided-dos'.")
1259    
1260    (defvar tramp-last-cmd-time nil
1261      "Internal Tramp variable recording the time when the last cmd was sent.
1262    This variable is buffer-local in every buffer.")
1263    (make-variable-buffer-local 'tramp-last-cmd-time)
1264    
1265  ;; New handlers should be added here.  The following operations can be  ;; New handlers should be added here.  The following operations can be
1266  ;; handled using the normal primitives: file-name-as-directory,  ;; handled using the normal primitives: file-name-as-directory,
# Line 1537  This is used to map a mode number to a p Line 1312  This is used to map a mode number to a p
1312          "Alist of handler functions.          "Alist of handler functions.
1313  Operations not mentioned here will be handled by the normal Emacs functions.")  Operations not mentioned here will be handled by the normal Emacs functions.")
1314    
 ;;; For better error reporting.  
   
 (defun tramp-version (arg)  
   "Print version number of tramp.el in minibuffer or current buffer."  
   (interactive "P")  
   (if arg (insert tramp-version) (message tramp-version)))  
   
1315  ;;; Internal functions which must come first.  ;;; Internal functions which must come first.
1316    
1317  (defsubst tramp-message (level fmt-string &rest args)  (defsubst tramp-message (level fmt-string &rest args)
# Line 1833  target of the symlink differ." Line 1601  target of the symlink differ."
1601    "Like `file-attributes' for tramp files.    "Like `file-attributes' for tramp files.
1602  Optional argument NONNUMERIC means return user and group name  Optional argument NONNUMERIC means return user and group name
1603  rather than as numbers."  rather than as numbers."
1604    (if (tramp-handle-file-exists-p filename)    (let (result)
1605        ;; file exists, find out stuff      (with-parsed-tramp-file-name filename nil
1606        (save-excursion        (when (tramp-ange-ftp-file-name-p multi-method method)
1607          (with-parsed-tramp-file-name filename nil          (tramp-invoke-ange-ftp 'file-attributes filename))
1608            (when (tramp-ange-ftp-file-name-p multi-method method)        (when (tramp-handle-file-exists-p filename)
1609              (tramp-invoke-ange-ftp 'file-attributes file))          ;; file exists, find out stuff
1610            (save-excursion
1611            (if (tramp-get-remote-perl multi-method method user host)            (if (tramp-get-remote-perl multi-method method user host)
1612                (tramp-handle-file-attributes-with-perl                (setq result
1613                 multi-method method user host path nonnumeric)                      (tramp-handle-file-attributes-with-perl
1614              (tramp-handle-file-attributes-with-ls                       multi-method method user host path nonnumeric))
1615               multi-method method user host path nonnumeric))))              (setq result
1616      nil))                               ; no file                    (tramp-handle-file-attributes-with-ls
1617                       multi-method method user host path nonnumeric))))))
1618        result))
1619    
1620    
1621  (defun tramp-handle-file-attributes-with-ls  (defun tramp-handle-file-attributes-with-ls
# Line 1853  rather than as numbers." Line 1624  rather than as numbers."
1624    (let (symlinkp dirp    (let (symlinkp dirp
1625                   res-inode res-filemodes res-numlinks                   res-inode res-filemodes res-numlinks
1626                   res-uid res-gid res-size res-symlink-target)                   res-uid res-gid res-size res-symlink-target)
1627        (tramp-message-for-buffer multi-method method user host 10
1628                                  "file attributes with ls: %s"
1629                                  (tramp-make-tramp-file-name
1630                                   multi-method method user host path))
1631      (tramp-send-command      (tramp-send-command
1632       multi-method method user host       multi-method method user host
1633       (format "%s %s %s"       (format "%s %s %s"
# Line 1934  rather than as numbers." Line 1709  rather than as numbers."
1709    
1710  The Perl command is sent to the remote machine when the connection  The Perl command is sent to the remote machine when the connection
1711  is initially created and is kept cached by the remote shell."  is initially created and is kept cached by the remote shell."
1712      (tramp-message-for-buffer multi-method method user host 10
1713                                "file attributes with perl: %s"
1714                                (tramp-make-tramp-file-name
1715                                 multi-method method user host path))
1716    (tramp-send-command    (tramp-send-command
1717     multi-method method user host     multi-method method user host
1718     (format "tramp_file_attributes %s"     (format "tramp_file_attributes %s"
# Line 2204  if the remote host can't provide the mod Line 1983  if the remote host can't provide the mod
1983    
1984  ;; Directory listings.  ;; Directory listings.
1985    
1986  (defun tramp-handle-directory-files (directory &optional full match nosort)  (defun tramp-handle-directory-files (directory
1987                                         &optional full match nosort files-only)
1988    "Like `directory-files' for tramp files."    "Like `directory-files' for tramp files."
1989    (with-parsed-tramp-file-name directory nil    (with-parsed-tramp-file-name directory nil
1990      (when (tramp-ange-ftp-file-name-p multi-method method)      (when (tramp-ange-ftp-file-name-p multi-method method)
1991        (tramp-invoke-ange-ftp 'directory-files        (tramp-invoke-ange-ftp 'directory-files
1992                               directory full match nosort))                               directory full match nosort files-only))
1993      (let (result x)      (let (result x)
1994        (save-excursion        (save-excursion
1995          (tramp-barf-unless-okay          (tramp-barf-unless-okay
# Line 2235  if the remote host can't provide the mod Line 2015  if the remote host can't provide the mod
2015                        result)                        result)
2016                (push x result))))                (push x result))))
2017          (tramp-send-command multi-method method user host "cd")          (tramp-send-command multi-method method user host "cd")
2018          (tramp-wait-for-output))          (tramp-wait-for-output)
2019            ;; Remove non-files or non-directories if necessary.  Using
2020            ;; the remote shell for this would probably be way faster.
2021            ;; Maybe something could be adapted from
2022            ;; tramp-handle-file-name-all-completions.
2023            (when files-only
2024              (let ((temp (nreverse result))
2025                    item)
2026                (setq result nil)
2027                (if (equal files-only t)
2028                    ;; files only
2029                    (while temp
2030                      (setq item (pop temp))
2031                      (when (file-regular-p item)
2032                        (push item result)))
2033                  ;; directories only
2034                  (while temp
2035                    (setq item (pop temp))
2036                    (when (file-directory-p item)
2037                      (push item result)))))))
2038        result)))        result)))
2039    
2040  ;; This function should return "foo/" for directories and "bar" for  ;; This function should return "foo/" for directories and "bar" for
# Line 2494  If KEEP-DATE is non-nil, preserve the ti Line 2293  If KEEP-DATE is non-nil, preserve the ti
2293  ;; mkdir  ;; mkdir
2294  (defun tramp-handle-make-directory (dir &optional parents)  (defun tramp-handle-make-directory (dir &optional parents)
2295    "Like `make-directory' for tramp files."    "Like `make-directory' for tramp files."
2296      (setq dir (expand-file-name dir))
2297    (with-parsed-tramp-file-name dir nil    (with-parsed-tramp-file-name dir nil
2298      (when (tramp-ange-ftp-file-name-p multi-method method)      (when (tramp-ange-ftp-file-name-p multi-method method)
2299        (tramp-invoke-ange-ftp 'make-directory dir parents))        (tramp-invoke-ange-ftp 'make-directory dir parents))
# Line 2508  If KEEP-DATE is non-nil, preserve the ti Line 2308  If KEEP-DATE is non-nil, preserve the ti
2308  ;; CCC error checking?  ;; CCC error checking?
2309  (defun tramp-handle-delete-directory (directory)  (defun tramp-handle-delete-directory (directory)
2310    "Like `delete-directory' for tramp files."    "Like `delete-directory' for tramp files."
2311      (setq directory (expand-file-name directory))
2312    (with-parsed-tramp-file-name directory nil    (with-parsed-tramp-file-name directory nil
2313      (when (tramp-ange-ftp-file-name-p multi-method method)      (when (tramp-ange-ftp-file-name-p multi-method method)
2314        (tramp-invoke-ange-ftp 'delete-directory directory))        (tramp-invoke-ange-ftp 'delete-directory directory))
# Line 2520  If KEEP-DATE is non-nil, preserve the ti Line 2321  If KEEP-DATE is non-nil, preserve the ti
2321    
2322  (defun tramp-handle-delete-file (filename)  (defun tramp-handle-delete-file (filename)
2323    "Like `delete-file' for tramp files."    "Like `delete-file' for tramp files."
2324      (setq filename (expand-file-name filename))
2325    (with-parsed-tramp-file-name filename nil    (with-parsed-tramp-file-name filename nil
2326      (when (tramp-ange-ftp-file-name-p multi-method method)      (when (tramp-ange-ftp-file-name-p multi-method method)
2327        (tramp-invoke-ange-ftp 'delete-file filename))        (tramp-invoke-ange-ftp 'delete-file filename))
# Line 2601  This is like `dired-recursive-delete-dir Line 2403  This is like `dired-recursive-delete-dir
2403  (defun tramp-handle-insert-directory  (defun tramp-handle-insert-directory
2404    (filename switches &optional wildcard full-directory-p)    (filename switches &optional wildcard full-directory-p)
2405    "Like `insert-directory' for tramp files."    "Like `insert-directory' for tramp files."
2406      (setq filename (expand-file-name filename))
2407    (with-parsed-tramp-file-name filename nil    (with-parsed-tramp-file-name filename nil
2408      (when (tramp-ange-ftp-file-name-p multi-method method)      (when (tramp-ange-ftp-file-name-p multi-method method)
2409        (tramp-invoke-ange-ftp 'insert-directory        (tramp-invoke-ange-ftp 'insert-directory
# Line 2754  Doesn't do anything if the NAME does not Line 2557  Doesn't do anything if the NAME does not
2557    "Like `shell-command' for tramp files.    "Like `shell-command' for tramp files.
2558  This will break if COMMAND prints a newline, followed by the value of  This will break if COMMAND prints a newline, followed by the value of
2559  `tramp-end-of-output', followed by another newline."  `tramp-end-of-output', followed by another newline."
2560    (if (tramp-tramp-file-p default-directory)    (when (tramp-tramp-file-p default-directory)
2561        (with-parsed-tramp-file-name default-directory nil      (with-parsed-tramp-file-name default-directory nil
2562          (when (tramp-ange-ftp-file-name-p multi-method method)        (when (tramp-ange-ftp-file-name-p multi-method method)
2563            (let ((default-directory (tramp-make-ange-ftp-file-name          (let ((default-directory (tramp-make-ange-ftp-file-name
2564                                      user host path)))                                    user host path)))
2565              (tramp-invoke-ange-ftp 'shell-command            (tramp-invoke-ange-ftp 'shell-command
2566                                     command output-buffer error-buffer)))                                   command output-buffer error-buffer)))
2567          (let (status)        (let (status)
2568            (when (string-match "&[ \t]*\\'" command)          (when (string-match "&[ \t]*\\'" command)
2569              (error "Tramp doesn't grok asynchronous shell commands, yet"))            (error "Tramp doesn't grok asynchronous shell commands, yet"))
2570            (when error-buffer          (when error-buffer
2571              (error "Tramp doesn't grok optional third arg ERROR-BUFFER, yet"))            (error "Tramp doesn't grok optional third arg ERROR-BUFFER, yet"))
2572            (save-excursion          (save-excursion
2573              (tramp-barf-unless-okay            (tramp-barf-unless-okay
2574               multi-method method user host             multi-method method user host
2575               (format "cd %s" (tramp-shell-quote-argument path))             (format "cd %s" (tramp-shell-quote-argument path))
2576               nil 'file-error             nil 'file-error
2577               "tramp-handle-shell-command: Couldn't `cd %s'"             "tramp-handle-shell-command: Couldn't `cd %s'"
2578               (tramp-shell-quote-argument path))             (tramp-shell-quote-argument path))
2579              (tramp-send-command multi-method method user host            (tramp-send-command multi-method method user host
2580                                  (concat command "; tramp_old_status=$?"))                                (concat command "; tramp_old_status=$?"))
2581              ;; This will break if the shell command prints "/////"            ;; This will break if the shell command prints "/////"
2582              ;; somewhere.  Let's just hope for the best...            ;; somewhere.  Let's just hope for the best...
2583              (tramp-wait-for-output))            (tramp-wait-for-output))
2584            (unless output-buffer          (unless output-buffer
2585              (setq output-buffer (get-buffer-create "*Shell Command Output*"))            (setq output-buffer (get-buffer-create "*Shell Command Output*"))
             (set-buffer output-buffer)  
             (erase-buffer))  
           (unless (bufferp output-buffer)  
             (setq output-buffer (current-buffer)))  
2586            (set-buffer output-buffer)            (set-buffer output-buffer)
2587            (insert-buffer (tramp-get-buffer multi-method method user host))            (erase-buffer))
2588            (save-excursion          (unless (bufferp output-buffer)
2589              (tramp-send-command multi-method method user host "cd")            (setq output-buffer (current-buffer)))
2590              (tramp-wait-for-output)          (set-buffer output-buffer)
2591              (tramp-send-command          (insert-buffer (tramp-get-buffer multi-method method user host))
2592               multi-method method user host          (save-excursion
2593               (concat "tramp_set_exit_status $tramp_old_status;"            (tramp-send-command multi-method method user host "cd")
2594                       " echo tramp_exit_status $?"))            (tramp-wait-for-output)
2595              (tramp-wait-for-output)            (tramp-send-command
2596              (goto-char (point-max))             multi-method method user host
2597              (unless (search-backward "tramp_exit_status " nil t)             (concat "tramp_set_exit_status $tramp_old_status;"
2598                (error "Couldn't find exit status of `%s'" command))                     " echo tramp_exit_status $?"))
2599              (skip-chars-forward "^ ")            (tramp-wait-for-output)
2600              (setq status (read (current-buffer))))            (goto-char (point-max))
2601            (unless (zerop (buffer-size))            (unless (search-backward "tramp_exit_status " nil t)
2602              (pop-to-buffer output-buffer))              (error "Couldn't find exit status of `%s'" command))
2603            status)))            (skip-chars-forward "^ ")
2604              (setq status (read (current-buffer))))
2605            (unless (zerop (buffer-size))
2606              (pop-to-buffer output-buffer))
2607            status)))
2608    ;; The following is only executed if something strange was    ;; The following is only executed if something strange was
2609    ;; happening.  Emit a helpful message and do it anyway.    ;; happening.  Emit a helpful message and do it anyway.
2610    (message "tramp-handle-shell-command called with non-tramp directory: `%s'"    (message "tramp-handle-shell-command called with non-tramp directory: `%s'"
# Line 2828  This will break if COMMAND prints a newl Line 2631  This will break if COMMAND prints a newl
2631                 filename))                 filename))
2632        (setq tmpfil (tramp-make-temp-file))        (setq tmpfil (tramp-make-temp-file))
2633        (cond ((tramp-get-rcp-program multi-method method)        (cond ((tramp-get-rcp-program multi-method method)
2634               ;; Use tramp-like program for file transfer.               ;; Use rcp-like program for file transfer.
2635               (tramp-message-for-buffer               (tramp-message-for-buffer
2636                multi-method method user host                multi-method method user host
2637                5 "Fetching %s to tmp file %s..." filename tmpfil)                5 "Fetching %s to tmp file %s..." filename tmpfil)
# Line 2852  This will break if COMMAND prints a newl Line 2655  This will break if COMMAND prints a newl
2655               (tramp-message-for-buffer               (tramp-message-for-buffer
2656                multi-method method user host                multi-method method user host
2657                5 "Fetching %s to tmp file %s...done" filename tmpfil))                5 "Fetching %s to tmp file %s...done" filename tmpfil))
2658              ((and (tramp-get-encoding-command multi-method method)              ((and (tramp-get-encoding-command multi-method method user host)
2659                    (tramp-get-decoding-command multi-method method))                    (tramp-get-decoding-command multi-method method user host))
2660               ;; Use inline encoding for file transfer.               ;; Use inline encoding for file transfer.
2661               (save-excursion               (save-excursion
2662                 ;; Following line for setting tramp-current-method,                 ;; Following line for setting tramp-current-method,
# Line 2862  This will break if COMMAND prints a newl Line 2665  This will break if COMMAND prints a newl
2665                 (tramp-message 5 "Encoding remote file %s..." filename)                 (tramp-message 5 "Encoding remote file %s..." filename)
2666                 (tramp-barf-unless-okay                 (tramp-barf-unless-okay
2667                  multi-method method user host                  multi-method method user host
2668                  (concat (tramp-get-encoding-command multi-method method)                  (concat (tramp-get-encoding-command multi-method method user host)
2669                          " < " (tramp-shell-quote-argument path))                          " < " (tramp-shell-quote-argument path))
2670                  nil 'file-error                  nil 'file-error
2671                  "Encoding remote file failed, see buffer `%s' for details"                  "Encoding remote file failed, see buffer `%s' for details"
# Line 2872  This will break if COMMAND prints a newl Line 2675  This will break if COMMAND prints a newl
2675                 (delete-region (point) (progn (forward-line -1) (point)))                 (delete-region (point) (progn (forward-line -1) (point)))
2676    
2677                 (tramp-message 5 "Decoding remote file %s..." filename)                 (tramp-message 5 "Decoding remote file %s..." filename)
2678                 (if (and (tramp-get-decoding-function multi-method method)                 (if (and (tramp-get-decoding-function multi-method method user host)
2679                          (fboundp (tramp-get-decoding-function                          (fboundp (tramp-get-decoding-function
2680                                    multi-method method)))                                    multi-method method user host)))
2681                     ;; If tramp-decoding-function is defined for this                     ;; If tramp-decoding-function is defined for this
2682                     ;; method, we call it.                     ;; method, we call it.
2683                     (let ((tmpbuf (get-buffer-create " *tramp tmp*")))                     (let ((tmpbuf (get-buffer-create " *tramp tmp*")))
# Line 2886  This will break if COMMAND prints a newl Line 2689  This will break if COMMAND prints a newl
2689                        multi-method method user host                        multi-method method user host
2690                        6 "Decoding remote file %s with function %s..."                        6 "Decoding remote file %s with function %s..."
2691                        filename                        filename
2692                        (tramp-get-decoding-function multi-method method))                        (tramp-get-decoding-function multi-method method user host))
2693                       (set-buffer tmpbuf)                       (set-buffer tmpbuf)
2694                       (let ((coding-system-for-write 'no-conversion))                       (let ((coding-system-for-write 'no-conversion))
2695                         (funcall (tramp-get-decoding-function                         (funcall (tramp-get-decoding-function
2696                                   multi-method method)                                   multi-method method user host)
2697                                  (point-min)                                  (point-min)
2698                                  (point-max))                                  (point-max))
2699                         (write-region (point-min) (point-max) tmpfil))                         (write-region (point-min) (point-max) tmpfil))
# Line 2902  This will break if COMMAND prints a newl Line 2705  This will break if COMMAND prints a newl
2705                     (tramp-message                     (tramp-message
2706                      6 "Decoding remote file %s with command %s..."                      6 "Decoding remote file %s with command %s..."
2707                      filename                      filename
2708                      (tramp-get-decoding-command multi-method method))                      (tramp-get-decoding-command multi-method method user host))
2709                     (call-process                     (call-process
2710                      tramp-sh-program                      tramp-sh-program
2711                      tmpfil2             ;input                      tmpfil2             ;input
2712                      nil                 ;output                      nil                 ;output
2713                      nil                 ;display                      nil                 ;display
2714                      "-c" (concat (tramp-get-decoding-command                      "-c" (concat (tramp-get-decoding-command
2715                                    multi-method method)                                    multi-method method user host)
2716                                   " > " tmpfil))                                   " > " tmpfil))
2717                     (delete-file tmpfil2)))                     (delete-file tmpfil2)))
2718                 (tramp-message-for-buffer                 (tramp-message-for-buffer
# Line 2990  This will break if COMMAND prints a newl Line 2793  This will break if COMMAND prints a newl
2793      (let ((curbuf (current-buffer))      (let ((curbuf (current-buffer))
2794            (rcp-program (tramp-get-rcp-program multi-method method))            (rcp-program (tramp-get-rcp-program multi-method method))
2795            (rcp-args (tramp-get-rcp-args multi-method method))            (rcp-args (tramp-get-rcp-args multi-method method))
2796            (encoding-command (tramp-get-encoding-command multi-method  method))            (encoding-command
2797               (tramp-get-encoding-command multi-method method user host))
2798            (encoding-function            (encoding-function
2799             (tramp-get-encoding-function multi-method method))             (tramp-get-encoding-function multi-method method user host))
2800            (decoding-command (tramp-get-decoding-command multi-method method))            (decoding-command
2801               (tramp-get-decoding-command multi-method method user host))
2802            (trampbuf (get-buffer-create "*tramp output*"))            (trampbuf (get-buffer-create "*tramp output*"))
2803            ;; We use this to save the value of `last-coding-system-used'            ;; We use this to save the value of `last-coding-system-used'
2804            ;; after writing the tmp file.  At the end of the function,            ;; after writing the tmp file.  At the end of the function,
# Line 3253  necessary anymore." Line 3058  necessary anymore."
3058    
3059  (defun tramp-invoke-ange-ftp (operation &rest args)  (defun tramp-invoke-ange-ftp (operation &rest args)
3060    "Invoke the Ange-FTP handler function and throw."    "Invoke the Ange-FTP handler function and throw."
3061      (or ange-ftp-name-format (require 'ange-ftp))
3062    (let ((ange-ftp-name-format    (let ((ange-ftp-name-format
3063           (list (nth 0 tramp-file-name-structure)           (list (nth 0 tramp-file-name-structure)
3064                 (nth 3 tramp-file-name-structure)                 (nth 3 tramp-file-name-structure)
# Line 3650  Returns nil if none was found, else the Line 3456  Returns nil if none was found, else the
3456  ;; -- Functions for establishing connection --  ;; -- Functions for establishing connection --
3457  ;; ------------------------------------------------------------  ;; ------------------------------------------------------------
3458    
3459  (defun tramp-process-actions  ;; The following functions are actions to be taken when seeing certain
3460    (multi-method method user host actions &optional timeout)  ;; prompts from the remote host.  See the variable
3461    "Process given ACTIONS for login specified via first four args.  ;; `tramp-actions-before-shell' for usage of these functions.
3462  ACTIONS is a list of items (REGEXP FUN), where REGEXP specifies what  
3463  output from the remote end to look for, and FUN specifies the action  (defun tramp-action-login (p multi-method method user host)
3464  to take when the regexp matches."    "Send the login name."
3465    nil)    (tramp-message 9 "Sending login name `%s'"
3466                     (or user (user-login-name)))
3467      (erase-buffer)
3468      (process-send-string nil (concat (or user (user-login-name))
3469                                       tramp-rsh-end-of-line)))
3470    
3471    (defun tramp-action-password (p multi-method method user host)
3472      "Query the user for a password."
3473      (when (tramp-method-out-of-band-p multi-method method)
3474        (kill-process (get-buffer-process (current-buffer)))
3475        (error (concat "Out of band method `%s' not applicable "
3476                       "for remote shell asking for a password")
3477               method))
3478      (tramp-enter-password p (match-string 0)))
3479    
3480    (defun tramp-action-succeed (p multi-method method user host)
3481      "Signal success in finding shell prompt."
3482      (tramp-message 9 "Found remote shell prompt.")
3483      (erase-buffer)
3484      (throw 'tramp-action 'ok))
3485    
3486    (defun tramp-action-permission-denied (p multi-method method user host)
3487      "Signal permission denied."
3488      (tramp-message 9 "Permission denied by remote host.")
3489      (kill-process p)
3490      (erase-buffer)
3491      (throw 'tramp-action 'permission-denied))
3492    
3493    (defun tramp-action-yesno (p multi-method method user host)
3494      "Ask the user if he is sure."
3495      (save-window-excursion
3496        (pop-to-buffer (tramp-get-buffer multi-method method user host))
3497        (unless (yes-or-no-p (match-string 0))
3498          (kill-process p)
3499          (erase-buffer)
3500          (throw 'tramp-action 'permission-denied))
3501        (process-send-string p (concat "yes" tramp-rsh-end-of-line))
3502        (erase-buffer)))
3503    
3504    ;; The following functions are specifically for multi connections.
3505    
3506    (defun tramp-multi-action-login (p method user host)
3507      "Send the login name."
3508      (tramp-message 9 "Sending login name `%s'" user)
3509      (erase-buffer)
3510      (process-send-string p (concat user tramp-rsh-end-of-line)))
3511    
3512    (defun tramp-multi-action-password (p method user host)
3513      "Query the user for a password."
3514      (tramp-enter-password p (match-string 0)))
3515    
3516    (defun tramp-multi-action-succeed (p method user host)
3517      "Signal success in finding shell prompt."
3518      (tramp-message 9 "Found shell prompt on `%s'" host)
3519      (erase-buffer)
3520      (throw 'tramp-action 'ok))
3521    
3522    (defun tramp-multi-action-permission-denied (p method user host)
3523      "Signal permission denied."
3524      (tramp-message 9 "Permission denied by remote host `%s'" host)
3525      (kill-process p)
3526      (erase-buffer)
3527      (throw 'tramp-action 'permission-denied))
3528    
3529    ;; Functions for processing the actions.
3530    
3531    (defun tramp-process-one-action (p multi-method method user host actions)
3532      "Wait for output from the shell and perform one action."
3533      (let (found item pattern action todo)
3534        (erase-buffer)
3535        (tramp-message 9 "Waiting 60s for prompt from remote shell")
3536        (with-timeout (60 (throw 'tramp-action 'timeout))
3537          (while (not found)
3538            (accept-process-output p 1)
3539            (goto-char (point-min))
3540            (setq todo actions)
3541            (while todo
3542              (goto-char (point-min))
3543              (setq item (pop todo))
3544              (setq pattern (symbol-value (nth 0 item)))
3545              (setq action (nth 1 item))
3546              (tramp-message 10 "Looking for pattern %s" pattern)
3547              (when (re-search-forward (concat pattern "\\'") nil t)
3548                (setq found (funcall action p multi-method method user host)))))
3549          found)))
3550    
3551    (defun tramp-process-actions (p multi-method method user host actions)
3552      "Perform actions until success."
3553      (let (exit)
3554        (while (not exit)
3555          (tramp-message 10 "Processing actions")
3556          (setq exit
3557                (catch 'tramp-action
3558                  (tramp-process-one-action
3559                   p multi-method method user host actions)
3560                  nil)))
3561        (unless (eq exit 'ok)
3562          (error "Login failed"))))
3563    
3564    ;; For multi-actions.
3565    
3566    (defun tramp-process-one-multi-action (p method user host actions)
3567      "Wait for output from the shell and perform one action."
3568      (let (found item pattern action todo)
3569        (erase-buffer)
3570        (tramp-message 9 "Waiting 60s for prompt from remote shell")
3571        (with-timeout (60 (throw 'tramp-action 'timeout))
3572          (while (not found)
3573            (accept-process-output p 1)
3574            (setq todo actions)
3575            (goto-char (point-min))
3576            (while todo
3577              (goto-char (point-min))
3578              (setq item (pop todo))
3579              (setq pattern (symbol-value (nth 0 item)))
3580              (setq action (nth 1 item))
3581              (tramp-message 10 "Looking for pattern %s" pattern)
3582              (when (re-search-forward (concat pattern "\\'") nil t)
3583                (setq found (funcall action p method user host)))))
3584          found)))
3585    
3586    (defun tramp-process-multi-actions (p method user host actions)
3587      "Perform actions until success."
3588      (let (exit)
3589        (while (not exit)
3590          (setq exit
3591                (catch 'tramp-action
3592                  (tramp-process-one-multi-action p method user host actions)
3593                  nil)))
3594        (unless (eq exit 'ok)
3595          (error "Login failed"))))
3596    
3597    ;; The actual functions for opening connections.
3598    
3599  (defun tramp-open-connection-telnet (multi-method method user host)  (defun tramp-open-connection-telnet (multi-method method user host)
3600    "Open a connection using a telnet METHOD.    "Open a connection using a telnet METHOD.
# Line 3702  Maybe the different regular expressions Line 3640  Maybe the different regular expressions
3640               (found nil)               (found nil)
3641               (pw nil))               (pw nil))
3642          (process-kill-without-query p)          (process-kill-without-query p)
3643          (tramp-message 9 "Waiting for login prompt...")          (set-buffer (tramp-get-buffer multi-method method user host))
3644          (unless (tramp-wait-for-regexp p nil tramp-login-prompt-regexp)          (erase-buffer)
3645            (pop-to-buffer (buffer-name))          (tramp-process-actions p multi-method method user host
3646            (kill-process p)                                 tramp-actions-before-shell)
3647            (error "Couldn't find remote login prompt"))  
3648          (erase-buffer)  ;;         (tramp-message 9 "Waiting for login prompt...")
3649          ;; Remote login defaults to local one.  ;;         (unless (tramp-wait-for-regexp p nil tramp-login-prompt-regexp)
3650          (tramp-message 9 "Sending login name %s" (or user (user-login-name)))  ;;           (pop-to-buffer (buffer-name))
3651          (process-send-string p (concat (or user (user-login-name))  ;;           (kill-process p)
3652                                         tramp-rsh-end-of-line))  ;;           (error "Couldn't find remote login prompt"))
3653          (tramp-message 9 "Waiting for password prompt...")  ;;         (erase-buffer)
3654          (unless (setq found (tramp-wait-for-regexp  ;;         ;; Remote login defaults to local one.
3655                               p nil tramp-password-prompt-regexp))  ;;         (tramp-message 9 "Sending login name %s" (or user (user-login-name)))
3656            (pop-to-buffer (buffer-name))  ;;         (process-send-string p (concat (or user (user-login-name))
3657            (kill-process p)  ;;                                        tramp-rsh-end-of-line))
3658            (error "Couldn't find remote password prompt"))  ;;         (tramp-message 9 "Waiting for password prompt...")
3659          (erase-buffer)  ;;         (unless (setq found (tramp-wait-for-regexp
3660          (setq pw (tramp-read-passwd (car found)))  ;;                              p nil tramp-password-prompt-regexp))
3661          (tramp-message 9 "Sending password")  ;;           (pop-to-buffer (buffer-name))
3662          (process-send-string p (concat pw tramp-rsh-end-of-line))  ;;           (kill-process p)
3663          (tramp-message 9 "Waiting 30s for remote shell to come up...")  ;;           (error "Couldn't find remote password prompt"))
3664          (unless (setq found  ;;         (erase-buffer)
3665                        (tramp-wait-for-regexp  ;;         (setq pw (tramp-read-passwd (car found)))
3666                         p 30 (format "\\(%s\\)\\|\\(%s\\)\\'"  ;;         (tramp-message 9 "Sending password")
3667                                      tramp-wrong-passwd-regexp  ;;         (process-send-string p (concat pw tramp-rsh-end-of-line))
3668                                      shell-prompt-pattern)))  ;;         (tramp-message 9 "Waiting 30s for remote shell to come up...")
3669            (pop-to-buffer (buffer-name))  ;;         (unless (setq found
3670            (kill-process p)  ;;                       (tramp-wait-for-regexp
3671            (error "Couldn't find remote shell prompt"))  ;;                        p 30 (format "\\(%s\\)\\|\\(%s\\)\\'"
3672          (when (nth 1 found)  ;;                                     tramp-wrong-passwd-regexp
3673            (pop-to-buffer (buffer-name))  ;;                                     shell-prompt-pattern)))
3674            (kill-process p)  ;;           (pop-to-buffer (buffer-name))
3675            (error "Login failed: %s" (nth 1 found)))  ;;           (kill-process p)
3676    ;;           (error "Couldn't find remote shell prompt"))
3677    ;;         (when (nth 1 found)
3678    ;;           (pop-to-buffer (buffer-name))
3679    ;;           (kill-process p)
3680    ;;           (error "Login failed: %s" (nth 1 found)))
3681    
3682          (tramp-open-connection-setup-interactive-shell          (tramp-open-connection-setup-interactive-shell
3683           p multi-method method user host)           p multi-method method user host)
3684          (tramp-post-connection multi-method method user host)))))          (tramp-post-connection multi-method method user host)))))
3685    
3686  ;; HHH: Changed to handle the case when USER is nil.              
3687  (defun tramp-open-connection-rsh (multi-method method user host)  (defun tramp-open-connection-rsh (multi-method method user host)
3688    "Open a connection using an rsh METHOD.    "Open a connection using an rsh METHOD.
3689  This starts the command `rsh HOST -l USER'[*], then waits for a remote  This starts the command `rsh HOST -l USER'[*], then waits for a remote
# Line 3794  arguments, and xx will be used as the ho Line 3738  arguments, and xx will be used as the ho
3738                           host rsh-args)))                           host rsh-args)))
3739               (found nil))               (found nil))
3740          (process-kill-without-query p)          (process-kill-without-query p)
3741          (tramp-message 9 "Waiting 60s for shell or passwd prompt from %s" host)  
3742          (setq found          (set-buffer buf)
3743                (tramp-wait-for-regexp          (tramp-process-actions p multi-method method user host
3744                 p 60                                 tramp-actions-before-shell)
3745                 (format  
3746                  "\\(%s\\)\\|\\(%s\\)\\'"  ;;         (tramp-message 9 "Waiting 60s for shell or passwd prompt from %s" host)
3747                  tramp-password-prompt-regexp  ;;         (setq found
3748                  shell-prompt-pattern)))  ;;               (tramp-wait-for-regexp
3749          (unless found  ;;                p 60
3750            (pop-to-buffer (buffer-name))  ;;                (format
3751            (kill-process p)  ;;                 "\\(%s\\)\\|\\(%s\\)\\'"
3752            (error "Couldn't find remote shell or passwd prompt"))  ;;                 tramp-password-prompt-regexp
3753          (when (nth 1 found)  ;;                 shell-prompt-pattern)))
3754            (when (tramp-method-out-of-band-p multi-method method)  ;;         (unless found
3755              (pop-to-buffer (buffer-name))  ;;           (pop-to-buffer (buffer-name))
3756              (kill-process p)  ;;           (kill-process p)
3757              (error (concat "Out of band method `%s' not applicable"  ;;           (error "Couldn't find remote shell or passwd prompt"))
3758                             " for remote shell asking for a password")  ;;         (when (nth 1 found)
3759                     method))  ;;           (when (tramp-method-out-of-band-p multi-method method)
3760            (erase-buffer)  ;;             (pop-to-buffer (buffer-name))
3761            (tramp-message 9 "Sending password...")  ;;             (kill-process p)
3762            (tramp-enter-password p (nth 1 found))  ;;             (error (concat "Out of band method `%s' not applicable"
3763            (tramp-message 9 "Sent password, waiting 60s for remote shell prompt")  ;;                            " for remote shell asking for a password")
3764            (setq found (tramp-wait-for-regexp p 60  ;;                    method))
3765                                               (format "\\(%s\\)\\|\\(%s\\)\\'"  ;;           (erase-buffer)
3766                                                       tramp-wrong-passwd-regexp  ;;           (tramp-message 9 "Sending password...")
3767                                                       shell-prompt-pattern))))  ;;           (tramp-enter-password p (nth 1 found))
3768          (unless found  ;;           (tramp-message 9 "Sent password, waiting 60s for remote shell prompt")
3769            (pop-to-buffer (buffer-name))  ;;           (setq found (tramp-wait-for-regexp p 60
3770            (kill-process p)  ;;                                              (format "\\(%s\\)\\|\\(%s\\)\\'"
3771            (error "Couldn't find remote shell prompt"))  ;;                                                      tramp-wrong-passwd-regexp
3772          (when (nth 1 found)  ;;                                                      shell-prompt-pattern))))
3773            (pop-to-buffer (buffer-name))  ;;         (unless found
3774            (kill-process p)  ;;           (pop-to-buffer (buffer-name))
3775            (error "Login failed: %s" (nth 1 found)))  ;;           (kill-process p)
3776    ;;           (error "Couldn't find remote shell prompt"))
3777    ;;         (when (nth 1 found)
3778    ;;           (pop-to-buffer (buffer-name))
3779    ;;           (kill-process p)
3780    ;;           (error "Login failed: %s" (nth 1 found)))
3781    
3782          (tramp-message 7 "Initializing remote shell")          (tramp-message 7 "Initializing remote shell")
3783          (tramp-open-connection-setup-interactive-shell          (tramp-open-connection-setup-interactive-shell
3784           p multi-method method user host)           p multi-method method user host)
3785          (tramp-post-connection multi-method method user host)))))          (tramp-post-connection multi-method method user host)))))
3786    
 ;; HHH: Changed.  Now utilizes (or user (user-login-name)) instead of USER.  
3787  (defun tramp-open-connection-su (multi-method method user host)  (defun tramp-open-connection-su (multi-method method user host)
3788    "Open a connection using the `su' program with METHOD.    "Open a connection using the `su' program with METHOD.
3789  This starts `su - USER', then waits for a password prompt.  The HOST  This starts `su - USER', then waits for a password prompt.  The HOST
# Line 3868  at all unlikely that this variable is se Line 3817  at all unlikely that this variable is se
3817                                                    (> emacs-major-version 20))                                                    (> emacs-major-version 20))
3818                                         tramp-dos-coding-system))                                         tramp-dos-coding-system))
3819               (p (apply 'start-process               (p (apply 'start-process
3820                         (tramp-buffer-name multi-method method                         (tramp-buffer-name multi-method method user host)
3821                                            user host)                         (tramp-get-buffer multi-method method user host)
                        (tramp-get-buffer multi-method method  
                                          user host)  
3822                         (tramp-get-su-program multi-method method)                         (tramp-get-su-program multi-method method)
3823                         (mapcar                         (mapcar
3824                          '(lambda (x)                          '(lambda (x)
3825                             (format-spec x `((?u ,user))))                             (format-spec x `((?u . ,user))))
3826                          (tramp-get-su-args multi-method method))))                          (tramp-get-su-args multi-method method))))
3827               (found nil)               (found nil)
3828               (pw nil))               (pw nil))
3829          (process-kill-without-query p)          (process-kill-without-query p)
3830          (tramp-message 9 "Waiting 30s for shell or password prompt...")          (set-buffer (tramp-get-buffer multi-method method user host))
3831          (unless (setq found (tramp-wait-for-regexp          (tramp-process-actions p multi-method method user host
3832                               p 30                                 tramp-actions-before-shell)
3833                               (format "\\(%s\\)\\|\\(%s\\)\\'"  
3834                                       tramp-password-prompt-regexp  ;;         (tramp-message 9 "Waiting 30s for shell or password prompt...")
3835                                       shell-prompt-pattern)))  ;;         (unless (setq found (tramp-wait-for-regexp
3836            (pop-to-buffer (buffer-name))  ;;                              p 30
3837            (kill-process p)  ;;                              (format "\\(%s\\)\\|\\(%s\\)\\'"
3838            (error "Couldn't find shell or password prompt"))  ;;                                      tramp-password-prompt-regexp
3839          (when (nth 1 found)  ;;                                      shell-prompt-pattern)))
3840            (erase-buffer)  ;;           (pop-to-buffer (buffer-name))
3841            (setq pw (tramp-read-passwd (car found)))  ;;           (kill-process p)
3842            (tramp-message 9 "Sending password")  ;;           (error "Couldn't find shell or password prompt"))
3843            (process-send-string p (concat pw tramp-rsh-end-of-line))  ;;         (when (nth 1 found)
3844            (tramp-message 9 "Waiting 30s for remote shell to come up...")  ;;           (erase-buffer)
3845            (unless (setq found  ;;           (setq pw (tramp-read-passwd (car found)))
3846                          (tramp-wait-for-regexp  ;;           (tramp-message 9 "Sending password")
3847                           p 30 (format "\\(%s\\)\\|\\(%s\\)\\'"  ;;           (process-send-string p (concat pw tramp-rsh-end-of-line))
3848                                        tramp-wrong-passwd-regexp  ;;           (tramp-message 9 "Waiting 30s for remote shell to come up...")
3849                                        shell-prompt-pattern)))  ;;           (unless (setq found
3850              (pop-to-buffer (buffer-name))  ;;                         (tramp-wait-for-regexp
3851              (kill-process p)  ;;                          p 30 (format "\\(%s\\)\\|\\(%s\\)\\'"
3852              (error "Couldn't find remote shell prompt"))  ;;                                       tramp-wrong-passwd-regexp
3853            (when (nth 1 found)  ;;                                       shell-prompt-pattern)))
3854              (pop-to-buffer (buffer-name))  ;;             (pop-to-buffer (buffer-name))
3855              (kill-process p)  ;;             (kill-process p)
3856              (error "`su' failed: %s" (nth 1 found))))  ;;             (error "Couldn't find remote shell prompt"))
3857    ;;           (when (nth 1 found)
3858    ;;             (pop-to-buffer (buffer-name))
3859    ;;             (kill-process p)
3860    ;;             (error "`su' failed: %s" (nth 1 found))))
3861    
3862          (tramp-open-connection-setup-interactive-shell          (tramp-open-connection-setup-interactive-shell
3863           p multi-method method user host)           p multi-method method user host)
3864          (tramp-post-connection multi-method method          (tramp-post-connection multi-method method
# Line 3990  set in `tramp-rsh-end-of-line'.  Use `%% Line 3942  set in `tramp-rsh-end-of-line'.  Use `%%
3942  character.  character.
3943    
3944  If USER is nil, uses the return value of (user-login-name) instead."  If USER is nil, uses the return value of (user-login-name) instead."
3945    (let ((cmd (format-spec command `((?h ,host) (?n ,tramp-rsh-end-of-line))))    (let ((cmd (format-spec command
3946          (cmd1 (format-spec command `((?h ,host) (?n ""))))                            `((?h . ,host) (?n . ,tramp-rsh-end-of-line))))
3947            (cmd1 (format-spec command `((?h . ,host) (?n . ""))))
3948          found pw)          found pw)
3949      (erase-buffer)      (erase-buffer)
3950      (tramp-message 9 "Sending telnet command `%s'" cmd1)      (tramp-message 9 "Sending telnet command `%s'" cmd1)
3951      (process-send-string p cmd)      (process-send-string p cmd)
3952      (tramp-message 9 "Waiting 30s for login prompt from %s" host)      (tramp-process-multi-actions p method user host
3953      (unless (tramp-wait-for-regexp p 30 tramp-login-prompt-regexp)                                   tramp-multi-actions)
3954        (pop-to-buffer (buffer-name))  
3955        (kill-process p)  ;;     (tramp-message 9 "Waiting 30s for login prompt from %s" host)
3956        (error "Couldn't find login prompt from host %s" host))  ;;     (unless (tramp-wait-for-regexp p 30 tramp-login-prompt-regexp)
3957      (erase-buffer)  ;;       (pop-to-buffer (buffer-name))
3958      (tramp-message 9 "Sending login name %s" (or user (user-login-name)))  ;;       (kill-process p)
3959      (process-send-string p (concat (or user (user-login-name)) tramp-rsh-end-of-line))  ;;       (error "Couldn't find login prompt from host %s" host))
3960      (tramp-message 9 "Waiting for password prompt")  ;;     (erase-buffer)
3961      (unless (setq found (tramp-wait-for-regexp p nil tramp-password-prompt-regexp))  ;;     (tramp-message 9 "Sending login name %s" (or user (user-login-name)))
3962        (pop-to-buffer (buffer-name))  ;;     (process-send-string p (concat (or user (user-login-name)) tramp-rsh-end-of-line))
3963        (kill-process p)  ;;     (tramp-message 9 "Waiting for password prompt")
3964        (error "Couldn't find password prompt from host %s" host))  ;;     (unless (setq found (tramp-wait-for-regexp p nil tramp-password-prompt-regexp))
3965      (erase-buffer)  ;;       (pop-to-buffer (buffer-name))
3966      (setq pw (tramp-read-passwd  ;;       (kill-process p)
3967                (format "Password for %s@%s, %s" (or user (user-login-name)) host found)))  ;;       (error "Couldn't find password prompt from host %s" host))
3968      (tramp-message 9 "Sending password")  ;;     (erase-buffer)
3969      (process-send-string p (concat pw tramp-rsh-end-of-line))  ;;     (setq pw (tramp-read-passwd
3970      (tramp-message 9 "Waiting 60s for remote shell to come up...")  ;;               (format "Password for %s@%s, %s" (or user (user-login-name)) host found)))
3971      (unless (setq found (tramp-wait-for-regexp  ;;     (tramp-message 9 "Sending password")
3972                           p 60 (format "\\(%s\\)\\|\\(%s\\)\\'"  ;;     (process-send-string p (concat pw tramp-rsh-end-of-line))
3973                                        tramp-wrong-passwd-regexp  ;;     (tramp-message 9 "Waiting 60s for remote shell to come up...")
3974                                        shell-prompt-pattern)))  ;;     (unless (setq found (tramp-wait-for-regexp
3975        (pop-to-buffer (buffer-name))  ;;                          p 60 (format "\\(%s\\)\\|\\(%s\\)\\'"
3976        (kill-process p)  ;;                                       tramp-wrong-passwd-regexp
3977        (error "Couldn't find shell prompt from host %s" host))  ;;                                       shell-prompt-pattern)))
3978      (when (nth 1 found)  ;;       (pop-to-buffer (buffer-name))
3979        (pop-to-buffer (buffer-name))  ;;       (kill-process p)
3980        (kill-process p)  ;;       (error "Couldn't find shell prompt from host %s" host))
3981        (error "Login to %s failed: %s" (nth 2 found)))))  ;;     (when (nth 1 found)
3982    ;;       (pop-to-buffer (buffer-name))
3983    ;;       (kill-process p)
3984    ;;       (error "Login to %s failed: %s" (nth 2 found)))
3985        ))
3986    
3987  ;; HHH: Changed.  Multi method.  Don't know how to handle this in the case  ;; HHH: Changed.  Multi method.  Don't know how to handle this in the case
3988  ;;      of no user name provided.  Hack to make it work as it did before:    ;;      of no user name provided.  Hack to make it work as it did before:  
# Line 4040  will be replaced with the value of `tram Line 3997  will be replaced with the value of `tram
3997  `%%' if you want to use a literal percent character.  `%%' if you want to use a literal percent character.
3998    
3999  If USER is nil, uses the return value of (user-login-name) instead."  If USER is nil, uses the return value of (user-login-name) instead."
4000    (let ((cmd (format-spec command `((?h ,host)    (let ((cmd (format-spec command `((?h . ,host)
4001                                      (?u ,(or user (user-login-name)))                                      (?u . ,(or user (user-login-name)))
4002                                      (?n ,tramp-rsh-end-of-line))))                                      (?n . ,tramp-rsh-end-of-line))))
4003          (cmd1 (format-spec command `((?h ,host)          (cmd1 (format-spec command `((?h . ,host)
4004                                       (?u ,(or user (user-login-name)))                                       (?u . ,(or user (user-login-name)))
4005                                       (?n ""))))                                       (?n . ""))))
4006          found)          found)
4007      (erase-buffer)      (erase-buffer)
4008      (tramp-message 9 "Sending rlogin command `%s'" cmd1)      (tramp-message 9 "Sending rlogin command `%s'" cmd1)
4009      (process-send-string p cmd)      (process-send-string p cmd)
4010      (tramp-message 9 "Waiting 60s for shell or passwd prompt from %s" host)      (tramp-process-multi-actions p method user host
4011      (unless (setq found                                   tramp-multi-actions)
4012                    (tramp-wait-for-regexp p 60  ;;     (tramp-message 9 "Waiting 60s for shell or passwd prompt from %s" host)
4013                                         (format "\\(%s\\)\\|\\(%s\\)\\'"  ;;     (unless (setq found
4014                                                 tramp-password-prompt-regexp  ;;                   (tramp-wait-for-regexp p 60
4015                                                 shell-prompt-pattern)))  ;;                                        (format "\\(%s\\)\\|\\(%s\\)\\'"
4016        (pop-to-buffer (buffer-name))  ;;                                                tramp-password-prompt-regexp
4017        (kill-process p)  ;;                                                shell-prompt-pattern)))
4018        (error "Couldn't find remote shell or passwd prompt"))  ;;       (pop-to-buffer (buffer-name))
4019      (when (nth 1 found)  ;;       (kill-process p)
4020        (erase-buffer)  ;;       (error "Couldn't find remote shell or passwd prompt"))
4021        (tramp-message 9 "Sending password...")  ;;     (when (nth 1 found)
4022        (tramp-enter-password p (nth 1 found))  ;;       (erase-buffer)
4023        (tramp-message 9 "Sent password, waiting 60s for remote shell prompt")  ;;       (tramp-message 9 "Sending password...")
4024        (setq found (tramp-wait-for-regexp p 60  ;;       (tramp-enter-password p (nth 1 found))
4025                                           (format "\\(%s\\)\\|\\(%s\\)\\'"  ;;       (tramp-message 9 "Sent password, waiting 60s for remote shell prompt")
4026                                                   tramp-wrong-passwd-regexp  ;;       (setq found (tramp-wait-for-regexp p 60
4027                                                   shell-prompt-pattern))))  ;;                                          (format "\\(%s\\)\\|\\(%s\\)\\'"
4028      (unless found  ;;                                                  tramp-wrong-passwd-regexp
4029        (pop-to-buffer (buffer-name))  ;;                                                  shell-prompt-pattern))))
4030        (kill-process p)  ;;     (unless found
4031        (error "Couldn't find remote shell prompt"))  ;;       (pop-to-buffer (buffer-name))
4032      (when (nth 1 found)  ;;       (kill-process p)
4033        (pop-to-buffer (buffer-name))  ;;       (error "Couldn't find remote shell prompt"))
4034        (kill-process p)  ;;     (when (nth 1 found)
4035        (error "Login failed: %s" (nth 1 found)))))  ;;       (pop-to-buffer (buffer-name))
4036    ;;       (kill-process p)
4037    ;;       (error "Login failed: %s" (nth 1 found)))
4038        ))
4039    
4040  ;; HHH: Changed.  Multi method.  Don't know how to handle this in the case  ;; HHH: Changed.  Multi method.  Don't know how to handle this in the case
4041  ;;      of no user name provided.  Hack to make it work as it did before:    ;;      of no user name provided.  Hack to make it work as it did before:  
# Line 4093  You can use percent escapes in the COMMA Line 4053  You can use percent escapes in the COMMA
4053  user name, and `%n' is replaced with the value of  user name, and `%n' is replaced with the value of
4054  `tramp-rsh-end-of-line'.  Use `%%' if you want a literal percent  `tramp-rsh-end-of-line'.  Use `%%' if you want a literal percent
4055  character."  character."
4056    (let ((cmd (format-spec command `((?u ,(or user (user-login-name)))    (let ((cmd (format-spec command `((?u . ,(or user (user-login-name)))
4057                                      (?n ,tramp-rsh-end-of-line))))                                      (?n . ,tramp-rsh-end-of-line))))
4058          (cmd1 (format-spec command `((?u ,(or user (user-login-name)))          (cmd1 (format-spec command `((?u . ,(or user (user-login-name)))
4059                                       (?n ""))))                                       (?n . ""))))
4060          found)          found)
4061      (erase-buffer)      (erase-buffer)
4062      (tramp-message 9 "Sending su command `%s'" cmd1)      (tramp-message 9 "Sending su command `%s'" cmd1)
4063      (process-send-string p cmd)      (process-send-string p cmd)
4064      (tramp-message 9 "Waiting 60s for shell or passwd prompt for %s" (or user (user-login-name)))      (tramp-process-multi-actions p method user host
4065      (unless (setq found (tramp-wait-for-regexp                                   tramp-multi-actions)
4066                           p 60 (format "\\(%s\\)\\|\\(%s\\)\\'"  ;;     (tramp-message 9 "Waiting 60s for shell or passwd prompt for %s" (or user (user-login-name)))
4067                                        tramp-password-prompt-regexp  ;;     (unless (setq found (tramp-wait-for-regexp
4068                                        shell-prompt-pattern)))  ;;                          p 60 (format "\\(%s\\)\\|\\(%s\\)\\'"
4069        (pop-to-buffer (buffer-name))  ;;                                       tramp-password-prompt-regexp
4070        (kill-process p)  ;;                                       shell-prompt-pattern)))
4071        (error "Couldn't find shell or passwd prompt for %s"  ;;       (pop-to-buffer (buffer-name))
4072               (or user (user-login-name))))  ;;       (kill-process p)
4073      (when (nth 1 found)  ;;       (error "Couldn't find shell or passwd prompt for %s"
4074        (tramp-message 9 "Sending password...")  ;;           (or user (user-login-name))))
4075        (tramp-enter-password p (nth 1 found))  ;;     (when (nth 1 found)
4076        (erase-buffer)  ;;       (tramp-message 9 "Sending password...")
4077        (tramp-message 9 "Sent password, waiting 60s for remote shell prompt")  ;;       (tramp-enter-password p (nth 1 found))
4078        (setq found (tramp-wait-for-regexp p 60  ;;       (erase-buffer)
4079                                         (format "\\(%s\\)\\|\\(%s\\)\\'"  ;;       (tramp-message 9 "Sent password, waiting 60s for remote shell prompt")
4080                                                 tramp-wrong-passwd-regexp  ;;       (setq found (tramp-wait-for-regexp p 60
4081                                                 shell-prompt-pattern))))  ;;                                        (format "\\(%s\\)\\|\\(%s\\)\\'"
4082      (unless found  ;;                                                tramp-wrong-passwd-regexp
4083        (pop-to-buffer (buffer-name))  ;;                                                shell-prompt-pattern))))
4084        (kill-process p)  ;;     (unless found
4085        (error "Couldn't find remote shell prompt"))  ;;       (pop-to-buffer (buffer-name))
4086      (when (nth 1 found)  ;;       (kill-process p)
4087        (pop-to-buffer (buffer-name))  ;;       (error "Couldn't find remote shell prompt"))
4088        (kill-process p)  ;;     (when (nth 1 found)
4089        (error "Login failed: %s" (nth 1 found)))))  ;;       (pop-to-buffer (buffer-name))
4090    ;;       (kill-process p)
4091    ;;       (error "Login failed: %s" (nth 1 found)))
4092        ))
4093    
4094  ;; Utility functions.  ;; Utility functions.
4095    
# Line 4176  nil." Line 4139  nil."
4139    "Prompt for a password and send it to the remote end.    "Prompt for a password and send it to the remote end.
4140  Uses PROMPT as a prompt and sends the password to process P."  Uses PROMPT as a prompt and sends the password to process P."
4141    (let ((pw (tramp-read-passwd prompt)))    (let ((pw (tramp-read-passwd prompt)))
4142        (erase-buffer)
4143      (process-send-string p (concat pw tramp-rsh-end-of-line))))      (process-send-string p (concat pw tramp-rsh-end-of-line))))
4144    
4145  ;; HHH: Not Changed.  This might handle the case where USER is not  ;; HHH: Not Changed.  This might handle the case where USER is not
# Line 4435  locale to C and sets up the remote shell Line 4399  locale to C and sets up the remote shell
4399                   " -e '" tramp-perl-file-attributes "' $1 2>/dev/null\n"                   " -e '" tramp-perl-file-attributes "' $1 2>/dev/null\n"
4400                   "}"))                   "}"))
4401          (tramp-wait-for-output)          (tramp-wait-for-output)
4402          (when (string= (tramp-get-encoding-command multi-method method)          (tramp-message 5 "Sending the Perl `mime-encode' implementation.")
4403                         "tramp_mimencode")          (tramp-send-linewise
4404            (tramp-message 5 "Sending the Perl `mime-encode' implementation.")           multi-method method user host
4405            (tramp-send-linewise           (concat "tramp_encode () {\n"
4406             multi-method method user host                   (format tramp-perl-encode tramp-remote-perl)
4407             (concat "tramp_mimencode () {\n"                   " 2>/dev/null"
4408                     (if (tramp-find-executable multi-method method user host                   "\n}"))
4409                                                "mimencode"  tramp-remote-path t)          (tramp-wait-for-output)
4410                         "mimencode -b $1"          (tramp-message 5 "Sending the Perl `mime-decode' implementation.")
4411                       (concat tramp-remote-perl          (tramp-send-linewise
4412                               " -e '" tramp-perl-mime-encode "' $1 2>/dev/null"))           multi-method method user host
4413                     "\n}"))           (concat "tramp_decode () {\n"
4414            (tramp-wait-for-output))                   (format tramp-perl-decode tramp-remote-perl)
4415          (when (string= (tramp-get-decoding-command multi-method method)                   " 2>/dev/null"
4416                         "tramp_mimedecode")                   "\n}"))
4417            (tramp-message 5 "Sending the Perl `mime-decode' implementation.")          (tramp-wait-for-output))))
           (tramp-send-linewise  
            multi-method method user host  
            (concat "tramp_mimedecode () {\n"  
                    (if (tramp-find-executable multi-method method user host  
                                               "mimencode"  tramp-remote-path t)  
                        "mimencode -u -b $1"  
                      (concat tramp-remote-perl  
                              " -e '" tramp-perl-mime-decode "' $1 2>/dev/null"))  
                    "\n}"))  
           (tramp-wait-for-output)))))  
4418    ;; Find ln(1)    ;; Find ln(1)
4419    (erase-buffer)    (erase-buffer)
4420    (let ((ln (tramp-find-executable multi-method method user host    (let ((ln (tramp-find-executable multi-method method user host
# Line 4468  locale to C and sets up the remote shell Line 4422  locale to C and sets up the remote shell
4422      (when ln      (when ln
4423        (tramp-set-connection-property "ln" ln multi-method method user host)))        (tramp-set-connection-property "ln" ln multi-method method user host)))
4424    (erase-buffer)    (erase-buffer)
4425      ;; Find the right encoding/decoding commands to use.
4426      (unless (tramp-get-rcp-program multi-method method)
4427        (tramp-find-inline-encoding multi-method method user host))
4428    ;; If encoding/decoding command are given, test to see if they work.    ;; If encoding/decoding command are given, test to see if they work.
4429    ;; CCC: Maybe it would be useful to run the encoder both locally and    ;; CCC: Maybe it would be useful to run the encoder both locally and
4430    ;; remotely to see if they produce the same result.    ;; remotely to see if they produce the same result.
4431    (let ((decoding (tramp-get-decoding-command multi-method method))    (let ((decoding (tramp-get-decoding-command multi-method method user host))
4432          (encoding (tramp-get-encoding-command multi-method method))          (encoding (tramp-get-encoding-command multi-method method user host))
4433          (magic-string "xyzzy"))          (magic-string "xyzzy"))
4434      (when (and (or decoding encoding) (not (and decoding encoding)))      (when (and (or decoding encoding) (not (and decoding encoding)))
4435        (tramp-kill-process multi-method method user host)        (tramp-kill-process multi-method method user host)
# Line 4495  locale to C and sets up the remote shell Line 4452  locale to C and sets up the remote shell
4452        (tramp-message        (tramp-message
4453         5 "Checking to see if encoding/decoding commands work on remote host...done"))))         5 "Checking to see if encoding/decoding commands work on remote host...done"))))
4454    
4455    ;; CCC: We should either implement a Perl version of base64 encoding
4456    ;; and decoding.  Then we just use that in the last item.  The other
4457    ;; alternative is to use the Perl version of UU encoding.  But then
4458    ;; we need a Lisp version of uuencode.
4459    (defvar tramp-coding-commands
4460      '(("mimencode -b" "mimencode -u -b"
4461         base64-encode-region base64-decode-region)
4462        ("mmencode -b" "mmencode -u -b"
4463         base64-encode-region base64-decode-region)
4464        ("recode data..base64" "recode base64..data"
4465         base64-encode-region base64-decode-region)
4466        ("uuencode xxx" "uudecode -o -"
4467         nil uudecode-decode-region)
4468        ("uuencode xxx" "uudecode -p"
4469         nil uudecode-decode-region)
4470        ("tramp_encode" "tramp_decode"
4471         base64-encode-region base64-decode-region))
4472      "List of coding commands for inline transfer.
4473    Each item is a list (ENCODING-COMMAND DECODING-COMMAND
4474    ENCODING-FUNCTION DECODING-FUNCTION).
4475    
4476    Each item can be a string, giving a command, or a symbol, giving
4477    a function.
4478    
4479    The ENCODING-COMMAND should be a command accepting a plain file on
4480    standard input and writing the encoded file to standard output.  The
4481    DECODING-COMMAND should be a command accepting an encoded file on
4482    standard input and writing the decoded file to standard output.
4483    
4484    The ENCODING-FUNCTION and DECODING-FUNCTION functions will be called
4485    with two arguments, start and end of region, and are expected to
4486    replace the region contents with the encoded or decoded results,
4487    respectively.")
4488    
4489    (defun tramp-find-inline-encoding (multi-method method user host)
4490      "Find an inline transfer encoding that works.
4491    Goes through the list `tramp-coding-commands'."
4492      (let ((commands tramp-coding-commands)
4493            item found)
4494        (while (and commands (null found))
4495          (setq item (pop commands))
4496          (catch 'wont-work
4497            (let ((ec (nth 0 item))
4498                  (dc (nth 1 item))
4499                  (ef (nth 2 item))
4500                  (df (nth 3 item)))
4501              ;; Check if encoding and decoding commands can be called
4502              ;; remotely with null input and output.  This makes sure there
4503              ;; are no syntax errors and the command is really found.
4504              (tramp-message-for-buffer
4505               multi-method method user host 10
4506               "Checking remote encoding command `%s' for sanity" ec)
4507              (unless (zerop (tramp-send-command-and-check
4508                              multi-method method user host
4509                              (format "%s </dev/null >/dev/null" ec) t))
4510                (throw 'wont-work nil))
4511              (tramp-message-for-buffer
4512               multi-method method user host 10
4513               "Checking remote decoding command `%s' for sanity" dc)
4514              (unless (zerop (tramp-send-command-and-check
4515                              multi-method method user host
4516                              (format "%s </dev/null >/dev/null" dc) t))
4517                (throw 'wont-work nil))
4518              ;; If no encoding/decoding function is given, the
4519              ;; corresponding encoding/decoding command also has to work
4520              ;; locally.
4521              (when (not (fboundp ef))
4522                (tramp-message-for-buffer
4523                 multi-method method user host 10
4524                 "Checking local encoding command `%s' for sanity" ec)
4525                (unless (zerop (call-process
4526                                tramp-sh-program ;program
4527                                nil         ;input
4528                                nil         ;output buffer
4529                                nil         ;redisplay
4530                                "-c"
4531                                (format "%s </dev/null >/dev/null" ec)))
4532                  (throw 'wont-work nil)))
4533              (when (not (fboundp df))
4534                (tramp-message-for-buffer
4535                 multi-method method user host 10
4536                 "Checking local decoding command `%s' for sanity" dc)
4537                (unless (zerop (call-process
4538                                tramp-sh-program ;program
4539                                nil         ;input file
4540                                nil         ;output buffer
4541                                nil         ;redisplay
4542                                "-c"
4543                                (format "%s </dev/null >/dev/null" dc)))
4544                  (throw 'wont-work nil)))
4545              ;; CCC: At this point, maybe we should check that the output
4546              ;; of the commands is correct.  But for the moment we will
4547              ;; assume that commands working on empty input will also
4548              ;; work in practice.
4549              (setq found item))))
4550        ;; Did we find something?  If not, issue error.  If so,
4551        ;; set connection properties.
4552        (unless found
4553          (error "Couldn't find an inline transfer encoding"))
4554        (let ((ec (nth 0 found))
4555              (dc (nth 1 found))
4556              (ef (nth 2 found))
4557              (df (nth 3 found)))
4558          (tramp-set-encoding-command multi-method method user host ec)
4559          (tramp-set-decoding-command multi-method method user host dc)
4560          (tramp-set-encoding-function multi-method method user host ef)
4561          (tramp-set-decoding-function multi-method method user host df))))
4562              
4563    
4564  (defun tramp-maybe-open-connection (multi-method method user host)  (defun tramp-maybe-open-connection (multi-method method user host)
4565    "Maybe open a connection to HOST, logging in as USER, using METHOD.    "Maybe open a connection to HOST, logging in as USER, using METHOD.
4566  Does not do anything if a connection is already open, but re-opens the  Does not do anything if a connection is already open, but re-opens the
4567  connection if a previous connection has died for some reason."  connection if a previous connection has died for some reason."
4568    (let ((p (get-buffer-process (tramp-get-buffer multi-method method user host))))    (let ((p (get-buffer-process (tramp-get-buffer multi-method method user host)))
4569      (unless (and p          last-cmd-time)
4570                   (processp p)      ;; If too much time has passed since last command was sent, look
4571                   (memq (process-status p) '(run open)))      ;; whether process is still alive.  If it isn't, kill it.  When
4572        ;; using ssh, it can sometimes happen that the remote end has hung
4573        ;; up but the local ssh client doesn't recognize this until it
4574        ;; tries to send some data to the remote end.  So that's why we
4575        ;; try to send a command from time to time, then look again
4576        ;; whether the process is really alive.
4577        (save-excursion
4578          (set-buffer (tramp-get-buffer multi-method method user host))
4579          (when (and tramp-last-cmd-time
4580                     (> (tramp-time-diff tramp-last-cmd-time (current-time)) 60))
4581            (process-send-string p (concat "echo hello" tramp-rsh-end-of-line))
4582            (unless (accept-process-output p 2)
4583              (delete-process p)
4584              (setq p nil))
4585            (erase-buffer)))
4586        (unless (and p (processp p) (memq (process-status p) '(run open)))
4587        (when (and p (processp p))        (when (and p (processp p))
4588          (delete-process p))          (delete-process p))
4589        (funcall (tramp-get-connection-function multi-method method)        (funcall (tramp-get-connection-function multi-method method)
# Line 4515  connection if a previous connection has Line 4595  connection if a previous connection has
4595  Erases temporary buffer before sending the command (unless NOERASE  Erases temporary buffer before sending the command (unless NOERASE
4596  is true)."  is true)."
4597    (tramp-maybe-open-connection multi-method method user host)    (tramp-maybe-open-connection multi-method method user host)
4598      (setq tramp-last-cmd-time (current-time))
4599    (when tramp-debug-buffer    (when tramp-debug-buffer
4600      (save-excursion      (save-excursion
4601        (set-buffer (tramp-get-debug-buffer multi-method method user host))        (set-buffer (tramp-get-debug-buffer multi-method method user host))
# Line 4927  remote path name." Line 5008  remote path name."
5008        (tramp-make-tramp-multi-file-name multi-method method user host path)        (tramp-make-tramp-multi-file-name multi-method method user host path)
5009      (if user      (if user
5010          (format-spec tramp-make-tramp-file-format          (format-spec tramp-make-tramp-file-format
5011                       `((?m ,method) (?u ,user) (?h ,host) (?p ,path)))                       `((?m . ,method) (?u . ,user) (?h . ,host) (?p . ,path)))
5012        (format-spec tramp-make-tramp-file-user-nil-format        (format-spec tramp-make-tramp-file-user-nil-format
5013                     `((?m ,method) (?h ,host) (?p ,path))))))                     `((?m . ,method) (?h . ,host) (?p . ,path))))))
5014    
5015  ;; CCC: Henrik Holm: Not Changed.  Multi Method.  What should be done  ;; CCC: Henrik Holm: Not Changed.  Multi Method.  What should be done
5016  ;; with this when USER is nil?  ;; with this when USER is nil?
# Line 4940  remote path name." Line 5021  remote path name."
5021    (let* ((prefix-format (nth 0 tramp-make-multi-tramp-file-format))    (let* ((prefix-format (nth 0 tramp-make-multi-tramp-file-format))
5022           (hop-format    (nth 1 tramp-make-multi-tramp-file-format))           (hop-format    (nth 1 tramp-make-multi-tramp-file-format))
5023           (path-format   (nth 2 tramp-make-multi-tramp-file-format))           (path-format   (nth 2 tramp-make-multi-tramp-file-format))
5024           (prefix (format-spec prefix-format `((?m ,multi-method))))           (prefix (format-spec prefix-format `((?m . ,multi-method))))
5025           (hops "")           (hops "")
5026           (path (format-spec path-format `((?p ,path))))           (path (format-spec path-format `((?p . ,path))))
5027           (i 0)           (i 0)
5028           (len (length method)))           (len (length method)))
5029      (while (< i len)      (while (< i len)
5030        (let ((m (aref method i)) (u (aref user i)) (h (aref host i)))        (let ((m (aref method i)) (u (aref user i)) (h (aref host i)))
5031          (setq hops (concat hops (format-spec hop-format          (setq hops (concat hops (format-spec hop-format
5032                                               `((?m ,m) (?u ,u) (?h ,h)))))                                               `((?m . ,m) (?u . ,u) (?h . ,h)))))
5033          (incf i)))          (incf i)))
5034      (concat prefix hops path)))      (concat prefix hops path)))
5035    
# Line 4997  to enter a password for the `tramp-rcp-p Line 5078  to enter a password for the `tramp-rcp-p
5078    (tramp-get-connection-property "ln" nil multi-method method user host))    (tramp-get-connection-property "ln" nil multi-method method user host))
5079    
5080  ;; Get a property of a TRAMP connection.  ;; Get a property of a TRAMP connection.
5081  (defun tramp-get-connection-property (property default multi-method method user host)  (defun tramp-get-connection-property
5082      (property default multi-method method user host)
5083    "Get the named property for the connection.    "Get the named property for the connection.
5084  If the value is not set for the connection, return `default'"  If the value is not set for the connection, return `default'"
5085    (tramp-maybe-open-connection multi-method method user host)    (tramp-maybe-open-connection multi-method method user host)
# Line 5008  If the value is not set for the connecti Line 5090  If the value is not set for the connecti
5090          (error  default)))))          (error  default)))))
5091    
5092  ;; Set a property of a TRAMP connection.  ;; Set a property of a TRAMP connection.
5093  (defun tramp-set-connection-property (property value multi-method method user host)  (defun tramp-set-connection-property
5094      (property value multi-method method user host)
5095    "Set the named property of a TRAMP connection."    "Set the named property of a TRAMP connection."
5096    (tramp-maybe-open-connection multi-method method user host)    (tramp-maybe-open-connection multi-method method user host)
5097    (with-current-buffer (tramp-get-buffer multi-method method user host)    (with-current-buffer (tramp-get-buffer multi-method method user host)
# Line 5016  If the value is not set for the connecti Line 5099  If the value is not set for the connecti
5099            (intern (concat "tramp-connection-property-" property)))            (intern (concat "tramp-connection-property-" property)))
5100            value)))            value)))
5101    
5102    ;; Some predefined connection properties.
5103    (defun tramp-get-encoding-command (multi-method method user host)
5104      (tramp-get-connection-property "encoding-command" nil
5105                                     multi-method method user host))
5106    (defun tramp-set-encoding-command (multi-method method user host command)
5107      (tramp-set-connection-property "encoding-command" command
5108                                     multi-method method user host))
5109    (defun tramp-get-decoding-command (multi-method method user host)
5110      (tramp-get-connection-property "decoding-command" nil
5111                                     multi-method method user host))
5112    (defun tramp-set-decoding-command (multi-method method user host command)
5113      (tramp-set-connection-property "decoding-command" command
5114                                     multi-method method user host))
5115    (defun tramp-get-encoding-function (multi-method method user host)
5116      (tramp-get-connection-property "encoding-function" nil
5117                                     multi-method method user host))
5118    (defun tramp-set-encoding-function (multi-method method user host func)
5119      (tramp-set-connection-property "encoding-function" func
5120                                     multi-method method user host))
5121    (defun tramp-get-decoding-function (multi-method method user host)
5122      (tramp-get-connection-property "decoding-function" nil
5123                                     multi-method method user host))
5124    (defun tramp-set-decoding-function (multi-method method user host func)
5125      (tramp-set-connection-property "decoding-function" func
5126                                     multi-method method user host))
5127    
5128    
5129  (defun tramp-get-connection-function (multi-method method)  (defun tramp-get-connection-function (multi-method method)
# Line 5081  If the value is not set for the connecti Line 5189  If the value is not set for the connecti
5189                (error "Method `%s' didn't specify su args"                (error "Method `%s' didn't specify su args"
5190                       (or multi-method method)))))                       (or multi-method method)))))
5191    
 (defun tramp-get-encoding-command (multi-method method)  
   (second (or (assoc 'tramp-encoding-command  
                      (assoc (or multi-method method tramp-default-method)  
                             tramp-methods))  
               (error "Method `%s' didn't specify an encoding command"  
                      (or multi-method method)))))  
   
 (defun tramp-get-decoding-command (multi-method method)  
   (second (or (assoc 'tramp-decoding-command  
                      (assoc (or multi-method method tramp-default-method)  
                             tramp-methods))  
               (error "Method `%s' didn't specify a decoding command"  
                      (or multi-method method)))))  
   
 (defun tramp-get-encoding-function (multi-method method)  
   (second (or (assoc 'tramp-encoding-function  
                      (assoc (or multi-method method tramp-default-method)  
                             tramp-methods))  
               (error "Method `%s' didn't specify an encoding function"  
                      (or multi-method method)))))  
   
 (defun tramp-get-decoding-function (multi-method method)  
   (second (or (assoc 'tramp-decoding-function  
                      (assoc (or multi-method method tramp-default-method)  
                             tramp-methods))  
               (error "Method `%s' didn't specify a decoding function"  
                      (or multi-method method)))))  
   
5192  (defun tramp-get-telnet-program (multi-method method)  (defun tramp-get-telnet-program (multi-method method)
5193    (second (or (assoc 'tramp-telnet-program    (second (or (assoc 'tramp-telnet-program
5194                       (assoc (or multi-method method tramp-default-method)                       (assoc (or multi-method method tramp-default-method)
# Line 5123  If the value is not set for the connecti Line 5203  If the value is not set for the connecti
5203                (error "Method `%s' didn't specify telnet args"                (error "Method `%s' didn't specify telnet args"
5204                       (or multi-method method)))))                       (or multi-method method)))))
5205    
5206    ;; (defun tramp-get-encoding-command (multi-method method)
5207    ;;   (second (or (assoc 'tramp-encoding-command
5208    ;;                      (assoc (or multi-method method tramp-default-method)
5209    ;;                             tramp-methods))
5210    ;;               (error "Method `%s' didn't specify an encoding command"
5211    ;;                      (or multi-method method)))))
5212    
5213    ;; (defun tramp-get-decoding-command (multi-method method)
5214    ;;   (second (or (assoc 'tramp-decoding-command
5215    ;;                      (assoc (or multi-method method tramp-default-method)
5216    ;;                             tramp-methods))
5217    ;;               (error "Method `%s' didn't specify a decoding command"
5218    ;;                      (or multi-method method)))))
5219    
5220    ;; (defun tramp-get-encoding-function (multi-method method)
5221    ;;   (second (or (assoc 'tramp-encoding-function
5222    ;;                      (assoc (or multi-method method tramp-default-method)
5223    ;;                             tramp-methods))
5224    ;;               (error "Method `%s' didn't specify an encoding function"
5225    ;;                      (or multi-method method)))))
5226    
5227    ;; (defun tramp-get-decoding-function (multi-method method)
5228    ;;   (second (or (assoc 'tramp-decoding-function
5229    ;;                      (assoc (or multi-method method tramp-default-method)
5230    ;;                             tramp-methods))
5231    ;;               (error "Method `%s' didn't specify a decoding function"
5232    ;;                      (or multi-method method)))))
5233    
5234  ;; Auto saving to a special directory.  ;; Auto saving to a special directory.
5235    
5236  (defun tramp-make-auto-save-file-name (fn)  (defun tramp-make-auto-save-file-name (fn)
# Line 5348  Only works for Bourne-like shells." Line 5456  Only works for Bourne-like shells."
5456          (setq ad-return-value (or res (list name)))))))          (setq ad-return-value (or res (list name)))))))
5457  ;;  )  ;;  )
5458    
5459    ;; Tramp version is useful in a number of situations.
5460    
5461    (defun tramp-version (arg)
5462      "Print version number of tramp.el in minibuffer or current buffer."
5463      (interactive "P")
5464      (if arg (insert tramp-version) (message tramp-version)))
5465    
5466  ;; Make the `reporter` functionality available for making bug reports about  ;; Make the `reporter` functionality available for making bug reports about
5467  ;; the package. A most useful piece of code.  ;; the package. A most useful piece of code.
5468    

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26