emacs-diffs
[Top][All Lists]
Advanced

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

master ab21414: Support old SMB1 protocol in Tramp


From: Michael Albinus
Subject: master ab21414: Support old SMB1 protocol in Tramp
Date: Wed, 22 Apr 2020 05:16:43 -0400 (EDT)

branch: master
commit ab214143bbc633bcbe1ae146647c2fdc882122f0
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>

    Support old SMB1 protocol in Tramp
    
    * doc/misc/tramp.texi (Frequently Asked Questions):
    Describe `tramp-smb-options'.
    
    * lisp/net/tramp-smb.el (tramp-smb-conf): Fix docstring.
    (tramp-smb-options): New defcustom.
    (tramp-smb-handle-copy-directory, tramp-smb-handle-file-acl)
    (tramp-smb-handle-set-file-acl, tramp-smb-maybe-open-connection):
    Use it.
---
 doc/misc/tramp.texi   | 17 +++++++++++++++++
 lisp/net/tramp-smb.el | 41 ++++++++++++++++++++++++++++++++++++-----
 2 files changed, 53 insertions(+), 5 deletions(-)

diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index 4e39728..0b13c17 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -4144,6 +4144,23 @@ your proxy host.
 
 
 @item
+@value{tramp} does not connect to Samba or MS Windows hosts running
+SMB1 connection protocol.
+
+@vindex tramp-smb-options
+Recent versions of @command{smbclient} do not support old connection
+protocols by default.  In order to connect to such a host, add a
+respective option:
+
+@lisp
+(add-to-list 'tramp-smb-options "client min protocol=NT1")
+@end lisp
+
+@strong{Note} that using a deprecated connection protocol raises
+security problems, you should do it only if absolutely necessary.
+
+
+@item
 File name completion does not work with @value{tramp}
 
 @acronym{ANSI} escape sequences from the remote shell may cause errors
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index d361db4..e0f5e05 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -75,12 +75,23 @@
 
 ;;;###tramp-autoload
 (defcustom tramp-smb-conf "/dev/null"
-  "Path of the smb.conf file.
-If it is nil, no smb.conf will be added to the `tramp-smb-program'
+  "Path of the \"smb.conf\" file.
+If it is nil, no \"smb.conf\" will be added to the `tramp-smb-program'
 call, letting the SMB client use the default one."
   :group 'tramp
   :type '(choice (const nil) (file :must-match t)))
 
+;;;###tramp-autoload
+(defcustom tramp-smb-options nil
+  "List of additional options.
+They are added to the `tramp-smb-program' call via \"--option '...'\".
+
+For example, if the deprecated SMB1 protocol shall be used, add to
+this variable (\"client min protocol=NT1\") ."
+  :group 'tramp
+  :type '(repeat string)
+  :version "28.1")
+
 (defvar tramp-smb-version nil
   "Version string of the SMB client.")
 
@@ -460,7 +471,8 @@ pass to the OPERATION."
                               (expand-file-name
                                tramp-temp-name-prefix
                                (tramp-compat-temporary-file-directory))))
-                  (args      (list (concat "//" host "/" share) "-E")))
+                  (args      (list (concat "//" host "/" share) "-E"))
+                  (options   tramp-smb-options))
 
              (if (not (zerop (length user)))
                  (setq args (append args (list "-U" user)))
@@ -470,6 +482,10 @@ pass to the OPERATION."
              (when port   (setq args (append args (list "-p" port))))
              (when tramp-smb-conf
                (setq args (append args (list "-s" tramp-smb-conf))))
+             (while options
+               (setq args
+                     (append args `("--option" ,(format "%s" (car options))))
+                     options (cdr options)))
              (setq args
                    (if t1
                        ;; Source is remote.
@@ -760,7 +776,8 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are 
completely ignored."
          (let* ((share     (tramp-smb-get-share v))
                 (localname (replace-regexp-in-string
                             "\\\\" "/" (tramp-smb-get-localname v)))
-                (args      (list (concat "//" host "/" share) "-E")))
+                (args      (list (concat "//" host "/" share) "-E"))
+                (options   tramp-smb-options))
 
            (if (not (zerop (length user)))
                (setq args (append args (list "-U" user)))
@@ -770,6 +787,10 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are 
completely ignored."
            (when port   (setq args (append args (list "-p" port))))
            (when tramp-smb-conf
              (setq args (append args (list "-s" tramp-smb-conf))))
+           (while options
+             (setq args
+                   (append args `("--option" ,(format "%s" (car options))))
+                   options (cdr options)))
            (setq
             args
             (append args (list (tramp-unquote-shell-quote-argument localname)
@@ -1412,7 +1433,8 @@ component is used as the target of the symlink."
                           "\\\\" "/" (tramp-smb-get-localname v)))
               (args      (list (concat "//" host "/" share) "-E" "-S"
                                (replace-regexp-in-string
-                                "\n" "," acl-string))))
+                                "\n" "," acl-string)))
+              (options   tramp-smb-options))
 
          (if (not (zerop (length user)))
              (setq args (append args (list "-U" user)))
@@ -1422,6 +1444,10 @@ component is used as the target of the symlink."
          (when port   (setq args (append args (list "-p" port))))
          (when tramp-smb-conf
            (setq args (append args (list "-s" tramp-smb-conf))))
+         (while options
+           (setq args
+                 (append args `("--option" ,(format "%s" (car options))))
+                 options (cdr options)))
          (setq
           args
           (append args (list (tramp-unquote-shell-quote-argument localname)
@@ -1947,6 +1973,7 @@ If ARGUMENT is non-nil, use it as argument for
               (host   (tramp-file-name-host vec))
               (domain (tramp-file-name-domain vec))
               (port   (tramp-file-name-port vec))
+              (options tramp-smb-options)
               args)
 
          (cond
@@ -1965,6 +1992,10 @@ If ARGUMENT is non-nil, use it as argument for
          (when port   (setq args (append args (list "-p" port))))
          (when tramp-smb-conf
            (setq args (append args (list "-s" tramp-smb-conf))))
+         (while options
+           (setq args
+                 (append args `("--option" ,(format "%s" (car options))))
+                 options (cdr options)))
          (when argument
            (setq args (append args (list argument))))
 



reply via email to

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