Bug 24922 - ftp proxy connects to 0.0.0.0
Summary: ftp proxy connects to 0.0.0.0
Status: CLOSED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_proxy (show other bugs)
Version: 2.0.48
Hardware: PC FreeBSD
: P3 major (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2003-11-22 23:13 UTC by Kirill K
Modified: 2004-11-16 19:05 UTC (History)
0 users



Attachments
A quick patch that made reverse ftp work fine for me (1.37 KB, patch)
2004-03-22 10:39 UTC, Pascal Terjan
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kirill K 2003-11-22 23:13:24 UTC
Hello.
I'm trying to forward requests to remote ftp-server with simple htaccess
(located in /ftp/ dir):
RewriteEngine on
RewriteRule (.*)\.txt$ ftp://123.123.123.123/$1.txt [P]

But Apache (2.0.48) returns such error:
Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /ftp/file.txt.

Reason: Could not connect to remote machine: (null) port 80

I've tested same htaccess with http forward and it just works fine. In
error.log (debug mode) i'm getting such messages:

proxy_ftp.c(824): proxy: FTP: serving URL ftp://123.123.123.123
proxy_ftp.c(917): proxy: FTP: connecting ftp://123.123.123.123 to (null):80
proxy_ftp.c(995): proxy: FTP: fam 2 socket created, trying to connect to
0.0.0.0:80 ((null))...
(OS 10049)The requested address is not valid in its context.  : proxy: FTP:
attempt to connect to 0.0.0.0:80 ((null)) failed

Some more info: i've tested it under FreeBSD and WinXP, got same result,
also if there's local ftp-server running (listening to 0.0.0.0, not
127.0.0.1), then apache connects to it successfully.
Also, i've tried different URI schemes, because i think that module just cant 
parse it correctly, but no way..
ftp://123.123.123.123
ftp://123.123.123.123/
ftp://123.123.123.123:21
ftp://123.123.123.123:21/
ftp://anonymous:password@123.123.123.123
etc, all failed.

Also, i've tried to bind remote ftp with ProxyPass directive -- same result 
(and again -- binding http server was successful)
Please help, I don't like SQUID for some reasons and really would like to have 
ftp-proxy with Apache running.
Thanks a lot in advance.
Comment 1 Kirill K 2003-11-24 00:19:18 UTC
Today i've added desired IP directly into proxy_ftp.c and though now Apache 
tries to open desired IP, i'm getting segfault (11) just like in this bug:
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14976

Seems like it still not fixed in 2.0.48.
Comment 2 William A. Rowe Jr. 2003-11-26 21:57:30 UTC
  Seriously doubt that this is an identical segfault, Kirill.  Why not attach
  a backtrace of the crash dump?  And why would you complain about segfaults
  in a modified module if you didn't post the patch you attempted to use???

  Please, more details - we don't read minds and would love to look closer at
  these issues :)
Comment 3 Kirill K 2003-11-27 14:01:52 UTC
Sorry, never did things like that :) Here goes the backtrace: 
(gdb) bt
#0  0x283572c6 in memcpy () from /usr/lib/libc.so.5
#1  0x0000000c in ?? ()
#2  0x28349d3f in strchr () from /usr/lib/libc.so.5
#3  0x2834cad5 in __vfprintf () from /usr/lib/libc.so.5
#4  0x2833cd35 in sprintf () from /usr/lib/libc.so.5
#5  0x284ff596 in ap_proxy_ftp_handler () 
from /opt/apache/modules/mod_proxy_ftp.so
#6  0x74662f2f in ?? ()
Cannot access memory at address 0x3a707466

I'll try to collect more info tomorrow, but need to re-compile apache for that.
Comment 4 Kirill K 2003-11-28 15:57:24 UTC
one more dump:
(gdb) bt full
#0  apr_palloc (pool=0x280d11d0, size=8) at apr_pools.c:640
        active = (struct apr_memnode_t *) 0x280d2a80
        node = (struct apr_memnode_t *) 0x2
        mem = (void *) 0x0
        free_index = 671945168
(gdb)

(after i've recompiled apache with -g option)
Comment 5 Pascal Terjan 2004-03-22 10:39:56 UTC
Created attachment 10892 [details]
A quick patch that made reverse ftp work fine for me
Comment 6 Graham Leggett 2004-05-21 22:09:01 UTC
Patch applied to v2.1.0-dev, awaiting backport to v2.0
Comment 7 Jeff Trawick 2004-07-03 12:59:59 UTC
committed to 2.0.51-dev

thanks again for the patch!