aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorMichael Albinus2018-05-02 12:31:51 +0200
committerMichael Albinus2018-05-02 12:31:51 +0200
commit8ae7c424c409aa31fa52304752ba62d4b5a9a4d0 (patch)
treeea18bd161145904adcf9bbe43557b29108f746dc /lisp
parent3e7ec620d4d49ee82bb2f4c5b9ac4095f06a15e7 (diff)
downloademacs-8ae7c424c409aa31fa52304752ba62d4b5a9a4d0.tar.gz
emacs-8ae7c424c409aa31fa52304752ba62d4b5a9a4d0.zip
Fix some edge cases of tramp-smb
* lisp/net/tramp-smb.el (tramp-smb-errors): Add "NT_STATUS_REVISION_MISMATCH". (tramp-smb-handle-delete-directory): Check, that the directory has been removed indeed. (tramp-smb-get-localname): Add further checks on filename syntax. * lisp/net/tramp.el (tramp-localname-regexp): Do not allow linefeeds. * test/lisp/net/tramp-tests.el (tramp-smb-get-localname): Declare. (auth-source-save-behavior): Set it to nil. (tramp-test01-file-name-syntax): Extend, checking for linefeeds. (tramp-test03-file-name-host-rules, tramp--test-utf8): Refine tests. (tramp-test03-file-name-method-rules): New test. (tramp--test-ignore-add-name-to-file-error): New defmacro. (tramp-test21-file-links): Use it.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/net/tramp-smb.el16
-rw-r--r--lisp/net/tramp.el2
2 files changed, 16 insertions, 2 deletions
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index 0e7386bf020..a4d0d53bf70 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -123,6 +123,7 @@ call, letting the SMB client use the default one."
123 "ERRnoaccess" 123 "ERRnoaccess"
124 "ERRnomem" 124 "ERRnomem"
125 "ERRnosuchshare" 125 "ERRnosuchshare"
126 ;; See /usr/include/samba-4.0/core/ntstatus.h.
126 ;; Windows 4.0 (Windows NT), Windows 5.0 (Windows 2000), 127 ;; Windows 4.0 (Windows NT), Windows 5.0 (Windows 2000),
127 ;; Windows 5.1 (Windows XP), Windows 5.2 (Windows Server 2003), 128 ;; Windows 5.1 (Windows XP), Windows 5.2 (Windows Server 2003),
128 ;; Windows 6.0 (Windows Vista), Windows 6.1 (Windows 7), 129 ;; Windows 6.0 (Windows Vista), Windows 6.1 (Windows 7),
@@ -154,6 +155,7 @@ call, letting the SMB client use the default one."
154 "NT_STATUS_OBJECT_PATH_SYNTAX_BAD" 155 "NT_STATUS_OBJECT_PATH_SYNTAX_BAD"
155 "NT_STATUS_PASSWORD_MUST_CHANGE" 156 "NT_STATUS_PASSWORD_MUST_CHANGE"
156 "NT_STATUS_RESOURCE_NAME_NOT_FOUND" 157 "NT_STATUS_RESOURCE_NAME_NOT_FOUND"
158 "NT_STATUS_REVISION_MISMATCH"
157 "NT_STATUS_SHARING_VIOLATION" 159 "NT_STATUS_SHARING_VIOLATION"
158 "NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE" 160 "NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE"
159 "NT_STATUS_UNSUCCESSFUL" 161 "NT_STATUS_UNSUCCESSFUL"
@@ -643,7 +645,12 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
643 (goto-char (point-min)) 645 (goto-char (point-min))
644 (search-forward-regexp tramp-smb-errors nil t) 646 (search-forward-regexp tramp-smb-errors nil t)
645 (tramp-error 647 (tramp-error
646 v 'file-error "%s `%s'" (match-string 0) directory)))))) 648 v 'file-error "%s `%s'" (match-string 0) directory)))
649
650 ;; "rmdir" does not report an error. So we check ourselves.
651 (when (file-exists-p directory)
652 (tramp-error
653 v 'file-error "`%s' not removed." directory)))))
647 654
648(defun tramp-smb-handle-delete-file (filename &optional _trash) 655(defun tramp-smb-handle-delete-file (filename &optional _trash)
649 "Like `delete-file' for Tramp files." 656 "Like `delete-file' for Tramp files."
@@ -1621,6 +1628,13 @@ If VEC has no cifs capabilities, exchange \"/\" by \"\\\\\"."
1621 (when (string-match "\\(\\$\\$\\)\\(/\\|$\\)" localname) 1628 (when (string-match "\\(\\$\\$\\)\\(/\\|$\\)" localname)
1622 (setq localname (replace-match "$" nil nil localname 1))) 1629 (setq localname (replace-match "$" nil nil localname 1)))
1623 1630
1631 ;; A period followed by a space, or trailing periods and spaces,
1632 ;; are not supported.
1633 (when (string-match "\\. \\|\\.$\\| $" localname)
1634 (tramp-error
1635 vec 'file-error
1636 "Invalid file name %s" (tramp-make-tramp-file-name vec localname)))
1637
1624 localname))) 1638 localname)))
1625 1639
1626;; Share names of a host are cached. It is very unlikely that the 1640;; Share names of a host are cached. It is very unlikely that the
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index c394f28a561..5dda18f3a3b 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -917,7 +917,7 @@ Used in `tramp-make-tramp-file-name'.")
917 "Regexp matching delimiter between host names and localnames. 917 "Regexp matching delimiter between host names and localnames.
918Derived from `tramp-postfix-host-format'.") 918Derived from `tramp-postfix-host-format'.")
919 919
920(defconst tramp-localname-regexp ".*$" 920(defconst tramp-localname-regexp "[^\n\r]*\\'"
921 "Regexp matching localnames.") 921 "Regexp matching localnames.")
922 922
923(defconst tramp-unknown-id-string "UNKNOWN" 923(defconst tramp-unknown-id-string "UNKNOWN"