Re: Unexpected "recover" from non-existing tramp-login-program

Michael Albinus <[email protected]>
Newsgroups gmane.emacs.tramp
Message-ID <[email protected]>
Tim Landscheidt <[email protected]> writes:

> Hi,

Hi Tim,

> while working with docker-tramp 0.1.1 and not setting
> docker-tramp-docker-executable correctly on a Fedora system,

First of all, docker-tramp from M(?)ELPA is deprecated. Since Tramp 2.6
(Eamcs 29), Tramp has an own implementation for docker containers.

This offers also the method "podman" which you might need on Fedora.

> I noticed this odd behaviour:
>
> | ELISP> (add-to-list 'tramp-methods
> |                     '("test-dne"
> |                       (tramp-login-program "does-not-exist")
> |                       (tramp-login-args (nil ("exec" "-it") ("-u" "%u") ("%h") ("sh")))
> |                       (tramp-remote-shell "/bin/sh")
> |                       (tramp-remote-shell-args ("-i" "-c"))))
> | (("test-dne"
> |   (tramp-login-program "does-not-exist")
> |   (tramp-login-args
> |    (nil
> |     ("exec" "-it")
> |     ("-u" "%u")
> |     ("%h")
> |     ("sh")))
> |   (tramp-remote-shell "/bin/sh")
> |   (tramp-remote-shell-args
> |    ("-i" "-c")))
> |  […])
>
> | ELISP> (find-file "/test-dne:does-not-exist-either:/etc/passwd")
> | #<buffer passwd>
> | ELISP>
>
> The resulting buffer will contain the contents of
> /etc/passwd on the primary system (well, there are no
> others :-)).

I've tried this with Emacs 29.2 (Tramp 2.6.2), and the result is
slightly better: it is an empty buffer #<buffer passwd>, and there is
the error message "Use M-x make-directory RET RET to create the
directory and its parents". Default directory is
"/test-dne:does-not-exist-either:/etc/", which is correct.

> My assumption is that technically this is not an error as
> with the great power that Emacs gives to the user comes
> great responsibility to set one's variables properly :-).

Indeed, as always with Emacs :-)

> I have not debugged where this behaviour is rooted and
> whether it can be "fixed" easily, but if TRAMP can detect
> that the call to tramp-login-program fails, it would be nice
> if it could croak.

Well, we could do something like this. Does this work for you?


> Tim

Best regards, Michael.
(unnamed) (text/x-patch, 529 B)
diff --git a/lisp/tramp-sh.el b/lisp/tramp-sh.el
index 38925652..1301cd63 100644
--- a/lisp/tramp-sh.el
+++ b/lisp/tramp-sh.el
@@ -5340,7 +5340,7 @@ connection if a previous connection has died for some reason."
 			    "2>" (tramp-get-remote-null-device previous-hop))
 			?l (concat remote-shell " " extra-args " -i"))
 		       ;; A restricted shell does not allow "exec".
-		       (when r-shell '("&&" "exit" "||" "exit")))
+		       (when r-shell '("&&" "exit")) '("||" "exit"))
 		      " "))

 		    ;; Send the command.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.