From owner-freebsd-ports Thu Jan 23 9:47:18 2003 Delivered-To: freebsd-ports@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 94E1437B401; Thu, 23 Jan 2003 09:47:14 -0800 (PST) Received: from comp.chem.msu.su (comp-ext.chem.msu.su [158.250.32.157]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1B5CA43E4A; Thu, 23 Jan 2003 09:47:12 -0800 (PST) (envelope-from yar@comp.chem.msu.su) Received: from comp.chem.msu.su (localhost [127.0.0.1]) by comp.chem.msu.su (8.12.3/8.12.3) with ESMTP id h0NHl8sA009149; Thu, 23 Jan 2003 20:47:08 +0300 (MSK) (envelope-from yar@comp.chem.msu.su) Received: (from yar@localhost) by comp.chem.msu.su (8.12.3/8.12.3/Submit) id h0NHl6gE009148; Thu, 23 Jan 2003 20:47:06 +0300 (MSK) (envelope-from yar) Date: Thu, 23 Jan 2003 20:47:06 +0300 From: Yar Tikhiy To: Ceri Davies , Julian Mayer , knu@FreeBSD.org, ports@FreeBSD.org, hackers@FreeBSD.org Subject: Re: FreeBSD Port: portupgrade-20021216 Message-ID: <20030123174706.GA8943@comp.chem.msu.su> References: <20030123081224.GA471@straylight.oblivion.bg> <20030123101216.GA2856@submonkey.net> <20030123134749.GA377@straylight.oblivion.bg> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030123134749.GA377@straylight.oblivion.bg> User-Agent: Mutt/1.5.3i Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org On Thu, Jan 23, 2003 at 03:47:49PM +0200, Peter Pentchev wrote: > > 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? Peter, here is a bit reworked version of your patch. Does it look reasonable? -- Yar Index: ftpd.8 =================================================================== RCS file: /home/ncvs/src/libexec/ftpd/ftpd.8,v retrieving revision 1.56 diff -u -r1.56 ftpd.8 --- ftpd.8 27 Dec 2002 12:15:31 -0000 1.56 +++ ftpd.8 23 Jan 2003 17:39:59 -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 @@ -55,7 +56,9 @@ server process. The server uses the .Tn TCP protocol -and listens at the port specified in the +and listens at the port specified with the +.Fl P +option or in the .Dq ftp service specification; see .Xr services 5 . @@ -133,6 +136,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 at +.Ar port , +specified as a numeric value or service name, instead of at the default +.Dq ftp +port. .It Fl p When .Fl D Index: ftpd.c =================================================================== RCS file: /home/ncvs/src/libexec/ftpd/ftpd.c,v retrieving revision 1.133 diff -u -r1.133 ftpd.c --- ftpd.c 21 Jan 2003 05:13:02 -0000 1.133 +++ ftpd.c 23 Jan 2003 17:40:01 -0000 @@ -115,6 +115,7 @@ int daemon_mode; int data; +int dataport; int logged_in; struct passwd *pw; int ftpdebug; @@ -277,6 +278,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 +298,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 +354,10 @@ pid_file = optarg; break; + case 'P': + bindport = optarg; + break; + case 'r': readonly = 1; break; @@ -436,11 +442,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); } } @@ -553,6 +559,7 @@ syslog(LOG_ERR, "getsockname (%s): %m",argv[0]); exit(1); } + dataport = ntohs(ctrl_addr.su_port) - 1; /* as per RFC 959 */ #ifdef VIRTUAL_HOSTING /* select our identity from virtual host table */ selecthost(&ctrl_addr); @@ -1722,7 +1729,7 @@ syslog(LOG_WARNING, "data setsockopt (SO_REUSEADDR): %m"); /* anchor socket to avoid multi-homing problems */ data_source = ctrl_addr; - data_source.su_port = htons(20); /* ftp-data port */ + data_source.su_port = htons(dataport); for (tries = 1; ; tries++) { if (bind(s, (struct sockaddr *)&data_source, data_source.su_len) >= 0) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message