X-Git-Url: https://git.octo.it/?p=rrdtool.git;a=blobdiff_plain;f=src%2Frrd_daemon.c;h=372adee9deea8e24f41160b794fbb34370fcd6b3;hp=d4cfa940e112bf2c6dc638287cc6294736385129;hb=4a15d03375160bbd7df66a4d754c37a206d60522;hpb=583f6f5af38d7dc1892ef627713abca25e303cd2 diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c index d4cfa94..372adee 100644 --- a/src/rrd_daemon.c +++ b/src/rrd_daemon.c @@ -141,6 +141,8 @@ struct listen_socket_s ssize_t wbuf_len; uint32_t permissions; + + gid_t socket_group; }; typedef struct listen_socket_s listen_socket_t; @@ -221,9 +223,6 @@ static uid_t daemon_uid; static listen_socket_t *listen_fds = NULL; static size_t listen_fds_num = 0; -static gboolean set_socket_group = FALSE; -static gid_t socket_group; - enum { RUNNING, /* normal operation */ FLUSHING, /* flushing remaining values */ @@ -2331,9 +2330,9 @@ static int open_listen_socket_unix (const listen_socket_t *sock) /* {{{ */ } /* tweak the sockets group ownership */ - if (set_socket_group) + if (sock->socket_group != (gid_t)-1) { - if ( (chown(path, getuid(), socket_group) != 0) || + if ( (chown(path, getuid(), sock->socket_group) != 0) || (chmod(path, (S_IRUSR|S_IWUSR|S_IXUSR | S_IRGRP|S_IWGRP)) != 0) ) { fprintf(stderr, "rrdcached: failed to set socket group permissions (%s)\n", strerror(errno)); @@ -2760,6 +2759,8 @@ static int read_options (int argc, char **argv) /* {{{ */ char **permissions = NULL; size_t permissions_len = 0; + gid_t socket_group = (gid_t)-1; + while ((option = getopt(argc, argv, "gl:s:P:f:w:z:t:Bb:p:Fj:h?")) != -1) { switch (option) @@ -2816,6 +2817,8 @@ static int read_options (int argc, char **argv) /* {{{ */ } /* }}} Done adding permissions. */ + new->socket_group = socket_group; + if (!rrd_add_ptr((void ***)&config_listen_address_list, &config_listen_address_list_len, new)) { @@ -2845,7 +2848,6 @@ static int read_options (int argc, char **argv) /* {{{ */ if (grp) { socket_group = grp->gr_gid; - set_socket_group = TRUE; } else {