ftpd: conditional support for broken clients
authorStefan Seyfried <stefan.seyfried@googlemail.com>
Mon, 18 Jan 2010 01:08:30 +0000 (02:08 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Mon, 18 Jan 2010 01:08:30 +0000 (02:08 +0100)
Signed-off-by: Stefan Seyfried <stefan.seyfried@googlemail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
networking/Config.in
networking/ftpd.c

index 80834c6d4f1063b8f956d8c9893587c8fe18bdff..788e128ea721e700d5106ca5b8c62ee635f6785d 100644 (file)
@@ -117,6 +117,17 @@ config FEATURE_FTP_WRITE
        help
          Enable all kinds of FTP upload commands (-w option)
 
+config FEATURE_FTPD_ACCEPT_BROKEN_LIST
+       bool "Enable workaround for RFC-violating clients"
+       default y
+       depends on FTPD
+       help
+         Some ftp-clients (among them KDE's Konqueror) issue illegal
+         "LIST -la" requests. This option works around those problems.
+         It might prevent you from listing files starting with "-" and
+         it increases the code size by ~40 bytes.
+         Most other ftp servers seem to behave similar to this.
+
 config FTPGET
        bool "ftpget"
        default n
index 4e9f65ca3d5de8549edf4f0e182b7f0c55d1625e..fdc6f5e452d5dad0fc62781b34ebf57275712d47 100644 (file)
@@ -632,6 +632,18 @@ popen_ls(const char *opt)
        argv[3] = G.ftp_arg;
        argv[4] = NULL;
 
+       /* Improve compatibility with non-RFC conforming FTP clients
+        * which send e.g. "LIST -l", "LIST -la".
+        * See https://bugs.kde.org/show_bug.cgi?id=195578 */
+       if (ENABLE_FEATURE_FTPD_ACCEPT_BROKEN_LIST
+        && G.ftp_arg && G.ftp_arg[0] == '-' && G.ftp_arg[1] == 'l'
+       ) {
+               const char *tmp = strchr(G.ftp_arg, ' ');
+               if (tmp) /* skip the space */
+                       tmp++;
+               argv[3] = tmp;
+       }
+
        xpiped_pair(outfd);
 
        /*fflush_all(); - so far we dont use stdio on output */