Handle too long commands in Tramp

* lisp/net/tramp-sh.el (tramp-sh-handle-make-symbolic-link)
(tramp-do-file-attributes-with-ls): Send sequence of commands, in
order to not exceed shell command line limit.

* test/automated/tramp-tests.el (tramp--test-darwin-p): Remove.
(tramp--test-utf8): Include Arabic file name, again.
This commit is contained in:
Michael Albinus 2016-01-10 13:07:21 +01:00
parent 684eb58db9
commit 1089dc98b7
2 changed files with 115 additions and 111 deletions

View file

@ -1100,15 +1100,19 @@ target of the symlink differ."
;; Right, they are on the same host, regardless of user, method, ;; Right, they are on the same host, regardless of user, method,
;; etc. We now make the link on the remote machine. This will ;; etc. We now make the link on the remote machine. This will
;; occur as the user that FILENAME belongs to. ;; occur as the user that FILENAME belongs to.
(and (tramp-send-command-and-check
l (format "cd %s" (tramp-shell-quote-argument cwd)))
(tramp-send-command-and-check (tramp-send-command-and-check
l l (format
(format "%s -sf %s %s"
"cd %s && %s -sf %s %s"
(tramp-shell-quote-argument cwd)
ln ln
(tramp-shell-quote-argument filename) (tramp-shell-quote-argument filename)
(tramp-shell-quote-argument l-localname)) ;; The command could exceed PATH_MAX, so we use
t)))) ;; relative file names. However, relative file names
;; could start with "-". `tramp-shell-quote-argument'
;; does not handle this, we must do it ourselves.
(tramp-shell-quote-argument
(concat "./" (file-name-nondirectory l-localname)))))))))
(defun tramp-sh-handle-file-truename (filename) (defun tramp-sh-handle-file-truename (filename)
"Like `file-truename' for Tramp files." "Like `file-truename' for Tramp files."
@ -1266,13 +1270,21 @@ target of the symlink differ."
res-inode res-filemodes res-numlinks res-inode res-filemodes res-numlinks
res-uid res-gid res-size res-symlink-target) res-uid res-gid res-size res-symlink-target)
(tramp-message vec 5 "file attributes with ls: %s" localname) (tramp-message vec 5 "file attributes with ls: %s" localname)
;; We cannot send all three commands combined, it could exceed
;; NAME_MAX or PATH_MAX. Happened on Mac OS X, for example.
(when (or (tramp-send-command-and-check
vec
(format "%s %s"
(tramp-get-file-exists-command vec)
(tramp-shell-quote-argument localname)))
(tramp-send-command-and-check
vec
(format "%s -h %s"
(tramp-get-test-command vec)
(tramp-shell-quote-argument localname))))
(tramp-send-command (tramp-send-command
vec vec
(format "(%s %s || %s -h %s) && %s %s %s %s" (format "%s %s %s %s"
(tramp-get-file-exists-command vec)
(tramp-shell-quote-argument localname)
(tramp-get-test-command vec)
(tramp-shell-quote-argument localname)
(tramp-get-ls-command vec) (tramp-get-ls-command vec)
(if (eq id-format 'integer) "-ildn" "-ild") (if (eq id-format 'integer) "-ildn" "-ild")
;; On systems which have no quoting style, file names ;; On systems which have no quoting style, file names
@ -1341,10 +1353,10 @@ target of the symlink differ."
res-uid res-uid
;; 3. File gid. ;; 3. File gid.
res-gid res-gid
;; 4. Last access time, as a list of integers. Normally this ;; 4. Last access time, as a list of integers. Normally
;; would be in the same format as `current-time', but the ;; this would be in the same format as `current-time', but
;; subseconds part is not currently implemented, and (0 0) ;; the subseconds part is not currently implemented, and (0
;; denotes an unknown time. ;; 0) denotes an unknown time.
;; 5. Last modification time, likewise. ;; 5. Last modification time, likewise.
;; 6. Last status change time, likewise. ;; 6. Last status change time, likewise.
'(0 0) '(0 0) '(0 0) ;CCC how to find out? '(0 0) '(0 0) '(0 0) ;CCC how to find out?
@ -1359,7 +1371,7 @@ target of the symlink differ."
res-inode res-inode
;; 11. Device number. Will be replaced by a virtual device number. ;; 11. Device number. Will be replaced by a virtual device number.
-1 -1
))))) ))))))
(defun tramp-do-file-attributes-with-perl (defun tramp-do-file-attributes-with-perl
(vec localname &optional id-format) (vec localname &optional id-format)

View file

@ -1785,14 +1785,6 @@ Several special characters do not work properly there."
(file-truename tramp-test-temporary-file-directory) nil (file-truename tramp-test-temporary-file-directory) nil
(string-match "^HP-UX" (tramp-get-connection-property v "uname" "")))) (string-match "^HP-UX" (tramp-get-connection-property v "uname" ""))))
(defun tramp--test-darwin-p ()
"Check, whether the remote host runs Mac OS X.
Several special characters do not work properly there."
;; We must refill the cache. `file-truename' does it.
(with-parsed-tramp-file-name
(file-truename tramp-test-temporary-file-directory) nil
(string-match "^Darwin" (tramp-get-connection-property v "uname" ""))))
(defun tramp--test-check-files (&rest files) (defun tramp--test-check-files (&rest files)
"Run a simple but comprehensive test over every file in FILES." "Run a simple but comprehensive test over every file in FILES."
;; We must use `file-truename' for the temporary directory, because ;; We must use `file-truename' for the temporary directory, because
@ -2046,7 +2038,7 @@ Use the `ls' command."
(file-name-coding-system 'utf-8)) (file-name-coding-system 'utf-8))
(tramp--test-check-files (tramp--test-check-files
(unless (tramp--test-hpux-p) "Γυρίστε το Γαλαξία με Ώτο Στοπ") (unless (tramp--test-hpux-p) "Γυρίστε το Γαλαξία με Ώτο Στοπ")
(unless (or (tramp--test-hpux-p) (tramp--test-darwin-p)) (unless (tramp--test-hpux-p)
"أصبح بوسعك الآن تنزيل نسخة كاملة من موسوعة ويكيبيديا العربية لتصفحها بلا اتصال بالإنترنت") "أصبح بوسعك الآن تنزيل نسخة كاملة من موسوعة ويكيبيديا العربية لتصفحها بلا اتصال بالإنترنت")
"银河系漫游指南系列" "银河系漫游指南系列"
"Автостопом по гала́ктике"))) "Автостопом по гала́ктике")))