Fix two bugs:
- The ftpPassive()
This commit is contained in:
parent
81e309b71b
commit
c387a49c7c
@ -213,8 +213,10 @@ from the peer before aborting an
|
|||||||
.Tn FTP
|
.Tn FTP
|
||||||
connection.
|
connection.
|
||||||
.It Ev FTP_PASSIVE_MODE
|
.It Ev FTP_PASSIVE_MODE
|
||||||
Force the use of passive mode
|
If defined, forces the use of passive mode, unless equal
|
||||||
.Tn FTP .
|
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
|
.El
|
||||||
.Sh BUGS
|
.Sh BUGS
|
||||||
I'm sure you can get this thing's internal state machine confused if
|
I'm sure you can get this thing's internal state machine confused if
|
||||||
|
@ -327,37 +327,12 @@ ftpPut(FILE *fp, char *file)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unlike binary mode, passive mode is a toggle! :-( */
|
|
||||||
int
|
int
|
||||||
ftpPassive(FILE *fp, int st)
|
ftpPassive(FILE *fp, int st)
|
||||||
{
|
{
|
||||||
FTP_t ftp = fcookie(fp);
|
FTP_t ftp = fcookie(fp);
|
||||||
int i;
|
|
||||||
|
|
||||||
if (ftp->is_passive == st)
|
ftp->is_passive = !!st; /* normalize "st" to zero or one */
|
||||||
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;
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -545,12 +520,17 @@ ftp_close_method(void *n)
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This function checks whether the FTP_PASSIVE_MODE environment
|
||||||
|
* variable is set, and, if so, enforces the desired mode.
|
||||||
|
*/
|
||||||
static void
|
static void
|
||||||
check_passive(FILE *fp)
|
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
|
static void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user