Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Adam Spiers <emacs <at> adamspiers.org>
Subject: ControlPersist breaks scpc method
Newsgroups: gmane.emacs.tramp
Date: Sunday 18th March 2012 20:43:12 UTC (over 5 years ago)
If ControlPersist is enabled in the user's ssh config, then use of
tramp's scpc method will result in a failure to create a new ssh
control master:

    19:24:58.114056 tramp-maybe-open-connection (3) # Opening
connection for example.org using scpc...
    19:24:58.115427 tramp-get-connection-property (7) # process-buffer nil
    19:24:58.117322 tramp-maybe-open-connection (6) # /bin/sh
    19:24:58.118014 tramp-get-connection-property (7) # check-remote-echo
nil
    19:24:58.118397 tramp-get-connection-property (7) # check-remote-echo
nil
    19:24:58.118941 tramp-accept-process-output (10) # *tramp/scpc
example.org* run
    19:24:58.122775 tramp-accept-process-output (10) #
    #$
    19:24:58.123209 tramp-get-connection-property (7) # check-remote-echo
nil
    19:24:58.123624 tramp-get-connection-property (7) # check-remote-echo
nil
    19:24:58.124020 tramp-wait-for-regexp (6) #
    #$
    19:24:58.124501 tramp-get-file-property (8) #  gateway nil
    19:24:58.125120 tramp-set-connection-property (7) # temp-file
/tmp/tramp.5471Xnt
    19:24:58.160803 tramp-maybe-open-connection (3) # Sending command
`exec ssh   -o ControlPath=/tmp/tramp.5471Xnt.%r@%h:%p -o
ControlMaster=yes -e none example.org'
    19:24:58.161281 tramp-get-connection-property (7) # process-name nil
    19:24:58.161851 tramp-get-connection-property (7) # remote-echo nil
    19:24:58.162188 tramp-send-command (6) # exec ssh   -o
ControlPath=/tmp/tramp.5471Xnt.%r@%h:%p -o ControlMaster=yes -e none
example.org
    19:24:58.162560 tramp-get-connection-property (7) # process-name nil
    19:24:58.162987 tramp-get-connection-property (7) # chunksize nil
    19:24:58.163386 tramp-set-connection-property (7) # last-cmd-time
(20326 13962 163181)
    19:24:58.163826 tramp-send-string (10) # exec ssh   -o
ControlPath=/tmp/tramp.5471Xnt.%r@%h:%p -o ControlMaster=yes -e none
example.org
    19:24:58.164171 tramp-get-connection-property (7) # process-buffer nil
    19:24:58.210133 tramp-set-connection-property (7) #
first-password-request t
    19:24:58.213936 tramp-process-actions (3) # Waiting for prompts
from remote shell
    19:24:58.214428 tramp-accept-process-output (10) # *tramp/scpc
example.org* run
    19:24:58.697631 tramp-accept-process-output (10) #
    Failed to connect to new control master^M

    Process *tramp/scpc example.org* exited abnormally with code 255

Here's the output from running the same ssh command manually, with
`-vvvvvv' added for extra debug:

    [snip]
    debug1: setting up multiplex master socket
    debug2: fd 4 setting O_NONBLOCK
    debug3: fd 4 is O_NONBLOCK
    debug3: fd 4 is O_NONBLOCK
    debug1: channel 0: new [[email protected]:22]
    debug3: muxserver_listen: mux listener channel 0 fd 4
    debug1: control_persist_detach: backgrounding master process
    debug2: control_persist_detach: background process is 24376
    Failed to connect to new control master
    debug1: forking to background
    debug1: Entering interactive session.
    debug2: set_control_persist_exit_time: schedule exit in 30 seconds

It's pretty clear what's happening - enabling ControlPersist causes
the new master connection to be backgrounded, which is the exact
opposite of what tramp wants.  I assume that a similar problem exists
for any other method which uses ssh with ControlMaster enabled.

Here's a patch against CVS for what I believe to be the correct fix.
However I don't know the tramp source at all, so it will need peer
review.

Index: lisp/tramp-sh.el
===================================================================
RCS file: /sources/tramp/tramp/lisp/tramp-sh.el,v
retrieving revision 2.65
diff -u -r2.65 tramp-sh.el
--- lisp/tramp-sh.el	1 Mar 2012 08:46:16 -0000	2.65
+++ lisp/tramp-sh.el	18 Mar 2012 20:11:20 -0000
@@ -162,6 +162,7 @@
     (tramp-login-program        "ssh")
     (tramp-login-args           (("-l" "%u") ("-p" "%p")
 				 ("-o" "ControlPath=%t.%%r@%%h:%%p")
+				 ("-o" "ControlPersist=no")
 				 ("-o" "ControlMaster=yes")
 				 ("-e" "none") ("%h")))
     (tramp-async-args           (("-q")))
 
CD: 3ms