+ if ((uid_t)0 == geteuid ()) {
+ struct group *grp;
+
+ errno = 0;
+ if (NULL != (grp = getgrnam (COLLECTD_GRP_NAME))) {
+ errno = 0;
+ if (0 != chown (SOCK_PATH, (uid_t)-1, grp->gr_gid)) {
+ syslog (LOG_WARNING, "chown() failed: %s", strerror (errno));
+ }
+ }
+ else {
+ syslog (LOG_WARNING, "getgrnam() failed: %s", strerror (errno));
+ }
+ }
+ else {
+ syslog (LOG_WARNING, "not running as root");
+ }
+
+ errno = 0;
+ if (0 != chmod (SOCK_PATH, S_IRWXU | S_IRWXG)) {
+ syslog (LOG_WARNING, "chmod() failed: %s", strerror (errno));
+ }
+