Date: Thu, 17 Aug 2000 14:41:47 -0700 (PDT) From: Archie Cobbs <archie@whistle.com> To: Hajimu UMEMOTO <ume@mahoroba.org> Cc: freebsd-current@freebsd.org Subject: Re: 5.0 snapshot install problem Message-ID: <200008172141.OAA96335@bubba.whistle.com> In-Reply-To: <20000818.055133.48522708.ume@mahoroba.org> from Hajimu UMEMOTO at "Aug 18, 2000 05:51:33 am"
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200008172141.OAA96335>