From: Florian Forster Date: Fri, 29 Sep 2017 11:08:25 +0000 (+0200) Subject: Merge branch 'collectd-5.7' X-Git-Tag: collectd-5.8.0~63 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4eca75de34e9c3d7f2391b9c7a5951a27a713804;p=collectd.git Merge branch 'collectd-5.7' --- 4eca75de34e9c3d7f2391b9c7a5951a27a713804 diff --cc src/exec.c index 22da3160,246584b7..a9f7be5c --- a/src/exec.c +++ b/src/exec.c @@@ -368,11 -369,17 +368,17 @@@ static int fork_child(program_list_t *p struct passwd *sp_ptr; struct passwd sp; - char nambuf[4096]; if (pl->pid != 0) - return (-1); + 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,8 -412,15 +411,15 @@@ 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 (0 != status) { + if (status != 0) { ERROR("exec plugin: Failed to get group information " "for group ``%s'': %s", pl->group, sstrerror(status, errbuf, sizeof(errbuf)));