mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
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.
This commit is contained in:
parent
f2e71edcbd
commit
177dbc7be0
7
CHANGES
7
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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
||||
|
17
lib/ftp.c
17
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;
|
||||
|
@ -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 */
|
||||
|
@ -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 */
|
||||
|
12
src/main.c
12
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;
|
||||
|
||||
|
@ -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
|
||||
|
44
tests/data/test228
Normal file
44
tests/data/test228
Normal file
@ -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>
|
32
tests/data/test229
Normal file
32
tests/data/test229
Normal file
@ -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>
|
Loading…
Reference in New Issue
Block a user