While using ftpd in 9vx and qemu I got response messages "Permission denied" in passive mode. This was caused in dialdata by dial(data,"20",0,0). While correcting this problem I also enhanced the options of ftpd to make it possible to use alternative ports instead of 20 for the data socket. ftpd got an optional parameter -P dataport which defaults to 20. The changes make it now possible to use ftpd from 9vx and qemu without port redirection.

with a call like :

aux/listen1 -vt tcp!*!13000 /bin/ip/ftpd -Aen namespace.ftp -P 13001

one can start a ftp server listening on port 13000 while using 13001 as its default data port.

The diffs for ftpd.c and ipserv-manpage against 9legacy (latest version) are :

DIFF FOR ftpd.c :
==============

137,138d136
< char *dataport="20" ;
< char dataadr[64] ;
177,178c175,176
< syslog(0, "ftp", "usage: %s [-aAde] [-n nsfile] [-P dataport]", argv0);
< fprint(2, "usage: %s [-aAde] [-n nsfile] [-P dataport]\n", argv0);
---
> syslog(0, "ftp", "usage: %s [-aAde] [-n nsfile]", argv0);
> fprint(2, "usage: %s [-aAde] [-n nsfile]\n", argv0);
194,195c192
< int dataportid ;
<
---
>
214,216d210
< case 'P' :
< dataport = EARGF(usage()) ;
< break ;
232,237d225
< /* prepare data port */
< dataportid=atol(dataport) ;
< if (dataportid==0)
< dataportid=20 ;
< snprint(dataadr,64,"tcp!*!%d",dataportid) ;
<
1697c1685
< fd = dial(data, dataadr, 0, 0);
---
> fd = dial(data, "20", 0, 0);
1710d1697
<

Diff for man/8/ipserv
==================
18,19d17
< .RB [ -P
< .IR dataport ]
170,172d167
< .TP
< .B P
< the port used for the data socket (default 20)
181,188d175
< .PP
< .SH EXAMPLE
< .PP
< Start ftpd with control port 13000 and data port 13001 while using prepared namespace /usr/glenda/ftp/namespace.ftp for anonymous access.
< .PP
< .EX
< aux/listen1 -vt tcp!*!13000 /bin/ip/ftpd -Aen /usr/glenda/ftp/namespace.ftp -P 13001
< .EE


FURTHER COMMENT :
==================
ftpd makes data exchange between UNIX hosts and plan9 guests while using qemu very simple.

ftpd can be started from 9vx in usermode when using ports other than 21(20).

Some ftp clients ask for utf8 opt and this is ignored by ftpd my next patch will adress this problem. Comments are welcome.