]> git.eshelyaron.com Git - emacs.git/commitdiff
Handle wrong login program in Tramp
authorMichael Albinus <michael.albinus@gmx.de>
Sun, 28 Jan 2024 09:31:45 +0000 (10:31 +0100)
committerEshel Yaron <me@eshelyaron.com>
Wed, 31 Jan 2024 20:13:13 +0000 (21:13 +0100)
* lisp/net/tramp-sh.el (tramp-maybe-open-connection): Exit remote
shell when login fails.

(cherry picked from commit e11c9f9c6e843779c4b69097490dd78de522a79d)

lisp/net/tramp-sh.el

index 84912bdfe6a288e07a282355b291e292a3babfb5..526cc6e3fd2319791c862aa68c132a1472a1d8c9 100644 (file)
@@ -5342,13 +5342,28 @@ connection if a previous connection has died for some reason."
                          :method l-method :user l-user :domain l-domain
                          :host l-host :port l-port)))
 
-                     ;; Set session timeout.
-                     (when (tramp-get-method-parameter
-                            hop 'tramp-session-timeout)
-                       (tramp-set-connection-property
-                        p "session-timeout"
-                        (tramp-get-method-parameter
-                         hop 'tramp-session-timeout)))
+                   ;; Replace `login-args' place holders.
+                   (setq
+                    command
+                    (mapconcat
+                     #'identity
+                     (append
+                      ;; We do not want to see the trailing local
+                      ;; prompt in `start-file-process'.
+                      (unless r-shell '("exec"))
+                      `(,command)
+                      ;; Add arguments for asynchronous processes.
+                      (when process-name async-args)
+                      (tramp-expand-args
+                       hop 'tramp-login-args
+                       ?h (or l-host "") ?u (or l-user "") ?p (or l-port "")
+                       ?c (format-spec options (format-spec-make ?t tmpfile))
+                       ?n (concat
+                           "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"))
+                     " "))
 
                      ;; Replace `login-args' place holders.
                      (setq