/* 501 Syntax error in parameters or arguments. */
/* 504 Command not implemented for that parameter. */
/* 530 Not logged in. */
- if (rc == -1 || rc == 421) {
+ if (rc == -1) {
+ ret = ap_proxyerror(r, HTTP_GATEWAY_TIME_OUT,
+ "Error reading from remote server");
+ }
+ else if (rc == 421) {
ret = ap_proxyerror(r, HTTP_BAD_GATEWAY,
"Error reading from remote server");
}
/* 550 Requested action not taken. */
switch (proxy_ftp_command("PWD" CRLF, r, ftp_ctrl, bb, &ftpmessage)) {
case -1:
+ ap_proxyerror(r, HTTP_GATEWAY_TIME_OUT,
+ "Failed to read PWD on ftp server");
+ break;
+
case 421:
case 550:
ap_proxyerror(r, HTTP_BAD_GATEWAY,
* them until we get a successful connection
*/
if (APR_SUCCESS != err) {
- return ap_proxyerror(r, HTTP_BAD_GATEWAY, apr_pstrcat(p,
+ return ap_proxyerror(r, HTTP_GATEWAY_TIME_OUT, apr_pstrcat(p,
"DNS lookup failure for: ",
connectname, NULL));
}
/* 220 Service ready for new user. */
/* 421 Service not available, closing control connection. */
rc = proxy_ftp_command(NULL, r, origin, bb, &ftpmessage);
- if (rc == -1 || rc == 421) {
- return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY, "Error reading from remote server");
+ if (rc == -1) {
+ return ftp_proxyerror(r, backend, HTTP_GATEWAY_TIME_OUT,
+ "Error reading from remote server");
+ }
+ else if (rc == 421) {
+ return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY,
+ "Error reading from remote server");
}
- if (rc == 120) {
+ else if (rc == 120) {
/*
* RFC2616 states: 14.37 Retry-After
*
}
return ftp_proxyerror(r, backend, HTTP_SERVICE_UNAVAILABLE, ftpmessage);
}
- if (rc != 220) {
+ else if (rc != 220) {
return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY, ftpmessage);
}
/* (This may include errors such as command line too long.) */
/* 501 Syntax error in parameters or arguments. */
/* 530 Not logged in. */
- if (rc == -1 || rc == 421) {
- return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY, "Error reading from remote server");
+ if (rc == -1) {
+ return ftp_proxyerror(r, backend, HTTP_GATEWAY_TIME_OUT,
+ "Error reading from remote server");
+ }
+ else if (rc == 421) {
+ return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY,
+ "Error reading from remote server");
}
- if (rc == 530) {
+ else if (rc == 530) {
proxy_ftp_cleanup(r, backend);
return ftp_unauthorized(r, 1); /* log it: user name guessing
* attempt? */
}
- if (rc != 230 && rc != 331) {
+ else if (rc != 230 && rc != 331) {
return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY, ftpmessage);
}
/* 501 Syntax error in parameters or arguments. */
/* 503 Bad sequence of commands. */
/* 530 Not logged in. */
- if (rc == -1 || rc == 421) {
+ if (rc == -1) {
+ return ftp_proxyerror(r, backend, HTTP_GATEWAY_TIME_OUT,
+ "Error reading from remote server");
+ }
+ else if (rc == 421) {
return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY,
"Error reading from remote server");
}
- if (rc == 332) {
+ else if (rc == 332) {
return ftp_proxyerror(r, backend, HTTP_UNAUTHORIZED,
apr_pstrcat(p, "Need account for login: ", ftpmessage, NULL));
}
/* @@@ questionable -- we might as well return a 403 Forbidden here */
- if (rc == 530) {
+ else if (rc == 530) {
proxy_ftp_cleanup(r, backend);
return ftp_unauthorized(r, 1); /* log it: passwd guessing
* attempt? */
}
- if (rc != 230 && rc != 202) {
+ else if (rc != 230 && rc != 202) {
return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY, ftpmessage);
}
}
++path;
rc = proxy_ftp_command("CWD /" CRLF, r, origin, bb, &ftpmessage);
- if (rc == -1 || rc == 421)
+ if (rc == -1) {
+ return ftp_proxyerror(r, backend, HTTP_GATEWAY_TIME_OUT,
+ "Error reading from remote server");
+ }
+ else if (rc == 421) {
return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY,
- "Error reading from remote server");
+ "Error reading from remote server");
+ }
}
/*
/* 502 Command not implemented. */
/* 530 Not logged in. */
/* 550 Requested action not taken. */
- if (rc == -1 || rc == 421) {
+ if (rc == -1) {
+ return ftp_proxyerror(r, backend, HTTP_GATEWAY_TIME_OUT,
+ "Error reading from remote server");
+ }
+ else if (rc == 421) {
return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY,
- "Error reading from remote server");
+ "Error reading from remote server");
}
- if (rc == 550) {
+ else if (rc == 550) {
return ftp_proxyerror(r, backend, HTTP_NOT_FOUND, ftpmessage);
}
- if (rc != 250) {
+ else if (rc != 250) {
return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY, ftpmessage);
}
/* 501 Syntax error in parameters or arguments. */
/* 502 Command not implemented. */
/* 530 Not logged in. */
- if (rc == -1 || rc == 421) {
+ if (rc == -1) {
+ return ftp_proxyerror(r, backend, HTTP_GATEWAY_TIME_OUT,
+ "Error reading from remote server");
+ }
+ else if (rc == 421) {
return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY,
- "Error reading from remote server");
+ "Error reading from remote server");
}
- if (rc != 229 && rc != 500 && rc != 501 && rc != 502) {
+ else if (rc != 229 && rc != 500 && rc != 501 && rc != 502) {
return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY, ftpmessage);
}
else if (rc == 229) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01043)
"EPSV attempt to connect to %pI failed - "
"Firewall/NAT?", &epsv_addr);
- return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY, apr_psprintf(r->pool,
- "EPSV attempt to connect to %pI failed - firewall/NAT?", &epsv_addr));
+ return ftp_proxyerror(r, backend, HTTP_GATEWAY_TIME_OUT,
+ apr_psprintf(r->pool,
+ "EPSV attempt to connect to %pI failed - firewall/NAT?",
+ &epsv_addr));
}
else {
ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r,
/* 501 Syntax error in parameters or arguments. */
/* 502 Command not implemented. */
/* 530 Not logged in. */
- if (rc == -1 || rc == 421) {
+ if (rc == -1) {
+ return ftp_proxyerror(r, backend, HTTP_GATEWAY_TIME_OUT,
+ "Error reading from remote server");
+ }
+ else if (rc == 421) {
return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY,
- "Error reading from remote server");
+ "Error reading from remote server");
}
- if (rc != 227 && rc != 502) {
+ else if (rc != 227 && rc != 502) {
return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY, ftpmessage);
}
else if (rc == 227) {
if (rv != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01048)
"PASV attempt to connect to %pI failed - Firewall/NAT?", pasv_addr);
- return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY, apr_psprintf(r->pool,
- "PASV attempt to connect to %pI failed - firewall/NAT?", pasv_addr));
+ return ftp_proxyerror(r, backend, HTTP_GATEWAY_TIME_OUT,
+ apr_psprintf(r->pool,
+ "PASV attempt to connect to %pI failed - firewall/NAT?",
+ pasv_addr));
}
else {
connect = 1;
/* 501 Syntax error in parameters or arguments. */
/* 502 Command not implemented. */
/* 530 Not logged in. */
- if (rc == -1 || rc == 421) {
+ if (rc == -1) {
+ return ftp_proxyerror(r, backend, HTTP_GATEWAY_TIME_OUT,
+ "Error reading from remote server");
+ }
+ else if (rc == 421) {
return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY,
- "Error reading from remote server");
+ "Error reading from remote server");
}
- if (rc != 200) {
+ else if (rc != 200) {
return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY, buffer);
}
rc = proxy_ftp_command(apr_pstrcat(p, "SIZE ",
ftp_escape_globbingchars(p, path, fdconf), CRLF, NULL),
r, origin, bb, &ftpmessage);
- if (rc == -1 || rc == 421) {
+ if (rc == -1) {
+ return ftp_proxyerror(r, backend, HTTP_GATEWAY_TIME_OUT,
+ "Error reading from remote server");
+ }
+ else if (rc == 421) {
return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY,
- "Error reading from remote server");
+ "Error reading from remote server");
}
else if (rc == 213) {/* Size command ok */
int j;
/* 502 Command not implemented. */
/* 530 Not logged in. */
/* 550 Requested action not taken. */
- if (rc == -1 || rc == 421) {
+ if (rc == -1) {
+ return ftp_proxyerror(r, backend, HTTP_GATEWAY_TIME_OUT,
+ "Error reading from remote server");
+ }
+ else if (rc == 421) {
return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY,
- "Error reading from remote server");
+ "Error reading from remote server");
}
- if (rc == 550) {
+ else if (rc == 550) {
return ftp_proxyerror(r, backend, HTTP_NOT_FOUND, ftpmessage);
}
- if (rc != 250) {
+ else if (rc != 250) {
return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY, ftpmessage);
}
path = "";
/* 501 Syntax error in parameters or arguments. */
/* 530 Not logged in. */
/* 550 Requested action not taken. */
- if (rc == -1 || rc == 421) {
+ if (rc == -1) {
+ return ftp_proxyerror(r, backend, HTTP_GATEWAY_TIME_OUT,
+ "Error reading from remote server");
+ }
+ else if (rc == 421) {
return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY,
"Error reading from remote server");
}
- if (rc == 550) {
+ else if (rc == 550) {
ap_log_rerror(APLOG_MARK, APLOG_TRACE4, 0, r,
"RETR failed, trying LIST instead");
/* 502 Command not implemented. */
/* 530 Not logged in. */
/* 550 Requested action not taken. */
- if (rc == -1 || rc == 421) {
+ if (rc == -1) {
+ return ftp_proxyerror(r, backend, HTTP_GATEWAY_TIME_OUT,
+ "Error reading from remote server");
+ }
+ else if (rc == 421) {
return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY,
- "Error reading from remote server");
+ "Error reading from remote server");
}
- if (rc == 550) {
+ else if (rc == 550) {
return ftp_proxyerror(r, backend, HTTP_NOT_FOUND, ftpmessage);
}
- if (rc != 250) {
+ else if (rc != 250) {
return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY, ftpmessage);
}
r, origin, bb, &ftpmessage);
/* rc is an intermediate response for the LIST command (125 transfer starting, 150 opening data connection) */
- if (rc == -1 || rc == 421)
+ if (rc == -1) {
+ return ftp_proxyerror(r, backend, HTTP_GATEWAY_TIME_OUT,
+ "Error reading from remote server");
+ }
+ else if (rc == 421) {
return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY,
- "Error reading from remote server");
+ "Error reading from remote server");
+ }
}
if (rc != 125 && rc != 150 && rc != 226 && rc != 250) {
return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY, ftpmessage);
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01053)
"failed to accept data connection");
proxy_ftp_cleanup(r, backend);
- return HTTP_BAD_GATEWAY;
+ return HTTP_GATEWAY_TIME_OUT;
}
}
}