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.
/* initialize curl for each host */
static int init_host (apache_t *st) /* {{{ */
{
/* initialize curl for each host */
static int init_host (apache_t *st) /* {{{ */
{
- static char credentials[1024];
-
assert (st->url != NULL);
/* (Assured by `config_add') */
assert (st->url != NULL);
/* (Assured by `config_add') */
+#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",
int status;
status = ssnprintf (credentials, sizeof (credentials), "%s:%s",
}
curl_easy_setopt (st->curl, CURLOPT_USERPWD, credentials);
}
curl_easy_setopt (st->curl, CURLOPT_USERPWD, credentials);
}
curl_easy_setopt (st->curl, CURLOPT_URL, st->url);
}
curl_easy_setopt (st->curl, CURLOPT_URL, st->url);
static int ascent_init (void) /* {{{ */
{
static int ascent_init (void) /* {{{ */
{
- static char credentials[1024];
-
if (url == NULL)
{
WARNING ("ascent plugin: ascent_init: No URL configured, "
if (url == NULL)
{
WARNING ("ascent plugin: ascent_init: No URL configured, "
+#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",
int status;
status = ssnprintf (credentials, sizeof (credentials), "%s:%s",
}
curl_easy_setopt (curl, CURLOPT_USERPWD, credentials);
}
curl_easy_setopt (curl, CURLOPT_USERPWD, credentials);
}
curl_easy_setopt (curl, CURLOPT_URL, url);
}
curl_easy_setopt (curl, CURLOPT_URL, url);
- static char credentials[1024];
-
if (curl != NULL)
curl_easy_cleanup (curl);
if (curl != NULL)
curl_easy_cleanup (curl);
+#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)))
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);
}
curl_easy_setopt (curl, CURLOPT_USERPWD, credentials);
+#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;
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);
ssnprintf (cb->credentials, credentials_size, "%s:%s",
cb->user, (cb->pass == NULL) ? "" : cb->pass);
curl_easy_setopt (cb->curl, CURLOPT_USERPWD, cb->credentials);
curl_easy_setopt (cb->curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
}
curl_easy_setopt (cb->curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
}