The environment variable 'https_proxy' is required by libcurl to use a
proxy for https targets.
The patch also uses CURLOPT_PROXYUSERNAME and CURLOPT_PROXYPASSWORD
instead of CURLOPT_PROXYUSERPWD to set the user credentials for the
proxy.
Signed-off-by: Mathias Kunert <
mathias...@dezem.de>
---
libopkg/opkg_conf.c | 1 +
libopkg/opkg_conf.h | 1 +
libopkg/opkg_download.c | 15 +++++++++------
3 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/libopkg/opkg_conf.c b/libopkg/opkg_conf.c
index 843f509..779906e 100644
--- a/libopkg/opkg_conf.c
+++ b/libopkg/opkg_conf.c
@@ -60,6 +60,7 @@ static opkg_option_t options[] = {
{ "check_signature", OPKG_OPT_TYPE_BOOL, &_conf.check_signature },
{ "ftp_proxy", OPKG_OPT_TYPE_STRING, &_conf.ftp_proxy },
{ "http_proxy", OPKG_OPT_TYPE_STRING, &_conf.http_proxy },
+ { "https_proxy", OPKG_OPT_TYPE_STRING, &_conf.https_proxy },
{ "no_proxy", OPKG_OPT_TYPE_STRING, &_conf.no_proxy },
{ "test", OPKG_OPT_TYPE_BOOL, &_conf.noaction },
{ "noaction", OPKG_OPT_TYPE_BOOL, &_conf.noaction },
diff --git a/libopkg/opkg_conf.h b/libopkg/opkg_conf.h
index 87a4d84..5b40d2c 100644
--- a/libopkg/opkg_conf.h
+++ b/libopkg/opkg_conf.h
@@ -122,6 +122,7 @@ typedef struct opkg_conf {
/* proxy options */
char *http_proxy;
+ char *https_proxy;
char *ftp_proxy;
char *no_proxy;
char *proxy_user;
diff --git a/libopkg/opkg_download.c b/libopkg/opkg_download.c
index 48be76d..cbde790 100644
--- a/libopkg/opkg_download.c
+++ b/libopkg/opkg_download.c
@@ -365,6 +365,11 @@ opkg_download_internal(const char *src, const char *dest,
opkg_config->http_proxy);
setenv("http_proxy", opkg_config->http_proxy, 1);
}
+ if (opkg_config->https_proxy) {
+ opkg_msg(DEBUG, "Setting environment variable: https_proxy = %s.\n",
+ opkg_config->https_proxy);
+ setenv("https_proxy", opkg_config->https_proxy, 1);
+ }
if (opkg_config->ftp_proxy) {
opkg_msg(DEBUG, "Setting environment variable: ftp_proxy = %s.\n",
opkg_config->ftp_proxy);
@@ -880,13 +885,11 @@ opkg_curl_init(curl_progress_func cb, void *data)
curl_easy_setopt (curl, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt (curl, CURLOPT_FAILONERROR, 1);
- if (opkg_config->http_proxy || opkg_config->ftp_proxy)
+ if (opkg_config->http_proxy || opkg_config->ftp_proxy || opkg_config->https_proxy)
{
- char *userpwd;
- sprintf_alloc (&userpwd, "%s:%s", opkg_config->proxy_user,
- opkg_config->proxy_passwd);
- curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, userpwd);
- free (userpwd);
+ curl_easy_setopt(curl, CURLOPT_PROXYUSERNAME, opkg_config->proxy_user);
+ curl_easy_setopt(curl, CURLOPT_PROXYPASSWORD, opkg_config->proxy_passwd);
+ curl_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
}
}
-- 1.8.3.2