summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 22fe7d9)
raw | patch | inline | side by side (parent: 22fe7d9)
author | Sebastian Harl <sh@tokkee.org> | |
Tue, 12 Jun 2007 16:48:52 +0000 (18:48 +0200) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Tue, 12 Jun 2007 22:01:41 +0000 (00:01 +0200) |
In addition make it configurable using the "SocketFile" config option just
as for the unixsock plugin.
Signed-off-by: Sebastian Harl <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
as for the unixsock plugin.
Signed-off-by: Sebastian Harl <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
src/collectd.conf.pod | patch | blob | history | |
src/email.c | patch | blob | history |
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index f7c10ad6071eaf9701d85ca4ff3e4a33ab0dc4e1..d6de96ee9242b2a34cd43203bf9c55cb759fa9e9 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
=over 4
+=item B<SocketFile> I<Path>
+
+Sets the socket-file which is to be created.
+
=item B<SocketGroup> I<Group>
If running as root change the group of the UNIX-socket after it has been
diff --git a/src/email.c b/src/email.c
index 594ef962d97c6441a6c53f17381142b15f65ea4b..f5a544ac4ea0a2745eaa2b7648112859c904c67a 100644 (file)
--- a/src/email.c
+++ b/src/email.c
/* 256 bytes ought to be enough for anybody ;-) */
#define BUFSIZE 256
-#ifndef COLLECTD_SOCKET_PREFIX
-# define COLLECTD_SOCKET_PREFIX "/tmp/.collectd-"
-#endif /* COLLECTD_SOCKET_PREFIX */
-
-#define SOCK_PATH COLLECTD_SOCKET_PREFIX"email"
+#define SOCK_PATH LOCALSTATEDIR"/run/"PACKAGE_NAME"-email"
#define MAX_CONNS 5
#define MAX_CONNS_LIMIT 16384
/* valid configuration file keys */
static const char *config_keys[] =
{
+ "SocketFile",
"SocketGroup",
"SocketPerms",
"MaxConns"
static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
/* socket configuration */
+static char *sock_file = SOCK_PATH;
static char *sock_group = COLLECTD_GRP_NAME;
static int sock_perms = S_IRWXU | S_IRWXG;
static int max_conns = MAX_CONNS;
*/
static int email_config (const char *key, const char *value)
{
- if (0 == strcasecmp (key, "SocketGroup")) {
+ if (0 == strcasecmp (key, "SocketFile")) {
+ sock_file = sstrdup (value);
+ }
+ else if (0 == strcasecmp (key, "SocketGroup")) {
sock_group = sstrdup (value);
}
else if (0 == strcasecmp (key, "SocketPerms")) {
addr.sun_family = AF_UNIX;
- strncpy (addr.sun_path, SOCK_PATH, (size_t)(UNIX_PATH_MAX - 1));
+ strncpy (addr.sun_path, sock_file, (size_t)(UNIX_PATH_MAX - 1));
addr.sun_path[UNIX_PATH_MAX - 1] = '\0';
unlink (addr.sun_path);
}
else
{
- status = chown (SOCK_PATH, (uid_t) -1, grp->gr_gid);
+ status = chown (sock_file, (uid_t) -1, grp->gr_gid);
if (status != 0)
{
char errbuf[1024];
log_warn ("chown (%s, -1, %i) failed: %s",
- SOCK_PATH, (int) grp->gr_gid,
+ sock_file, (int) grp->gr_gid,
sstrerror (errno, errbuf, sizeof (errbuf)));
}
}
}
errno = 0;
- if (0 != chmod (SOCK_PATH, sock_perms)) {
+ if (0 != chmod (sock_file, sock_perms)) {
char errbuf[1024];
log_warn ("chmod() failed: %s",
sstrerror (errno, errbuf, sizeof (errbuf)));
pthread_mutex_unlock (&conns_mutex);
- unlink (SOCK_PATH);
+ unlink (sock_file);
errno = 0;
return (0);