proxy_ftp.c revision 3c59b18ce62f97468aaa5951d4e21a5478ef36ec
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
*
* Portions of this software are based upon public domain software
* originally written at the National Center for Supercomputing Applications,
* University of Illinois, Urbana-Champaign.
*/
/* FTP routines for Apache proxy */
#include "mod_proxy.h"
#define AUTODETECT_PWD
/*
* Decodes a '%' escaped string, and returns the number of characters
*/
static int decodeenc(char *x)
{
int i, j, ch;
if (x[0] == '\0')
return 0; /* special case for no characters */
for (i = 0, j = 0; x[i] != '\0'; i++, j++) {
/* decode it if not already done */
ch = x[i];
i += 2;
}
x[j] = ch;
}
x[j] = '\0';
return j;
}
/*
* checks an encoded ftp string for bad characters, namely, CR, LF or
* non-ascii character
*/
static int ftp_check_string(const char *x)
{
int i, ch = 0;
for (i = 0; x[i] != '\0'; i++) {
ch = x[i];
i += 2;
}
#if !APR_CHARSET_EBCDIC
#else /*APR_CHARSET_EBCDIC*/
#endif /*APR_CHARSET_EBCDIC*/
return 0;
}
return 1;
}
/*
* Canonicalise ftp URLs.
*/
{
apr_pool_t *p = r->pool;
const char *err;
int port;
if (err)
return HTTP_BAD_REQUEST;
return HTTP_BAD_REQUEST;
return HTTP_BAD_REQUEST;
/* now parse path/parameters args, according to rfc1738 */
/* N.B. if this isn't a true proxy request, then the URL path
* (but not query args) has already been decoded.
* This gives rise to the problem of a ; being decoded into the
* path.
*/
*(strp++) = '\0';
r->proxyreq);
return HTTP_BAD_REQUEST;
}
else
parms = "";
return HTTP_BAD_REQUEST;
if (!ftp_check_string(path))
return HTTP_BAD_REQUEST;
return HTTP_BAD_REQUEST;
}
else {
return HTTP_BAD_REQUEST;
}
}
/* now, rebuild URL */
if (port != DEFAULT_FTP_PORT)
else
sport[0] = '\0';
return OK;
}
/*
* Like ftp_getrc but returns both the ftp status code and
* remembers the response message in the supplied buffer
*/
{
char *response;
char buff[5];
apr_bucket *e;
/* Tell http_filter to grab the data one line at a time. */
c->remain = 0;
e = APR_BRIGADE_FIRST(bb);
if (len == -1) {
return -1;
}
status = 0;
else
/* FIXME: If the line was too long, read till LF */
do {
if (len == -1)
return -1;
/* FIXME: If the line was too long, read till LF */
}
return status;
}
/* this is a filter that turns a raw ASCII directory listing into pretty HTML */
/* ideally, mod_proxy should simply send the raw directory list up the filter
* stack to mod_autoindex, which in theory should turn the raw ascii into
* pretty html along with all the bells and whistles it provides...
*
* all in good time...! :)
*/
{
conn_rec *c = f->r->connection;
apr_pool_t *p = f->r->pool;
apr_bucket *e;
char buf[MAX_STRING_LEN];
char buf2[MAX_STRING_LEN];
char *filename;
int searchidx = 0;
int firstfile = 1;
register int n;
/* Save "scheme://site" prefix without password */
/* ... and path without query args */
/* Copy path, strip (all except the last) trailing slashes */
/* print "ftp://host/" */
"<HTML><HEAD><TITLE>%s%s</TITLE>\n"
"<BASE HREF=\"%s%s\"></HEAD>\n"
"<BODY><H2>Directory of "
"<A HREF=\"/\">%s</A>/",
e = apr_bucket_pool_create(buf, n, p);
{
*dir = '\0';
else
++reldir;
/* print "path/" component */
e = apr_bucket_pool_create(buf, n, p);
*dir = '/';
}
/* If the caller has determined the current directory, and it differs */
/* from what the client requested, then show the real name */
} else {
}
e = apr_bucket_pool_create(buf, n, p);
e = apr_bucket_flush_create();
while (!c->aborted) {
if (n == -1) { /* input error */
break;
}
if (n == 0) {
break; /* EOF */
}
do {
filename--;
} while (filename[0] != ' ');
*(filename++) = '\0';
*(link_ptr++) = '\0';
apr_snprintf(buf2, sizeof(buf2), "%s <A HREF=\"%s\">%s %s</A>\n", buf, filename, filename, link_ptr);
}
*searchptr = '[';
*searchptr = ']';
}
*(filename++) = 0;
/* handle filenames with spaces in 'em */
firstfile = 0;
}
*(--filename) = ' ';
}
/* Special handling for '.' and '..' */
}
else {
}
}
e = apr_bucket_pool_create(buf, n, p);
e = apr_bucket_flush_create();
}
e = apr_bucket_pool_create(buf, n, p);
e = apr_bucket_eos_create();
/* probably not necessary */
/* e = apr_bucket_flush_create();
APR_BRIGADE_INSERT_TAIL(bb, e);
*/
return APR_SUCCESS;
}
/* Common routine for failed authorization (i.e., missing or wrong password)
* to an ftp service. This causes most browsers to retry the request
* with username and password (which was presumably queried from the user)
* supplied in the Authorization: header.
* Note that we "invent" a realm name which consists of the
* ftp://user@host part of the reqest (sans password -if supplied but invalid-)
*/
{
r->proxyreq = PROXYREQ_NONE;
/* Log failed requests if they supplied a password
*/
if (log_it)
"proxy: missing or failed auth to %s",
&r->parsed_uri, UNP_OMITPATHINFO));
"\"", NULL));
return HTTP_UNAUTHORIZED;
}
/*
* Handles direct access of ftp:// URLs
* Original (Non-PASV) version from
* Troy Morrison <spiffnet@zoom.com>
* PASV added by Chuck
* Filters by [Graham Leggett <minfrin@sharp.fm>]
*/
{
apr_pool_t *p = r->pool;
int err;
apr_bucket *e;
char buffer[MAX_STRING_LEN];
/* char *account = NULL; how to supply an account in a URL? */
int one = 1;
/* stuff for PASV mode */
int pasvmode = 0;
char dates[AP_RFC822_DATE_LEN];
/*
* I: Who Do I Connect To?
* -----------------------
*
* Break up the URL to determine the host to connect to
*/
/* we only support GET and HEAD */
if (r->method_number != M_GET)
return HTTP_NOT_IMPLEMENTED;
/* We break the URL into host, port, path-search */
? r->parsed_uri.port
*(parms++) = '\0';
/* The "Authorization:" header must be checked first.
* We allow the user to "override" the URL-coded user [ & password ]
* in the Browsers' User&Password Dialog.
* NOTE that this is only marginally more secure than having the
* password travel in plain as part of the URL, because Basic Auth
* simply uuencodes the plain text password.
* But chances are still smaller that the URL is logged regularly.
*/
/* Note that this allocation has to be made from r->connection->pool
* because it has the lifetime of the connection. The other allocations
* are temporary and can be tossed away any time.
*/
r->ap_auth_type = "Basic";
}
}
}
else {
user = "anonymous";
password = "apache_proxy@";
}
/* do a DNS lookup for the destination host */
/* check if ProxyBlock directive on this host */
return ap_proxyerror(r, HTTP_FORBIDDEN,
"Connect to remote machine blocked");
}
//return HTTP_NOT_IMPLEMENTED;
/*
* II: Make the Connection
* -----------------------
*
* We have determined who to connect to. Now make the connection.
*/
/* get all the possible IP addresses for the destname and loop through them
* until we get a successful connection
*/
if (APR_SUCCESS != err) {
"DNS lookup failure for: ",
connectname, NULL));
}
"proxy: error creating socket");
return HTTP_INTERNAL_SERVER_ERROR;
}
if (conf->recv_buffer_size > 0
conf->recv_buffer_size)) {
"setsockopt(SO_RCVBUF): Failed to set ProxyReceiveBufferSize, using default");
}
#endif
#ifndef _OSD_POSIX /* BS2000 has this option "always on" */
"proxy: error setting reuseaddr option: setsockopt(SO_REUSEADDR)");
return HTTP_INTERNAL_SERVER_ERROR;
#endif /*_OSD_POSIX*/
}
"proxy: socket has been created");
/*
* At this point we have a list of one or more IP addresses of
* the machine to connect to. If configured, reorder this
* list so that the "best candidate" is first try. "best
* candidate" could mean the least loaded server, the fastest
* responding server, whatever.
*
* For now we do nothing, ie we get DNS round robin.
* XXX FIXME
*/
/* try each IP address until we connect successfully */
{
int failed = 1;
while (connect_addr) {
/* make the connection out of the socket */
/* if an error occurred, loop round and try again */
if (err != APR_SUCCESS) {
continue;
}
/* if we get here, all is well */
failed = 0;
break;
}
/* handle a permanent error from the above loop */
if (failed) {
"Could not connect to remote machine: ",
}
}
/* the socket is now open, create a new connection */
if (!origin) {
/* the peer reset the connection already; ap_new_connection()
* closed the socket */
return HTTP_INTERNAL_SERVER_ERROR;
}
/* allocate this out of the connection pool - the check on r->connection->id makes
* sure that this string does not live past the connection lifetime */
/* if a keepalive connection is floating around, close it first! */
if (conf->client_socket) {
}
"proxy: connection complete");
/*
* III: Send Control Request
* -------------------------
*
* Log into the ftp server, send the username & password, change to the correct
* directory...
*/
/* set up the connection filters */
/* possible results: */
/* 120 Service ready in nnn minutes. */
/* 220 Service ready for new user. */
/* 421 Service not available, closing control connection. */
"FTP: initial connect returned status %d", i);
if (i == -1) {
return ap_proxyerror(r, HTTP_BAD_GATEWAY,
"Error reading from remote server");
}
#if 0
if (i == 120) {
/* RFC2068 states:
* 14.38 Retry-After
*
* The Retry-After response-header field can be used with a 503 (Service
* Unavailable) response to indicate how long the service is expected to
* be unavailable to the requesting client. The value of this field can
* be either an HTTP-date or an integer number of seconds (in decimal)
* after the time of the response.
* Retry-After = "Retry-After" ":" ( HTTP-date | delta-seconds )
*/
}
#endif
if (i != 220) {
}
"FTP: connected.");
bb = apr_brigade_create(p);
e = apr_bucket_flush_create();
"FTP: USER %s", user);
/* possible results; 230, 331, 332, 421, 500, 501, 530 */
/* states: 1 - error, 2 - success; 3 - send password, 4,5 fail */
/* 230 User logged in, proceed. */
/* 331 User name okay, need password. */
/* 332 Need account for login. */
/* 421 Service not available, closing control connection. */
/* 500 Syntax error, command unrecognized. */
/* (This may include errors such as command line too long.) */
/* 501 Syntax error in parameters or arguments. */
/* 530 Not logged in. */
"FTP: returned status %d", i);
if (i == -1) {
}
if (i == 530) {
/* FIXME: Insert clean disconnect */
}
if (i != 230 && i != 331) {
return HTTP_BAD_GATEWAY;
}
if (i == 331) { /* send password */
/* FIXME: Insert clean disconnect */
return ftp_unauthorized (r, 0);
}
bb = apr_brigade_create(p);
e = apr_bucket_flush_create();
"FTP: PASS %s", password);
/* possible results 202, 230, 332, 421, 500, 501, 503, 530 */
/* 230 User logged in, proceed. */
/* 332 Need account for login. */
/* 421 Service not available, closing control connection. */
/* 500 Syntax error, command unrecognized. */
/* 501 Syntax error in parameters or arguments. */
/* 503 Bad sequence of commands. */
/* 530 Not logged in. */
"FTP: returned status %d", i);
if (i == -1) {
return ap_proxyerror(r, HTTP_BAD_GATEWAY,
"Error reading from remote server");
}
if (i == 332) {
return ap_proxyerror(r, HTTP_UNAUTHORIZED,
}
/* @@@ questionable -- we might as well return a 403 Forbidden here */
if (i == 530) {
/* FIXME: Insert clean disconnect */
}
if (i != 230 && i != 202) {
return HTTP_BAD_GATEWAY;
}
}
/* set the directory (walk directory component by component):
* this is what we must do if we don't know the OS type of the remote
* machine
*/
for (;;) {
break;
*strp = '\0';
bb = apr_brigade_create(p);
e = apr_bucket_flush_create();
"FTP: CWD %s", path);
*strp = '/';
/* responses: 250, 421, 500, 501, 502, 530, 550 */
/* 250 Requested file action okay, completed. */
/* 421 Service not available, closing control connection. */
/* 500 Syntax error, command unrecognized. */
/* 501 Syntax error in parameters or arguments. */
/* 502 Command not implemented. */
/* 530 Not logged in. */
/* 550 Requested action not taken. */
"FTP: returned status %d", i);
if (i == -1) {
return ap_proxyerror(r, HTTP_BAD_GATEWAY,
"Error reading from remote server");
}
if (i == 550) {
}
if (i != 250) {
}
}
parms += 5;
parms = "";
}
else
parms = "";
/* changed to make binary transfers the default */
if (parms[0] != 'a') {
/* set type to image */
bb = apr_brigade_create(p);
e = apr_bucket_flush_create();
"FTP: TYPE I");
/* responses: 200, 421, 500, 501, 504, 530 */
/* 200 Command okay. */
/* 421 Service not available, closing control connection. */
/* 500 Syntax error, command unrecognized. */
/* 501 Syntax error in parameters or arguments. */
/* 504 Command not implemented for that parameter. */
/* 530 Not logged in. */
"FTP: returned status %d", i);
if (i == -1) {
return ap_proxyerror(r, HTTP_BAD_GATEWAY,
"Error reading from remote server");
}
if (i != 200 && i != 504) {
}
/* Allow not implemented */
if (i == 504)
parms[0] = '\0';
}
/*
* IV: Make Data Connection?
* -------------------------
*
* Try PASV, if that fails try normally.
*/
/* try to set up PASV data connection first */
"proxy: error creating PASV socket");
return HTTP_INTERNAL_SERVER_ERROR;
}
conf->recv_buffer_size)) {
"setsockopt(SO_RCVBUF): Failed to set ProxyReceiveBufferSize, using default");
}
#endif
bb = apr_brigade_create(p);
e = apr_bucket_flush_create();
"FTP: PASV command issued");
/* possible results: 227, 421, 500, 501, 502, 530 */
/* 227 Entering Passive Mode (h1,h2,h3,h4,p1,p2). */
/* 421 Service not available, closing control connection. */
/* 500 Syntax error, command unrecognized. */
/* 501 Syntax error in parameters or arguments. */
/* 502 Command not implemented. */
/* 530 Not logged in. */
bb = apr_brigade_create(p);
e = APR_BRIGADE_FIRST(bb);
if (len < 5) {
"PASV: control connection is toast");
return HTTP_BAD_GATEWAY;
}
else {
char *pstr;
else
{
}
}
else
"FTP: PASV returned status %d", presult);
/* FIXME: Only supports IPV4 */
"FTP: PASV contacting host %d.%d.%d.%d:%d",
/* make the connection */
apr_sockaddr_info_get(&pasv_addr, apr_psprintf(p, "%d.%d.%d.%d", h3, h2, h1, h0), APR_UNSPEC, pasvport, 0, p);
if (err != APR_SUCCESS) {
}
else {
pasvmode = 1;
}
}
else
/* and try the regular way */
}
/* set up data connection */
if (!pasvmode) {
char *local_ip;
"proxy: error creating socket");
return HTTP_INTERNAL_SERVER_ERROR;
}
#ifndef _OSD_POSIX /* BS2000 has this option "always on" */
"proxy: error setting reuseaddr option");
return HTTP_INTERNAL_SERVER_ERROR;
#endif /*_OSD_POSIX*/
}
"proxy: error creating local socket address");
return HTTP_INTERNAL_SERVER_ERROR;
}
char buff[22];
"proxy: error binding to ftp data socket %s", buff);
return HTTP_INTERNAL_SERVER_ERROR;
}
/* only need a short queue */
}
/*
* V: Set The Headers
* -------------------
*
* Get the size of the request, set up the environment for HTTP.
*/
/* set request; "path" holds last path component */
/* TM - if len == 0 then it must be a directory (you can't RETR nothing) */
if (len == 0) {
parms = "d";
}
else {
bb = apr_brigade_create(p);
e = apr_bucket_flush_create();
"FTP: SIZE %s", path);
"FTP: returned status %d with response %s", i, buffer);
if (i != 500) { /* Size command not recognized */
if (i == 550) { /* Not a regular file */
"FTP: SIZE shows this is a directory");
parms = "d";
bb = apr_brigade_create(p);
e = apr_bucket_flush_create();
"FTP: CWD %s", path);
/* possible results: 250, 421, 500, 501, 502, 530, 550 */
/* 250 Requested file action okay, completed. */
/* 421 Service not available, closing control connection. */
/* 500 Syntax error, command unrecognized. */
/* 501 Syntax error in parameters or arguments. */
/* 502 Command not implemented. */
/* 530 Not logged in. */
/* 550 Requested action not taken. */
"FTP: returned status %d", i);
if (i == -1) {
return ap_proxyerror(r, HTTP_BAD_GATEWAY,
"Error reading from remote server");
}
if (i == 550) {
}
if (i != 250) {
}
path = "";
len = 0;
}
else if (i == 213) { /* Size command ok */
buffer[j] = '\0';
if (buffer[0] != '\0')
}
}
}
#ifdef AUTODETECT_PWD
bb = apr_brigade_create(p);
e = apr_bucket_flush_create();
"FTP: PWD");
/* responses: 257, 500, 501, 502, 421, 550 */
/* 257 "<directory-name>" <commentary> */
/* 421 Service not available, closing control connection. */
/* 500 Syntax error, command unrecognized. */
/* 501 Syntax error in parameters or arguments. */
/* 502 Command not implemented. */
/* 550 Requested action not taken. */
"FTP: PWD returned status %d", i);
if (i == -1 || i == 421) {
return ap_proxyerror(r, HTTP_BAD_GATEWAY,
"Error reading from remote server");
}
if (i == 550) {
}
if (i == 257) {
}
#endif /*AUTODETECT_PWD*/
if (parms[0] == 'd') {
if (len != 0)
else
}
else {
"FTP: RETR %s", path);
}
bb = apr_brigade_create(p);
e = apr_bucket_flush_create();
/* RETR: 110, 125, 150, 226, 250, 421, 425, 426, 450, 451, 500, 501, 530, 550
* NLST: 125, 150, 226, 250, 421, 425, 426, 450, 451, 500, 501, 502, 530 */
/* 110 Restart marker reply. */
/* 125 Data connection already open; transfer starting. */
/* 150 File status okay; about to open data connection. */
/* 226 Closing data connection. */
/* 250 Requested file action okay, completed. */
/* 421 Service not available, closing control connection. */
/* 425 Can't open data connection. */
/* 426 Connection closed; transfer aborted. */
/* 450 Requested file action not taken. */
/* 451 Requested action aborted. Local error in processing. */
/* 500 Syntax error, command unrecognized. */
/* 501 Syntax error in parameters or arguments. */
/* 530 Not logged in. */
/* 550 Requested action not taken. */
"FTP: returned status %d", rc);
if (rc == -1) {
return ap_proxyerror(r, HTTP_BAD_GATEWAY,
"Error reading from remote server");
}
if (rc == 550) {
"FTP: RETR failed, trying LIST instead");
parms = "d";
bb = apr_brigade_create(p);
e = apr_bucket_flush_create();
"FTP: CWD %s", path);
/* possible results: 250, 421, 500, 501, 502, 530, 550 */
/* 250 Requested file action okay, completed. */
/* 421 Service not available, closing control connection. */
/* 500 Syntax error, command unrecognized. */
/* 501 Syntax error in parameters or arguments. */
/* 502 Command not implemented. */
/* 530 Not logged in. */
/* 550 Requested action not taken. */
"FTP: returned status %d", rc);
if (rc == -1) {
return ap_proxyerror(r, HTTP_BAD_GATEWAY,
"Error reading from remote server");
}
if (rc == 550) {
}
if (rc != 250) {
}
#ifdef AUTODETECT_PWD
bb = apr_brigade_create(p);
e = apr_bucket_flush_create();
"FTP: PWD");
/* responses: 257, 500, 501, 502, 421, 550 */
/* 257 "<directory-name>" <commentary> */
/* 421 Service not available, closing control connection. */
/* 500 Syntax error, command unrecognized. */
/* 501 Syntax error in parameters or arguments. */
/* 502 Command not implemented. */
/* 550 Requested action not taken. */
"FTP: PWD returned status %d", i);
if (i == -1 || i == 421) {
return ap_proxyerror(r, HTTP_BAD_GATEWAY,
"Error reading from remote server");
}
if (i == 550) {
}
if (i == 257) {
}
#endif /*AUTODETECT_PWD*/
bb = apr_brigade_create(p);
e = apr_bucket_flush_create();
"FTP: LIST -lag");
"FTP: returned status %d", rc);
if (rc == -1)
return ap_proxyerror(r, HTTP_BAD_GATEWAY,
"Error reading from remote server");
}
}
r->status_line = "200 OK";
if (parms[0] == 'd')
else {
if (r->content_type != NULL) {
"FTP: Content-Type set to %s", r->content_type);
}
else {
}
/* We "trust" the ftp server to really serve (size) bytes... */
"FTP: Content-Length set to %s", size);
}
}
"FTP: Content-Encoding set to %s", r->content_encoding);
}
/* wait for connection */
if (!pasvmode) {
for(;;)
{
{
case APR_EINTR:
continue;
case APR_SUCCESS:
break;
default:
"proxy: failed to accept data connection");
return HTTP_BAD_GATEWAY;
}
}
}
/* the transfer socket is now open, create a new connection */
if (!remote) {
/* the peer reset the connection already; ap_new_connection()
* closed the socket */
"proxy: an error occurred creating a new connection");
return HTTP_INTERNAL_SERVER_ERROR;
}
/* set up the connection filters */
/*
* VI: Receive the Response
* ------------------------
*
* Get response from the remote ftp socket, and pass it up the
* filter chain.
*/
/* send response */
r->sent_bodyct = 1;
if (parms[0] == 'd') {
/* insert directory filter */
}
/* send body */
if (!r->header_only) {
"proxy: FTP start body send");
/* read the body, pass it to the output filters */
bb = apr_brigade_create(p);
break;
}
bb = apr_brigade_create(p);
}
"proxy: FTP end body send");
}
else {
/* abort the transfer */
bb = apr_brigade_create(p);
e = apr_bucket_flush_create();
"FTP: ABOR");
/* responses: 225, 226, 421, 500, 501, 502 */
/* 225 Data connection open; no transfer in progress. */
/* 226 Closing data connection. */
/* 421 Service not available, closing control connection. */
/* 500 Syntax error, command unrecognized. */
/* 501 Syntax error in parameters or arguments. */
/* 502 Command not implemented. */
"FTP: returned status %d", i);
}
/*
* VII: Clean Up
* -------------
*
* If there are no KeepAlives, or if the connection has been signalled
* to close, close the socket and clean up
*/
/* finish */
bb = apr_brigade_create(p);
e = apr_bucket_flush_create();
"FTP: QUIT");
/* responses: 221, 500 */
/* 221 Service closing control connection. */
/* 500 Syntax error, command unrecognized. */
"FTP: QUIT: status %d", i);
return OK;
}