author | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Fri, 30 Jun 2017 14:20:16 +0000 (16:20 +0200) | ||
committer | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Fri, 30 Jun 2017 14:20:16 +0000 (16:20 +0200) |
Conflicts:
src/openldap.c
src/openldap.c
1 | 2 | |||
---|---|---|---|---|
src/email.c | patch | | diff1 | | diff2 | | blob | history |
src/exec.c | patch | | diff1 | | diff2 | | blob | history |
src/openldap.c | patch | | diff1 | | diff2 | | blob | history |
src/unixsock.c | patch | | diff1 | | diff2 | | blob | history |
diff --combined src/email.c
index 871ddf8b997b93cbc6484b904cbfd18de7f91372,50f766269368059f4047b3821a5f438407a6768f..52e41a70b9b2bfc76992896f434d845dc84de9f0
--- 1/src/email.c
--- 2/src/email.c
+++ b/src/email.c
} /* while (1) */
pthread_exit((void *)0);
- return ((void *)0);
+ return (void *)0;
} /* static void *collect (void *) */
static void *open_connection(void __attribute__((unused)) * arg) {
{
struct group sg;
struct group *grp;
- char grbuf[2048];
+ char grbuf[4096];
int status;
grp = NULL;
if (status != 0) {
char errbuf[1024];
log_warn("getgrnam_r (%s) failed: %s", group,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ sstrerror(status, errbuf, sizeof(errbuf)));
} else if (grp == NULL) {
log_warn("No such group: `%s'", group);
} else {
}
pthread_exit((void *)0);
- return ((void *)0);
+ return (void *)0;
} /* static void *open_connection (void *) */
static int email_init(void) {
disabled = 1;
log_err("plugin_thread_create() failed: %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
- return (-1);
+ return -1;
}
- return (0);
+ return 0;
} /* int email_init */
static void type_list_free(type_list_t *t) {
sfree(sock_file);
sfree(sock_group);
- return (0);
+ return 0;
} /* static void email_shutdown (void) */
static void email_submit(const char *type, const char *type_instance,
int score_count_old;
if (disabled)
- return (-1);
+ return -1;
/* email count */
pthread_mutex_lock(&count_mutex);
for (type_t *ptr = list_check_copy.head; NULL != ptr; ptr = ptr->next)
email_submit("spam_check", ptr->name, ptr->value);
- return (0);
+ return 0;
} /* int email_read */
void module_register(void) {
plugin_register_read("email", email_read);
plugin_register_shutdown("email", email_shutdown);
} /* void module_register */
-
-/* vim: set sw=4 ts=4 tw=78 noexpandtab : */
diff --combined src/exec.c
index f10b816b2c9dd7d19bc6d2b35f6815f1727f2a5d,28380ac33677788acd1ffc2b4058ba08a9661e53..80515d93d3ec4861d3cd69de7260bbd4e60ba8d3
--- 1/src/exec.c
--- 2/src/exec.c
+++ b/src/exec.c
if (ci->children_num != 0) {
WARNING("exec plugin: The config option `%s' may not be a block.", ci->key);
- return (-1);
+ return -1;
}
if (ci->values_num < 2) {
WARNING("exec plugin: The config option `%s' needs at least two "
"arguments.",
ci->key);
- return (-1);
+ return -1;
}
if ((ci->values[0].type != OCONFIG_TYPE_STRING) ||
(ci->values[1].type != OCONFIG_TYPE_STRING)) {
WARNING("exec plugin: The first two arguments to the `%s' option must "
"be string arguments.",
ci->key);
- return (-1);
+ return -1;
}
pl = calloc(1, sizeof(*pl));
if (pl == NULL) {
ERROR("exec plugin: calloc failed.");
- return (-1);
+ return -1;
}
if (strcasecmp("NotificationExec", ci->key) == 0)
if (pl->user == NULL) {
ERROR("exec plugin: strdup failed.");
sfree(pl);
- return (-1);
+ return -1;
}
pl->group = strchr(pl->user, ':');
ERROR("exec plugin: strdup failed.");
sfree(pl->user);
sfree(pl);
- return (-1);
+ return -1;
}
pl->argv = calloc(ci->values_num, sizeof(*pl->argv));
sfree(pl->exec);
sfree(pl->user);
sfree(pl);
- return (-1);
+ return -1;
}
{
sfree(pl->exec);
sfree(pl->user);
sfree(pl);
- return (-1);
+ return -1;
}
for (i = 1; i < (ci->values_num - 1); i++) {
sfree(pl->exec);
sfree(pl->user);
sfree(pl);
- return (-1);
+ return -1;
}
for (i = 0; pl->argv[i] != NULL; i++) {
pl->next = pl_head;
pl_head = pl;
- return (0);
+ return 0;
} /* int exec_config_exec }}} */
static int exec_config(oconfig_item_t *ci) /* {{{ */
}
} /* for (i) */
- return (0);
+ return 0;
} /* int exec_config }}} */
static void set_environment(void) /* {{{ */
if (status != 0) {
ERROR("exec plugin: pipe failed: %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
- return (-1);
+ return -1;
}
return 0;
struct passwd *sp_ptr;
struct passwd sp;
- char nambuf[2048];
+ char nambuf[4096];
if (pl->pid != 0)
- return (-1);
+ return -1;
if ((create_pipe(fd_pipe_in) == -1) || (create_pipe(fd_pipe_out) == -1) ||
(create_pipe(fd_pipe_err) == -1))
status = getpwnam_r(pl->user, &sp, nambuf, sizeof(nambuf), &sp_ptr);
if (status != 0) {
ERROR("exec plugin: Failed to get user information for user ``%s'': %s",
- pl->user, sstrerror(errno, errbuf, sizeof(errbuf)));
+ pl->user, sstrerror(status, errbuf, sizeof(errbuf)));
goto failed;
}
if (0 != status) {
ERROR("exec plugin: Failed to get group information "
"for group ``%s'': %s",
- pl->group, sstrerror(errno, errbuf, sizeof(errbuf)));
+ pl->group, sstrerror(status, errbuf, sizeof(errbuf)));
goto failed;
}
if (NULL == gr_ptr) {
else
close(fd_pipe_err[0]);
- return (pid);
+ return pid;
failed:
close_pipe(fd_pipe_in);
close_pipe(fd_pipe_out);
close_pipe(fd_pipe_err);
- return (-1);
+ return -1;
} /* int fork_child }}} */
static int parse_line(char *buffer) /* {{{ */
{
if (strncasecmp("PUTVAL", buffer, strlen("PUTVAL")) == 0)
- return (cmd_handle_putval(stdout, buffer));
+ return cmd_handle_putval(stdout, buffer);
else if (strncasecmp("PUTNOTIF", buffer, strlen("PUTNOTIF")) == 0)
- return (handle_putnotif(stdout, buffer));
+ return handle_putnotif(stdout, buffer);
else {
ERROR("exec plugin: Unable to parse command, ignoring line: \"%s\"",
buffer);
- return (-1);
+ return -1;
}
} /* int parse_line }}} */
close(fd_err);
pthread_exit((void *)0);
- return (NULL);
+ return NULL;
} /* void *exec_read_one }}} */
static void *exec_notification_one(void *arg) /* {{{ */
n->meta = NULL;
sfree(arg);
pthread_exit((void *)0);
- return (NULL);
+ return NULL;
} /* void *exec_notification_one }}} */
static int exec_init(void) /* {{{ */
}
#endif
- return (0);
+ return 0;
} /* int exec_init }}} */
static int exec_read(void) /* {{{ */
pthread_attr_destroy(&attr);
} /* for (pl) */
- return (0);
+ return 0;
} /* int exec_read }}} */
static int exec_notification(const notification_t *n, /* {{{ */
pthread_attr_destroy(&attr);
} /* for (pl) */
- return (0);
+ return 0;
} /* }}} int exec_notification */
static int exec_shutdown(void) /* {{{ */
} /* while (pl) */
pl_head = NULL;
- return (0);
+ return 0;
} /* int exec_shutdown }}} */
void module_register(void) {
/* user_data = */ NULL);
plugin_register_shutdown("exec", exec_shutdown);
} /* void module_register */
-
-/*
- * vim:shiftwidth=2:softtabstop=2:tabstop=8:fdm=marker
- */
diff --combined src/openldap.c
index 1156169c41e4c01d66ec23bbbf28e5e787335dc5,50757db8ac513017c954a690cd227b0e2291ea02..7aa8c39278ec009166d4b605ee33084b79e6f30e
--- 1/src/openldap.c
--- 2/src/openldap.c
+++ b/src/openldap.c
if (st->state && st->ld) {
DEBUG("openldap plugin: Already connected to %s", st->url);
- return (0);
+ return 0;
}
rc = ldap_initialize(&ld, st->url);
if (rc != LDAP_SUCCESS) {
ERROR("openldap plugin: ldap_initialize failed: %s", ldap_err2string(rc));
st->state = 0;
- ldap_unbind_ext_s(ld, NULL, NULL);
- return -1;
+ if (ld != NULL)
+ ldap_unbind_ext_s(ld, NULL, NULL);
+ return (-1);
}
st->ld = ld;
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);
++>>>>>>> collectd-5.7
}
}
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);
++>>>>>>> collectd-5.7
} else {
DEBUG("openldap plugin: Successfully connected to %s", st->url);
st->state = 1;
- return (0);
+ return 0;
}
} /* }}} static cldap_init_host */
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)
- return (-1);
+ return -1;
rc = ldap_search_ext_s(st->ld, "cn=Monitor", LDAP_SCOPE_SUBTREE,
"(|(!(cn=* *))(cn=Database*))", attrs, 0, NULL, NULL,
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);
++>>>>>>> collectd-5.7
}
for (LDAPMessage *e = ldap_first_entry(st->ld, result); e != NULL;
}
ldap_msgfree(result);
- return (0);
+ return 0;
} /* }}} int cldap_read_host */
/* Configuration handling functions {{{
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);
- return (status);
+ return status;
}
st->starttls = 0;
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) /* {{{ */
child->key);
} /* for (ci->children) */
- return (status);
+ return status;
} /* }}} int cldap_config */
/* }}} End of configuration handling functions */
* 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) /* {{{ */
sfree(databases);
databases_num = 0;
- return (0);
+ return 0;
} /* }}} int cldap_shutdown */
void module_register(void) /* {{{ */
diff --combined src/unixsock.c
index 8ccde80b9342e1c4aac0f6af4d24a1e6dbc1db34,32fa9bc7ddbb003715089a891e5fd522c7e70ed8..00b930e660f0c126d9db15e0658e8c4c50f14bb3
--- 1/src/unixsock.c
--- 2/src/unixsock.c
+++ b/src/unixsock.c
char errbuf[1024];
ERROR("unixsock plugin: socket failed: %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
- return (-1);
+ return -1;
}
sa.sun_family = AF_UNIX;
ERROR("unixsock plugin: bind failed: %s", errbuf);
close(sock_fd);
sock_fd = -1;
- return (-1);
+ return -1;
}
status = chmod(sa.sun_path, sock_perms);
sstrerror(errno, errbuf, sizeof(errbuf)));
close(sock_fd);
sock_fd = -1;
- return (-1);
+ return -1;
}
status = listen(sock_fd, 8);
sstrerror(errno, errbuf, sizeof(errbuf)));
close(sock_fd);
sock_fd = -1;
- return (-1);
+ return -1;
}
do {
const char *grpname;
struct group *g;
struct group sg;
- char grbuf[2048];
+ char grbuf[4096];
grpname = (sock_group != NULL) ? sock_group : COLLECTD_GRP_NAME;
g = NULL;
if (status != 0) {
char errbuf[1024];
WARNING("unixsock plugin: getgrnam_r (%s) failed: %s", grpname,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ sstrerror(status, errbuf, sizeof(errbuf)));
break;
}
if (g == NULL) {
}
} while (0);
- return (0);
+ return 0;
} /* int us_open_socket */
static void *us_handle_client(void *arg) {
close(fdin);
close(fdout);
pthread_exit((void *)1);
- return ((void *)1);
+ return (void *)1;
}
fhout = fdopen(fdout, "w");
fclose(fhin); /* this closes fdin as well */
close(fdout);
pthread_exit((void *)1);
- return ((void *)1);
+ return (void *)1;
}
/* change output buffer to line buffered mode */
fclose(fhin);
fclose(fhout);
pthread_exit((void *)1);
- return ((void *)0);
+ return (void *)0;
}
while (42) {
fclose(fhin);
fclose(fhout);
pthread_exit((void *)1);
- return ((void *)1);
+ return (void *)1;
}
if (strcasecmp(fields[0], "getval") == 0) {
fclose(fhout);
pthread_exit((void *)0);
- return ((void *)0);
+ return (void *)0;
} /* void *us_handle_client */
static void *us_server_thread(void __attribute__((unused)) * arg) {
sstrerror(errno, errbuf, sizeof(errbuf)));
}
- return ((void *)0);
+ return (void *)0;
} /* void *us_server_thread */
static int us_config(const char *key, const char *val) {
if (strcasecmp(key, "SocketFile") == 0) {
char *new_sock_file = strdup(val);
if (new_sock_file == NULL)
- return (1);
+ return 1;
sfree(sock_file);
sock_file = new_sock_file;
} else if (strcasecmp(key, "SocketGroup") == 0) {
char *new_sock_group = strdup(val);
if (new_sock_group == NULL)
- return (1);
+ return 1;
sfree(sock_group);
sock_group = new_sock_group;
else
delete_socket = 0;
} else {
- return (-1);
+ return -1;
}
- return (0);
+ return 0;
} /* int us_config */
static int us_init(void) {
/* Initialize only once. */
if (have_init != 0)
- return (0);
+ return 0;
have_init = 1;
loop = 1;
char errbuf[1024];
ERROR("unixsock plugin: pthread_create failed: %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
- return (-1);
+ return -1;
}
- return (0);
+ return 0;
} /* int us_init */
static int us_shutdown(void) {
plugin_unregister_init("unixsock");
plugin_unregister_shutdown("unixsock");
- return (0);
+ return 0;
} /* int us_shutdown */
void module_register(void) {
plugin_register_init("unixsock", us_init);
plugin_register_shutdown("unixsock", us_shutdown);
} /* void module_register (void) */
-
-/* vim: set sw=4 ts=4 sts=4 tw=78 : */