On Thu, Jan 23, 2003 at 10:12:16AM +0000, Ceri Davies wrote: [longish exchange preserved for the benefit of the newly-CC'd people: yar@ as a de-facto maintainer of libexec/ftpd, and -hackers for additional discussion] > On Thu, Jan 23, 2003 at 10:12:24AM +0200, Peter Pentchev wrote: > > On Thu, Jan 23, 2003 at 01:09:29AM +0100, Julian Mayer wrote: > > > hello > > > there is a bug in portupgrade-20021216: when you change the FTP port in > > > /etc/services to run the FTP demon on another port, portupgrade is > > > unable to download ports/packages via ftp > > > is there a workaround? > > > > Errr.. this is not a bug in portupgrade, but the way most (all?) FTP > > clients work. If you change the port for the 'ftp' service, *any* > > program that asks about the 'ftp' service will use the new port, > > including all FTP clients that try to make outgoing connections. > > In that case, it sounds like a bug in our stock ftpd. > > DESCRIPTION > Ftpd is the Internet File Transfer Protocol server process. The server > uses the TCP protocol and listens at the port specified in the ``ftp'' > service specification; see services(5). > > If this breaks outgoing ftp connections, then that's quite serious. > > > The appropriate way to "fix" that problem is to NOT change the port for > > the 'ftp' service, but merely specify a different port on which to run > > the FTP server. > > RTF ftpd(8) manual - there isn't any other (documented) way to do it. > > If I'm not missing something obvious, then I'll file a PR for this later.
Yes, it would seem that the stock ftpd does not provide a way to specify a different port/service to use in daemon mode. In inetd mode, everything is fine and dandy. Attached is a patch to the libexec/ftpd source, which adds a new -P option taking an argument of either a numeric port number or a service name as described in the getaddrinfo(3) manual page. What do people think about adding this functionality? G'luck, Peter -- Peter Pentchev [EMAIL PROTECTED] [EMAIL PROTECTED] PGP key: http://people.FreeBSD.org/~roam/roam.key.asc Key fingerprint FDBA FD79 C26F 3C51 C95E DF9E ED18 B68D 1619 4553 The rest of this sentence is written in Thailand, on
Index: src/libexec/ftpd/ftpd.8
===================================================================
RCS file: /home/ncvs/src/libexec/ftpd/ftpd.8,v
retrieving revision 1.56
diff -u -r1.56 ftpd.8
--- src/libexec/ftpd/ftpd.8 27 Dec 2002 12:15:31 -0000 1.56
+++ src/libexec/ftpd/ftpd.8 23 Jan 2003 13:35:57 -0000
@@ -43,6 +43,7 @@
.Op Fl 46ADdEMmOoRrSUvW
.Op Fl l Op Fl l
.Op Fl a Ar address
+.Op Fl P Ar port
.Op Fl p Ar file
.Op Fl T Ar maxtimeout
.Op Fl t Ar timeout
@@ -133,6 +134,14 @@
.It Fl o
Put server in write-only mode.
RETR is disabled, preventing downloads.
+.It Fl P
+When
+.Fl D
+is specified, accept connections on the specified
+.Ar port
+or service name instead of using the default
+.Nm ftp
+port.
.It Fl p
When
.Fl D
Index: src/libexec/ftpd/ftpd.c
===================================================================
RCS file: /home/ncvs/src/libexec/ftpd/ftpd.c,v
retrieving revision 1.133
diff -u -r1.133 ftpd.c
--- src/libexec/ftpd/ftpd.c 21 Jan 2003 05:13:02 -0000 1.133
+++ src/libexec/ftpd/ftpd.c 23 Jan 2003 12:48:42 -0000
@@ -277,6 +277,7 @@
FILE *fd;
int error;
char *bindname = NULL;
+ const char *bindport = "ftp";
int family = AF_UNSPEC;
int enable_v4 = 0;
struct sigaction sa;
@@ -296,7 +297,7 @@
#endif /* OLD_SETPROCTITLE */
- while ((ch = getopt(argc, argv, "46a:AdDElmMoOp:rRSt:T:u:UvW")) != -1) {
+ while ((ch = getopt(argc, argv, "46a:AdDElmMoOp:P:rRSt:T:u:UvW")) != -1) {
switch (ch) {
case '4':
enable_v4 = 1;
@@ -352,6 +353,10 @@
pid_file = optarg;
break;
+ case 'P':
+ bindport = optarg;
+ break;
+
case 'r':
readonly = 1;
break;
@@ -436,11 +441,11 @@
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = 0;
hints.ai_flags = AI_PASSIVE;
- error = getaddrinfo(bindname, "ftp", &hints, &res);
+ error = getaddrinfo(bindname, bindport, &hints, &res);
if (error) {
if (family == AF_UNSPEC) {
hints.ai_family = AF_UNSPEC;
- error = getaddrinfo(bindname, "ftp", &hints,
+ error = getaddrinfo(bindname, bindport, &hints,
&res);
}
}
msg39376/pgp00000.pgp
Description: PGP signature

