9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "Nils M Holm" <nmh@t3x.org>
To: Fans of the Plan 9 OS <9fans@9fans.net>
Subject: Re: [9fans] ftpfs shows empty /n/ftp after login
Date: Fri, 26 Jun 2015 11:41:26 +0200	[thread overview]
Message-ID: <20150626094126.GA3572@ananda.local> (raw)
In-Reply-To: <20150625172536.GA1214@ananda.local>

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



      parent reply	other threads:[~2015-06-26  9:41 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-25 17:25 Nils M Holm
2015-06-25 18:09 ` Ryan Gonzalez
2015-06-25 19:57   ` Nils M Holm
2015-06-25 22:01     ` Ryan Gonzalez
2015-06-25 18:28 ` Bakul Shah
2015-06-25 19:51   ` Nils M Holm
2015-06-25 20:16     ` Bakul Shah
2015-06-25 20:29       ` Nils M Holm
2015-06-26  8:22       ` Nils M Holm
2015-06-26  8:24         ` Mark van Atten
2015-06-26  9:32           ` Nils M Holm
2015-06-26 10:00             ` David du Colombier
2015-06-27  9:11               ` Nils M Holm
2015-06-27  9:54                 ` David du Colombier
2015-06-27 20:24                   ` Nils M Holm
2015-06-29 18:04                     ` Nils M Holm
2015-06-26  8:29         ` Nils M Holm
2015-06-26  8:52           ` Bakul Shah
2015-06-26  9:44             ` Nils M Holm
2015-06-26 13:57               ` fgergo
2015-06-25 19:00 ` Steve Simon
2015-06-26  9:41 ` Nils M Holm [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150626094126.GA3572@ananda.local \
    --to=nmh@t3x.org \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).