aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2005-01-25 22:13:12 +0000
committerDaniel Stenberg <daniel@haxx.se>2005-01-25 22:13:12 +0000
commit177dbc7be07125582ddb7416dba7140b88ab9f62 (patch)
tree427fa08bfdea3642ac8ecd19776b43b888b2bc24
parentf2e71edcbd479345678bb03e76fad17157fc318e (diff)
Ian Ford asked about support for the FTP command ACCT, and I discovered it is
present in RFC959... so now (lib)curl supports it as well. --ftp-account and CURLOPT_FTP_ACCOUNT set the account string. (The server may ask for an account string after PASS have been sent away. The client responds with "ACCT [account string]".) Added test case 228 and 229 to verify the functionality. Updated the test FTP server to support ACCT somewhat.
-rw-r--r--CHANGES7
-rw-r--r--RELEASE-NOTES7
-rw-r--r--docs/curl.18
-rw-r--r--docs/libcurl/curl_easy_setopt.36
-rw-r--r--include/curl/curl.h4
-rw-r--r--lib/ftp.c17
-rw-r--r--lib/url.c4
-rw-r--r--lib/urldata.h1
-rw-r--r--src/main.c12
-rw-r--r--tests/data/Makefile.am3
-rw-r--r--tests/data/test22844
-rw-r--r--tests/data/test22932
12 files changed, 136 insertions, 9 deletions
diff --git a/CHANGES b/CHANGES
index fd824be96..77b770f71 100644
--- a/CHANGES
+++ b/CHANGES
@@ -7,6 +7,13 @@
Changelog
Daniel (25 January 2005)
+- Ian Ford asked about support for the FTP command ACCT, and I discovered it
+ is present in RFC959... so now (lib)curl supports it as well. --ftp-account
+ and CURLOPT_FTP_ACCOUNT set the account string. (The server may ask for an
+ account string after PASS have been sent away. The client responds
+ with "ACCT [account string]".) Added test case 228 and 229 to verify the
+ functionality. Updated the test FTP server to support ACCT somewhat.
+
- David Shaw contributed a fairly complete and detailed autoconf test you can
use to detect libcurl and setup variables for the protocols the installed
libcurl supports: docs/libcurl/libcurl.m4
diff --git a/RELEASE-NOTES b/RELEASE-NOTES
index de34cbb52..5e57b2231 100644
--- a/RELEASE-NOTES
+++ b/RELEASE-NOTES
@@ -2,14 +2,15 @@ Curl and libcurl 7.13.0
Public curl release number: 85
Releases counted from the very beginning: 112
- Available command line options: 103
- Available curl_easy_setopt() options: 121
+ Available command line options: 104
+ Available curl_easy_setopt() options: 122
Number of public functions in libcurl: 46
Amount of public web site mirrors: 15
Number of known libcurl bindings: 29
This release includes the following changes:
+ o added --ftp-account and CURLOPT_FTP_ACCOUNT
o added CURLOPT_SOURCE_URL and CURLOPT_SOURCE_QUOTE
o obsoleted CURLOPT_SOURCE_HOST, CURLOPT_SOURCE_PATH, CURLOPT_SOURCE_PORT
and CURLOPT_PASV_HOST
@@ -49,6 +50,6 @@ advice from friends like these:
Werner Koch, Gisle Vanem, Alex Neblett, Kai Sommerfeld, Marty Kuhrt,
Hzhijun, Pavel Orehov, Bruce Mitchener, Cyrill Osterwalder, Dan Torop,
Martijn Koster, Alex aka WindEagle, Cody Jones, Samuel Díaz García,
- Stephan Bergmann, Philippe Hameau
+ Stephan Bergmann, Philippe Hameau, Ian Ford
Thanks! (and sorry if I forgot to mention someone)
diff --git a/docs/curl.1 b/docs/curl.1
index 3556d1ce6..4dc8f0425 100644
--- a/docs/curl.1
+++ b/docs/curl.1
@@ -21,7 +21,7 @@
.\" * $Id$
.\" **************************************************************************
.\"
-.TH curl 1 "20 Jan 2005" "Curl 7.13.0" "Curl Manual"
+.TH curl 1 "25 Jan 2005" "Curl 7.13.0" "Curl Manual"
.SH NAME
curl \- transfer a URL
.SH SYNOPSIS
@@ -330,6 +330,12 @@ document stating so (which often also describes why and more). This flag will
prevent curl from outputting that and fail silently instead.
If this option is used twice, the second will again disable silent failure.
+.IP "--ftp-account [data]"
+(FTP) When an FTP server asks for "account data" after user name and password
+has been provided, this data is sent off using the ACCT command. (Added in
+7.13.0)
+
+If this option is used twice, the second will override the previous use.
.IP "--ftp-create-dirs"
(FTP) When an FTP URL/operation uses a path that doesn't currently exist on
the server, the standard behavior of curl is to fail. Using this option, curl
diff --git a/docs/libcurl/curl_easy_setopt.3 b/docs/libcurl/curl_easy_setopt.3
index 776e3da90..84e5c1b80 100644
--- a/docs/libcurl/curl_easy_setopt.3
+++ b/docs/libcurl/curl_easy_setopt.3
@@ -21,7 +21,7 @@
.\" * $Id$
.\" **************************************************************************
.\"
-.TH curl_easy_setopt 3 "20 Jan 2005" "libcurl 7.12.4" "libcurl Manual"
+.TH curl_easy_setopt 3 "25 Jan 2005" "libcurl 7.13.0" "libcurl Manual"
.SH NAME
curl_easy_setopt - set options for a curl easy handle
.SH SYNOPSIS
@@ -763,6 +763,10 @@ Exactly like \fICURLOPT_QUOTE\fP, but for the source host.
Exactly like \fICURLOPT_PREQUOTE\fP, but for the source host.
.IP CURLOPT_SOURCE_POSTQUOTE
Exactly like \fICURLOPT_POSTQUOTE\fP, but for the source host.
+.IP CURLOPT_FTP_ACCOUNT
+Pass a pointer to a zero-terminated string (or NULL to disable). When an FTP
+server asks for "account data" after user name and password has been provided,
+this data is sent off using the ACCT command. (Added in 7.13.0)
.SH PROTOCOL OPTIONS
.IP CURLOPT_TRANSFERTEXT
A non-zero parameter tells the library to use ASCII mode for ftp transfers,
diff --git a/include/curl/curl.h b/include/curl/curl.h
index 07c028b3b..019ef08a0 100644
--- a/include/curl/curl.h
+++ b/include/curl/curl.h
@@ -882,6 +882,10 @@ typedef enum {
commands with this */
CINIT(SOURCE_QUOTE, OBJECTPOINT, 133),
+ /* zero terminated string for pass on to the FTP server when asked for
+ "account" info */
+ CINIT(FTP_ACCOUNT, OBJECTPOINT, 134),
+
CURLOPT_LASTENTRY /* the last unused */
} CURLoption;
diff --git a/lib/ftp.c b/lib/ftp.c
index 3f4b23fe7..caca95e95 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -621,6 +621,23 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
infof(data, "We have successfully logged in\n");
}
+ else if(ftpcode == 332) {
+ /* 332 Please provide account info */
+ if(data->set.ftp_account) {
+ FTPSENDF(conn, "ACCT %s", data->set.ftp_account);
+ result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
+ if(!result && (ftpcode != 230)) {
+ failf(data, "ACCT rejected by server: %03d", ftpcode);
+ result = CURLE_FTP_WEIRD_PASS_REPLY; /* FIX */
+ }
+ }
+ else {
+ failf(data, "ACCT requested by none available");
+ result = CURLE_FTP_WEIRD_PASS_REPLY;
+ }
+ if(result)
+ return result;
+ }
else {
failf(data, "Odd return code after PASS");
return CURLE_FTP_WEIRD_PASS_REPLY;
diff --git a/lib/url.c b/lib/url.c
index 8b433f606..f5fc82be4 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -1396,6 +1396,10 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, ...)
data->set.source_postquote = va_arg(param, struct curl_slist *);
break;
+ case CURLOPT_FTP_ACCOUNT:
+ data->set.ftp_account = va_arg(param, char *);
+ break;
+
default:
/* unknown tag and its companion, just ignore: */
result = CURLE_FAILED_INIT; /* correct this */
diff --git a/lib/urldata.h b/lib/urldata.h
index 70045de79..76de45757 100644
--- a/lib/urldata.h
+++ b/lib/urldata.h
@@ -862,6 +862,7 @@ struct UserDefined {
char *cookiejar; /* dump all cookies to this file */
bool cookiesession; /* new cookie session? */
bool crlf; /* convert crlf on ftp upload(?) */
+ char *ftp_account; /* ftp account data */
struct curl_slist *quote; /* after connection is established */
struct curl_slist *postquote; /* after the transfer */
struct curl_slist *prequote; /* before the transfer, after type */
diff --git a/src/main.c b/src/main.c
index 708b8124d..14f34fac1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -548,7 +548,7 @@ struct Configurable {
struct curl_slist *tp_quote;
struct curl_slist *tp_postquote;
struct curl_slist *tp_prequote;
-
+ char *ftp_account; /* for ACCT */
};
/* global variable to hold info about libcurl */
@@ -1249,10 +1249,10 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
{"$g", "retry", TRUE},
{"$h", "retry-delay", TRUE},
{"$i", "retry-max-time", TRUE},
-
{"$j", "3p-url", TRUE},
{"$k", "3p-user", TRUE},
{"$l", "3p-quote", TRUE},
+ {"$m", "ftp-account", TRUE},
{"0", "http1.0", FALSE},
{"1", "tlsv1", FALSE},
@@ -1631,6 +1631,9 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
break;
/* break */
+ case 'm': /* --ftp-account */
+ GetStr(&config->ftp_account, nextarg);
+ break;
}
break;
case '#': /* added 19990617 larsa */
@@ -2830,6 +2833,8 @@ static void free_config_fields(struct Configurable *config)
free(config->tp_url);
if(config->tp_user)
free(config->tp_user);
+ if(config->ftp_account)
+ free(config->ftp_account);
curl_slist_free_all(config->quote); /* checks for config->quote == NULL */
curl_slist_free_all(config->prequote);
@@ -3655,12 +3660,13 @@ operate(struct Configurable *config, int argc, char *argv[])
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
}
- /* curl 7.12.4 */
+ /* curl 7.13.0 */
curl_easy_setopt(curl, CURLOPT_SOURCE_URL, config->tp_url);
curl_easy_setopt(curl, CURLOPT_SOURCE_USERPWD, config->tp_user);
curl_easy_setopt(curl, CURLOPT_SOURCE_PREQUOTE, config->tp_prequote);
curl_easy_setopt(curl, CURLOPT_SOURCE_POSTQUOTE, config->tp_postquote);
curl_easy_setopt(curl, CURLOPT_SOURCE_QUOTE, config->tp_quote);
+ curl_easy_setopt(curl, CURLOPT_FTP_ACCOUNT, config->ftp_account);
retry_numretries = config->req_retry;
diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
index 7fe4a1818..ebbfdab0b 100644
--- a/tests/data/Makefile.am
+++ b/tests/data/Makefile.am
@@ -31,7 +31,8 @@ EXTRA_DIST = test1 test108 test117 test127 test20 test27 test34 test46 \
test517 test518 test210 test211 test212 test220 test221 test222 \
test223 test224 test206 test207 test208 test209 test213 test240 \
test241 test242 test519 test214 test215 test216 test217 test218 \
- test199 test225 test226 test227 test230 test231 test232
+ test199 test225 test226 test227 test230 test231 test232 test228 \
+ test229
# The following tests have been removed from the dist since they no longer
# work. We need to fix the test suite's FTPS server first, then bring them
diff --git a/tests/data/test228 b/tests/data/test228
new file mode 100644
index 000000000..85f7989a5
--- /dev/null
+++ b/tests/data/test228
@@ -0,0 +1,44 @@
+# Server-side
+<reply>
+<data>
+data
+ to
+ see
+that FTP
+works
+ so does it?
+</data>
+</reply>
+
+# Client-side
+<client>
+<server>
+ftp
+</server>
+ <name>
+FTP RETR with ACCT
+ </name>
+ <command>
+ftp://%HOSTIP:%FTPPORT/228 --ftp-account "one count"
+</command>
+<file name="log/ftpserver.cmd">
+REPLY PASS 332 please provide account name
+REPLY ACCT 230 thank you
+</file>
+</client>
+
+
+# Verify data after the test has been "shot"
+<verify>
+<protocol>
+USER anonymous
+PASS curl_by_daniel@haxx.se
+ACCT one count
+PWD
+EPSV
+TYPE I
+SIZE 228
+RETR 228
+QUIT
+</protocol>
+</verify>
diff --git a/tests/data/test229 b/tests/data/test229
new file mode 100644
index 000000000..ea8ceb53a
--- /dev/null
+++ b/tests/data/test229
@@ -0,0 +1,32 @@
+# Server-side
+<reply>
+</reply>
+
+# Client-side
+<client>
+<server>
+ftp
+</server>
+ <name>
+FTP RETR with bad ACCT
+ </name>
+ <command>
+ftp://%HOSTIP:%FTPPORT/229 --ftp-account "one count"
+</command>
+<file name="log/ftpserver.cmd">
+REPLY PASS 332 please provide account name
+REPLY ACCT 532 bluah!
+</file>
+</client>
+
+# Verify data after the test has been "shot"
+<verify>
+<protocol>
+USER anonymous
+PASS curl_by_daniel@haxx.se
+ACCT one count
+</protocol>
+<errorcode>
+11
+</errorcode>
+</verify>