projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
openldap: initialize StartTLS option to it's default value
[collectd.git]
/
src
/
openldap.c
diff --git
a/src/openldap.c
b/src/openldap.c
index
9763a06
..
0c5a0a5
100644
(file)
--- a/
src/openldap.c
+++ b/
src/openldap.c
@@
-47,17
+47,18
@@
typedef struct ldap_s ldap_t; /* }}} */
static void ldap_free (ldap_t *st) /* {{{ */
{
static void ldap_free (ldap_t *st) /* {{{ */
{
- if(st == NULL)
+ if
(st == NULL)
return;
sfree (st->cacert);
sfree (st->host);
sfree (st->name);
sfree (st->url);
return;
sfree (st->cacert);
sfree (st->host);
sfree (st->name);
sfree (st->url);
- if(st->ld)
- ldap_memfree(st->ld);
+ if
(st->ld)
+ ldap_memfree
(st->ld);
sfree (st);
} /* }}} void ldap_free */
sfree (st);
} /* }}} void ldap_free */
+
/* initialize ldap for each host */
static int ldap_init_host (ldap_t *st) /* {{{ */
{
/* initialize ldap for each host */
static int ldap_init_host (ldap_t *st) /* {{{ */
{
@@
-66,9
+67,8
@@
static int ldap_init_host (ldap_t *st) /* {{{ */
rc = ldap_initialize (&ld, st->url);
if (rc != LDAP_SUCCESS)
{
rc = ldap_initialize (&ld, st->url);
if (rc != LDAP_SUCCESS)
{
- char errbuf[1024];
- sstrerror (errno, errbuf, sizeof (errbuf));
- ERROR ("ldap_initialize failed: %s", errbuf);
+ ERROR ("openldap plugin: ldap_initialize failed: %s",
+ ldap_err2string (rc));
st->state = 0;
return (-1);
}
st->state = 0;
return (-1);
}
@@
-77,24
+77,27
@@
static int ldap_init_host (ldap_t *st) /* {{{ */
ldap_set_option (st->ld, LDAP_OPT_PROTOCOL_VERSION, &st->version);
ldap_set_option (st->ld, LDAP_OPT_PROTOCOL_VERSION, &st->version);
- if(st->cacert != NULL)
+ ldap_set_option (st->ld, LDAP_OPT_TIMEOUT,
+ &(const struct timeval){st->timeout, 0});
+
+ if (st->cacert != NULL)
ldap_set_option (st->ld, LDAP_OPT_X_TLS_CACERTFILE, st->cacert);
ldap_set_option (st->ld, LDAP_OPT_X_TLS_CACERTFILE, st->cacert);
- if(st->verifyhost == 0)
+ if
(st->verifyhost == 0)
{
int never = LDAP_OPT_X_TLS_NEVER;
ldap_set_option (st->ld, LDAP_OPT_X_TLS_REQUIRE_CERT, &never);
}
{
int never = LDAP_OPT_X_TLS_NEVER;
ldap_set_option (st->ld, LDAP_OPT_X_TLS_REQUIRE_CERT, &never);
}
- if(st->starttls != 0)
+ if
(st->starttls != 0)
{
{
- rc = ldap_start_tls_s(ld, NULL, NULL);
+ rc = ldap_start_tls_s
(ld, NULL, NULL);
if (rc != LDAP_SUCCESS)
{
ERROR ("openldap plugin: Failed to start tls on %s: %s",
st->url, ldap_err2string (rc));
st->state = 0;
if (rc != LDAP_SUCCESS)
{
ERROR ("openldap plugin: Failed to start tls on %s: %s",
st->url, ldap_err2string (rc));
st->state = 0;
- ldap_unbind_ext_s(st->ld, NULL, NULL);
+ ldap_unbind_ext_s
(st->ld, NULL, NULL);
return (-1);
}
}
return (-1);
}
}
@@
-103,13
+106,13
@@
static int ldap_init_host (ldap_t *st) /* {{{ */
cred.bv_val = "";
cred.bv_len = 0;
cred.bv_val = "";
cred.bv_len = 0;
- rc = ldap_sasl_bind_s(st->ld, NULL, NULL, &cred, NULL, NULL, NULL);
+ rc = ldap_sasl_bind_s
(st->ld, NULL, NULL, &cred, NULL, NULL, NULL);
if (rc != LDAP_SUCCESS)
{
ERROR ("openldap plugin: Failed to bind to %s: %s",
st->url, ldap_err2string (rc));
st->state = 0;
if (rc != LDAP_SUCCESS)
{
ERROR ("openldap plugin: Failed to bind to %s: %s",
st->url, ldap_err2string (rc));
st->state = 0;
- ldap_unbind_ext_s(st->ld, NULL, NULL);
+ ldap_unbind_ext_s
(st->ld, NULL, NULL);
return (-1);
}
else
return (-1);
}
else
@@
-624,6
+627,8
@@
static int ldap_config_add (oconfig_item_t *ci) /* {{{ */
return (status);
}
return (status);
}
+ st->starttls = 0;
+ st->timeout = -1;
st->verifyhost = 1;
st->version = LDAP_VERSION3;
st->verifyhost = 1;
st->version = LDAP_VERSION3;
@@
-669,7
+674,7
@@
static int ldap_config_add (oconfig_item_t *ci) /* {{{ */
LDAPURLDesc *ludpp;
int rc;
LDAPURLDesc *ludpp;
int rc;
- if ((rc = ldap_url_parse
(
st->url, &ludpp)) != 0)
+ if ((rc = ldap_url_parse
(
st->url, &ludpp)) != 0)
{
ERROR ("openldap plugin: Instance `%s': "
"Invalid URL: `%s'",
{
ERROR ("openldap plugin: Instance `%s': "
"Invalid URL: `%s'",
@@
-681,7
+686,7
@@
static int ldap_config_add (oconfig_item_t *ci) /* {{{ */
st->host = strdup (ludpp->lud_host);
}
st->host = strdup (ludpp->lud_host);
}
- ldap_free_urldesc(ludpp);
+ ldap_free_urldesc
(ludpp);
}
if (status == 0)
}
if (status == 0)
@@
-743,9
+748,8
@@
static int ldap_init (void) /* {{{ */
/* Initialize LDAP library while still single-threaded as recommended in
* ldap_initialize(3) */
int debug_level;
/* Initialize LDAP library while still single-threaded as recommended in
* ldap_initialize(3) */
int debug_level;
- ldap_get_option(NULL, LDAP_OPT_DEBUG_LEVEL, &debug_level);
+ ldap_get_option
(NULL, LDAP_OPT_DEBUG_LEVEL, &debug_level);
return (0);
return (0);
-
} /* }}} int ldap_init */
void module_register (void) /* {{{ */
} /* }}} int ldap_init */
void module_register (void) /* {{{ */