Subject: Re: bug#63578: 29.0.91; Org Cannot tangle with tramp using sudo

From: Michael Albinus <[email-masked]>
Date: Sat, 20 May 2023 18:50:46 +0200

Michael Albinus <[email-masked]> writes:

Hi Kostadin,

> Thanks, I can reproduce the problem now. Let's see what analysis yields.

The problem happens, when tramp-add-hops is called with a
tramp-file-name structure which has not expanded the default user and
host names yet, like in "/sudo::". The appended patch should fix it,
could you pls check in your environment?

Since the change is very basic to Tramp, I'll let run all regression
tests for Tramp. This will take 2-3 days. I'll let you know.

Best regards, Michael.

diff --git a/lisp/tramp.el b/lisp/tramp.el
index b70fd95a..90e497a9 100644
--- a/lisp/tramp.el
+++ b/lisp/tramp.el
@@ -1692,8 +1692,9 @@ The structure consists of method, user, domain, host, port,
 localname (file name on remote host), and hop.

 Unless NODEFAULT is non-nil, method, user and host are expanded
-to their default values.  For the other file name parts, no
-default values are used."
+to their default values.  Hop is set to nil if NODEFAULT is non-nil.
+
+For the other file name parts, no default values are used."
   (save-match-data
     (unless (tramp-tramp-file-p name)
       (tramp-user-error nil "Not a Tramp file name: \"%s\"" name))
@@ -1719,7 +1720,8 @@ default values are used."
 	  (when (string-match tramp-postfix-ipv6-regexp host)
 	    (setq host (replace-match "" nil t host))))

-	(unless nodefault
+	(if nodefault
+	    (setq hop nil)
 	  (when hop
 	    (setq v (tramp-dissect-hop-name hop)
 		  hop (and hop (tramp-make-tramp-hop-name v))))