]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
rrdcached: support new option to listen on all addresses at default port 489/head
authorPeter A. Bigot <pab@pabigot.com>
Tue, 20 May 2014 15:59:07 +0000 (10:59 -0500)
committerPeter A. Bigot <pab@pabigot.com>
Tue, 20 May 2014 15:59:07 +0000 (10:59 -0500)
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 <pab@pabigot.com>
doc/rrdcached.pod
etc/rrdcached-default-lsb.in
src/rrd_daemon.c

index 58c34f71c358b9f5addd170d1e30a7134a56d58f..b46a9455f31031d5eb3a46f40516fc82c7a02ea3 100644 (file)
@@ -66,12 +66,19 @@ domain socket B<must> start with a slash in the second case!
    <hostname-or-ipv4>:<port>
 
 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<unix:/tmp/rrdcached.sock>, 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<group_name>|I<gid>
 
 Set the group permissions of a UNIX domain socket. The option accepts either
index f57289c6c6d99d4778552d886ff39db69b5b4eca..44e163d11f16a5e27d6476242fb11cb845babe65 100644 (file)
@@ -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"
index 08f97595e8f0e619af79e36dde4c1f8778928d7f..546e2920a8227dbf22793538bb6e6db53f06fe06 100644 (file)
@@ -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)