MCPcopy Create free account
hub / github.com/apache/httpd / proxy_ftp_handler

Function proxy_ftp_handler

modules/proxy/mod_proxy_ftp.c:972–2085  ·  view source on GitHub ↗

* Handles direct access of ftp:// URLs * Original (Non-PASV) version from * Troy Morrison * PASV added by Chuck * Filters by [Graham Leggett ] */

Source from the content-addressed store, hash-verified

970 * Filters by [Graham Leggett <minfrin@sharp.fm>]
971 */
972static int proxy_ftp_handler(request_rec *r, proxy_worker *worker,
973 proxy_server_conf *conf, char *url,
974 const char *proxyhost, apr_port_t proxyport)
975{
976 apr_pool_t *p = r->pool;
977 conn_rec *c = r->connection;
978 proxy_conn_rec *backend;
979 apr_socket_t *sock, *local_sock, *data_sock = NULL;
980 conn_rec *origin, *data = NULL;
981 apr_status_t err = APR_SUCCESS;
982 apr_bucket_brigade *bb;
983 char *buf, *connectname;
984 apr_port_t connectport;
985 char *ftpmessage = NULL;
986 char *path, *strp, *type_suffix, *cwd = NULL;
987 apr_uri_t uri;
988 char *user = NULL;
989/* char *account = NULL; how to supply an account in a URL? */
990 const char *password = NULL;
991 int len, rc;
992 int one = 1;
993 char *size = NULL;
994 char xfer_type = 'A'; /* after ftp login, the default is ASCII */
995 int dirlisting = 0;
996#if defined(USE_MDTM) && (defined(HAVE_TIMEGM) || defined(HAVE_GMTOFF))
997 apr_time_t mtime = 0L;
998#endif
999 proxy_ftp_dir_conf *fdconf = ap_get_module_config(r->per_dir_config,
1000 &proxy_ftp_module);
1001
1002 /* stuff for PASV mode */
1003 int connect = 0, use_port = 0;
1004 char dates[APR_RFC822_DATE_LEN];
1005 apr_status_t rv;
1006 int status;
1007
1008 /* is this for us? */
1009 if (proxyhost) {
1010 ap_log_rerror(APLOG_MARK, APLOG_TRACE3, 0, r,
1011 "declining URL %s - proxyhost %s specified:", url,
1012 proxyhost);
1013 return DECLINED; /* proxy connections are via HTTP */
1014 }
1015 if (ap_cstr_casecmpn(url, "ftp:", 4)) {
1016 ap_log_rerror(APLOG_MARK, APLOG_TRACE3, 0, r,
1017 "declining URL %s - not ftp:", url);
1018 return DECLINED; /* only interested in FTP */
1019 }
1020 ap_log_rerror(APLOG_MARK, APLOG_TRACE3, 0, r, "serving URL %s", url);
1021
1022
1023 /*
1024 * I: Who Do I Connect To? -----------------------
1025 *
1026 * Break up the URL to determine the host to connect to
1027 */
1028
1029 /* we only support GET and HEAD */

Callers

nothing calls this directly

Calls 15

ap_get_module_configFunction · 0.85
ap_cstr_casecmpnFunction · 0.85
ap_proxyerrorFunction · 0.85
ap_cstr_casecmpFunction · 0.85
ap_getwordFunction · 0.85
ap_pbase64decodeFunction · 0.85
ftp_check_stringFunction · 0.85
ap_getword_nullsFunction · 0.85
decodeencFunction · 0.85
ap_set_module_configFunction · 0.85

Tested by

no test coverage detected