aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2020-04-22 11:16:31 +0200
committerMichael Albinus2020-04-22 11:16:31 +0200
commitab214143bbc633bcbe1ae146647c2fdc882122f0 (patch)
tree64b438534277a6fc2698f31f36cbc07435eca899
parentf212daf0a96999b8c1e63217c22a86d6e1671687 (diff)
downloademacs-ab214143bbc633bcbe1ae146647c2fdc882122f0.tar.gz
emacs-ab214143bbc633bcbe1ae146647c2fdc882122f0.zip
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.
-rw-r--r--doc/misc/tramp.texi17
-rw-r--r--lisp/net/tramp-smb.el41
2 files changed, 53 insertions, 5 deletions
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index 4e39728a146..0b13c17dbcf 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -4144,6 +4144,23 @@ your proxy host.
4144 4144
4145 4145
4146@item 4146@item
4147@value{tramp} does not connect to Samba or MS Windows hosts running
4148SMB1 connection protocol.
4149
4150@vindex tramp-smb-options
4151Recent versions of @command{smbclient} do not support old connection
4152protocols by default. In order to connect to such a host, add a
4153respective option:
4154
4155@lisp
4156(add-to-list 'tramp-smb-options "client min protocol=NT1")
4157@end lisp
4158
4159@strong{Note} that using a deprecated connection protocol raises
4160security problems, you should do it only if absolutely necessary.
4161
4162
4163@item
4147File name completion does not work with @value{tramp} 4164File name completion does not work with @value{tramp}
4148 4165
4149@acronym{ANSI} escape sequences from the remote shell may cause errors 4166@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 d361db483a1..e0f5e05eb07 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -75,12 +75,23 @@
75 75
76;;;###tramp-autoload 76;;;###tramp-autoload
77(defcustom tramp-smb-conf "/dev/null" 77(defcustom tramp-smb-conf "/dev/null"
78 "Path of the smb.conf file. 78 "Path of the \"smb.conf\" file.
79If it is nil, no smb.conf will be added to the `tramp-smb-program' 79If it is nil, no \"smb.conf\" will be added to the `tramp-smb-program'
80call, letting the SMB client use the default one." 80call, letting the SMB client use the default one."
81 :group 'tramp 81 :group 'tramp
82 :type '(choice (const nil) (file :must-match t))) 82 :type '(choice (const nil) (file :must-match t)))
83 83
84;;;###tramp-autoload
85(defcustom tramp-smb-options nil
86 "List of additional options.
87They are added to the `tramp-smb-program' call via \"--option '...'\".
88
89For example, if the deprecated SMB1 protocol shall be used, add to
90this variable (\"client min protocol=NT1\") ."
91 :group 'tramp
92 :type '(repeat string)
93 :version "28.1")
94
84(defvar tramp-smb-version nil 95(defvar tramp-smb-version nil
85 "Version string of the SMB client.") 96 "Version string of the SMB client.")
86 97
@@ -460,7 +471,8 @@ pass to the OPERATION."
460 (expand-file-name 471 (expand-file-name
461 tramp-temp-name-prefix 472 tramp-temp-name-prefix
462 (tramp-compat-temporary-file-directory)))) 473 (tramp-compat-temporary-file-directory))))
463 (args (list (concat "//" host "/" share) "-E"))) 474 (args (list (concat "//" host "/" share) "-E"))
475 (options tramp-smb-options))
464 476
465 (if (not (zerop (length user))) 477 (if (not (zerop (length user)))
466 (setq args (append args (list "-U" user))) 478 (setq args (append args (list "-U" user)))
@@ -470,6 +482,10 @@ pass to the OPERATION."
470 (when port (setq args (append args (list "-p" port)))) 482 (when port (setq args (append args (list "-p" port))))
471 (when tramp-smb-conf 483 (when tramp-smb-conf
472 (setq args (append args (list "-s" tramp-smb-conf)))) 484 (setq args (append args (list "-s" tramp-smb-conf))))
485 (while options
486 (setq args
487 (append args `("--option" ,(format "%s" (car options))))
488 options (cdr options)))
473 (setq args 489 (setq args
474 (if t1 490 (if t1
475 ;; Source is remote. 491 ;; Source is remote.
@@ -760,7 +776,8 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
760 (let* ((share (tramp-smb-get-share v)) 776 (let* ((share (tramp-smb-get-share v))
761 (localname (replace-regexp-in-string 777 (localname (replace-regexp-in-string
762 "\\\\" "/" (tramp-smb-get-localname v))) 778 "\\\\" "/" (tramp-smb-get-localname v)))
763 (args (list (concat "//" host "/" share) "-E"))) 779 (args (list (concat "//" host "/" share) "-E"))
780 (options tramp-smb-options))
764 781
765 (if (not (zerop (length user))) 782 (if (not (zerop (length user)))
766 (setq args (append args (list "-U" user))) 783 (setq args (append args (list "-U" user)))
@@ -770,6 +787,10 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
770 (when port (setq args (append args (list "-p" port)))) 787 (when port (setq args (append args (list "-p" port))))
771 (when tramp-smb-conf 788 (when tramp-smb-conf
772 (setq args (append args (list "-s" tramp-smb-conf)))) 789 (setq args (append args (list "-s" tramp-smb-conf))))
790 (while options
791 (setq args
792 (append args `("--option" ,(format "%s" (car options))))
793 options (cdr options)))
773 (setq 794 (setq
774 args 795 args
775 (append args (list (tramp-unquote-shell-quote-argument localname) 796 (append args (list (tramp-unquote-shell-quote-argument localname)
@@ -1412,7 +1433,8 @@ component is used as the target of the symlink."
1412 "\\\\" "/" (tramp-smb-get-localname v))) 1433 "\\\\" "/" (tramp-smb-get-localname v)))
1413 (args (list (concat "//" host "/" share) "-E" "-S" 1434 (args (list (concat "//" host "/" share) "-E" "-S"
1414 (replace-regexp-in-string 1435 (replace-regexp-in-string
1415 "\n" "," acl-string)))) 1436 "\n" "," acl-string)))
1437 (options tramp-smb-options))
1416 1438
1417 (if (not (zerop (length user))) 1439 (if (not (zerop (length user)))
1418 (setq args (append args (list "-U" user))) 1440 (setq args (append args (list "-U" user)))
@@ -1422,6 +1444,10 @@ component is used as the target of the symlink."
1422 (when port (setq args (append args (list "-p" port)))) 1444 (when port (setq args (append args (list "-p" port))))
1423 (when tramp-smb-conf 1445 (when tramp-smb-conf
1424 (setq args (append args (list "-s" tramp-smb-conf)))) 1446 (setq args (append args (list "-s" tramp-smb-conf))))
1447 (while options
1448 (setq args
1449 (append args `("--option" ,(format "%s" (car options))))
1450 options (cdr options)))
1425 (setq 1451 (setq
1426 args 1452 args
1427 (append args (list (tramp-unquote-shell-quote-argument localname) 1453 (append args (list (tramp-unquote-shell-quote-argument localname)
@@ -1947,6 +1973,7 @@ If ARGUMENT is non-nil, use it as argument for
1947 (host (tramp-file-name-host vec)) 1973 (host (tramp-file-name-host vec))
1948 (domain (tramp-file-name-domain vec)) 1974 (domain (tramp-file-name-domain vec))
1949 (port (tramp-file-name-port vec)) 1975 (port (tramp-file-name-port vec))
1976 (options tramp-smb-options)
1950 args) 1977 args)
1951 1978
1952 (cond 1979 (cond
@@ -1965,6 +1992,10 @@ If ARGUMENT is non-nil, use it as argument for
1965 (when port (setq args (append args (list "-p" port)))) 1992 (when port (setq args (append args (list "-p" port))))
1966 (when tramp-smb-conf 1993 (when tramp-smb-conf
1967 (setq args (append args (list "-s" tramp-smb-conf)))) 1994 (setq args (append args (list "-s" tramp-smb-conf))))
1995 (while options
1996 (setq args
1997 (append args `("--option" ,(format "%s" (car options))))
1998 options (cdr options)))
1968 (when argument 1999 (when argument
1969 (setq args (append args (list argument)))) 2000 (setq args (append args (list argument))))
1970 2001