#
-# $Id: cf.data.pre,v 1.346 2004/04/04 13:57:30 hno Exp $
+# $Id: cf.data.pre,v 1.347 2004/04/04 15:05:13 hno Exp $
#
#
# SQUID Web Proxy Cache http://www.squid-cache.org/
Squid to perform these checks then turn this directive off.
DOC_END
+NAME: ftp_telnet_protocol
+TYPE: onoff
+DEFAULT: on
+LOC: Config.Ftp.telnet
+DOC_START
+The FTP protocol is officially defined to use the telnet protocol
+as transport channel for the control connection. However, many
+implemenations are broken and does not respect this aspect of
+the FTP protocol.
+
+If you have trouble accessing files with ASCII code 255 in the
+path or similar problems involving this ASCII code then you can
+try setting this directive to off. If that helps report to the
+operator of the FTP server in question that their FTP server
+is broken and does not follow the FTP standard.
+DOC_END
+
NAME: cache_dns_program
TYPE: string
IFDEF: USE_DNSSERVERS
/*
- * $Id: ftp.cc,v 1.356 2004/04/04 14:47:06 hno Exp $
+ * $Id: ftp.cc,v 1.357 2004/04/04 15:05:13 hno Exp $
*
* DEBUG: section 9 File Transfer Protocol (FTP)
* AUTHOR: Harvest Derived
/* ====================================================================== */
+static char *
+escapeIAC(const char *buf)
+{
+ int n;
+ char *ret;
+ unsigned const char *p;
+ unsigned char *r;
+
+ for (p = (unsigned const char *)buf, n = 1; *p; n++, p++)
+ if (*p == 255)
+ n++;
+
+ ret = (char *)xmalloc(n);
+
+ for (p = (unsigned const char *)buf, r=(unsigned char *)ret; *p; p++) {
+ *r++ = *p;
+
+ if (*p == 255)
+ *r++ = 255;
+ }
+
+ *r++ = '\0';
+ assert((r - (unsigned char *)ret) == n );
+ return ret;
+}
+
static void
ftpWriteCommand(const char *buf, FtpStateData * ftpState)
{
+ char *ebuf;
debug(9, 5) ("ftpWriteCommand: %s\n", buf);
+
+ if (Config.Ftp.telnet)
+ ebuf = escapeIAC(buf);
+ else
+ ebuf = xstrdup(buf);
+
safe_free(ftpState->ctrl.last_command);
+
safe_free(ftpState->ctrl.last_reply);
- ftpState->ctrl.last_command = xstrdup(buf);
+
+ ftpState->ctrl.last_command = ebuf;
+
comm_write(ftpState->ctrl.fd,
ftpState->ctrl.last_command,
strlen(ftpState->ctrl.last_command),
ftpWriteCommandCallback,
ftpState);
+
ftpScheduleReadControlReply(ftpState, 0);
}