Provide a different error message than `invalid url' when an

auto-login ftp URL is used when $ftp_proxy is defined. It now prints:
	Auto-login using ftp URLs isn't supported when using $ftp_proxy
Should solve rest of [bin/3643].

Whilst this is inconsistant with the behaviour when $ftp_proxy isn't
defined, the following constraints apply:
* it's not possible to support ftp URL auto-login when $ftp_proxy is
  defined, since it uses http not ftp, and you can't `login' to http
  servers; fudging this would require a major rewrite of ftp anyway)
* silently ignoring $ftp_proxy and not using it if an ftp auto-login
  URL is given is bad user interface design)
* mrg & others will harrass me if I remove support for autologin ftp URLs
  when $ftp_proxy isn't defined, even though it made the behaviour
  consistant whether $ftp_proxy was set or not.
This commit is contained in:
lukem 1997-06-29 06:34:50 +00:00
parent 0b7e64bbfa
commit 4a8077f211

View File

@ -1,4 +1,4 @@
/* $NetBSD: fetch.c,v 1.10 1997/05/23 18:54:18 lukem Exp $ */
/* $NetBSD: fetch.c,v 1.11 1997/06/29 06:34:50 lukem Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#ifndef lint
static char rcsid[] = "$NetBSD: fetch.c,v 1.10 1997/05/23 18:54:18 lukem Exp $";
static char rcsid[] = "$NetBSD: fetch.c,v 1.11 1997/06/29 06:34:50 lukem Exp $";
#endif /* not lint */
/*
@ -86,7 +86,7 @@ url_get(origline, proxyenv)
const char *proxyenv;
{
struct sockaddr_in sin;
int i, out, port, s;
int i, out, port, s, isftpurl;
size_t buflen, len;
char c, *cp, *cp2, *savefile, *portnum, *path, buf[4096];
char *line, *proxy, *host;
@ -95,25 +95,31 @@ url_get(origline, proxyenv)
s = -1;
proxy = NULL;
isftpurl = 0;
line = strdup(origline);
if (line == NULL)
errx(1, "Can't allocate memory to parse URL");
if (strncasecmp(line, HTTP_URL, sizeof(HTTP_URL) - 1) == 0)
host = line + sizeof(HTTP_URL) - 1;
else if (strncasecmp(line, FTP_URL, sizeof(FTP_URL) - 1) == 0)
else if (strncasecmp(line, FTP_URL, sizeof(FTP_URL) - 1) == 0) {
host = line + sizeof(FTP_URL) - 1;
else
isftpurl = 1;
} else
errx(1, "url_get: Invalid URL '%s'", line);
path = strchr(host, '/'); /* find path */
if (EMPTYSTRING(path)) {
warnx("Invalid URL: %s", origline);
if (isftpurl)
goto noftpautologin;
warnx("Invalid URL (no `/' after host): %s", origline);
goto cleanup_url_get;
}
*path++ = '\0';
if (EMPTYSTRING(path)) {
warnx("Invalid URL: %s", origline);
if (isftpurl)
goto noftpautologin;
warnx("Invalid URL (no file after host): %s", origline);
goto cleanup_url_get;
}
@ -123,7 +129,9 @@ url_get(origline, proxyenv)
else
savefile = path;
if (EMPTYSTRING(savefile)) {
warnx("Invalid URL: %s", origline);
if (isftpurl)
goto noftpautologin;
warnx("Invalid URL (no file after directory): %s", origline);
goto cleanup_url_get;
}
@ -337,8 +345,14 @@ url_get(origline, proxyenv)
free(line);
return (0);
noftpautologin:
warnx(
"Auto-login using ftp URLs isn't supported when using $ftp_proxy");
goto cleanup_url_get;
improper:
warnx("Improper response from %s", host);
cleanup_url_get:
if (s != -1)
close(s);