Merge pull request #2327 from rpv-tomsk/snmp-custom-port
authorRuben Kerkhof <ruben@rubenkerkhof.com>
Sat, 1 Jul 2017 10:57:27 +0000 (12:57 +0200)
committerGitHub <noreply@github.com>
Sat, 1 Jul 2017 10:57:27 +0000 (12:57 +0200)
snmp plugin: Option `Address` documented in more details.

ChangeLog
src/email.c
src/exec.c
src/openldap.c
src/unixsock.c
version-gen.sh

index 9f1b639..b8755d9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,50 @@
+2017-06-06, Version 5.7.2
+       * Build system: The Notify Email plugin is no longer linked with
+         indirect dependencies. Thanks to Marc Fournier.
+       * collectd: A race condition when calculating a metric's rate has been
+         fixed. Thanks to Florian Forster. #1193
+       * AMQP, Exec, UnixSock, Write Kafka plugins: Parsing of the PUTVAL
+         command with multiple values has been fixed. Thanks to Florian
+         Forster. #2274
+       * AMQP plugin: The "ExchangeType" option is now also valid for
+         publishers. Thanks to Florian Forster. #2286
+       * BIND plugin: Fix parsing of the sample time provided by BIND.
+         Previously, the time was assumed to be in the local timezone when in
+         fact it was in UTC. Thanks to Ed Ravin. #1268
+       * BIND plugin: Memory leaks have been fixed. Thanks to Ruben Kerkhof.
+         #2303
+       * cURL-JSON plugin: Handling of arrays has been fixed. Thanks to Florian
+         Forster. #2266
+       * DPDKStat plugin: Error handling during initialization has been
+         improved. Thanks to Ruben Kerkhof.
+       * DPDKStat plugin: Handling of a number of metrics has been improved,
+         for example "rx_q0bytes". Thanks to Przemyslaw Szczerbik. #2167
+       * Intel RDT plugin: Configuration handling has been changed to be more
+         graceful. Thanks to Maryam Tahhan. #2165
+       * Log Logstash plugin: If writing the log entry fails, print it to
+         "STDERR" instead. Thanks to Marc Fournier.
+       * LogFile plugin: If writing to the file fails, print log messages on
+         "STDERR" instead. Thanks to Marc Fournier.
+       * memcachec, Tail plugins: A resource leak in the matching
+         infrastructure has been fixed. Thanks to Krzysztof Matczak. #2192
+       * MQTT plugin: Invalid symbols in topic names are now replaced and a
+         resource leak has been fixed. Thanks to Denys Fedoryshchenko. #2123
+       * Network plugin: A potential endless-loop has been fixed. This can be
+         triggered remotely by sending a signed network packet to a server
+         which is not set up to check signatures. Thanks to Marcin Kozlowski
+         and Pavel Rochnyack. #2174, #2233, CVE-2017-7401
+       * Perl plugin: A potential double-free has been fixed. Thanks to Florian
+         Forster. #2278
+       * Processes plugin: A compilation error on AIX has been fixed. Thanks to
+         Pavel Rochnyack. #2210
+       * SMART plugin: A check for the "CAP_SYS_RAWIO" capability has been
+         added. Thanks to Marc Fournier.
+       * Write Graphite plugin: Error handling in the case that calculating a
+         metric's rate fails has been improved. Previously, the raw counter
+         values were sent to Graphite. Thanks to Iain Buclaw. #2209
+       * Write Prometheus plugin: An incorrect use of "realloc(3)" has been
+         fixed. Thanks to Florian Forster. #2275
+
 2017-01-23, Version 5.7.1
        * collectd: Handling of boolean configuration options has been unified.
          Thanks to Sebastian Harl. #2083, #2098
