summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dd8429c)
raw | patch | inline | side by side (parent: dd8429c)
author | Marc Fournier <marc.fournier@camptocamp.com> | |
Tue, 24 Feb 2015 20:46:53 +0000 (21:46 +0100) | ||
committer | Marc Fournier <marc.fournier@camptocamp.com> | |
Tue, 24 Feb 2015 20:46:53 +0000 (21:46 +0100) |
CURLOPT_USERPWD chokes on colons inside usernames or passwords, so use
CURLOPT_USERNAME and CURLOPT_PASSWORD if curl 7.19.1 or newer is found.
Follow-up to 0af75dc13 for the rest of the plugins based on libcurl.
CURLOPT_USERNAME and CURLOPT_PASSWORD if curl 7.19.1 or newer is found.
Follow-up to 0af75dc13 for the rest of the plugins based on libcurl.
src/apache.c | patch | blob | history | |
src/ascent.c | patch | blob | history | |
src/nginx.c | patch | blob | history | |
src/write_http.c | patch | blob | history |
diff --git a/src/apache.c b/src/apache.c
index 75ef3e1b9e8fdec4822b21653f9e862bea558e0e..1099248a24293485b8af3595793e03dbc1409fa4 100644 (file)
--- a/src/apache.c
+++ b/src/apache.c
/* initialize curl for each host */
static int init_host (apache_t *st) /* {{{ */
{
- static char credentials[1024];
-
assert (st->url != NULL);
/* (Assured by `config_add') */
if (st->user != NULL)
{
+#ifdef HAVE_CURLOPT_USERNAME
+ curl_easy_setopt (st->curl, CURLOPT_USERNAME, st->user);
+ curl_easy_setopt (st->curl, CURLOPT_PASSWORD,
+ (st->pass == NULL) ? "" : st->pass);
+#else
+ static char credentials[1024];
int status;
status = ssnprintf (credentials, sizeof (credentials), "%s:%s",
}
curl_easy_setopt (st->curl, CURLOPT_USERPWD, credentials);
+#endif
}
curl_easy_setopt (st->curl, CURLOPT_URL, st->url);
diff --git a/src/ascent.c b/src/ascent.c
index ca0fac7fb7ad37a8c323bc386c71628f5a35e208..e9d25bd551743885e2257c4751d285af42d6193b 100644 (file)
--- a/src/ascent.c
+++ b/src/ascent.c
static int ascent_init (void) /* {{{ */
{
- static char credentials[1024];
-
if (url == NULL)
{
WARNING ("ascent plugin: ascent_init: No URL configured, "
if (user != NULL)
{
+#ifdef HAVE_CURLOPT_USERNAME
+ curl_easy_setopt (curl, CURLOPT_USERNAME, user);
+ curl_easy_setopt (curl, CURLOPT_PASSWORD, (pass == NULL) ? "" : pass);
+#else
+ static char credentials[1024];
int status;
status = ssnprintf (credentials, sizeof (credentials), "%s:%s",
}
curl_easy_setopt (curl, CURLOPT_USERPWD, credentials);
+#endif
}
curl_easy_setopt (curl, CURLOPT_URL, url);
diff --git a/src/nginx.c b/src/nginx.c
index e8282f23601c7c40516ee6e150e9ac7e8f740c81..b0daa05b31a555732a0f58940d732df84de3b57d 100644 (file)
--- a/src/nginx.c
+++ b/src/nginx.c
static int init (void)
{
- static char credentials[1024];
-
if (curl != NULL)
curl_easy_cleanup (curl);
if (user != NULL)
{
+#ifdef HAVE_CURLOPT_USERNAME
+ curl_easy_setopt (curl, CURLOPT_USERNAME, user);
+ curl_easy_setopt (curl, CURLOPT_PASSWORD, (pass == NULL) ? "" : pass);
+#else
+ static char credentials[1024];
int status = ssnprintf (credentials, sizeof (credentials),
"%s:%s", user, pass == NULL ? "" : pass);
if ((status < 0) || ((size_t) status >= sizeof (credentials)))
}
curl_easy_setopt (curl, CURLOPT_USERPWD, credentials);
+#endif
}
if (url != NULL)
diff --git a/src/write_http.c b/src/write_http.c
index 9d8f30c2a6a2ed2324924d9c74500d8f09e950d8..8d3b85b366079e75232a5ff8dcfd9a586aa39c61 100644 (file)
--- a/src/write_http.c
+++ b/src/write_http.c
if (cb->user != NULL)
{
+#ifdef HAVE_CURLOPT_USERNAME
+ curl_easy_setopt (cb->curl, CURLOPT_USERNAME, cb->user);
+ curl_easy_setopt (cb->curl, CURLOPT_PASSWORD,
+ (cb->pass == NULL) ? "" : cb->pass);
+#else
size_t credentials_size;
credentials_size = strlen (cb->user) + 2;
ssnprintf (cb->credentials, credentials_size, "%s:%s",
cb->user, (cb->pass == NULL) ? "" : cb->pass);
curl_easy_setopt (cb->curl, CURLOPT_USERPWD, cb->credentials);
+#endif
curl_easy_setopt (cb->curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
}