mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
Support for FTP third party transfers is now dropped
This commit is contained in:
parent
ae13c93b7d
commit
5e0d9aea32
21
CHANGES
21
CHANGES
@ -6,6 +6,27 @@
|
||||
|
||||
Changelog
|
||||
|
||||
Daniel (29 September 2006)
|
||||
- Removed a few other no-longer present options from the header file.
|
||||
|
||||
- Support for FTP third party transfers was removed. Here's why:
|
||||
|
||||
o The recent multi interface changes broke it and the design of the 3rd party
|
||||
transfers made it very hard to fix the problems
|
||||
o It was still blocking and thus nasty for the multi interface
|
||||
o It was a lot of extra code for a very rarely used feature
|
||||
o It didn't use the same code as for "plain" FTP transfers, so it didn't work
|
||||
fine for IPv6 and it didn't properly re-use connections and more
|
||||
o There's nobody around who's willing to work on and improve the existing
|
||||
code
|
||||
|
||||
This does not mean that third party transfers are banned forever, only that
|
||||
they need to be done better if they are to be re-added in the future.
|
||||
|
||||
The CURLOPT_SOURCE_* options are removed from the lib and so are the --3p*
|
||||
options from the command line tool. For this reason, I also bumped the
|
||||
version info for the lib.
|
||||
|
||||
Daniel (28 September 2006)
|
||||
- Reported in #1561470 (http://curl.haxx.se/bug/view.cgi?id=1561470), libcurl
|
||||
would crash if a bad function sequence was used when shutting down after
|
||||
|
@ -2,8 +2,8 @@ Curl and libcurl 7.16.0
|
||||
|
||||
Public curl release number: 96
|
||||
Releases counted from the very beginning: 123
|
||||
Available command line options: 117
|
||||
Available curl_easy_setopt() options: 138
|
||||
Available command line options: 112
|
||||
Available curl_easy_setopt() options: 133
|
||||
Number of public functions in libcurl: 54
|
||||
Amount of public web site mirrors: 33
|
||||
Number of known libcurl bindings: 34
|
||||
@ -11,6 +11,8 @@ Curl and libcurl 7.16.0
|
||||
|
||||
This release includes the following changes:
|
||||
|
||||
o The CURLOPT_SOURCE_* options are removed and so are the --3p* command line
|
||||
options
|
||||
o curl_multi_socket() and family are suitable to start using
|
||||
o uses WSAPoll() on Windows Vista
|
||||
o (FTP) --ftp-ssl-control was added
|
||||
|
11
docs/curl.1
11
docs/curl.1
@ -1242,17 +1242,6 @@ Forces curl to use SSL version 2 when negotiating with a remote SSL server.
|
||||
.IP "-3/--sslv3"
|
||||
(SSL)
|
||||
Forces curl to use SSL version 3 when negotiating with a remote SSL server.
|
||||
.IP "--3p-quote"
|
||||
(FTP) Specify arbitrary commands to send to the source server. See the
|
||||
\fI-Q/--quote\fP option for details. (Added in 7.13.0)
|
||||
.IP "--3p-url"
|
||||
(FTP) Activates a FTP 3rd party transfer. Specifies the source URL to get a
|
||||
file from, while the "normal" URL will be used as target URL, the file that
|
||||
will be written/created.
|
||||
|
||||
Note that not all FTP server allow 3rd party transfers. (Added in 7.13.0)
|
||||
.IP "--3p-user"
|
||||
(FTP) Specify user:password for the source URL transfer. (Added in 7.13.0)
|
||||
.IP "-4/--ipv4"
|
||||
If libcurl is capable of resolving an address to multiple IP versions (which
|
||||
it is if it is ipv6-capable), this option tells libcurl to resolve names to
|
||||
|
@ -917,18 +917,6 @@ Try "AUTH SSL" first, and only if that fails try "AUTH TLS"
|
||||
.IP CURLFTPAUTH_TLS
|
||||
Try "AUTH TLS" first, and only if that fails try "AUTH SSL"
|
||||
.RE
|
||||
.IP CURLOPT_SOURCE_URL
|
||||
When set, it enables a FTP third party transfer, using the set URL as source,
|
||||
while \fICURLOPT_URL\fP is the target.
|
||||
.IP CURLOPT_SOURCE_USERPWD
|
||||
Set "username:password" to use for the source connection when doing FTP third
|
||||
party transfers.
|
||||
.IP CURLOPT_SOURCE_QUOTE
|
||||
Exactly like \fICURLOPT_QUOTE\fP, but for the source host.
|
||||
.IP CURLOPT_SOURCE_PREQUOTE
|
||||
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,
|
||||
|
@ -941,22 +941,12 @@ typedef enum {
|
||||
CINIT(TCP_NODELAY, LONG, 121),
|
||||
|
||||
/* 122 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */
|
||||
|
||||
/* When doing 3rd party transfer, set the source user and password with
|
||||
this */
|
||||
CINIT(SOURCE_USERPWD, OBJECTPOINT, 123),
|
||||
|
||||
/* 123 OBSOLETE. Gone in 7.16.0 */
|
||||
/* 124 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */
|
||||
/* 125 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */
|
||||
/* 126 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */
|
||||
|
||||
/* When doing 3rd party transfer, set the source pre-quote linked list
|
||||
of commands with this */
|
||||
CINIT(SOURCE_PREQUOTE, OBJECTPOINT, 127),
|
||||
|
||||
/* When doing 3rd party transfer, set the source post-quote linked list
|
||||
of commands with this */
|
||||
CINIT(SOURCE_POSTQUOTE, OBJECTPOINT, 128),
|
||||
/* 127 OBSOLETE. Gone in 7.16.0 */
|
||||
/* 128 OBSOLETE. Gone in 7.16.0 */
|
||||
|
||||
/* When FTP over SSL/TLS is selected (with CURLOPT_FTP_SSL), this option
|
||||
can be used to change libcurl's default action which is to first try
|
||||
@ -973,12 +963,8 @@ typedef enum {
|
||||
CINIT(IOCTLFUNCTION, FUNCTIONPOINT, 130),
|
||||
CINIT(IOCTLDATA, OBJECTPOINT, 131),
|
||||
|
||||
/* To make a 3rd party transfer, set the source URL with this */
|
||||
CINIT(SOURCE_URL, OBJECTPOINT, 132),
|
||||
|
||||
/* When doing 3rd party transfer, set the source quote linked list of
|
||||
commands with this */
|
||||
CINIT(SOURCE_QUOTE, OBJECTPOINT, 133),
|
||||
/* 132 OBSOLETE. Gone in 7.16.0 */
|
||||
/* 133 OBSOLETE. Gone in 7.16.0 */
|
||||
|
||||
/* zero terminated string for pass on to the FTP server when asked for
|
||||
"account" info */
|
||||
@ -1059,18 +1045,6 @@ typedef enum {
|
||||
|
||||
#ifndef CURL_NO_OLDIES /* define this to test if your app builds with all
|
||||
the obsolete stuff removed! */
|
||||
#define CURLOPT_HTTPREQUEST -1
|
||||
#define CURLOPT_FTPASCII CURLOPT_TRANSFERTEXT
|
||||
#define CURLOPT_MUTE -2
|
||||
#define CURLOPT_PASSWDFUNCTION -3
|
||||
#define CURLOPT_PASSWDDATA -4
|
||||
#define CURLOPT_CLOSEFUNCTION -5
|
||||
|
||||
#define CURLOPT_SOURCE_HOST -6
|
||||
#define CURLOPT_SOURCE_PATH -7
|
||||
#define CURLOPT_SOURCE_PORT -8
|
||||
#define CURLOPT_PASV_HOST -9
|
||||
|
||||
#else
|
||||
/* This is set if CURL_NO_OLDIES is defined at compile-time */
|
||||
#undef CURLOPT_DNS_USE_GLOBAL_CACHE /* soon obsolete */
|
||||
|
@ -48,7 +48,7 @@ INCLUDES = -I$(top_srcdir)/include \
|
||||
-I$(top_builddir)/lib \
|
||||
-I$(top_srcdir)/lib
|
||||
|
||||
VERSION=-version-info 3:0:0
|
||||
VERSION=-version-info 4:0:0
|
||||
|
||||
# This flag accepts an argument of the form current[:revision[:age]]. So,
|
||||
# passing -version-info 3:12:1 sets current to 3, revision to 12, and age to
|
||||
|
298
lib/ftp.c
298
lib/ftp.c
@ -118,12 +118,9 @@ static CURLcode ftp_cwd(struct connectdata *conn, char *path);
|
||||
static CURLcode ftp_mkd(struct connectdata *conn, char *path);
|
||||
static CURLcode ftp_cwd_and_mkd(struct connectdata *conn, char *path);
|
||||
static CURLcode ftp_quit(struct connectdata *conn);
|
||||
static CURLcode ftp_3rdparty_pretransfer(struct connectdata *conn);
|
||||
static CURLcode ftp_3rdparty_transfer(struct connectdata *conn);
|
||||
static CURLcode ftp_parse_url_path(struct connectdata *conn);
|
||||
static CURLcode ftp_cwd_and_create_path(struct connectdata *conn);
|
||||
static CURLcode ftp_regular_transfer(struct connectdata *conn, bool *done);
|
||||
static CURLcode ftp_3rdparty(struct connectdata *conn);
|
||||
static void ftp_pasv_verbose(struct connectdata *conn,
|
||||
Curl_addrinfo *ai,
|
||||
char *newhost, /* ascii version */
|
||||
@ -2962,10 +2959,6 @@ CURLcode Curl_ftp_done(struct connectdata *conn, CURLcode status)
|
||||
*/
|
||||
return CURLE_OK;
|
||||
|
||||
|
||||
if (conn->sec_path)
|
||||
path_to_use = conn->sec_path;
|
||||
|
||||
/* now store a copy of the directory we are in */
|
||||
if(ftpc->prevpath)
|
||||
free(ftpc->prevpath);
|
||||
@ -3098,11 +3091,6 @@ CURLcode Curl_ftp_done(struct connectdata *conn, CURLcode status)
|
||||
ftp->no_transfer = FALSE;
|
||||
ftpc->dont_check = FALSE;
|
||||
|
||||
if (!result && conn->sec_conn) { /* 3rd party transfer */
|
||||
/* "done" with the secondary connection */
|
||||
result = Curl_ftp_done(conn->sec_conn, status);
|
||||
}
|
||||
|
||||
/* Send any post-transfer QUOTE strings? */
|
||||
if(!status && !result && data->set.postquote)
|
||||
result = ftp_sendquote(conn, data->set.postquote);
|
||||
@ -3147,40 +3135,6 @@ CURLcode ftp_sendquote(struct connectdata *conn, struct curl_slist *quote)
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* ftp_transfertype()
|
||||
*
|
||||
* Set transfer type. We only deal with ASCII or BINARY so this function
|
||||
* sets one of them.
|
||||
*/
|
||||
static CURLcode ftp_transfertype(struct connectdata *conn,
|
||||
bool ascii)
|
||||
{
|
||||
struct SessionHandle *data = conn->data;
|
||||
int ftpcode;
|
||||
ssize_t nread;
|
||||
CURLcode result;
|
||||
|
||||
FTPSENDF(conn, "TYPE %c", ascii?'A':'I');
|
||||
|
||||
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
|
||||
if(result)
|
||||
return result;
|
||||
|
||||
if(ftpcode != 200) {
|
||||
failf(data, "Couldn't set %s mode",
|
||||
ascii?"ASCII":"binary");
|
||||
return ascii? CURLE_FTP_COULDNT_SET_ASCII:CURLE_FTP_COULDNT_SET_BINARY;
|
||||
}
|
||||
|
||||
/* keep track of our current transfer type */
|
||||
conn->proto.ftpc.transfertype = ascii?'A':'I';
|
||||
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* ftp_need_type()
|
||||
@ -3428,13 +3382,7 @@ CURLcode Curl_ftp(struct connectdata *conn, bool *done)
|
||||
if (retcode)
|
||||
return retcode;
|
||||
|
||||
if (conn->sec_conn) {
|
||||
/* 3rd party transfer */
|
||||
*done = TRUE; /* BLOCKING */
|
||||
retcode = ftp_3rdparty(conn);
|
||||
}
|
||||
else
|
||||
retcode = ftp_regular_transfer(conn, done);
|
||||
retcode = ftp_regular_transfer(conn, done);
|
||||
|
||||
return retcode;
|
||||
}
|
||||
@ -3720,182 +3668,6 @@ static CURLcode ftp_cwd_and_mkd(struct connectdata *conn, char *path)
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* ftp_3rdparty_pretransfer()
|
||||
*
|
||||
* Preparation for 3rd party transfer.
|
||||
*
|
||||
*/
|
||||
static CURLcode ftp_3rdparty_pretransfer(struct connectdata *conn)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct SessionHandle *data = conn->data;
|
||||
struct connectdata *sec_conn = conn->sec_conn;
|
||||
|
||||
conn->xfertype = TARGET3RD;
|
||||
sec_conn->xfertype = SOURCE3RD;
|
||||
|
||||
/* sets transfer type */
|
||||
result = ftp_transfertype(conn, data->set.prefer_ascii);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
result = ftp_transfertype(sec_conn, data->set.prefer_ascii);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
/* Send any PREQUOTE strings after transfer type is set? */
|
||||
if (data->set.source_prequote) {
|
||||
/* sends command(s) to source server before file transfer */
|
||||
result = ftp_sendquote(sec_conn, data->set.source_prequote);
|
||||
}
|
||||
if (!result && data->set.prequote)
|
||||
result = ftp_sendquote(conn, data->set.prequote);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* ftp_3rdparty_transfer()
|
||||
*
|
||||
* Performs 3rd party transfer.
|
||||
*
|
||||
*/
|
||||
static CURLcode ftp_3rdparty_transfer(struct connectdata *conn)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
ssize_t nread;
|
||||
int ftpcode, ip[4], port[2];
|
||||
struct SessionHandle *data = conn->data;
|
||||
struct connectdata *sec_conn = conn->sec_conn;
|
||||
char *buf = data->state.buffer; /* this is our buffer */
|
||||
char *str = buf;
|
||||
char pasv_port[50];
|
||||
const char *stor_cmd;
|
||||
struct connectdata *pasv_conn;
|
||||
struct connectdata *port_conn;
|
||||
|
||||
char *path = data->reqdata.path;
|
||||
|
||||
if (data->set.ftpport == NULL) {
|
||||
pasv_conn = conn;
|
||||
port_conn = sec_conn;
|
||||
}
|
||||
else {
|
||||
pasv_conn = sec_conn;
|
||||
port_conn = conn;
|
||||
}
|
||||
|
||||
if (sec_conn->sec_path)
|
||||
path = sec_conn->sec_path;
|
||||
|
||||
result = ftp_cwd_and_create_path(conn);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
/* sets the passive mode */
|
||||
FTPSENDF(pasv_conn, "%s", "PASV");
|
||||
result = Curl_GetFTPResponse(&nread, pasv_conn, &ftpcode);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
if (ftpcode != 227) {
|
||||
failf(data, "Odd return code after PASV: %03d", ftpcode);
|
||||
return CURLE_FTP_WEIRD_PASV_REPLY;
|
||||
}
|
||||
|
||||
while (*str) {
|
||||
if (6 == sscanf(str, "%d,%d,%d,%d,%d,%d",
|
||||
&ip[0], &ip[1], &ip[2], &ip[3], &port[0], &port[1]))
|
||||
break;
|
||||
str++;
|
||||
}
|
||||
|
||||
if (!*str) {
|
||||
failf(pasv_conn->data, "Couldn't interpret the 227-reply");
|
||||
return CURLE_FTP_WEIRD_227_FORMAT;
|
||||
}
|
||||
|
||||
snprintf(pasv_port, sizeof(pasv_port), "%d,%d,%d,%d,%d,%d", ip[0], ip[1],
|
||||
ip[2], ip[3], port[0], port[1]);
|
||||
|
||||
/* sets data connection between remote hosts */
|
||||
FTPSENDF(port_conn, "PORT %s", pasv_port);
|
||||
result = Curl_GetFTPResponse(&nread, port_conn, &ftpcode);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
if (ftpcode != 200) {
|
||||
failf(data, "PORT command attempts failed: %03d", ftpcode);
|
||||
return CURLE_FTP_PORT_FAILED;
|
||||
}
|
||||
|
||||
/* we might append onto the file instead of overwriting it */
|
||||
stor_cmd = data->set.ftp_append?"APPE":"STOR";
|
||||
|
||||
/* transfers file between remote hosts */
|
||||
/* FIX: this should send a series of CWD commands and then RETR only the
|
||||
ftp->file file. The conn->data->reqdata.path "full path" is not
|
||||
unescaped. Test case 230 tests this. */
|
||||
FTPSENDF(sec_conn, "RETR %s", path);
|
||||
|
||||
if(!data->set.ftpport) {
|
||||
|
||||
result = Curl_GetFTPResponse(&nread, sec_conn, &ftpcode);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
if((ftpcode != 150) && (ftpcode != 125)) {
|
||||
failf(data, "Failed RETR: %03d", ftpcode);
|
||||
return CURLE_FTP_COULDNT_RETR_FILE;
|
||||
}
|
||||
|
||||
result = Curl_ftpsendf(conn, "%s %s", stor_cmd,
|
||||
data->reqdata.proto.ftp->file);
|
||||
if(CURLE_OK == result)
|
||||
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
if (ftpcode >= 400) {
|
||||
failf(data, "Failed FTP upload: %03d", ftpcode);
|
||||
return CURLE_FTP_COULDNT_STOR_FILE;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
result = Curl_ftpsendf(conn, "%s %s", stor_cmd,
|
||||
data->reqdata.proto.ftp->file);
|
||||
if(CURLE_OK == result)
|
||||
result = Curl_GetFTPResponse(&nread, sec_conn, &ftpcode);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
if (ftpcode >= 400) {
|
||||
failf(data, "Failed FTP upload: %03d", ftpcode);
|
||||
return CURLE_FTP_COULDNT_STOR_FILE;
|
||||
}
|
||||
|
||||
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
if((ftpcode != 150) && (ftpcode != 125)) {
|
||||
failf(data, "Failed FTP upload: %03d", ftpcode);
|
||||
return CURLE_FTP_COULDNT_STOR_FILE;
|
||||
}
|
||||
}
|
||||
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* ftp_parse_url_path()
|
||||
@ -3916,10 +3688,6 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
|
||||
char *path_to_use = data->reqdata.path;
|
||||
char *cur_pos;
|
||||
|
||||
if (conn->sec_path) {
|
||||
path_to_use = conn->sec_path;
|
||||
}
|
||||
|
||||
cur_pos = path_to_use; /* current position in path. point at the begin
|
||||
of next path component */
|
||||
|
||||
@ -4056,44 +3824,6 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
|
||||
return retcode;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* ftp_cwd_and_create_path()
|
||||
*
|
||||
* Creates full path on remote target host.
|
||||
*
|
||||
*/
|
||||
static
|
||||
CURLcode ftp_cwd_and_create_path(struct connectdata *conn)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct ftp_conn *ftpc = &conn->proto.ftpc;
|
||||
int i;
|
||||
|
||||
if(ftpc->cwddone)
|
||||
/* already done and fine */
|
||||
return CURLE_OK;
|
||||
|
||||
/* This is a re-used connection. Since we change directory to where the
|
||||
transfer is taking place, we must now get back to the original dir
|
||||
where we ended up after login: */
|
||||
if (conn->bits.reuse && ftpc->entrypath) {
|
||||
if ((result = ftp_cwd_and_mkd(conn, ftpc->entrypath)) != CURLE_OK)
|
||||
return result;
|
||||
}
|
||||
|
||||
for (i=0; i < ftpc->dirdepth; i++) {
|
||||
/* RFC 1738 says empty components should be respected too, but
|
||||
that is plain stupid since CWD can't be used with an empty argument */
|
||||
if ((result = ftp_cwd_and_mkd(conn, ftpc->dirs[i])) != CURLE_OK)
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* call this when the DO phase has completed */
|
||||
static CURLcode ftp_dophase_done(struct connectdata *conn,
|
||||
bool connected)
|
||||
@ -4188,30 +3918,4 @@ CURLcode ftp_regular_transfer(struct connectdata *conn,
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* ftp_3rdparty()
|
||||
*
|
||||
* The input argument is already checked for validity.
|
||||
* Performs a 3rd party transfer between two remote hosts.
|
||||
*/
|
||||
static CURLcode ftp_3rdparty(struct connectdata *conn)
|
||||
{
|
||||
struct Curl_transfer_keeper *k = &conn->data->reqdata.keep;
|
||||
CURLcode result = CURLE_OK;
|
||||
|
||||
/* both control connections start out fine */
|
||||
conn->proto.ftpc.ctl_valid = TRUE;
|
||||
conn->sec_conn->proto.ftpc.ctl_valid = TRUE;
|
||||
k->size = -1;
|
||||
|
||||
result = ftp_3rdparty_pretransfer(conn);
|
||||
if (!result)
|
||||
result = ftp_3rdparty_transfer(conn);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif /* CURL_DISABLE_FTP */
|
||||
|
@ -590,9 +590,7 @@ int Curl_debug(struct SessionHandle *data, curl_infotype type,
|
||||
}
|
||||
|
||||
if(t) {
|
||||
snprintf(buffer, sizeof(buffer), "[%s %s %s%s]", w, t,
|
||||
conn->xfertype==NORMAL?"":
|
||||
(conn->xfertype==SOURCE3RD?"source ":"target "),
|
||||
snprintf(buffer, sizeof(buffer), "[%s %s %s]", w, t,
|
||||
conn->host.dispname);
|
||||
rc = showit(data, CURLINFO_TEXT, buffer, strlen(buffer));
|
||||
if(rc)
|
||||
|
@ -2246,13 +2246,6 @@ CURLcode Curl_perform(struct SessionHandle *data)
|
||||
do {
|
||||
res = Curl_connect_host(data, &conn); /* primary connection */
|
||||
|
||||
if(res == CURLE_OK) {
|
||||
if (data->set.source_url) /* 3rd party transfer */
|
||||
res = Curl_second_connect(conn);
|
||||
else
|
||||
conn->sec_conn = NULL;
|
||||
}
|
||||
|
||||
if(res == CURLE_OK) {
|
||||
bool do_done;
|
||||
if(data->set.connect_only) {
|
||||
@ -2263,8 +2256,7 @@ CURLcode Curl_perform(struct SessionHandle *data)
|
||||
}
|
||||
res = Curl_do(&conn, &do_done);
|
||||
|
||||
/* for non 3rd party transfer only */
|
||||
if(res == CURLE_OK && !data->set.source_url) {
|
||||
if(res == CURLE_OK) {
|
||||
res = Transfer(conn); /* now fetch that URL please */
|
||||
if(res == CURLE_OK) {
|
||||
retry = Curl_retry_request(conn, &newurl);
|
||||
@ -2382,57 +2374,3 @@ Curl_setup_transfer(
|
||||
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Curl_second_connect() makes the secondary connection (used for 3rd party
|
||||
* FTP transfers).
|
||||
*/
|
||||
CURLcode Curl_second_connect(struct connectdata *conn)
|
||||
{
|
||||
CURLcode status = CURLE_OK;
|
||||
struct SessionHandle *data = conn->data;
|
||||
struct connectdata *sec_conn = NULL; /* secondary connection */
|
||||
bool backup_reuse_fresh = data->set.reuse_fresh;
|
||||
char *backup_userpwd = data->set.userpwd;
|
||||
char *backup_path = data->reqdata.path;
|
||||
char *backup_pathbuffer = data->reqdata.pathbuffer;
|
||||
|
||||
if(data->change.url_alloc)
|
||||
free(data->change.url);
|
||||
|
||||
data->change.url_alloc = FALSE;
|
||||
data->change.url = data->set.source_url;
|
||||
|
||||
/* We must never actually alter 'data->set' properties, so we restore the
|
||||
backed up values afterwards! */
|
||||
|
||||
#if 0
|
||||
/* if both remote hosts are the same host - create new connection */
|
||||
if (strequal(conn->host.dispname, data->set.source_host))
|
||||
#endif
|
||||
data->set.reuse_fresh = TRUE;
|
||||
|
||||
data->set.userpwd = data->set.source_userpwd;
|
||||
|
||||
/* secondary connection */
|
||||
status = Curl_connect_host(data, &sec_conn);
|
||||
if(CURLE_OK == status) {
|
||||
sec_conn->sec_conn = NULL; /* important if re-using existing connection
|
||||
to prevent loop */
|
||||
sec_conn->data = data;
|
||||
conn->sec_conn = sec_conn;
|
||||
}
|
||||
|
||||
data->set.reuse_fresh = backup_reuse_fresh;
|
||||
data->set.userpwd = backup_userpwd;
|
||||
|
||||
/* Copy the source path into a separate place */
|
||||
sec_conn->sec_path = data->reqdata.path;
|
||||
sec_conn->sec_pathbuffer = data->reqdata.pathbuffer;
|
||||
|
||||
/* Restore the original */
|
||||
data->reqdata.path = backup_path;
|
||||
data->reqdata.pathbuffer = backup_pathbuffer;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
42
lib/url.c
42
lib/url.c
@ -1618,42 +1618,13 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
|
||||
data->set.tcp_nodelay = (bool)(0 != va_arg(param, long));
|
||||
break;
|
||||
|
||||
/*********** 3rd party transfer options ***********/
|
||||
case CURLOPT_SOURCE_URL:
|
||||
/*
|
||||
* SOURCE URL
|
||||
*/
|
||||
data->set.source_url = va_arg(param, char *);
|
||||
data->set.printhost = (bool)(NULL != data->set.source_url);
|
||||
break;
|
||||
|
||||
case CURLOPT_SOURCE_USERPWD:
|
||||
/*
|
||||
* Use SOURCE USER[:PASSWORD]
|
||||
*/
|
||||
data->set.source_userpwd = va_arg(param, char *);
|
||||
break;
|
||||
|
||||
case CURLOPT_SOURCE_QUOTE:
|
||||
/*
|
||||
* List of RAW FTP commands to use after a connect
|
||||
*/
|
||||
data->set.source_quote = va_arg(param, struct curl_slist *);
|
||||
break;
|
||||
|
||||
case CURLOPT_SOURCE_PREQUOTE:
|
||||
/*
|
||||
* List of RAW FTP commands to use before a transfer on the source host
|
||||
*/
|
||||
data->set.source_prequote = va_arg(param, struct curl_slist *);
|
||||
break;
|
||||
|
||||
case CURLOPT_SOURCE_POSTQUOTE:
|
||||
/*
|
||||
* List of RAW FTP commands to use after a transfer on the source host
|
||||
*/
|
||||
data->set.source_postquote = va_arg(param, struct curl_slist *);
|
||||
break;
|
||||
case CURLOPT_SOURCE_URL:
|
||||
case CURLOPT_SOURCE_USERPWD:
|
||||
case CURLOPT_SOURCE_QUOTE:
|
||||
case CURLOPT_SOURCE_PREQUOTE:
|
||||
case CURLOPT_SOURCE_POSTQUOTE:
|
||||
These former 3rd party transfer options are deprecated */
|
||||
|
||||
case CURLOPT_FTP_ACCOUNT:
|
||||
data->set.ftp_account = va_arg(param, char *);
|
||||
@ -1726,7 +1697,6 @@ static void conn_free(struct connectdata *conn)
|
||||
Curl_safefree(conn->allocptr.cookiehost);
|
||||
Curl_safefree(conn->ip_addr_str);
|
||||
Curl_safefree(conn->trailer);
|
||||
Curl_safefree(conn->sec_pathbuffer);
|
||||
Curl_safefree(conn->host.rawalloc); /* host name buffer */
|
||||
Curl_safefree(conn->proxy.rawalloc); /* proxy name buffer */
|
||||
|
||||
|
@ -834,13 +834,6 @@ struct connectdata {
|
||||
struct Curl_async async;
|
||||
#endif
|
||||
|
||||
struct connectdata *sec_conn; /* secondary connection for 3rd party
|
||||
transfer */
|
||||
char *sec_path; /* The source path for FTP 3rd party */
|
||||
char *sec_pathbuffer;
|
||||
|
||||
enum { NORMAL, SOURCE3RD, TARGET3RD } xfertype;
|
||||
|
||||
/* These three are used for chunked-encoding trailer support */
|
||||
char *trailer; /* allocated buffer to store trailer in */
|
||||
int trlMax; /* allocated buffer size */
|
||||
|
52
src/main.c
52
src/main.c
@ -349,11 +349,6 @@ struct Configurable {
|
||||
long retry_delay; /* delay between retries (in seconds) */
|
||||
long retry_maxtime; /* maximum time to keep retrying */
|
||||
|
||||
char *tp_url; /* third party URL */
|
||||
char *tp_user; /* third party userpwd */
|
||||
struct curl_slist *tp_quote;
|
||||
struct curl_slist *tp_postquote;
|
||||
struct curl_slist *tp_prequote;
|
||||
char *ftp_account; /* for ACCT */
|
||||
char *ftp_alternative_to_user; /* send command if USER/PASS fails */
|
||||
int ftp_filemethod;
|
||||
@ -596,9 +591,6 @@ static void help(void)
|
||||
" -1/--tlsv1 Use TLSv1 (SSL)",
|
||||
" -2/--sslv2 Use SSLv2 (SSL)",
|
||||
" -3/--sslv3 Use SSLv3 (SSL)",
|
||||
" --3p-quote like -Q for the source URL for 3rd party transfer (F)",
|
||||
" --3p-url source URL to activate 3rd party transfer (F)",
|
||||
" --3p-user user and password for source 3rd party transfer (F)",
|
||||
" -4/--ipv4 Resolve name to IPv4 address",
|
||||
" -6/--ipv6 Resolve name to IPv6 address",
|
||||
" -#/--progress-bar Display transfer progress as a progress bar",
|
||||
@ -1340,9 +1332,6 @@ 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},
|
||||
{"$n", "proxy-anyauth", FALSE},
|
||||
{"$o", "trace-time", FALSE},
|
||||
@ -1733,35 +1722,6 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
|
||||
return PARAM_BAD_NUMERIC;
|
||||
break;
|
||||
|
||||
case 'j': /* --3p-url */
|
||||
GetStr(&config->tp_url, nextarg);
|
||||
break;
|
||||
case 'k': /* --3p-user */
|
||||
GetStr(&config->tp_user, nextarg);
|
||||
break;
|
||||
case 'l': /* --3p-quote */
|
||||
/* QUOTE commands to send to source FTP server */
|
||||
err = PARAM_OK;
|
||||
switch(nextarg[0]) {
|
||||
case '-':
|
||||
/* prefixed with a dash makes it a POST TRANSFER one */
|
||||
nextarg++;
|
||||
err = add2list(&config->tp_postquote, nextarg);
|
||||
break;
|
||||
case '+':
|
||||
/* prefixed with a plus makes it a just-before-transfer one */
|
||||
nextarg++;
|
||||
err = add2list(&config->tp_prequote, nextarg);
|
||||
break;
|
||||
default:
|
||||
err = add2list(&config->tp_quote, nextarg);
|
||||
break;
|
||||
}
|
||||
if(err)
|
||||
return err;
|
||||
|
||||
break;
|
||||
/* break */
|
||||
case 'm': /* --ftp-account */
|
||||
GetStr(&config->ftp_account, nextarg);
|
||||
break;
|
||||
@ -3138,19 +3098,12 @@ static void free_config_fields(struct Configurable *config)
|
||||
free(config->capath);
|
||||
if(config->cookiejar)
|
||||
free(config->cookiejar);
|
||||
if(config->tp_url)
|
||||
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);
|
||||
curl_slist_free_all(config->postquote);
|
||||
curl_slist_free_all(config->tp_quote);
|
||||
curl_slist_free_all(config->tp_prequote);
|
||||
curl_slist_free_all(config->tp_postquote);
|
||||
curl_slist_free_all(config->headers);
|
||||
}
|
||||
|
||||
@ -4017,11 +3970,6 @@ operate(struct Configurable *config, int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* 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);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_IGNORE_CONTENT_LENGTH, config->ignorecl);
|
||||
|
@ -3,6 +3,5 @@
|
||||
# test cases are run by runtests.pl. Just add the plain test case numbers, one
|
||||
# per line.
|
||||
# Lines starting with '#' letters are treated as comments.
|
||||
230
|
||||
231
|
||||
232
|
||||
#230
|
||||
|
||||
|
@ -28,8 +28,8 @@ EXTRA_DIST = test1 test108 test117 test127 test20 test27 test34 test46 \
|
||||
test194 test195 test196 test197 test198 test515 test516 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 test228 test229 test233 test234 test235 test236 test520 \
|
||||
test215 test216 test217 test218 test199 test225 test226 test227 \
|
||||
test228 test229 test233 test234 test235 test236 test520 \
|
||||
test237 test238 test239 test243 test245 test246 test247 test248 test249 \
|
||||
test250 test251 test252 test253 test254 test255 test521 test522 test523 \
|
||||
test256 test257 test258 test259 test260 test261 test262 test263 test264 \
|
||||
|
@ -1,57 +0,0 @@
|
||||
<info>
|
||||
<keywords>
|
||||
FTP
|
||||
3rd party
|
||||
</keywords>
|
||||
</info>
|
||||
#
|
||||
# Server-side
|
||||
<reply>
|
||||
<data nocheck=1>
|
||||
contents of source file 230
|
||||
</data>
|
||||
</reply>
|
||||
|
||||
#
|
||||
# Client-side
|
||||
<client>
|
||||
<server>
|
||||
ftp
|
||||
ftp2
|
||||
</server>
|
||||
<name>
|
||||
FTP 3rd party transfer
|
||||
</name>
|
||||
<command>
|
||||
ftp://%HOSTIP:%FTPPORT/dest/destpath/230 -u daniel:stenberg --3p-url ftp://%HOSTIP:%FTP2PORT/source/sourcepath/230 --3p-user daniel2:stenberg2
|
||||
</command>
|
||||
</client>
|
||||
|
||||
#
|
||||
# Verify data after the test has been "shot"
|
||||
<verify>
|
||||
# target-side protocol check
|
||||
<protocol>
|
||||
USER daniel
|
||||
PASS stenberg
|
||||
PWD
|
||||
TYPE I
|
||||
CWD dest
|
||||
CWD destpath
|
||||
PASV
|
||||
STOR 230
|
||||
QUIT
|
||||
</protocol>
|
||||
<stripfile>
|
||||
s/^(PORT 127,0,0,1).*/$1/
|
||||
</stripfile>
|
||||
<file name="log/server2.input">
|
||||
USER daniel2
|
||||
PASS stenberg2
|
||||
PWD
|
||||
TYPE I
|
||||
PORT 127,0,0,1
|
||||
RETR source/sourcepath/230
|
||||
QUIT
|
||||
</file>
|
||||
</verify>
|
@ -1,57 +0,0 @@
|
||||
<info>
|
||||
<keywords>
|
||||
FTP
|
||||
3rd party
|
||||
</keywords>
|
||||
</info>
|
||||
#
|
||||
# Server-side
|
||||
<reply>
|
||||
<data nocheck=1>
|
||||
contents of source file 231
|
||||
</data>
|
||||
</reply>
|
||||
|
||||
#
|
||||
# Client-side
|
||||
<client>
|
||||
<server>
|
||||
ftp
|
||||
ftp2
|
||||
</server>
|
||||
<name>
|
||||
FTP 3rd party transfer, make target use PORT
|
||||
</name>
|
||||
<command>
|
||||
ftp://%HOSTIP:%FTPPORT/dest/destpath/231 -u daniel:stenberg --3p-url ftp://%HOSTIP:%FTP2PORT/source/sourcepath/231 --3p-user daniel2:stenberg2 -P -
|
||||
</command>
|
||||
</client>
|
||||
|
||||
#
|
||||
# Verify data after the test has been "shot"
|
||||
<verify>
|
||||
# target-side protocol check
|
||||
<strippart>>
|
||||
s/^(PORT 127,0,0,1).*/$1/
|
||||
</strippart>
|
||||
<protocol>
|
||||
USER daniel
|
||||
PASS stenberg
|
||||
PWD
|
||||
TYPE I
|
||||
CWD dest
|
||||
CWD destpath
|
||||
PORT 127,0,0,1
|
||||
STOR 231
|
||||
QUIT
|
||||
</protocol>
|
||||
<file name="log/server2.input">
|
||||
USER daniel2
|
||||
PASS stenberg2
|
||||
PWD
|
||||
TYPE I
|
||||
PASV
|
||||
RETR source/sourcepath/231
|
||||
QUIT
|
||||
</file>
|
||||
</verify>
|
@ -1,57 +0,0 @@
|
||||
<info>
|
||||
<keywords>
|
||||
FTP
|
||||
3rd party
|
||||
</keywords>
|
||||
</info>
|
||||
#
|
||||
# Server-side
|
||||
<reply>
|
||||
<data nocheck=1>
|
||||
contents of source file 232
|
||||
</data>
|
||||
</reply>
|
||||
|
||||
#
|
||||
# Client-side
|
||||
<client>
|
||||
<server>
|
||||
ftp
|
||||
ftp2
|
||||
</server>
|
||||
<name>
|
||||
FTP 3rd party transfer, anonymous user
|
||||
</name>
|
||||
<command>
|
||||
ftp://%HOSTIP:%FTPPORT/dest/destpath/232 --3p-url ftp://%HOSTIP:%FTP2PORT/source/sourcepath/232
|
||||
</command>
|
||||
</client>
|
||||
|
||||
#
|
||||
# Verify data after the test has been "shot"
|
||||
<verify>
|
||||
# target-side protocol check
|
||||
<protocol>
|
||||
USER anonymous
|
||||
PASS curl_by_daniel@haxx.se
|
||||
PWD
|
||||
TYPE I
|
||||
CWD dest
|
||||
CWD destpath
|
||||
PASV
|
||||
STOR 232
|
||||
QUIT
|
||||
</protocol>
|
||||
<stripfile>
|
||||
s/^(PORT 127,0,0,1).*/$1/
|
||||
</stripfile>
|
||||
<file name="log/server2.input">
|
||||
USER anonymous
|
||||
PASS curl_by_daniel@haxx.se
|
||||
PWD
|
||||
TYPE I
|
||||
PORT 127,0,0,1
|
||||
RETR source/sourcepath/232
|
||||
QUIT
|
||||
</file>
|
||||
</verify>
|
Loading…
Reference in New Issue
Block a user