diff options
Diffstat (limited to 'src/libstrongswan/plugins/curl')
-rw-r--r-- | src/libstrongswan/plugins/curl/Makefile.in | 8 | ||||
-rw-r--r-- | src/libstrongswan/plugins/curl/curl_fetcher.c | 23 |
2 files changed, 27 insertions, 4 deletions
diff --git a/src/libstrongswan/plugins/curl/Makefile.in b/src/libstrongswan/plugins/curl/Makefile.in index 2aedb2f75..0dbcca895 100644 --- a/src/libstrongswan/plugins/curl/Makefile.in +++ b/src/libstrongswan/plugins/curl/Makefile.in @@ -310,8 +310,6 @@ RANLIB = @RANLIB@ RTLIB = @RTLIB@ RUBY = @RUBY@ RUBYGEMDIR = @RUBYGEMDIR@ -RUBYINCLUDE = @RUBYINCLUDE@ -RUBYLIB = @RUBYLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ @@ -412,6 +410,8 @@ random_device = @random_device@ resolv_conf = @resolv_conf@ routing_table = @routing_table@ routing_table_prio = @routing_table_prio@ +ruby_CFLAGS = @ruby_CFLAGS@ +ruby_LIBS = @ruby_LIBS@ runstatedir = @runstatedir@ s_plugins = @s_plugins@ sbindir = @sbindir@ @@ -440,6 +440,10 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ tss2_CFLAGS = @tss2_CFLAGS@ tss2_LIBS = @tss2_LIBS@ +tss2_socket_CFLAGS = @tss2_socket_CFLAGS@ +tss2_socket_LIBS = @tss2_socket_LIBS@ +tss2_tabrmd_CFLAGS = @tss2_tabrmd_CFLAGS@ +tss2_tabrmd_LIBS = @tss2_tabrmd_LIBS@ urandom_device = @urandom_device@ xml_CFLAGS = @xml_CFLAGS@ xml_LIBS = @xml_LIBS@ diff --git a/src/libstrongswan/plugins/curl/curl_fetcher.c b/src/libstrongswan/plugins/curl/curl_fetcher.c index 9207f11b6..b52b35ba0 100644 --- a/src/libstrongswan/plugins/curl/curl_fetcher.c +++ b/src/libstrongswan/plugins/curl/curl_fetcher.c @@ -58,6 +58,11 @@ struct private_curl_fetcher_t { * Timeout for a transfer */ long timeout; + + /** + * Maximum number of redirects to follow + */ + long redir; }; /** @@ -85,7 +90,7 @@ static size_t curl_cb(void *ptr, size_t size, size_t nmemb, cb_data_t *data) METHOD(fetcher_t, fetch, status_t, private_curl_fetcher_t *this, char *uri, void *userdata) { - char error[CURL_ERROR_SIZE], *enc_uri; + char error[CURL_ERROR_SIZE], *enc_uri, *p1, *p2; CURLcode curl_status; status_t status; long result = 0; @@ -116,6 +121,8 @@ METHOD(fetcher_t, fetch, status_t, curl_easy_setopt(this->curl, CURLOPT_TIMEOUT, this->timeout); } curl_easy_setopt(this->curl, CURLOPT_CONNECTTIMEOUT, CONNECT_TIMEOUT); + curl_easy_setopt(this->curl, CURLOPT_FOLLOWLOCATION, TRUE); + curl_easy_setopt(this->curl, CURLOPT_MAXREDIRS, this->redir); curl_easy_setopt(this->curl, CURLOPT_WRITEFUNCTION, (void*)curl_cb); curl_easy_setopt(this->curl, CURLOPT_WRITEDATA, &data); if (this->headers) @@ -123,7 +130,17 @@ METHOD(fetcher_t, fetch, status_t, curl_easy_setopt(this->curl, CURLOPT_HTTPHEADER, this->headers); } - DBG2(DBG_LIB, " sending request to '%s'...", uri); + /* if the URI contains a username[:password] prefix then mask it */ + p1 = strstr(uri, "://"); + p2 = strchr(uri, '@'); + if (p1 && p2) + { + DBG2(DBG_LIB, " sending request to '%.*sxxxx%s'...", p1+3-uri, uri, p2); + } + else + { + DBG2(DBG_LIB, " sending request to '%s'...", uri); + } curl_status = curl_easy_perform(this->curl); switch (curl_status) { @@ -250,6 +267,8 @@ curl_fetcher_t *curl_fetcher_create() }, .curl = curl_easy_init(), .cb = fetcher_default_callback, + .redir = lib->settings->get_int(lib->settings, "%s.plugins.curl.redir", + -1, lib->ns), ); if (!this->curl) |