summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bd119c6)
raw | patch | inline | side by side (parent: bd119c6)
author | Sebastian Harl <sh@tokkee.org> | |
Thu, 30 Nov 2006 11:02:10 +0000 (12:02 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sat, 2 Dec 2006 17:02:43 +0000 (18:02 +0100) |
Set the owner and mode to COLLECTD_GRP_NAME (defaulting to "collectd") and 0770
respectively. A couple of different daemons running as different users might
want to connect to it.
Signed-off-by: Sebastian Harl <sh@tokkee.org>
respectively. A couple of different daemons running as different users might
want to connect to it.
Signed-off-by: Sebastian Harl <sh@tokkee.org>
configure.in | patch | blob | history | |
src/collectd.h | patch | blob | history | |
src/email.c | patch | blob | history |
diff --git a/configure.in b/configure.in
index ca10e21781ef000a2ba4396778aa2b35c17d714e..823845a1518790a28a2615982b8053d035ae4d34 100644 (file)
--- a/configure.in
+++ b/configure.in
#endif
])
AC_CHECK_HEADERS(sys/un.h)
+AC_CHECK_HEADERS(grp.h)
# For debugging interface (variable number of arguments)
AC_CHECK_HEADERS(stdarg.h)
diff --git a/src/collectd.h b/src/collectd.h
index 4d75db48108e7ce22a2e5db828a56d0adcd7595d..d8f74f9549a67753e155299a5aec15bc3f4ee3c4 100644 (file)
--- a/src/collectd.h
+++ b/src/collectd.h
#define MODE_LOCAL 0x04
#define MODE_LOG 0x08
+#ifndef COLLECTD_GRP_NAME
+# define COLLECTD_GRP_NAME "collectd"
+#endif
+
#ifndef COLLECTD_STEP
# define COLLECTD_STEP "10"
#endif
diff --git a/src/email.c b/src/email.c
index 5f612cd7eab121c92eb5a1b4cb883959788e1f5b..27370aee683bfb44a2f9d33e6674a79e7c772294 100644 (file)
--- a/src/email.c
+++ b/src/email.c
# include <sys/un.h>
#endif /* HAVE_LINUX_UN_H | HAVE_SYS_UN_H */
+#if HAVE_GRP_H
+# include <grp.h>
+#endif /* HAVE_GRP_H */
+
#define MODULE_NAME "email"
/* 256 bytes ought to be enough for anybody ;-) */
pthread_exit ((void *)1);
}
+ 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));
+ }
+
{ /* initialize queue of available threads */
int i = 0;