projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'collectd-5.7'
[collectd.git]
/
src
/
openldap.c
diff --git
a/src/openldap.c
b/src/openldap.c
index
c060bdc
..
7aa8c39
100644
(file)
--- a/
src/openldap.c
+++ b/
src/openldap.c
@@
-85,7
+85,7
@@
static int cldap_init_host(cldap_t *st) /* {{{ */
if (st->state && st->ld) {
DEBUG("openldap plugin: Already connected to %s", st->url);
if (st->state && st->ld) {
DEBUG("openldap plugin: Already connected to %s", st->url);
- return
(0)
;
+ return
0
;
}
rc = ldap_initialize(&ld, st->url);
}
rc = ldap_initialize(&ld, st->url);
@@
-120,9
+120,14
@@
static int cldap_init_host(cldap_t *st) /* {{{ */
ERROR("openldap plugin: Failed to start tls on %s: %s", st->url,
ldap_err2string(rc));
st->state = 0;
ERROR("openldap plugin: Failed to start tls on %s: %s", st->url,
ldap_err2string(rc));
st->state = 0;
+<<<<<<< HEAD
+ ldap_unbind_ext_s(st->ld, NULL, NULL);
+ return -1;
+=======
if (st->ld != NULL)
ldap_unbind_ext_s(st->ld, NULL, NULL);
return (-1);
if (st->ld != NULL)
ldap_unbind_ext_s(st->ld, NULL, NULL);
return (-1);
+>>>>>>> collectd-5.7
}
}
}
}
@@
-141,13
+146,18
@@
static int cldap_init_host(cldap_t *st) /* {{{ */
ERROR("openldap plugin: Failed to bind to %s: %s", st->url,
ldap_err2string(rc));
st->state = 0;
ERROR("openldap plugin: Failed to bind to %s: %s", st->url,
ldap_err2string(rc));
st->state = 0;
+<<<<<<< HEAD
+ ldap_unbind_ext_s(st->ld, NULL, NULL);
+ return -1;
+=======
if (st->ld != NULL)
ldap_unbind_ext_s(st->ld, NULL, NULL);
return (-1);
if (st->ld != NULL)
ldap_unbind_ext_s(st->ld, NULL, NULL);
return (-1);
+>>>>>>> collectd-5.7
} else {
DEBUG("openldap plugin: Successfully connected to %s", st->url);
st->state = 1;
} else {
DEBUG("openldap plugin: Successfully connected to %s", st->url);
st->state = 1;
- return
(0)
;
+ return
0
;
}
} /* }}} static cldap_init_host */
}
} /* }}} static cldap_init_host */
@@
-159,10
+169,7
@@
static void cldap_submit_value(const char *type,
vl.values = &value;
vl.values_len = 1;
vl.values = &value;
vl.values_len = 1;
- if ((st->host == NULL) || (strcmp("", st->host) == 0) ||
- (strcmp("localhost", st->host) == 0))
- sstrncpy(vl.host, hostname_g, sizeof(vl.host));
- else
+ if ((st->host != NULL) && (strcmp("localhost", st->host) != 0))
sstrncpy(vl.host, st->host, sizeof(vl.host));
sstrncpy(vl.plugin, "openldap", sizeof(vl.plugin));
sstrncpy(vl.host, st->host, sizeof(vl.host));
sstrncpy(vl.plugin, "openldap", sizeof(vl.plugin));
@@
-179,17
+186,13
@@
static void cldap_submit_value(const char *type,
static void cldap_submit_derive(const char *type,
const char *type_instance, /* {{{ */
derive_t d, cldap_t *st) {
static void cldap_submit_derive(const char *type,
const char *type_instance, /* {{{ */
derive_t d, cldap_t *st) {
- value_t v;
- v.derive = d;
- cldap_submit_value(type, type_instance, v, st);
+ cldap_submit_value(type, type_instance, (value_t){.derive = d}, st);
} /* }}} void cldap_submit_derive */
static void cldap_submit_gauge(const char *type,
const char *type_instance, /* {{{ */
gauge_t g, cldap_t *st) {
} /* }}} void cldap_submit_derive */
static void cldap_submit_gauge(const char *type,
const char *type_instance, /* {{{ */
gauge_t g, cldap_t *st) {
- value_t v;
- v.gauge = g;
- cldap_submit_value(type, type_instance, v, st);
+ cldap_submit_value(type, type_instance, (value_t){.gauge = g}, st);
} /* }}} void cldap_submit_gauge */
static int cldap_read_host(user_data_t *ud) /* {{{ */
} /* }}} void cldap_submit_gauge */
static int cldap_read_host(user_data_t *ud) /* {{{ */
@@
-207,14
+210,14
@@
static int cldap_read_host(user_data_t *ud) /* {{{ */
if ((ud == NULL) || (ud->data == NULL)) {
ERROR("openldap plugin: cldap_read_host: Invalid user data.");
if ((ud == NULL) || (ud->data == NULL)) {
ERROR("openldap plugin: cldap_read_host: Invalid user data.");
- return
(-1)
;
+ return
-1
;
}
st = (cldap_t *)ud->data;
status = cldap_init_host(st);
if (status != 0)
}
st = (cldap_t *)ud->data;
status = cldap_init_host(st);
if (status != 0)
- return
(-1)
;
+ return
-1
;
rc = ldap_search_ext_s(st->ld, "cn=Monitor", LDAP_SCOPE_SUBTREE,
"(|(!(cn=* *))(cn=Database*))", attrs, 0, NULL, NULL,
rc = ldap_search_ext_s(st->ld, "cn=Monitor", LDAP_SCOPE_SUBTREE,
"(|(!(cn=* *))(cn=Database*))", attrs, 0, NULL, NULL,
@@
-224,9
+227,14
@@
static int cldap_read_host(user_data_t *ud) /* {{{ */
ERROR("openldap plugin: Failed to execute search: %s", ldap_err2string(rc));
ldap_msgfree(result);
st->state = 0;
ERROR("openldap plugin: Failed to execute search: %s", ldap_err2string(rc));
ldap_msgfree(result);
st->state = 0;
+<<<<<<< HEAD
+ ldap_unbind_ext_s(st->ld, NULL, NULL);
+ return -1;
+=======
if (st->ld != NULL)
ldap_unbind_ext_s(st->ld, NULL, NULL);
return (-1);
if (st->ld != NULL)
ldap_unbind_ext_s(st->ld, NULL, NULL);
return (-1);
+>>>>>>> collectd-5.7
}
for (LDAPMessage *e = ldap_first_entry(st->ld, result); e != NULL;
}
for (LDAPMessage *e = ldap_first_entry(st->ld, result); e != NULL;
@@
-383,7
+391,7
@@
static int cldap_read_host(user_data_t *ud) /* {{{ */
}
ldap_msgfree(result);
}
ldap_msgfree(result);
- return
(0)
;
+ return
0
;
} /* }}} int cldap_read_host */
/* Configuration handling functions {{{
} /* }}} int cldap_read_host */
/* Configuration handling functions {{{
@@
-404,17
+412,17
@@
static int cldap_config_add(oconfig_item_t *ci) /* {{{ */
st = calloc(1, sizeof(*st));
if (st == NULL) {
ERROR("openldap plugin: calloc failed.");
st = calloc(1, sizeof(*st));
if (st == NULL) {
ERROR("openldap plugin: calloc failed.");
- return
(-1)
;
+ return
-1
;
}
status = cf_util_get_string(ci, &st->name);
if (status != 0) {
sfree(st);
}
status = cf_util_get_string(ci, &st->name);
if (status != 0) {
sfree(st);
- return
(status)
;
+ return
status
;
}
st->starttls = 0;
}
st->starttls = 0;
- st->timeout = (long)
(CDTIME_T_TO_MS(plugin_get_interval()) / 1000
);
+ st->timeout = (long)
CDTIME_T_TO_TIME_T(plugin_get_interval()
);
st->verifyhost = 1;
st->version = LDAP_VERSION3;
st->verifyhost = 1;
st->version = LDAP_VERSION3;
@@
-491,22
+499,21
@@
static int cldap_config_add(oconfig_item_t *ci) /* {{{ */
(st->host != NULL) ? st->host : hostname_g,
(st->name != NULL) ? st->name : "default");
(st->host != NULL) ? st->host : hostname_g,
(st->name != NULL) ? st->name : "default");
- user_data_t ud = {.data = st};
-
status = plugin_register_complex_read(/* group = */ NULL,
/* name = */ callback_name,
/* callback = */ cldap_read_host,
status = plugin_register_complex_read(/* group = */ NULL,
/* name = */ callback_name,
/* callback = */ cldap_read_host,
- /* interval = */ 0,
- /* user_data = */ &ud);
+ /* interval = */ 0, &(user_data_t){
+ .data = st,
+ });
}
}
if (status != 0) {
cldap_free(st);
}
}
if (status != 0) {
cldap_free(st);
- return
(-1)
;
+ return
-1
;
}
}
- return
(0)
;
+ return
0
;
} /* }}} int cldap_config_add */
static int cldap_config(oconfig_item_t *ci) /* {{{ */
} /* }}} int cldap_config_add */
static int cldap_config(oconfig_item_t *ci) /* {{{ */
@@
-526,7
+533,7
@@
static int cldap_config(oconfig_item_t *ci) /* {{{ */
child->key);
} /* for (ci->children) */
child->key);
} /* for (ci->children) */
- return
(status)
;
+ return
status
;
} /* }}} int cldap_config */
/* }}} End of configuration handling functions */
} /* }}} int cldap_config */
/* }}} End of configuration handling functions */
@@
-537,7
+544,7
@@
static int cldap_init(void) /* {{{ */
* ldap_initialize(3) */
int debug_level;
ldap_get_option(NULL, LDAP_OPT_DEBUG_LEVEL, &debug_level);
* ldap_initialize(3) */
int debug_level;
ldap_get_option(NULL, LDAP_OPT_DEBUG_LEVEL, &debug_level);
- return
(0)
;
+ return
0
;
} /* }}} int cldap_init */
static int cldap_shutdown(void) /* {{{ */
} /* }}} int cldap_init */
static int cldap_shutdown(void) /* {{{ */
@@
-548,7
+555,7
@@
static int cldap_shutdown(void) /* {{{ */
sfree(databases);
databases_num = 0;
sfree(databases);
databases_num = 0;
- return
(0)
;
+ return
0
;
} /* }}} int cldap_shutdown */
void module_register(void) /* {{{ */
} /* }}} int cldap_shutdown */
void module_register(void) /* {{{ */