summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 18e6a18)
raw | patch | inline | side by side (parent: 18e6a18)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sat, 10 Mar 2007 09:49:18 +0000 (10:49 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sat, 10 Mar 2007 09:49:18 +0000 (10:49 +0100) |
src/unixsock.c | patch | blob | history |
diff --git a/src/unixsock.c b/src/unixsock.c
index 12ebc0995cf0d2bfe85ca9c56768ca83988f8c92..b4af8b386a67e8b48e23f0bba02cef1d2275d7b7 100644 (file)
--- a/src/unixsock.c
+++ b/src/unixsock.c
do
{
+ char *grpname;
struct group *g;
+ struct group sg;
+ char grbuf[2048];
- errno = 0;
- g = getgrnam ((sock_group != NULL) ? sock_group : COLLECTD_GRP_NAME);
+ grpname = (sock_group != NULL) ? sock_group : COLLECTD_GRP_NAME;
+ g = NULL;
- if (errno != 0)
+ status = getgrnam_r (grpname, &sg, grbuf, sizeof (grbuf), &g);
+ if (status != 0)
{
- syslog (LOG_WARNING, "unixsock plugin: getgrnam (%s) failed: %s",
- (sock_group != NULL) ? sock_group : COLLECTD_GRP_NAME,
- strerror (errno));
+ syslog (LOG_WARNING, "unixsock plugin: getgrnam_r (%s) failed: %s",
+ grpname, strerror (status));
break;
}
-
if (g == NULL)
+ {
+ syslog (LOG_WARNING, "unixsock plugin: No such group: `%s'",
+ grpname);
break;
+ }
if (chown ((sock_file != NULL) ? sock_file : US_DEFAULT_PATH,
(uid_t) -1, g->gr_gid) != 0)