GNU bug report logs - #19192
25.0.50; TRAMP uses `dired-listing-switches' for ftp-connection

Previous Next

Package: emacs;

Reported by: Rasmus <rasmus <at> gmx.us>

Date: Wed, 26 Nov 2014 12:05:02 UTC

Severity: normal

Found in version 25.0.50

Done: Michael Albinus <michael.albinus <at> gmx.de>

Bug is archived. No further changes may be made.

Full log


Message #41 received at 19192 <at> debbugs.gnu.org (full text, mbox):

From: Rasmus <rasmus <at> gmx.us>
To: schwab <at> suse.de
Cc: 19192 <at> debbugs.gnu.org, michael.albinus <at> gmx.de
Subject: Re: bug#19192: 25.0.50;
 TRAMP uses `dired-listing-switches' for ftp-connection
Date: Wed, 10 Dec 2014 16:28:20 +0100
[Message part 1 (text/plain, inline)]
Andreas Schwab <schwab <at> suse.de> writes:

> Rasmus <rasmus <at> gmx.us> writes:
>
>> diff --git a/lisp/net/ange-ftp.el b/lisp/net/ange-ftp.el
>> index d7632ed..5e9bc27 100644
>> --- a/lisp/net/ange-ftp.el
>> +++ b/lisp/net/ange-ftp.el
>> @@ -2831,16 +2831,20 @@ match subdirectories as well.")
>>  		      files ange-ftp-files-hashtable)))
>>  
>>  (defun ange-ftp-switches-ok (switches)
>> -  "Return SWITCHES (a string) if suitable for our use."
>> +  "Return SWITCHES (a string) if suitable for use with ls over ftp."
>>    (and (stringp switches)
>>         ;; We allow the A switch, which lists all files except "." and
>>         ;; "..".  This is OK because we manually insert these entries
>>         ;; in the hash table.
>>         (string-match
>>  	"--\\(almost-\\)?all\\>\\|\\(\\`\\| \\)-[[:alpha:]]*[aA]" switches)
>> +       ;; Allow flags starting with a single dash
>>         (string-match "\\(\\`\\| \\)-[[:alpha:]]*l" switches)
>> +       ;; Disallow recursive flag
>>         (not (string-match
>> -	     "--recursive\\>\\|\\(\\`\\| \\)-[[:alpha:]]*R" switches))
>> +	     "\\(\\`\\| \\)-[[:alpha:]]*R" switches))
>> +       ;; Disallow long flags.
>> +       (not (string-match "--\\w\\{2,\\}"))
>
> This contradicts the first string-match.

You are right.

How about this one: allow --(almost-)all for legacy reasons.  Disallow
other long flags.  Allow short flag as long as their is an "l" and not an
"R"?  (At least that was the intention).

—Rasmus

-- 
Together we will make the possible totalllly impossible!
[0001-ange-ftp.el-Disallow-more-dired-ls-flags.patch (text/x-diff, inline)]
From 07f99a06a30e271989a27dc58a2db54602d60e51 Mon Sep 17 00:00:00 2001
From: rasmus <x200s <at> pank.eu>
Date: Wed, 10 Dec 2014 16:18:00 +0100
Subject: [PATCH] ange-ftp.el: Disallow more dired ls-flags

* net/ange-ftp.el (ange-ftp-switches-ok): Disallow most lonng flags,
  as they may cause Tramp-breakage.

Fixes: debbugs:19192
---
 lisp/ChangeLog       |  6 ++++++
 lisp/net/ange-ftp.el | 20 ++++++++++++++------
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 454ee00..09b64f5 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2014-11-29  Rasmus Pank Roulund  <emacs <at> pank.eu>
+
+	* net/ange-ftp.el (ange-ftp-switches-ok): Disallow flags causing
+	trouble with ls over ftp.  These flags result in ls returning no
+	output, causing Tramp-breakage.  (bug#19192)
+
 2014-12-10  Andreas Schwab  <schwab <at> suse.de>
 
 	* files.el (file-tree-walk): Use file-name-as-directory
diff --git a/lisp/net/ange-ftp.el b/lisp/net/ange-ftp.el
index d7632ed..db79c0d 100644
--- a/lisp/net/ange-ftp.el
+++ b/lisp/net/ange-ftp.el
@@ -2831,16 +2831,24 @@ match subdirectories as well.")
 		      files ange-ftp-files-hashtable)))
 
 (defun ange-ftp-switches-ok (switches)
-  "Return SWITCHES (a string) if suitable for our use."
+  "Return SWITCHES (a string) if suitable for use with ls over ftp."
   (and (stringp switches)
-       ;; We allow the A switch, which lists all files except "." and
-       ;; "..".  This is OK because we manually insert these entries
-       ;; in the hash table.
+       ;; We allow the --almost-all switch, which lists all files
+       ;; except "." and "..".  This is OK because we manually
+       ;; insert these entries in the hash table.
        (string-match
-	"--\\(almost-\\)?all\\>\\|\\(\\`\\| \\)-[[:alpha:]]*[aA]" switches)
+        "--\\(almost-\\)?all\\>\\|\\(\\`\\| \\)-[[:alpha:]]*[aA]"
+        switches)
+       ;; Disallow other long flags except --(almost-)all.
+       (not (string-match "\\(\\`\\| \\)--\\w+"
+                          (replace-regexp-in-string
+                           "--\\(almost-\\)?all\\>" ""
+                           switches)))
+       ;; Must include 'l'.
        (string-match "\\(\\`\\| \\)-[[:alpha:]]*l" switches)
+       ;; Disallow recursive flag.
        (not (string-match
-	     "--recursive\\>\\|\\(\\`\\| \\)-[[:alpha:]]*R" switches))
+             "\\(\\`\\| \\)-[[:alpha:]]*R" switches))
        switches))
 
 (defun ange-ftp-get-files (directory &optional no-error)
-- 
2.1.3


This bug report was last modified 10 years and 169 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.