diff options
author | archie <archie@FreeBSD.org> | 2000-08-17 23:46:13 +0000 |
---|---|---|
committer | archie <archie@FreeBSD.org> | 2000-08-17 23:46:13 +0000 |
commit | 0df88a05d9089445536ece33cbd62f932786a6b7 (patch) | |
tree | db65840d0007dbb982415f5d8b5d761955bb21c2 /lib | |
parent | d2bdccc3f89d8e510f1953252ff3057c2b08046b (diff) | |
download | FreeBSD-src-0df88a05d9089445536ece33cbd62f932786a6b7.zip FreeBSD-src-0df88a05d9089445536ece33cbd62f932786a6b7.tar.gz |
Fix two bugs:
- The ftpPassive()
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libftpio/ftpio.3 | 6 | ||||
-rw-r--r-- | lib/libftpio/ftpio.c | 36 |
2 files changed, 12 insertions, 30 deletions
diff --git a/lib/libftpio/ftpio.3 b/lib/libftpio/ftpio.3 index 510324d..8e1b86f 100644 --- a/lib/libftpio/ftpio.3 +++ b/lib/libftpio/ftpio.3 @@ -213,8 +213,10 @@ from the peer before aborting an .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 --git a/lib/libftpio/ftpio.c b/lib/libftpio/ftpio.c index d4e4a9e..fcf2424 100644 --- a/lib/libftpio/ftpio.c +++ b/lib/libftpio/ftpio.c @@ -327,37 +327,12 @@ ftpPut(FILE *fp, char *file) 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 @@ ftp_close_method(void *n) 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 |