X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fexec.c;h=6be6faec7bcbefa78fb7123686c7498d38fd5167;hp=22da3160be6c6bb7054c80f9533e8089d421910f;hb=1159cb5d383c55a80a0db100b8f7aadcf44740a5;hpb=e746ad785774de37a30302fef65f1c4aaf8698ab diff --git a/src/exec.c b/src/exec.c index 22da3160..6be6faec 100644 --- a/src/exec.c +++ b/src/exec.c @@ -368,11 +368,17 @@ static int fork_child(program_list_t *pl, int *fd_in, int *fd_out, struct passwd *sp_ptr; struct passwd sp; - char nambuf[4096]; if (pl->pid != 0) return -1; + long int nambuf_size = sysconf(_SC_GETPW_R_SIZE_MAX); + if (nambuf_size <= 0) + nambuf_size = sysconf(_SC_PAGESIZE); + if (nambuf_size <= 0) + nambuf_size = 4096; + char nambuf[nambuf_size]; + if ((create_pipe(fd_pipe_in) == -1) || (create_pipe(fd_pipe_out) == -1) || (create_pipe(fd_pipe_err) == -1)) goto failed; @@ -405,7 +411,14 @@ static int fork_child(program_list_t *pl, int *fd_in, int *fd_out, struct group *gr_ptr = NULL; struct group gr; - status = getgrnam_r(pl->group, &gr, nambuf, sizeof(nambuf), &gr_ptr); + long int grbuf_size = sysconf(_SC_GETGR_R_SIZE_MAX); + if (grbuf_size <= 0) + grbuf_size = sysconf(_SC_PAGESIZE); + if (grbuf_size <= 0) + grbuf_size = 4096; + char grbuf[grbuf_size]; + + status = getgrnam_r(pl->group, &gr, grbuf, sizeof(grbuf), &gr_ptr); if (status != 0) { ERROR("exec plugin: Failed to get group information " "for group ``%s'': %s", @@ -786,7 +799,11 @@ static int exec_read(void) /* {{{ */ pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - plugin_thread_create(&t, &attr, exec_read_one, (void *)pl, "exec read"); + int status = + plugin_thread_create(&t, &attr, exec_read_one, (void *)pl, "exec read"); + if (status != 0) { + ERROR("exec plugin: plugin_thread_create failed."); + } pthread_attr_destroy(&attr); } /* for (pl) */ @@ -825,8 +842,11 @@ static int exec_notification(const notification_t *n, /* {{{ */ pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - plugin_thread_create(&t, &attr, exec_notification_one, (void *)pln, - "exec notify"); + int status = plugin_thread_create(&t, &attr, exec_notification_one, + (void *)pln, "exec notify"); + if (status != 0) { + ERROR("exec plugin: plugin_thread_create failed."); + } pthread_attr_destroy(&attr); } /* for (pl) */