]> granicus.if.org Git - apache/commitdiff
Small fix to allow reverse proxying to an ftp server. Previously
authorGraham Leggett <minfrin@apache.org>
Fri, 21 May 2004 22:05:31 +0000 (22:05 +0000)
committerGraham Leggett <minfrin@apache.org>
Fri, 21 May 2004 22:05:31 +0000 (22:05 +0000)
an attempt to do this would try and connect to 0.0.0.0, regardless
of the server specified.
PR: 24922
Obtained from:
Submitted by: Pascal Terjan <pterjan@linuxfr.org>
Reviewed by:

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@103725 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/proxy/proxy_ftp.c

diff --git a/CHANGES b/CHANGES
index 7650cb1612ed14bfd265813929655fc31ff8adc2..33bf33bed2dc8646953544946ff58358e94bbc56 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,11 @@ Changes with Apache 2.1.0-dev
 
   [Remove entries to the current 2.0 section below, when backported]
 
+  *) Small fix to allow reverse proxying to an ftp server. Previously
+     an attempt to do this would try and connect to 0.0.0.0, regardless
+     of the server specified. PR 24922
+     [Pascal Terjan <pterjan@linuxfr.org>]
+
   *) Fix a potential segfault if the bind password in the LDAP cache
      is NULL. PR 26686 [Jari Ahonen <jah@progress.com>]
 
index a054ea84c2e98d475f3ac00e7b371a4b5c900b58..d2a833a3c5b70784263e886b5b21fe564edabac3 100644 (file)
@@ -754,6 +754,7 @@ int ap_proxy_ftp_handler(request_rec *r, proxy_server_conf *conf,
     char buffer[MAX_STRING_LEN];
     char *ftpmessage = NULL;
     char *path, *strp, *type_suffix, *cwd = NULL;
+    apr_uri_t uri; 
     char *user = NULL;
 /*    char *account = NULL; how to supply an account in a URL? */
     const char *password = NULL;
@@ -808,13 +809,23 @@ int ap_proxy_ftp_handler(request_rec *r, proxy_server_conf *conf,
     if (r->method_number != M_GET)
         return HTTP_NOT_IMPLEMENTED;
 
-
     /* We break the URL into host, port, path-search */
-    connectname = r->parsed_uri.hostname;
-    connectport = (r->parsed_uri.port != 0)
-        ? r->parsed_uri.port
-        : apr_uri_port_of_scheme("ftp");
-    path = apr_pstrdup(p, r->parsed_uri.path);
+    if(r->parsed_uri.hostname==NULL){
+        if (APR_SUCCESS != apr_uri_parse(p, url, &uri)) {
+            return ap_proxyerror(r, HTTP_BAD_REQUEST,
+                apr_psprintf(p, "URI cannot be parsed: %s", url));
+        }
+        connectname = uri.hostname;
+        connectport = uri.port;
+        path = apr_pstrdup(p, uri.path);
+    } else {
+        connectname = r->parsed_uri.hostname;
+        connectport = r->parsed_uri.port;
+        path = apr_pstrdup(p, r->parsed_uri.path);
+    }
+    if (connectport==0) {
+        connectport = apr_uri_port_of_scheme("ftp");
+    }
     path = (path != NULL && path[0] != '\0') ? &path[1] : "";
 
     type_suffix = strchr(path, ';');