index 871ddf8..e5f015b 100644 (file)
@@ -159,18 +159,18 @@ static type_list_t list_check_copy;
  * Private functions
  */
 static int email_config(const char *key, const char *value) {
-  if (0 == strcasecmp(key, "SocketFile")) {
-    if (NULL != sock_file)
+  if (strcasecmp(key, "SocketFile") == 0) {
+    if (sock_file != NULL)
       free(sock_file);
     sock_file = sstrdup(value);
-  } else if (0 == strcasecmp(key, "SocketGroup")) {
-    if (NULL != sock_group)
+  } else if (strcasecmp(key, "SocketGroup") == 0) {
+    if (sock_group != NULL)
       free(sock_group);
     sock_group = sstrdup(value);
-  } else if (0 == strcasecmp(key, "SocketPerms")) {
+  } else if (strcasecmp(key, "SocketPerms") == 0) {
     /* the user is responsible for providing reasonable values */
     sock_perms = (int)strtol(value, NULL, 8);
-  } else if (0 == strcasecmp(key, "MaxConns")) {
+  } else if (strcasecmp(key, "MaxConns") == 0) {
     long int tmp = strtol(value, NULL, 0);
 
     if (tmp < 1) {
@@ -200,7 +200,7 @@ static int email_config(const char *key, const char *value) {
 
 /* Increment the value of the given name in the given list by incr. */
 static void type_list_incr(type_list_t *list, char *name, int incr) {
-  if (NULL == list->head) {
+  if (list->head == NULL) {
     list->head = smalloc(sizeof(*list->head));
 
     list->head->name = sstrdup(name);
@@ -212,11 +212,11 @@ static void type_list_incr(type_list_t *list, char *name, int incr) {
     type_t *ptr;
 
     for (ptr = list->head; NULL != ptr; ptr = ptr->next) {
-      if (0 == strcmp(name, ptr->name))
+      if (strcmp(name, ptr->name) == 0)
         break;
     }
 
-    if (NULL == ptr) {
+    if (ptr == NULL) {
       list->tail->next = smalloc(sizeof(*list->tail->next));
       list->tail = list->tail->next;
 
@@ -238,14 +238,14 @@ static void *collect(void *arg) {
 
     pthread_mutex_lock(&conns_mutex);
 
-    while (NULL == conns.head) {
+    while (conns.head == NULL) {
       pthread_cond_wait(&conn_available, &conns_mutex);
     }
 
     connection = conns.head;
     conns.head = conns.head->next;
 
-    if (NULL == conns.head) {
+    if (conns.head == NULL) {
       conns.tail = NULL;
     }
 
@@ -263,8 +263,8 @@ static void *collect(void *arg) {
       int len = 0;
 
       errno = 0;
-      if (NULL == fgets(line, sizeof(line), this->socket)) {
-        if (0 != errno) {
+      if (fgets(line, sizeof(line), this->socket) == NULL) {
+        if (errno != 0) {
           char errbuf[1024];
           log_err("collect: reading from socket (fd #%i) "
                   "failed: %s",
@@ -275,13 +275,13 @@ static void *collect(void *arg) {
       }
 
       len = strlen(line);
-      if (('\n' != line[len - 1]) && ('\r' != line[len - 1])) {
+      if ((line[len - 1] != '\n') && (line[len - 1] != '\r')) {
         log_warn("collect: line too long (> %zu characters): "
                  "'%s' (truncated)",
                  sizeof(line) - 1, line);
 
-        while (NULL != fgets(line, sizeof(line), this->socket))
-          if (('\n' == line[len - 1]) || ('\r' == line[len - 1]))
+        while (fgets(line, sizeof(line), this->socket) != NULL)
+          if ((line[len - 1] == '\n') || (line[len - 1] == '\r'))
             break;
         continue;
       }
@@ -293,18 +293,18 @@ static void *collect(void *arg) {
 
       log_debug("collect: line = '%s'", line);
 
-      if (':' != line[1]) {
+      if (line[1] != ':') {
         log_err("collect: syntax error in line '%s'", line);
         continue;
       }
 
-      if ('e' == line[0]) { /* e:<type>:<bytes> */
+      if (line[0] == 'e') { /* e:<type>:<bytes> */
         char *ptr = NULL;
         char *type = strtok_r(line + 2, ":", &ptr);
         char *tmp = strtok_r(NULL, ":", &ptr);
         int bytes = 0;
 
-        if (NULL == tmp) {
+        if (tmp == NULL) {
           log_err("collect: syntax error in line '%s'", line);
           continue;
         }
@@ -320,13 +320,13 @@ static void *collect(void *arg) {
           type_list_incr(&list_size, type, /* increment = */ bytes);
           pthread_mutex_unlock(&size_mutex);
         }
-      } else if ('s' == line[0]) { /* s:<value> */
+      } else if (line[0] == 's') { /* s:<value> */
         pthread_mutex_lock(&score_mutex);
         score = (score * (double)score_count + atof(line + 2)) /
                 (double)(score_count + 1);
         ++score_count;
         pthread_mutex_unlock(&score_mutex);
-      } else if ('c' == line[0]) { /* c:<type1>[,<type2>,...] */
+      } else if (line[0] == 'c') { /* c:<type1>[,<type2>,...] */
         char *dummy = line + 2;
         char *endptr = NULL;
         char *type;
@@ -366,7 +366,7 @@ static void *open_connection(void __attribute__((unused)) * arg) {
 
   /* create UNIX socket */
   errno = 0;
-  if (-1 == (connector_socket = socket(PF_UNIX, SOCK_STREAM, 0))) {
+  if ((connector_socket = socket(PF_UNIX, SOCK_STREAM, 0)) == -1) {
     char errbuf[1024];
     disabled = 1;
     log_err("socket() failed: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
@@ -379,9 +379,8 @@ static void *open_connection(void __attribute__((unused)) * arg) {
   sstrncpy(addr.sun_path, path, (size_t)(UNIX_PATH_MAX - 1));
 
   errno = 0;
-  if (-1 ==
-      bind(connector_socket, (struct sockaddr *)&addr,
-           offsetof(struct sockaddr_un, sun_path) + strlen(addr.sun_path))) {
+  if (bind(connector_socket, (struct sockaddr *)&addr,
+           offsetof(struct sockaddr_un, sun_path) + strlen(addr.sun_path)) == -1) {
     char errbuf[1024];
     disabled = 1;
     close(connector_socket);
@@ -391,7 +390,7 @@ static void *open_connection(void __attribute__((unused)) * arg) {
   }
 
   errno = 0;
-  if (-1 == listen(connector_socket, 5)) {
+  if (listen(connector_socket, 5) == -1) {
     char errbuf[1024];
     disabled = 1;
     close(connector_socket);
@@ -403,7 +402,7 @@ static void *open_connection(void __attribute__((unused)) * arg) {
   {
     struct group sg;
     struct group *grp;
-    char grbuf[2048];
+    char grbuf[4096];
     int status;
 
     grp = NULL;
@@ -411,7 +410,7 @@ static void *open_connection(void __attribute__((unused)) * arg) {
     if (status != 0) {
       char errbuf[1024];
       log_warn("getgrnam_r (%s) failed: %s", group,
-               sstrerror(errno, errbuf, sizeof(errbuf)));
+               sstrerror(status, errbuf, sizeof(errbuf)));
     } else if (grp == NULL) {
       log_warn("No such group: `%s'", group);
     } else {
@@ -425,7 +424,7 @@ static void *open_connection(void __attribute__((unused)) * arg) {
   }
 
   errno = 0;
-  if (0 != chmod(path, sock_perms)) {
+  if (chmod(path, sock_perms) != 0) {
     char errbuf[1024];
     log_warn("chmod() failed: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
   }
@@ -466,7 +465,7 @@ static void *open_connection(void __attribute__((unused)) * arg) {
 
     pthread_mutex_lock(&available_mutex);
 
-    while (0 == available_collectors) {
+    while (available_collectors == 0) {
       pthread_cond_wait(&collector_available, &available_mutex);
     }
 
@@ -505,7 +504,7 @@ static void *open_connection(void __attribute__((unused)) * arg) {
     connection->socket = fdopen(remote, "r");
     connection->next = NULL;
 
-    if (NULL == connection->socket) {
+    if (connection->socket == NULL) {
       close(remote);
       sfree(connection);
       continue;
@@ -513,7 +512,7 @@ static void *open_connection(void __attribute__((unused)) * arg) {
 
     pthread_mutex_lock(&conns_mutex);
 
-    if (NULL == conns.head) {
+    if (conns.head == NULL) {
       conns.head = connection;
       conns.tail = connection;
     } else {
@@ -605,7 +604,7 @@ static int email_shutdown(void) {
   type_list_free(&list_check);
   type_list_free(&list_check_copy);
 
-  unlink((NULL == sock_file) ? SOCK_PATH : sock_file);
+  unlink((sock_file == NULL) ? SOCK_PATH : sock_file);
 
   sfree(sock_file);
   sfree(sock_group);
@@ -632,14 +631,14 @@ static void email_submit(const char *type, const char *type_instance,
 static void copy_type_list(type_list_t *l1, type_list_t *l2) {
   type_t *last = NULL;
 
-  for (type_t *ptr1 = l1->head, *ptr2 = l2->head; NULL != ptr1;
+  for (type_t *ptr1 = l1->head, *ptr2 = l2->head; ptr1 != NULL;
        ptr1 = ptr1->next, last = ptr2, ptr2 = ptr2->next) {
-    if (NULL == ptr2) {
+    if (ptr2 == NULL) {
       ptr2 = smalloc(sizeof(*ptr2));
       ptr2->name = NULL;
       ptr2->next = NULL;
 
-      if (NULL == last) {
+      if (last == NULL) {
         l2->head = ptr2;
       } else {
         last->next = ptr2;
@@ -648,7 +647,7 @@ static void copy_type_list(type_list_t *l1, type_list_t *l2) {
       l2->tail = ptr2;
     }
 
-    if (NULL == ptr2->name) {
+    if (ptr2->name == NULL) {
       ptr2->name = sstrdup(ptr1->name);
     }
 
@@ -672,7 +671,7 @@ static int email_read(void) {
 
   pthread_mutex_unlock(&count_mutex);
 
-  for (type_t *ptr = list_count_copy.head; NULL != ptr; ptr = ptr->next) {
+  for (type_t *ptr = list_count_copy.head; ptr != NULL; ptr = ptr->next) {
     email_submit("email_count", ptr->name, ptr->value);
   }
 
@@ -683,7 +682,7 @@ static int email_read(void) {
 
   pthread_mutex_unlock(&size_mutex);
 
-  for (type_t *ptr = list_size_copy.head; NULL != ptr; ptr = ptr->next) {
+  for (type_t *ptr = list_size_copy.head; ptr != NULL; ptr = ptr->next) {
     email_submit("email_size", ptr->name, ptr->value);
   }
 
@@ -707,7 +706,7 @@ static int email_read(void) {
 
   pthread_mutex_unlock(&check_mutex);
 
-  for (type_t *ptr = list_check_copy.head; NULL != ptr; ptr = ptr->next)
+  for (type_t *ptr = list_check_copy.head; ptr != NULL; ptr = ptr->next)
     email_submit("spam_check", ptr->name, ptr->value);
 
   return 0;
index f10b816..3d12a2d 100644 (file)
@@ -369,7 +369,7 @@ static int fork_child(program_list_t *pl, int *fd_in, int *fd_out,
 
   struct passwd *sp_ptr;
   struct passwd sp;
-  char nambuf[2048];
+  char nambuf[4096];
 
   if (pl->pid != 0)
     return -1;
@@ -382,7 +382,7 @@ static int fork_child(program_list_t *pl, int *fd_in, int *fd_out,
   status = getpwnam_r(pl->user, &sp, nambuf, sizeof(nambuf), &sp_ptr);
   if (status != 0) {
     ERROR("exec plugin: Failed to get user information for user ``%s'': %s",
-          pl->user, sstrerror(errno, errbuf, sizeof(errbuf)));
+          pl->user, sstrerror(status, errbuf, sizeof(errbuf)));
     goto failed;
   }
 
@@ -401,19 +401,19 @@ static int fork_child(program_list_t *pl, int *fd_in, int *fd_out,
   /* The group configured in the configfile is set as effective group, because
    * this way the forked process can (re-)gain the user's primary group. */
   egid = -1;
-  if (NULL != pl->group) {
-    if ('\0' != *pl->group) {
+  if (pl->group != NULL) {
+    if (*pl->group != '\0') {
       struct group *gr_ptr = NULL;
       struct group gr;
 
       status = getgrnam_r(pl->group, &gr, nambuf, sizeof(nambuf), &gr_ptr);
-      if (0 != status) {
+      if (status != 0) {
         ERROR("exec plugin: Failed to get group information "
               "for group ``%s'': %s",
-              pl->group, sstrerror(errno, errbuf, sizeof(errbuf)));
+              pl->group, sstrerror(status, errbuf, sizeof(errbuf)));
         goto failed;
       }
-      if (NULL == gr_ptr) {
+      if (gr_ptr == NULL) {
         ERROR("exec plugin: No such group: `%s'", pl->group);
         goto failed;
       }
index 1156169..8053929 100644 (file)
@@ -92,8 +92,9 @@ static int cldap_init_host(cldap_t *st) /* {{{ */
   if (rc != LDAP_SUCCESS) {
     ERROR("openldap plugin: ldap_initialize failed: %s", ldap_err2string(rc));
     st->state = 0;
-    ldap_unbind_ext_s(ld, NULL, NULL);
-    return -1;
+    if (ld != NULL)
+      ldap_unbind_ext_s(ld, NULL, NULL);
+    return (-1);
   }
 
   st->ld = ld;
@@ -119,8 +120,9 @@ static int cldap_init_host(cldap_t *st) /* {{{ */
       ERROR("openldap plugin: Failed to start tls on %s: %s", st->url,
             ldap_err2string(rc));
       st->state = 0;
-      ldap_unbind_ext_s(st->ld, NULL, NULL);
-      return -1;
+      if (st->ld != NULL)
+        ldap_unbind_ext_s(st->ld, NULL, NULL);
+      return (-1);
     }
   }
 
@@ -139,8 +141,9 @@ static int cldap_init_host(cldap_t *st) /* {{{ */
     ERROR("openldap plugin: Failed to bind to %s: %s", st->url,
           ldap_err2string(rc));
     st->state = 0;
-    ldap_unbind_ext_s(st->ld, NULL, NULL);
-    return -1;
+    if (st->ld != NULL)
+      ldap_unbind_ext_s(st->ld, NULL, NULL);
+    return (-1);
   } else {
     DEBUG("openldap plugin: Successfully connected to %s", st->url);
     st->state = 1;
@@ -214,8 +217,9 @@ static int cldap_read_host(user_data_t *ud) /* {{{ */
     ERROR("openldap plugin: Failed to execute search: %s", ldap_err2string(rc));
     ldap_msgfree(result);
     st->state = 0;
-    ldap_unbind_ext_s(st->ld, NULL, NULL);
-    return -1;
+    if (st->ld != NULL)
+      ldap_unbind_ext_s(st->ld, NULL, NULL);
+    return (-1);
   }
 
   for (LDAPMessage *e = ldap_first_entry(st->ld, result); e != NULL;
index 8ccde80..00b930e 100644 (file)
@@ -134,7 +134,7 @@ static int us_open_socket(void) {
     const char *grpname;
     struct group *g;
     struct group sg;
-    char grbuf[2048];
+    char grbuf[4096];
 
     grpname = (sock_group != NULL) ? sock_group : COLLECTD_GRP_NAME;
     g = NULL;
@@ -143,7 +143,7 @@ static int us_open_socket(void) {
     if (status != 0) {
       char errbuf[1024];
       WARNING("unixsock plugin: getgrnam_r (%s) failed: %s", grpname,
-              sstrerror(errno, errbuf, sizeof(errbuf)));
+              sstrerror(status, errbuf, sizeof(errbuf)));
       break;
     }
     if (g == NULL) {
index bdbb847..2c7a2e5 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-DEFAULT_VERSION="5.7.1.git"
+DEFAULT_VERSION="5.7.2.git"
 
 if [ -d .git ]; then
        VERSION="`git describe --dirty=+ --abbrev=7 2> /dev/null | grep collectd | sed -e 's/^collectd-//' -e 's/-/./g'`"