emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master b2b26bd: Use RemoteCommand option for Tramp's sshx and scpx metho


From: Michael Albinus
Subject: master b2b26bd: Use RemoteCommand option for Tramp's sshx and scpx methods
Date: Fri, 22 Jan 2021 11:40:03 -0500 (EST)

branch: master
commit b2b26bd4d66d25f2456baa4e9eb9516c122a30e0
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>

    Use RemoteCommand option for Tramp's sshx and scpx methods
    
    * doc/misc/tramp.texi (Inline methods) <sshx>:
    (External methods) <scpx>: Adapt call sequence.
    (Remote shell setup): Mention, that sshx and scpx overwrite
    RemoteCommand.
    (Remote processes): Restriction: direct asynchronous processes
    cannot be used when RemoteCommand is in use.
    `tramp-remote-process-environment' is not ignored any longer.
    
    * lisp/net/tramp-sh.el (tramp-methods) <sshx, scpx>: Handle login
    shell via RemoteCommand.  Remove `tramp-direct-async' parameter.
    (tramp-maybe-open-connection): Add "-i" to login.
    
    * lisp/net/tramp-smb.el (tramp-smb-errors):
    Add "NT_STATUS_NOT_SUPPORTED".
    (tramp-smb-handle-insert-directory): Fix point moving error.
    
    * test/lisp/net/tramp-tests.el (tramp-test34-explicit-shell-file-name):
    Use `get-buffer-process' where appropriate.
---
 doc/misc/tramp.texi          | 27 +++++++++++++++++----------
 lisp/net/tramp-sh.el         | 12 +++++-------
 lisp/net/tramp-smb.el        | 24 ++++++++++++------------
 test/lisp/net/tramp-tests.el |  2 +-
 4 files changed, 35 insertions(+), 30 deletions(-)

diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index e9ffd6a..5d89b06 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -810,9 +810,10 @@ behavior.
 @cindex @option{sshx} method
 
 Works like @option{ssh} but without the extra authentication prompts.
-@option{sshx} uses @samp{ssh -t -t @var{host} -l @var{user} /bin/sh}
-to open a connection with a ``standard'' login shell.  It supports
-changing the remote login shell @command{/bin/sh}.
+@option{sshx} uses @samp{ssh -t -t -l @var{user} -o
+RemoteCommand='/bin/sh -i' @var{host}} to open a connection with a
+``standard'' login shell.  It supports changing the remote login shell
+@command{/bin/sh}.
 
 @strong{Note} that @option{sshx} does not bypass authentication
 questions.  For example, if the host key of the remote host is not
@@ -935,9 +936,10 @@ This method supports the @samp{-p} argument.
 @cindex @command{ssh} (with @option{scpx} method)
 
 @option{scpx} is useful to avoid login shell questions.  It is similar
-in performance to @option{scp}.  @option{scpx} uses @samp{ssh -t -t
-@var{host} -l @var{user} /bin/sh} to open a connection.  It supports
-changing the remote login shell @command{/bin/sh}.
+in performance to @option{scp}.  @option{scpx} uses @samp{ssh -t -t -l
+@var{user} -o RemoteCommand='/bin/sh -i' @var{host}} to open a
+connection.  It supports changing the remote login shell
+@command{/bin/sh}.
 
 @option{scpx} is useful for MS Windows users when @command{ssh}
 triggers an error about allocating a pseudo tty.  This happens due to
@@ -2220,7 +2222,10 @@ This uses also the settings in 
@code{tramp-sh-extra-args}.
 @vindex RemoteCommand@r{, ssh option}
 @strong{Note}: If you use an @option{ssh}-based method for connection,
 do @emph{not} set the @option{RemoteCommand} option in your
-@command{ssh} configuration, for example to @command{screen}.
+@command{ssh} configuration, for example to @command{screen}.  On the
+other hand, some @option{ssh}-based methods, like @option{sshx} or
+@option{scpx}, silently overwrite a @option{RemoteCommand} option of
+the configuration file.
 
 
 @subsection Other remote shell setup hints
@@ -3580,7 +3585,6 @@ Furthermore, this approach has the following limitations:
 It works only for connection methods defined in @file{tramp-sh.el} and
 @file{tramp-adb.el}.
 
-@vindex ControlMaster@r{, ssh option}
 @item
 It does not support interactive user authentication.  With
 @option{ssh}-based methods, this can be avoided by using a password
@@ -3588,6 +3592,10 @@ agent like @command{ssh-agent}, using public key 
authentication, or
 using @option{ControlMaster} options.
 
 @item
+It cannot be applied for @option{ssh}-based methods, which use the
+@option{RemoteCommand} option.
+
+@item
 It cannot be killed via @code{interrupt-process}.
 
 @item
@@ -3597,8 +3605,7 @@ It does not report the remote terminal name via 
@code{process-tty-name}.
 It does not set process property @code{remote-pid}.
 
 @item
-It does not use @code{tramp-remote-path} and
-@code{tramp-remote-process-environment}.
+It does not use @code{tramp-remote-path}.
 @end itemize
 
 In order to gain even more performance, it is recommended to bind
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 618a9fb..d7ca7c9 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -181,10 +181,9 @@ The string is used in `tramp-methods'.")
               `("scpx"
                 (tramp-login-program        "ssh")
                 (tramp-login-args           (("-l" "%u") ("-p" "%p") ("%c")
-                                            ("-e" "none") ("-t" "-t") ("%h")
-                                            ("%l")))
+                                            ("-e" "none") ("-t" "-t")
+                                            ("-o" "RemoteCommand='%l'") 
("%h")))
                 (tramp-async-args           (("-q")))
-                (tramp-direct-async         t)
                 (tramp-remote-shell         ,tramp-default-remote-shell)
                 (tramp-remote-shell-login   ("-l"))
                 (tramp-remote-shell-args    ("-c"))
@@ -238,10 +237,9 @@ The string is used in `tramp-methods'.")
               `("sshx"
                 (tramp-login-program        "ssh")
                 (tramp-login-args           (("-l" "%u") ("-p" "%p") ("%c")
-                                            ("-e" "none") ("-t" "-t") ("%h")
-                                            ("%l")))
+                                            ("-e" "none") ("-t" "-t")
+                                            ("-o" "RemoteCommand='%l'") 
("%h")))
                 (tramp-async-args           (("-q")))
-                (tramp-direct-async         t)
                 (tramp-remote-shell         ,tramp-default-remote-shell)
                 (tramp-remote-shell-login   ("-l"))
                 (tramp-remote-shell-args    ("-c"))))
@@ -5124,7 +5122,7 @@ connection if a previous connection has died for some 
reason."
                     options (format-spec options spec)
                     spec (format-spec-make
                           ?h l-host ?u l-user ?p l-port ?c options
-                          ?l (concat remote-shell " " extra-args))
+                          ?l (concat remote-shell " " extra-args " -i"))
                     command
                     (concat
                      ;; We do not want to see the trailing local
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index 1604e89..c5a74a5 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -156,6 +156,7 @@ this variable (\"client min protocol=NT1\") ."
         "NT_STATUS_NO_SUCH_FILE"
         "NT_STATUS_NO_SUCH_USER"
         "NT_STATUS_NOT_A_DIRECTORY"
+        "NT_STATUS_NOT_SUPPORTED"
         "NT_STATUS_OBJECT_NAME_COLLISION"
         "NT_STATUS_OBJECT_NAME_INVALID"
         "NT_STATUS_OBJECT_NAME_NOT_FOUND"
@@ -371,17 +372,17 @@ pass to the OPERATION."
        (tramp-error
         v2 'file-error
         "add-name-to-file: %s must not be a directory" filename))
-       ;; Do the 'confirm if exists' thing.
-       (when (file-exists-p newname)
-         ;; What to do?
-         (if (or (null ok-if-already-exists) ; not allowed to exist
-                 (and (numberp ok-if-already-exists)
-                      (not (yes-or-no-p
-                            (format
-                             "File %s already exists; make it a link anyway? "
-                             v2-localname)))))
-             (tramp-error v2 'file-already-exists newname)
-           (delete-file newname)))
+      ;; Do the 'confirm if exists' thing.
+      (when (file-exists-p newname)
+       ;; What to do?
+       (if (or (null ok-if-already-exists) ; not allowed to exist
+               (and (numberp ok-if-already-exists)
+                    (not (yes-or-no-p
+                          (format
+                           "File %s already exists; make it a link anyway? "
+                           v2-localname)))))
+           (tramp-error v2 'file-already-exists newname)
+         (delete-file newname)))
       ;; We must also flush the cache of the directory, because
       ;; `file-attributes' reads the values from there.
       (tramp-flush-file-properties v2 v2-localname)
@@ -1166,7 +1167,6 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are 
completely ignored."
                   (insert " -> " (tramp-compat-file-attribute-type attr))))
 
               (insert "\n")
-              (forward-line)
               (beginning-of-line)))
           entries))))))
 
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 5deee65..4c84507 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -5247,7 +5247,7 @@ Use direct async.")
          ;; order to avoid a question.  `explicit-sh-args' echoes the
          ;; test data.
          (with-current-buffer (get-buffer-create "*shell*")
-           (ignore-errors (kill-process (current-buffer)))
+           (ignore-errors (kill-process (get-buffer-process (current-buffer))))
            (should-not explicit-shell-file-name)
            (call-interactively #'shell)
            (with-timeout (10)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]