From: Peter A. Bigot Date: Tue, 20 May 2014 15:59:07 +0000 (-0500) Subject: rrdcached: support new option to listen on all addresses at default port X-Git-Tag: v1.5.0-rc1~83^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F489%2Fhead;p=thirdparty%2Frrdtool-1.x.git rrdcached: support new option to listen on all addresses at default port This functionality can be achieved with "-l ''" (specifying an empty string for host:port) but empty strings may be dropped during option processing in scripts. A separate option to support this capability is much more clear. Signed-off-by: Peter A. Bigot --- diff --git a/doc/rrdcached.pod b/doc/rrdcached.pod index 58c34f71..b46a9455 100644 --- a/doc/rrdcached.pod +++ b/doc/rrdcached.pod @@ -66,12 +66,19 @@ domain socket B start with a slash in the second case! : Given a port without a host (e.g. C<-l :42217>) the daemon will listen -on that port on all network interfaces. +on that port on all network interfaces. Use C<-L> to avoid the need +to explicitly provide the port if the default port is desired. If no B<-l> option is not specified the default address, C, will be used. Multiple B<-l> options may be provided. +=item B<-L> + +Tells the daemon to bind to the default TCP port on all available +interfaces. It is equivalent to C<-l ''> without the confusion of the +empty string parameter. + =item B<-s> I|I Set the group permissions of a UNIX domain socket. The option accepts either diff --git a/etc/rrdcached-default-lsb.in b/etc/rrdcached-default-lsb.in index f57289c6..44e163d1 100644 --- a/etc/rrdcached-default-lsb.in +++ b/etc/rrdcached-default-lsb.in @@ -35,10 +35,15 @@ SOCKFILE=/var/run/rrdcached.sock #SOCKMODE=0660 # Network socket address requests. Use in conjunction with SOCKFILE to -# also listen on INET domain sockets. (The option is a lower-case ell -# ASCII 108 = 0x6c, and should be repeated for each address.). -NETWORK_OPTIONS="-l :42217" +# also listen on INET domain sockets. The option is a lower-case ell +# ASCII 108 = 0x6c, and should be repeated for each address. The +# parameter is an optional IP address, followed by an optional port with +# a colon separating it from the address. The empty string is +# interpreted as "open sockets on the default port on all available +# interfaces", but generally does not pass through init script functions +# so use -L with no parameters for that configuration. +#NETWORK_OPTIONS="-L" # Any other options not specifically supported by the script (-P, -f, # -F, -B). -BASE_OPTIONS=-B +BASE_OPTIONS="-B" diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c index 08f97595..546e2920 100644 --- a/src/rrd_daemon.c +++ b/src/rrd_daemon.c @@ -3434,7 +3434,7 @@ static int read_options (int argc, char **argv) /* {{{ */ default_socket.socket_group = (gid_t)-1; default_socket.socket_permissions = (mode_t)-1; - while ((option = getopt(argc, argv, "Ogl:s:m:P:f:w:z:t:BRb:p:Fj:a:h?")) != -1) + while ((option = getopt(argc, argv, "OgLl:s:m:P:f:w:z:t:BRb:p:Fj:a:h?")) != -1) { switch (option) { @@ -3446,6 +3446,7 @@ static int read_options (int argc, char **argv) /* {{{ */ stay_foreground=1; break; + case 'L': case 'l': { listen_socket_t *new; @@ -3458,7 +3459,10 @@ static int read_options (int argc, char **argv) /* {{{ */ } memset(new, 0, sizeof(listen_socket_t)); - strncpy(new->addr, optarg, sizeof(new->addr)-1); + if ('L' == option) + new->addr[0] = 0; + else + strncpy(new->addr, optarg, sizeof(new->addr)-1); /* Add permissions to the socket {{{ */ if (default_socket.permissions != 0)