version 1.80, 2008/07/08 21:07:57 |
version 1.81, 2008/09/26 11:11:59 |
|
|
char *ftp_readline(FILE *, SSL *, size_t *); |
char *ftp_readline(FILE *, SSL *, size_t *); |
size_t ftp_read(FILE *, SSL *, char *, size_t); |
size_t ftp_read(FILE *, SSL *, char *, size_t); |
#ifndef SMALL |
#ifndef SMALL |
int proxy_connect(int, char *); |
int proxy_connect(int, char *, char *); |
int SSL_vprintf(SSL *, const char *, va_list); |
int SSL_vprintf(SSL *, const char *, va_list); |
char *SSL_readline(SSL *, size_t *); |
char *SSL_readline(SSL *, size_t *); |
#endif /* !SMALL */ |
#endif /* !SMALL */ |
|
|
|
|
path = strchr(host, '@'); /* look for credentials in proxy */ |
path = strchr(host, '@'); /* look for credentials in proxy */ |
if (!EMPTYSTRING(path)) { |
if (!EMPTYSTRING(path)) { |
*path++ = '\0'; |
*path = '\0'; |
cookie = strchr(host, ':'); |
cookie = strchr(host, ':'); |
if (EMPTYSTRING(cookie)) { |
if (EMPTYSTRING(cookie)) { |
warnx("Malformed proxy URL: %s", proxyenv); |
warnx("Malformed proxy URL: %s", proxyenv); |
goto cleanup_url_get; |
goto cleanup_url_get; |
} |
} |
cookie = malloc(COOKIE_MAX_LEN); |
cookie = malloc(COOKIE_MAX_LEN); |
b64_ntop(host, strlen(host), cookie, COOKIE_MAX_LEN); |
if (cookie == NULL) |
|
errx(1, "out of memory"); |
|
if (b64_ntop(host, strlen(host), cookie, COOKIE_MAX_LEN) == -1) |
|
errx(1, "error in base64 encoding"); |
|
*path = '@'; /* restore @ in proxyurl */ |
/* |
/* |
* This removes the password from proxyenv, |
* This removes the password from proxyurl, |
* filling with stars |
* filling with stars |
*/ |
*/ |
for (host = strchr(proxyenv + 5, ':'); *host != '@'; |
for (host = 1 + strchr(proxyurl + 5, ':'); *host != '@'; |
host++) |
host++) |
*host = '*'; |
*host = '*'; |
|
|
host = path; |
host = path + 1; |
} |
} |
path = newline; |
path = newline; |
} |
} |
|
|
|
|
#ifndef SMALL |
#ifndef SMALL |
if (proxyenv && sslhost) |
if (proxyenv && sslhost) |
proxy_connect(s, sslhost); |
proxy_connect(s, sslhost, cookie); |
#endif /* !SMALL */ |
#endif /* !SMALL */ |
break; |
break; |
} |
} |
|
|
#endif /* !SMALL */ |
#endif /* !SMALL */ |
if (proxyurl) { |
if (proxyurl) { |
if (verbose) |
if (verbose) |
fprintf(ttyout, " (via %s)\n", proxyenv); |
fprintf(ttyout, " (via %s)\n", proxyurl); |
/* |
/* |
* Host: directive must use the destination host address for |
* Host: directive must use the destination host address for |
* the original URI (path). We do not attach it at this moment. |
* the original URI (path). We do not attach it at this moment. |
|
|
close(s); |
close(s); |
free(proxyurl); |
free(proxyurl); |
free(newline); |
free(newline); |
|
free(cookie); |
rval = url_get(cp, proxyenv, outfile); |
rval = url_get(cp, proxyenv, outfile); |
free(buf); |
free(buf); |
return (rval); |
return (rval); |
|
|
free(buf); |
free(buf); |
free(proxyurl); |
free(proxyurl); |
free(newline); |
free(newline); |
|
free(cookie); |
return (rval); |
return (rval); |
} |
} |
|
|
|
|
} |
} |
|
|
int |
int |
proxy_connect(int socket, char *host) |
proxy_connect(int socket, char *host, char *cookie) |
{ |
{ |
int l; |
int l; |
char buf[1024]; |
char buf[1024]; |
|
|
if (!port) |
if (!port) |
port = "443"; |
port = "443"; |
|
|
l = asprintf(&connstr, "CONNECT %s:%s HTTP/1.1\n\n", host, port); |
if (cookie) { |
|
l = asprintf(&connstr, "CONNECT %s:%s HTTP/1.1\r\n" |
|
"Proxy-Authorization: Basic %s\r\n%s\r\n\r\n", |
|
host, port, cookie, HTTP_USER_AGENT); |
|
} else { |
|
l = asprintf(&connstr, "CONNECT %s:%s HTTP/1.1\r\n%s\r\n\r\n", |
|
host, port, HTTP_USER_AGENT); |
|
} |
|
|
if (l == -1) |
if (l == -1) |
errx(1, "Could not allocate memory to assemble connect string!"); |
errx(1, "Could not allocate memory to assemble connect string!"); |
#ifndef SMALL |
#ifndef SMALL |