From owner-freebsd-current Thu Aug 17 18:56:30 2000 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.129.65]) by hub.freebsd.org (Postfix) with ESMTP id 2ABF137BF11 for ; Thu, 17 Aug 2000 18:51:43 -0700 (PDT) Received: from gatekeeper.whistle.com (gatekeeper.whistle.com [207.76.204.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id E9EB96E3C78 for ; Thu, 17 Aug 2000 14:43:08 -0700 (PDT) Received: from bubba.whistle.com (bubba.whistle.com [207.76.205.7]) by gatekeeper.whistle.com (8.9.3/8.9.3) with ESMTP id OAA11392; Thu, 17 Aug 2000 14:41:55 -0700 (PDT) (envelope-from archie@whistle.com) Received: (from archie@localhost) by bubba.whistle.com (8.9.3/8.9.3) id OAA96335; Thu, 17 Aug 2000 14:41:47 -0700 (PDT) (envelope-from archie) From: Archie Cobbs Message-Id: <200008172141.OAA96335@bubba.whistle.com> Subject: Re: 5.0 snapshot install problem In-Reply-To: <20000818.055133.48522708.ume@mahoroba.org> from Hajimu UMEMOTO at "Aug 18, 2000 05:51:33 am" To: Hajimu UMEMOTO Date: Thu, 17 Aug 2000 14:41:47 -0700 (PDT) Cc: freebsd-current@freebsd.org X-Mailer: ELM [version 2.4ME+ PL68 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hajimu UMEMOTO writes: > archie> But why is sysinstall going to active mode? I *know* FTP passive > archie> was selected.. > > This is just because ftpPassive() is called from ftpGet(). > > ftpGet() > check_passive() > ftpPassive() > > Further more, if FTP_PASSIVE_MODE is not set, check_passive() calls > ftpPassive(fp, 0). > First, sysinstall calls ftpPassive() to intend to use PASV. Then, > ftp->is_passive is reset to 1. > Next, ftpGet() calls ftpPassive() according to the setting of > FTP_PASSIVE_MODE. In installer, FTP_PASSIVE_MODE is not set. Then, > ftp->is_passive is reset to 0 by ftpPassive() toggle. > So, ftp_file_op() issues PORT. Yes, now I understand.. you and your patch are exactly right. A combined patch is below; please review. -Archie ___________________________________________________________________________ Archie Cobbs * Whistle Communications, Inc. * http://www.whistle.com diff -ur /usr/src/lib/libftpio/ftpio.3 ./ftpio.3 --- /usr/src/lib/libftpio/ftpio.3 Mon Aug 7 14:14:40 2000 +++ ./ftpio.3 Thu Aug 17 14:39:48 2000 @@ -213,8 +213,10 @@ .Tn FTP connection. .It Ev FTP_PASSIVE_MODE -Force the use of passive mode -.Tn FTP . +If defined, forces the use of passive mode, unless equal +to ``NO'' or ``no'' in which case active mode is forced. +If defined, the setting of this variable always overrides any calls to +.Fn ftpPassive . .El .Sh BUGS I'm sure you can get this thing's internal state machine confused if diff -ur /usr/src/lib/libftpio/ftpio.c ./ftpio.c --- /usr/src/lib/libftpio/ftpio.c Mon Aug 7 14:14:40 2000 +++ ./ftpio.c Thu Aug 17 14:36:10 2000 @@ -327,37 +327,12 @@ return NULL; } -/* Unlike binary mode, passive mode is a toggle! :-( */ int ftpPassive(FILE *fp, int st) { FTP_t ftp = fcookie(fp); - int i; - if (ftp->is_passive == st) - return SUCCESS; - switch (ftp->addrtype) { - case AF_INET: - i = cmd(ftp, "PASV"); - if (i < 0) - return i; - if (i != FTP_PASSIVE_HAPPY) - return FAILURE; - break; - case AF_INET6: - i = cmd(ftp, "EPSV"); - if (i < 0) - return i; - if (i != FTP_EPASSIVE_HAPPY) { - i = cmd(ftp, "LPSV"); - if (i < 0) - return i; - if (i != FTP_LPASSIVE_HAPPY) - return FAILURE; - } - break; - } - ftp->is_passive = !ftp->is_passive; + ftp->is_passive = !!st; /* normalize "st" to zero or one */ return SUCCESS; } @@ -545,12 +520,17 @@ return i; } +/* + * This function checks whether the FTP_PASSIVE_MODE environment + * variable is set, and, if so, enforces the desired mode. + */ static void check_passive(FILE *fp) { - char *cp = getenv("FTP_PASSIVE_MODE"); + const char *cp = getenv("FTP_PASSIVE_MODE"); - ftpPassive(fp, (cp && strncasecmp(cp, "no", 2))); + if (cp != NULL) + ftpPassive(fp, strncasecmp(cp, "no", 2)); } static void To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message