summaryrefslogtreecommitdiffstats
path: root/lib/libfetch/ftp.c
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2000-11-10 08:43:40 +0000
committerdes <des@FreeBSD.org>2000-11-10 08:43:40 +0000
commit985bff769942e74d8a4614115b7153a96bf6d0b6 (patch)
treeda8eae065a0f12e6489dde4d5fef45d7a0b7ac3d /lib/libfetch/ftp.c
parentfaf86e96f0a2a44d87ffbce68497bf4426dcc3af (diff)
downloadFreeBSD-src-985bff769942e74d8a4614115b7153a96bf6d0b6.zip
FreeBSD-src-985bff769942e74d8a4614115b7153a96bf6d0b6.tar.gz
Use the documented (and historical) defaults. Centralize the decision logic
in order to avoid this bug in the future. Submitted by: se
Diffstat (limited to 'lib/libfetch/ftp.c')
-rw-r--r--lib/libfetch/ftp.c21
1 files changed, 4 insertions, 17 deletions
diff --git a/lib/libfetch/ftp.c b/lib/libfetch/ftp.c
index 18da8b2..3e56342 100644
--- a/lib/libfetch/ftp.c
+++ b/lib/libfetch/ftp.c
@@ -711,19 +711,6 @@ ouch:
}
/*
- * Return default port
- */
-static int
-_ftp_default_port(void)
-{
- struct servent *se;
-
- if ((se = getservbyname(SCHEME_FTP, "tcp")) != NULL)
- return ntohs(se->s_port);
- return FTP_DEFAULT_PORT;
-}
-
-/*
* Log on to FTP server
*/
static int
@@ -776,7 +763,7 @@ _ftp_connect(struct url *url, struct url *purl, char *flags)
user = url->user;
if (!user || !*user)
user = FTP_ANONYMOUS_USER;
- if (purl && url->port == FTP_DEFAULT_PORT)
+ if (purl && url->port == _fetch_default_port(url->scheme))
e = _ftp_cmd(cd, "USER %s@%s", user, url->host);
else if (purl)
e = _ftp_cmd(cd, "USER %s@%s@%d", user, url->host, url->port);
@@ -859,7 +846,7 @@ _ftp_cached_connect(struct url *url, struct url *purl, char *flags)
/* set default port */
if (!url->port)
- url->port = _ftp_default_port();
+ url->port = _fetch_default_port(url->scheme);
/* try to use previously cached connection */
if (_ftp_isconnected(url)) {
@@ -890,9 +877,9 @@ _ftp_get_proxy(void)
if (((p = getenv("FTP_PROXY")) || (p = getenv("HTTP_PROXY"))) &&
*p && (purl = fetchParseURL(p)) != NULL) {
if (!*purl->scheme)
- strcpy(purl->scheme, SCHEME_FTP);
+ strcpy(purl->scheme, SCHEME_HTTP);
if (!purl->port)
- purl->port = _ftp_default_port();
+ purl->port = _fetch_default_proxy_port(purl->scheme);
if (strcasecmp(purl->scheme, SCHEME_FTP) == 0 ||
strcasecmp(purl->scheme, SCHEME_HTTP) == 0)
return purl;
OpenPOWER on IntegriCloud