Function: tramp-ssh-controlmaster-options

tramp-ssh-controlmaster-options is a byte-compiled function defined in tramp-sh.el.gz.

Signature

(tramp-ssh-controlmaster-options VEC)

Documentation

Return the Control* arguments of the local ssh.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp-sh.el.gz
(defun tramp-ssh-controlmaster-options (vec)
  "Return the Control* arguments of the local ssh."
  (cond
   ;; No options to be computed.
   ((or (null tramp-use-ssh-controlmaster-options)
	(null (assoc "%c" (tramp-get-method-parameter vec 'tramp-login-args))))
    "")

   ;; There is already a value to be used.
   ((stringp tramp-ssh-controlmaster-options) tramp-ssh-controlmaster-options)

   ;; Determine the options.
   (t (setq tramp-ssh-controlmaster-options "")
      (let ((case-fold-search t))
	(ignore-errors
	  (with-tramp-progress-reporter
	      vec 4 "Computing ControlMaster options"
	    ;; We use a non-existing IP address, in order to avoid
	    ;; useless connections, and DNS timeouts.
	    (when (zerop
		   (tramp-call-process
		    vec "ssh" nil nil nil
		    "-G" "-o" "ControlMaster=auto" "0.0.0.1"))
	      (setq tramp-ssh-controlmaster-options
		    "-o ControlMaster=auto")
	      (if (zerop
		   (tramp-call-process
		    vec "ssh" nil nil nil
		    "-G" "-o" "ControlPath=tramp.%C" "0.0.0.1"))
		  (setq tramp-ssh-controlmaster-options
			(concat tramp-ssh-controlmaster-options
				" -o ControlPath=tramp.%%C"))
		(setq tramp-ssh-controlmaster-options
		      (concat tramp-ssh-controlmaster-options
			      " -o ControlPath=tramp.%%r@%%h:%%p")))
	      (when (zerop
		     (tramp-call-process
		      vec "ssh" nil nil nil
		      "-G" "-o" "ControlPersist=no" "0.0.0.1"))
		(setq tramp-ssh-controlmaster-options
		      (concat tramp-ssh-controlmaster-options
			      " -o ControlPersist=no")))))))
      tramp-ssh-controlmaster-options)))