commit 7b15cc3ebb45e50ac5faf3bbc2a813afffdaa418 (HEAD, refs/remotes/origin/master) Author: Paul Eggert Date: Wed Apr 22 19:00:08 2020 -0700 text-char-description minor cleanup * src/keymap.c (push_text_char_description): Omit useless code. (Ftext_char_description): Minor code cleanup, inspired by seeing an incorrect comment about MAX_MULTIBYTE_LENGTH’s value. diff --git a/src/keymap.c b/src/keymap.c index 51433e2b5c..d98b27b7a1 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -2268,12 +2268,6 @@ See `text-char-description' for describing character codes. */) static char * push_text_char_description (register unsigned int c, register char *p) { - if (c >= 0200) - { - *p++ = 'M'; - *p++ = '-'; - c -= 0200; - } if (c < 040) { *p++ = '^'; @@ -2302,23 +2296,22 @@ characters into "C-char", and uses the 2**27 bit for Meta. See Info node `(elisp)Describing Characters' for examples. */) (Lisp_Object character) { - /* Currently MAX_MULTIBYTE_LENGTH is 4 (< 6). */ - char str[6]; - int c; - CHECK_CHARACTER (character); - c = XFIXNUM (character); + int c = XFIXNUM (character); if (!ASCII_CHAR_P (c)) { + char str[MAX_MULTIBYTE_LENGTH]; int len = CHAR_STRING (c, (unsigned char *) str); return make_multibyte_string (str, 1, len); } - - *push_text_char_description (c & 0377, str) = 0; - - return build_string (str); + else + { + char desc[4]; + int len = push_text_char_description (c, desc) - desc; + return make_string (desc, len); + } } static int where_is_preferred_modifier; commit 023ff119fb511e262e7cd64b8abb7482720ac4a6 Author: Paul Eggert Date: Wed Apr 22 18:58:45 2020 -0700 Tweak multibyte parsing loops * src/character.c (parse_str_as_multibyte, str_as_multibyte): Let the fast loop run a little longer, fixing what appears to be an off-by-1 performance nit. diff --git a/src/character.c b/src/character.c index da09e77e13..edcec5f1c7 100644 --- a/src/character.c +++ b/src/character.c @@ -512,7 +512,7 @@ parse_str_as_multibyte (const unsigned char *str, ptrdiff_t len, if (len >= MAX_MULTIBYTE_LENGTH) { - const unsigned char *adjusted_endp = endp - MAX_MULTIBYTE_LENGTH; + const unsigned char *adjusted_endp = endp - (MAX_MULTIBYTE_LENGTH - 1); while (str < adjusted_endp) { int n = multibyte_length (str, NULL, false, false); @@ -556,7 +556,7 @@ str_as_multibyte (unsigned char *str, ptrdiff_t len, ptrdiff_t nbytes, if (nbytes >= MAX_MULTIBYTE_LENGTH) { - unsigned char *adjusted_endp = endp - MAX_MULTIBYTE_LENGTH; + unsigned char *adjusted_endp = endp - (MAX_MULTIBYTE_LENGTH - 1); while (p < adjusted_endp) { int n = multibyte_length (p, NULL, false, false); @@ -585,7 +585,7 @@ str_as_multibyte (unsigned char *str, ptrdiff_t len, ptrdiff_t nbytes, if (nbytes >= MAX_MULTIBYTE_LENGTH) { - unsigned char *adjusted_endp = endp - MAX_MULTIBYTE_LENGTH; + unsigned char *adjusted_endp = endp - (MAX_MULTIBYTE_LENGTH - 1); while (p < adjusted_endp) { int n = multibyte_length (p, NULL, false, false); commit ab214143bbc633bcbe1ae146647c2fdc882122f0 Author: Michael Albinus Date: Wed Apr 22 11:16:31 2020 +0200 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. diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi index 4e39728a14..0b13c17dbc 100644 --- a/doc/misc/tramp.texi +++ b/doc/misc/tramp.texi @@ -4143,6 +4143,23 @@ Check @command{man ssh_config} whether these options are supported on 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} diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index d361db483a..e0f5e05eb0 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))))