From 06841282097c583a3c0b92790a5553895002bffd Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 27 Jul 2009 18:36:56 +0000 Subject: [PATCH] - All the quote options (CURLOPT_QUOTE, CURLOPT_POSTQUOTE and CURLOPT_PREQUOTE) now accept a preceeding asterisk before the command to send when using FTP, as a sign that libcurl shall simply ignore the response from the server instead of treating it as an error. Not treating a 400+ FTP response code as an error means that failed commands will not abort the chain of commands, nor will they cause the connection to get disconnected. --- CHANGES | 18 ++++++++++++++---- RELEASE-NOTES | 4 +++- lib/ftp.c | 21 ++++++++++++++++++--- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index 0b5ec2536..52995a6bf 100644 --- a/CHANGES +++ b/CHANGES @@ -6,11 +6,21 @@ Changelog +Daniel Stenberg (27 Jul 2009) +- All the quote options (CURLOPT_QUOTE, CURLOPT_POSTQUOTE and + CURLOPT_PREQUOTE) now accept a preceeding asterisk before the command to + send when using FTP, as a sign that libcurl shall simply ignore the response + from the server instead of treating it as an error. Not treating a 400+ FTP + response code as an error means that failed commands will not abort the + chain of commands, nor will they cause the connection to get disconnected. + Daniel Stenberg (26 Jul 2009) -- Bug report #2825989 (http://curl.haxx.se/bug/view.cgi?id=2825989) pointed - out that OpenSSL-powered libcurl didn't support the SHA-2 digest algorithm, - and provided the solution too: to use OpenSSL_add_all_algorithms() instead - of the older SSLeay_* alternative. +- Johan van Selst posted bug report #2825989 + (http://curl.haxx.se/bug/view.cgi?id=2825989) pointing out that + OpenSSL-powered libcurl didn't support the SHA-2 digest algorithm, and + provided the solution too: to use OpenSSL_add_all_algorithms() in addition + to the older SSLeay_* alternative. OpenSSL_add_all_algorithms was added in + OpenSSL 0.9.5 Daniel Stenberg (23 Jul 2009) - Added CURLOPT_SSH_KNOWNHOSTS, CURLOPT_SSH_KEYFUNCTION, CURLOPT_SSH_KEYDATA. diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 5f68c1bc5..1b94e20c1 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -11,6 +11,8 @@ This release includes the following changes: o CURLOPT_FTPPORT (and curl's -P/--ftpport) support port ranges o Added CURLOPT_SSH_KNOWNHOSTS, CURLOPT_SSH_KEYFUNCTION, CURLOPT_SSH_KEYDATA + o CURLOPT_QUOTE, CURLOPT_POSTQUOTE and CURLOPT_PREQUOTE can be told to ignore + error responses when used with FTP This release includes the following bugfixes: @@ -48,6 +50,6 @@ advice from friends like these: Andre Guibert de Bruet, Mike Crowe, Claes Jakobsson, John E. Malmberg, Aaron Oneal, Igor Novoseltsev, Eric Wong, Bill Hoffman, Daniel Steinberg, Fabian Keil, Michal Marek, Reuven Wachtfogel, Markus Koetter, - Constantine Sapuntzakis, David Binderman + Constantine Sapuntzakis, David Binderman, Johan van Selst Thanks! (and sorry if I forgot to mention someone) diff --git a/lib/ftp.c b/lib/ftp.c index ebd971571..4ded990b6 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -3323,6 +3323,8 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status, * * Where a 'quote' means a list of custom commands to send to the server. * The quote list is passed as an argument. + * + * BLOCKING */ static @@ -3336,14 +3338,27 @@ CURLcode ftp_sendquote(struct connectdata *conn, struct curl_slist *quote) item = quote; while(item) { if(item->data) { - FTPSENDF(conn, "%s", item->data); + char *cmd = item->data; + bool acceptfail = FALSE; + + /* if a command starts with an asterisk, which a legal FTP command never + can, the command will be allowed to fail without it causing any + aborts or cancels etc. It will cause libcurl to act as if the command + is successful, whatever the server reponds. */ + + if(cmd[0] == '*') { + cmd++; + acceptfail = TRUE; + } + + FTPSENDF(conn, "%s", cmd); result = Curl_GetFTPResponse(&nread, conn, &ftpcode); if(result) return result; - if(ftpcode >= 400) { - failf(conn->data, "QUOT string not accepted: %s", item->data); + if(!acceptfail && (ftpcode >= 400)) { + failf(conn->data, "QUOT string not accepted: %s", cmd); return CURLE_QUOTE_ERROR; } }