aboutsummaryrefslogtreecommitdiff
path: root/lib/libfetch
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2015-11-29 14:26:59 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2015-11-29 14:26:59 +0000
commit4d8b056ef182f278d706e7528b871f0631e22a80 (patch)
tree11cba80d20f13df7fdb24b944c9c65bd18e96686 /lib/libfetch
parent5c859bfb63b7a7c8cc325ca1139ecd5603f1bef0 (diff)
downloadsrc-4d8b056ef182f278d706e7528b871f0631e22a80.tar.gz
src-4d8b056ef182f278d706e7528b871f0631e22a80.zip
Use .netrc for HTTP sites and proxies, not just FTP.
PR: 193740 Submitted by: TEUBEL György <tgyurci@gmail.com> MFC after: 1 week
Notes
Notes: svn path=/head/; revision=291453
Diffstat (limited to 'lib/libfetch')
-rw-r--r--lib/libfetch/fetch.36
-rw-r--r--lib/libfetch/http.c8
2 files changed, 11 insertions, 3 deletions
diff --git a/lib/libfetch/fetch.3 b/lib/libfetch/fetch.3
index 53a4e424a834..0ad91660bfb9 100644
--- a/lib/libfetch/fetch.3
+++ b/lib/libfetch/fetch.3
@@ -26,7 +26,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd March 25, 2015
+.Dd November 29, 2015
.Dt FETCH 3
.Os
.Sh NAME
@@ -631,11 +631,11 @@ If defined but empty, no User-Agent header is sent.
.It Ev NETRC
Specifies a file to use instead of
.Pa ~/.netrc
-to look up login names and passwords for FTP sites.
+to look up login names and passwords for FTP and HTTP sites as well as
+HTTP proxies.
See
.Xr ftp 1
for a description of the file format.
-This feature is experimental.
.It Ev NO_PROXY
Either a single asterisk, which disables the use of proxies
altogether, or a comma- or whitespace-separated list of hosts for
diff --git a/lib/libfetch/http.c b/lib/libfetch/http.c
index f6a74540c8fc..f678b366f68e 100644
--- a/lib/libfetch/http.c
+++ b/lib/libfetch/http.c
@@ -1658,6 +1658,9 @@ http_request_body(struct url *URL, const char *op, struct url_stat *us,
http_seterr(HTTP_NEED_PROXY_AUTH);
goto ouch;
}
+ } else if (fetch_netrc_auth(purl) == 0) {
+ aparams.user = strdup(purl->user);
+ aparams.password = strdup(purl->pwd);
}
http_authorize(conn, "Proxy-Authorization",
&proxy_challenges, &aparams, url);
@@ -1685,6 +1688,11 @@ http_request_body(struct url *URL, const char *op, struct url_stat *us,
http_seterr(HTTP_NEED_AUTH);
goto ouch;
}
+ } else if (fetch_netrc_auth(url) == 0) {
+ aparams.user = url->user ?
+ strdup(url->user) : strdup("");
+ aparams.password = url->pwd ?
+ strdup(url->pwd) : strdup("");
} else if (fetchAuthMethod &&
fetchAuthMethod(url) == 0) {
aparams.user = strdup(url->user);