Date: Fri, 12 Apr 2002 04:10:03 -0700 (PDT) From: Maxim Konovalov <maxim@macomnet.ru> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/36955: Stock ftpd does not reuse ports in passive mode andfails Message-ID: <200204121110.g3CBA3Q34259@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/36955; it has been noted by GNATS.
From: Maxim Konovalov <maxim@macomnet.ru>
To: Eugene Grosbein <eugen@svzserv.kemerovo.su>
Cc: bug-followup@freebsd.org
Subject: Re: bin/36955: Stock ftpd does not reuse ports in passive mode
andfails
Date: Fri, 12 Apr 2002 15:03:54 +0400 (MSD)
Eugene,
The patch below solves the problem but I am not sure yet is it good
idea or not..
Index: ftpd.c
===================================================================
RCS file: /home/ncvs/src/libexec/ftpd/ftpd.c,v
retrieving revision 1.99
diff -u -r1.99 ftpd.c
--- ftpd.c 25 Feb 2002 16:39:34 -0000 1.99
+++ ftpd.c 12 Apr 2002 10:53:00 -0000
@@ -2415,7 +2415,7 @@
void
passive(void)
{
- int len;
+ int len, on;
char *p, *a;
if (pdata >= 0) /* close old port if one set */
@@ -2426,12 +2426,15 @@
perror_reply(425, "Can't open passive connection");
return;
}
-
+ on = 1;
+ if (setsockopt(pdata, SOL_SOCKET, SO_REUSEADDR,
+ (char *)&on, sizeof(on)) < 0)
+ syslog(LOG_ERR, "passive data connection setsockopt: %m");
(void) seteuid((uid_t)0);
#ifdef IP_PORTRANGE
if (ctrl_addr.su_family == AF_INET) {
- int on = restricted_data_ports ? IP_PORTRANGE_HIGH
+ on = restricted_data_ports ? IP_PORTRANGE_HIGH
: IP_PORTRANGE_DEFAULT;
if (setsockopt(pdata, IPPROTO_IP, IP_PORTRANGE,
@@ -2441,7 +2444,7 @@
#endif
#ifdef IPV6_PORTRANGE
if (ctrl_addr.su_family == AF_INET6) {
- int on = restricted_data_ports ? IPV6_PORTRANGE_HIGH
+ on = restricted_data_ports ? IPV6_PORTRANGE_HIGH
: IPV6_PORTRANGE_DEFAULT;
if (setsockopt(pdata, IPPROTO_IPV6, IPV6_PORTRANGE,
%%%
--
Maxim Konovalov, MAcomnet, Internet Dept., system engineer
phone: +7 (095) 796-9079, mailto:maxim@macomnet.ru
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200204121110.g3CBA3Q34259>
