From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Nils M Holm" Date: Fri, 26 Jun 2015 11:41:26 +0200 To: Fans of the Plan 9 OS <9fans@9fans.net> Message-ID: <20150626094126.GA3572@ananda.local> References: <20150625172536.GA1214@ananda.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150625172536.GA1214@ananda.local> Subject: Re: [9fans] ftpfs shows empty /n/ftp after login Topicbox-Message-UUID: 5bad7090-ead9-11e9-9d60-3106f5b1d025 On 2015-06-25T19:25:36+0200, Nils M Holm wrote: > When logging in via ftpfs, though, I get an empty /n/ftp directory. Turns out that ftpd on FreeBSD announces a port on localhost for passive mode connections: 227 Entering Passive Mode (127,0,0,1,247,55) If I understand QEMU user networking correctly, it sees incoming traffic as originating from localhost, in which case the above would make sense. So I patched ftpfs and added an additional command line option to ignore the host address part of the above message and substitute the destination system's address. The patch works fine for me. I'm not a networking expert, though, so it may have some subtle side effects that I'm not aware of. The patch is below in case anybody is interested. Thanks for your help! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /sys/src/cmd/ip/ftpfs/ftpfs.c.OLD:32,39 - /sys/src/cmd/ip/ftpfs/ftpfs.c:32,37 int kapid = -1; int dying; /* set when any process decides to die */ int dokeepalive; + char *system; + int qemu_hack = 0; char *rflush(Fid*), *rnop(Fid*), *rversion(Fid*), *rattach(Fid*), *rclone(Fid*), *rwalk(Fid*), /sys/src/cmd/ip/ftpfs/ftpfs.c.OLD:151,159 - /sys/src/cmd/ip/ftpfs/ftpfs.c:149,154 case 'q': quiet = 1; break; + case 'Q': + qemu_hack = 1; + break; } ARGEND if(argc != 1) usage(); /sys/src/cmd/ip/ftpfs/ftpfs.c.OLD:165,171 - /sys/src/cmd/ip/ftpfs/ftpfs.c:160,165 /* initial handshakes with remote side */ hello(*argv); + system = *argv; if(cpassword == 0) rlogin(*argv, keyspec); else /sys/src/cmd/ip/ftpfs/proto.c.OLD:1272,1277 - /sys/src/cmd/ip/ftpfs/proto.c:1272,1279 char *p; int x, fd; TLSconn conn; + extern char *system; + extern int qemu_hack; if(nopassive) return Impossible; /sys/src/cmd/ip/ftpfs/proto.c.OLD:1297,1305 - /sys/src/cmd/ip/ftpfs/proto.c:1299,1314 nopassive = 1; return Impossible; } - snprint(ds, sizeof(ds), "%s!%s.%s.%s.%s!%d", net, - f[0], f[1], f[2], f[3], - ((atoi(f[4])&0xff)<<8) + (atoi(f[5])&0xff)); + if (qemu_hack) { + snprint(ds, sizeof(ds), "%s!%s!%d", net, + system, + ((atoi(f[4])&0xff)<<8) + (atoi(f[5])&0xff)); + } + else { + snprint(ds, sizeof(ds), "%s!%s.%s.%s.%s!%d", net, + f[0], f[1], f[2], f[3], + ((atoi(f[4])&0xff)<<8) + (atoi(f[5])&0xff)); + } /* open data connection */ fd = dial(ds, 0, 0, 0); /sys/man/4/ftpfs.OLD:4,10 - /sys/man/4/ftpfs:4,10 .SH SYNOPSIS .B ftpfs [ - .B -/dqnt + .B -/dqntKQ ] [ .B -m /sys/man/4/ftpfs.OLD:96,101 - /sys/man/4/ftpfs:96,107 option causes ftp to send a NOP command every 15 seconds to attempt to keep the connection open. This command can cause some servers to hangup, so you'll have to feel your way. + .PP + QEMU will see incoming connections as coming from localhost and therefore + announce a port for passive mode on 127.0.0.1, which will confuse + .I ftpfs. + The -Q option ignores the host addresses announced by FTP servers in + passive mode negotation and uses the destination address instead. .PP The .B -t - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- Nils M Holm < n m h @ t 3 x . o r g > www.t3x.org