Auto-Merge pull request #3193 from dago/fileoffsetbits
authorcollectd bot <32910397+collectd-bot@users.noreply.github.com>
Fri, 28 Jun 2019 10:17:47 +0000 (12:17 +0200)
committerGitHub <noreply@github.com>
Fri, 28 Jun 2019 10:17:47 +0000 (12:17 +0200)
Automatically merged due to "Automerge" label

configure.ac
src/barometer.c
src/daemon/configfile.c
src/load.c
src/logfile.c
src/openvpn.c
src/syslog.c
src/ted.c
src/utils/dns/dns.c
src/utils/dns/dns.h

index 7454fb4..7cdf2c7 100644 (file)
@@ -635,16 +635,6 @@ fi
 
 # }}}
 
-# For the dns plugin
-AC_CHECK_HEADERS([arpa/nameser.h])
-AC_CHECK_HEADERS([arpa/nameser_compat.h], [], [],
-  [[
-    #if HAVE_ARPA_NAMESER_H
-    # include <arpa/nameser.h>
-    #endif
-  ]]
-)
-
 AC_CHECK_HEADERS([net/if_arp.h], [], [],
   [[
     #if HAVE_SYS_SOCKET_H
index 468a237..fd733b4 100644 (file)
@@ -1309,8 +1309,8 @@ static int collectd_barometer_config(const char *key, const char *value) {
   } else if (strcasecmp(key, "Normalization") == 0) {
     int normalize_tmp = atoi(value);
     if (normalize_tmp < 0 || normalize_tmp > 2) {
-      WARNING("barometer: collectd_barometer_config: invalid normalization: %d",
-              normalize_tmp);
+      ERROR("barometer: collectd_barometer_config: invalid normalization: %d",
+            normalize_tmp);
       return 1;
     }
     config_normalize = normalize_tmp;
index 735be83..5cf8ac1 100644 (file)
@@ -267,7 +267,8 @@ static int dispatch_loadplugin(oconfig_item_t *ci) {
 
   /* default to the global interval set before loading this plugin */
   plugin_ctx_t ctx = {
-      .interval = cf_get_default_interval(), .name = strdup(name),
+      .interval = cf_get_default_interval(),
+      .name = strdup(name),
   };
   if (ctx.name == NULL)
     return ENOMEM;
@@ -413,9 +414,13 @@ static int dispatch_block_plugin(oconfig_item_t *ci) {
   /* Hm, no complex plugin found. Dispatch the values one by one */
   for (int i = 0, ret = 0; i < ci->children_num; i++) {
     if (ci->children[i].children == NULL) {
-      ret = dispatch_value_plugin(name, ci->children + i);
-      if (ret != 0)
+      oconfig_item_t *child = ci->children + i;
+      ret = dispatch_value_plugin(name, child);
+      if (ret != 0) {
+        ERROR("Plugin %s failed to handle option %s, return code: %i", name,
+              child->key, ret);
         return ret;
+      }
     } else {
       WARNING("There is a `%s' block within the "
               "configuration for the %s plugin. "
@@ -475,9 +480,9 @@ static int cf_ci_replace_child(oconfig_item_t *dst, oconfig_item_t *src,
     return 0;
   }
 
-  temp = realloc(dst->children,
-                 sizeof(oconfig_item_t) *
-                     (dst->children_num + src->children_num - 1));
+  temp =
+      realloc(dst->children, sizeof(oconfig_item_t) *
+                                 (dst->children_num + src->children_num - 1));
   if (temp == NULL) {
     ERROR("configfile: realloc failed.");
     return -1;
@@ -516,9 +521,8 @@ static int cf_ci_append_children(oconfig_item_t *dst, oconfig_item_t *src) {
   if ((src == NULL) || (src->children_num == 0))
     return 0;
 
-  temp =
-      realloc(dst->children,
-              sizeof(oconfig_item_t) * (dst->children_num + src->children_num));
+  temp = realloc(dst->children, sizeof(oconfig_item_t) *
+                                    (dst->children_num + src->children_num));
   if (temp == NULL) {
     ERROR("configfile: realloc failed.");
     return -1;
@@ -806,7 +810,7 @@ static oconfig_item_t *cf_read_generic(const char *path, const char *pattern,
 
   return root;
 } /* oconfig_item_t *cf_read_generic */
-/* #endif HAVE_WORDEXP_H */
+  /* #endif HAVE_WORDEXP_H */
 
 #else  /* if !HAVE_WORDEXP_H */
 static oconfig_item_t *cf_read_generic(const char *path, const char *pattern,
index da7fe58..a94ee96 100644 (file)
@@ -61,7 +61,7 @@ static const char *config_keys[] = {"ReportRelative"};
 static int config_keys_num = STATIC_ARRAY_SIZE(config_keys);
 
 static int load_config(const char *key, const char *value) {
-  if (strcasecmp(key, "ReportRelative") == 0)
+  if (strcasecmp(key, "ReportRelative") == 0) {
 #ifdef _SC_NPROCESSORS_ONLN
     report_relative_load = IS_TRUE(value);
 #else
@@ -69,6 +69,8 @@ static int load_config(const char *key, const char *value) {
             "is not available, because I can't determine the "
             "number of CPUS on this system. Sorry.");
 #endif
+    return 0;
+  }
   return -1;
 }
 static void load_submit(gauge_t snum, gauge_t mnum, gauge_t lnum) {
@@ -89,7 +91,9 @@ static void load_submit(gauge_t snum, gauge_t mnum, gauge_t lnum) {
 
   value_list_t vl = VALUE_LIST_INIT;
   value_t values[] = {
-      {.gauge = snum}, {.gauge = mnum}, {.gauge = lnum},
+      {.gauge = snum},
+      {.gauge = mnum},
+      {.gauge = lnum},
   };
 
   vl.values = values;
@@ -114,7 +118,7 @@ static int load_read(void) {
   else {
     WARNING("load: getloadavg failed: %s", STRERRNO);
   }
-/* #endif HAVE_GETLOADAVG */
+    /* #endif HAVE_GETLOADAVG */
 
 #elif defined(KERNEL_LINUX)
   gauge_t snum, mnum, lnum;
@@ -149,7 +153,7 @@ static int load_read(void) {
   lnum = atof(fields[2]);
 
   load_submit(snum, mnum, lnum);
-/* #endif KERNEL_LINUX */
+  /* #endif KERNEL_LINUX */
 
 #elif HAVE_LIBSTATGRAB
   gauge_t snum, mnum, lnum;
@@ -162,7 +166,7 @@ static int load_read(void) {
   mnum = ls->min5;
   lnum = ls->min15;
   load_submit(snum, mnum, lnum);
-/* #endif HAVE_LIBSTATGRAB */
+  /* #endif HAVE_LIBSTATGRAB */
 
 #elif HAVE_PERFSTAT
   gauge_t snum, mnum, lnum;
@@ -178,7 +182,7 @@ static int load_read(void) {
   mnum = (float)cputotal.loadavg[1] / (float)(1 << SBITS);
   lnum = (float)cputotal.loadavg[2] / (float)(1 << SBITS);
   load_submit(snum, mnum, lnum);
-/* #endif HAVE_PERFSTAT */
+  /* #endif HAVE_PERFSTAT */
 
 #else
 #error "No applicable input method."
index 3a25319..ef75052 100644 (file)
@@ -52,8 +52,8 @@ static int logfile_config(const char *key, const char *value) {
     log_level = parse_log_severity(value);
     if (log_level < 0) {
       log_level = LOG_INFO;
-      ERROR("logfile: invalid loglevel [%s] defaulting to 'info'", value);
-      return 1;
+      WARNING("logfile: invalid loglevel [%s] defaulting to 'info'", value);
+      return 0;
     }
   } else if (0 == strcasecmp(key, "File")) {
     sfree(log_file);
index 4d4a878..b0e4bf4 100644 (file)
@@ -139,7 +139,8 @@ static void iostats_submit(const char *pinst, const char *tinst, derive_t rx,
                            derive_t tx) {
   value_list_t vl = VALUE_LIST_INIT;
   value_t values[] = {
-      {.derive = rx}, {.derive = tx},
+      {.derive = rx},
+      {.derive = tx},
   };
 
   /* NOTE ON THE NEW NAMING SCHEMA:
@@ -165,7 +166,8 @@ static void compression_submit(const char *pinst, const char *tinst,
                                derive_t uncompressed, derive_t compressed) {
   value_list_t vl = VALUE_LIST_INIT;
   value_t values[] = {
-      {.derive = uncompressed}, {.derive = compressed},
+      {.derive = uncompressed},
+      {.derive = compressed},
   };
 
   vl.values = values;
@@ -502,14 +504,15 @@ static int openvpn_config(const char *key, const char *value) {
         /* callback  = */ openvpn_read,
         /* interval  = */ 0,
         &(user_data_t){
-            .data = instance, .free_func = openvpn_free,
+            .data = instance,
+            .free_func = openvpn_free,
         });
 
     if (status == EINVAL) {
-      WARNING("openvpn plugin: status filename \"%s\" "
-              "already used, please choose a "
-              "different one.",
-              status_name);
+      ERROR("openvpn plugin: status filename \"%s\" "
+            "already used, please choose a "
+            "different one.",
+            status_name);
       return -1;
     }
 
index a600f30..d3be5c9 100644 (file)
@@ -41,7 +41,8 @@ static int log_level = LOG_INFO;
 static int notif_severity;
 
 static const char *config_keys[] = {
-    "LogLevel", "NotifyLevel",
+    "LogLevel",
+    "NotifyLevel",
 };
 static int config_keys_num = STATIC_ARRAY_SIZE(config_keys);
 
@@ -56,7 +57,8 @@ static int sl_config(const char *key, const char *value) {
   } else if (strcasecmp(key, "NotifyLevel") == 0) {
     notif_severity = parse_notif_severity(value);
     if (notif_severity < 0)
-      return 1;
+      ERROR("syslog: invalid notification severity [%s]", value);
+    return 1;
   }
 
   return 0;
index e1b48fd..ff650a8 100644 (file)
--- a/src/ted.c
+++ b/src/ted.c
@@ -243,7 +243,7 @@ static int ted_config(const char *key, const char *value) {
 
     tmp = atoi(value);
     if (tmp < 0) {
-      WARNING("ted plugin: Invalid retry count: %i", tmp);
+      ERROR("ted plugin: Invalid retry count: %i", tmp);
       return 1;
     }
     conf_retries = tmp;
index 2ea919b..fb5cb4f 100644 (file)
 #if HAVE_ARPA_INET_H
 #include <arpa/inet.h>
 #endif
-#if HAVE_ARPA_NAMESER_H
-#include <arpa/nameser.h>
-#endif
-#if HAVE_ARPA_NAMESER_COMPAT_H
-#include <arpa/nameser_compat.h>
-#endif
 
 #if HAVE_NETDB_H
 #include <netdb.h>
@@ -666,251 +660,182 @@ void handle_pcap(u_char *udata, const struct pcap_pkthdr *hdr,
 
 const char *qtype_str(int t) {
   static char buf[32];
+  // clang-format off
+  /*
+  Built (with minor cleanup) from glibc-2.29 by
+    cat resolv/arpa/nameser.h | grep "ns_t_" | \
+    perl -ne '/ns_t_(\S+)\ =\ (\d+)/; print "  case $2:\n    return \"".uc($1)."\";\n";'
+  */
+  // clang-format on
   switch (t) {
-#if (defined(__NAMESER)) && (__NAMESER >= 19991001)
-  case ns_t_a:
+  case 1:
     return "A";
-  case ns_t_ns:
+  case 2:
     return "NS";
-  case ns_t_md:
+  case 3:
     return "MD";
-  case ns_t_mf:
+  case 4:
     return "MF";
-  case ns_t_cname:
+  case 5:
     return "CNAME";
-  case ns_t_soa:
+  case 6:
     return "SOA";
-  case ns_t_mb:
+  case 7:
     return "MB";
-  case ns_t_mg:
+  case 8:
     return "MG";
-  case ns_t_mr:
+  case 9:
     return "MR";
-  case ns_t_null:
+  case 10:
     return "NULL";
-  case ns_t_wks:
+  case 11:
     return "WKS";
-  case ns_t_ptr:
+  case 12:
     return "PTR";
-  case ns_t_hinfo:
+  case 13:
     return "HINFO";
-  case ns_t_minfo:
+  case 14:
     return "MINFO";
-  case ns_t_mx:
+  case 15:
     return "MX";
-  case ns_t_txt:
+  case 16:
     return "TXT";
-  case ns_t_rp:
+  case 17:
     return "RP";
-  case ns_t_afsdb:
+  case 18:
     return "AFSDB";
-  case ns_t_x25:
+  case 19:
     return "X25";
-  case ns_t_isdn:
+  case 20:
     return "ISDN";
-  case ns_t_rt:
+  case 21:
     return "RT";
-  case ns_t_nsap:
+  case 22:
     return "NSAP";
-  case ns_t_nsap_ptr:
+  case 23:
     return "NSAP-PTR";
-  case ns_t_sig:
+  case 24:
     return "SIG";
-  case ns_t_key:
+  case 25:
     return "KEY";
-  case ns_t_px:
+  case 26:
     return "PX";
-  case ns_t_gpos:
+  case 27:
     return "GPOS";
-  case ns_t_aaaa:
+  case 28:
     return "AAAA";
-  case ns_t_loc:
+  case 29:
     return "LOC";
-  case ns_t_nxt:
+  case 30:
     return "NXT";
-  case ns_t_eid:
+  case 31:
     return "EID";
-  case ns_t_nimloc:
+  case 32:
     return "NIMLOC";
-  case ns_t_srv:
+  case 33:
     return "SRV";
-  case ns_t_atma:
+  case 34:
     return "ATMA";
-  case ns_t_naptr:
+  case 35:
     return "NAPTR";
-  case ns_t_opt:
-    return "OPT";
-#if __NAMESER >= 19991006
-  case ns_t_kx:
+  case 36:
     return "KX";
-  case ns_t_cert:
+  case 37:
     return "CERT";
-  case ns_t_a6:
+  case 38:
     return "A6";
-  case ns_t_dname:
+  case 39:
     return "DNAME";
-  case ns_t_sink:
+  case 40:
     return "SINK";
-  case ns_t_tsig:
-    return "TSIG";
-#endif
-#if __NAMESER >= 20090302
-  case ns_t_apl:
+  case 41:
+    return "OPT";
+  case 42:
     return "APL";
-  case ns_t_ds:
+  case 43:
     return "DS";
-  case ns_t_sshfp:
+  case 44:
     return "SSHFP";
-  case ns_t_ipseckey:
+  case 45:
     return "IPSECKEY";
-  case ns_t_rrsig:
+  case 46:
     return "RRSIG";
-  case ns_t_nsec:
+  case 47:
     return "NSEC";
-  case ns_t_dnskey:
+  case 48:
     return "DNSKEY";
-  case ns_t_dhcid:
+  case 49:
     return "DHCID";
-  case ns_t_nsec3:
+  case 50:
     return "NSEC3";
-  case ns_t_nsec3param:
+  case 51:
     return "NSEC3PARAM";
-  case ns_t_hip:
+  case 52:
+    return "TLSA";
+  case 53:
+    return "SMIMEA";
+  case 55:
     return "HIP";
-  case ns_t_spf:
+  case 56:
+    return "NINFO";
+  case 57:
+    return "RKEY";
+  case 58:
+    return "TALINK";
+  case 59:
+    return "CDS";
+  case 60:
+    return "CDNSKEY";
+  case 61:
+    return "OPENPGPKEY";
+  case 62:
+    return "CSYNC";
+  case 99:
     return "SPF";
-  case ns_t_ixfr:
+  case 100:
+    return "UINFO";
+  case 101:
+    return "UID";
+  case 102:
+    return "GID";
+  case 103:
+    return "UNSPEC";
+  case 104:
+    return "NID";
+  case 105:
+    return "L32";
+  case 106:
+    return "L64";
+  case 107:
+    return "LP";
+  case 108:
+    return "EUI48";
+  case 109:
+    return "EUI64";
+  case 249:
+    return "TKEY";
+  case 250:
+    return "TSIG";
+  case 251:
     return "IXFR";
-#endif
-  case ns_t_axfr:
+  case 252:
     return "AXFR";
-  case ns_t_mailb:
+  case 253:
     return "MAILB";
-  case ns_t_maila:
+  case 254:
     return "MAILA";
-  case ns_t_any:
+  case 255:
     return "ANY";
-#if __NAMESER >= 19991006
-  case ns_t_zxfr:
-    return "ZXFR";
-#endif
-#if __NAMESER >= 20090302
-  case ns_t_dlv:
+  case 256:
+    return "URI";
+  case 257:
+    return "CAA";
+  case 258:
+    return "AVC";
+  case 32768:
+    return "TA";
+  case 32769:
     return "DLV";
-#endif
-/* #endif __NAMESER >= 19991001 */
-#elif (defined(__BIND)) && (__BIND >= 19950621)
-  case T_A:
-    return "A"; /* 1 ... */
-  case T_NS:
-    return "NS";
-  case T_MD:
-    return "MD";
-  case T_MF:
-    return "MF";
-  case T_CNAME:
-    return "CNAME";
-  case T_SOA:
-    return "SOA";
-  case T_MB:
-    return "MB";
-  case T_MG:
-    return "MG";
-  case T_MR:
-    return "MR";
-  case T_NULL:
-    return "NULL";
-  case T_WKS:
-    return "WKS";
-  case T_PTR:
-    return "PTR";
-  case T_HINFO:
-    return "HINFO";
-  case T_MINFO:
-    return "MINFO";
-  case T_MX:
-    return "MX";
-  case T_TXT:
-    return "TXT";
-  case T_RP:
-    return "RP";
-  case T_AFSDB:
-    return "AFSDB";
-  case T_X25:
-    return "X25";
-  case T_ISDN:
-    return "ISDN";
-  case T_RT:
-    return "RT";
-  case T_NSAP:
-    return "NSAP";
-  case T_NSAP_PTR:
-    return "NSAP_PTR";
-  case T_SIG:
-    return "SIG";
-  case T_KEY:
-    return "KEY";
-  case T_PX:
-    return "PX";
-  case T_GPOS:
-    return "GPOS";
-  case T_AAAA:
-    return "AAAA";
-  case T_LOC:
-    return "LOC";
-  case T_NXT:
-    return "NXT";
-  case T_EID:
-    return "EID";
-  case T_NIMLOC:
-    return "NIMLOC";
-  case T_SRV:
-    return "SRV";
-  case T_ATMA:
-    return "ATMA";
-  case T_NAPTR:
-    return "NAPTR"; /* ... 35 */
-#if (__BIND >= 19960801)
-  case T_KX:
-    return "KX"; /* 36 ... */
-  case T_CERT:
-    return "CERT";
-  case T_A6:
-    return "A6";
-  case T_DNAME:
-    return "DNAME";
-  case T_SINK:
-    return "SINK";
-  case T_OPT:
-    return "OPT";
-  case T_APL:
-    return "APL";
-  case T_DS:
-    return "DS";
-  case T_SSHFP:
-    return "SSHFP";
-  case T_RRSIG:
-    return "RRSIG";
-  case T_NSEC:
-    return "NSEC";
-  case T_DNSKEY:
-    return "DNSKEY"; /* ... 48 */
-  case T_TKEY:
-    return "TKEY"; /* 249 */
-#endif /* __BIND >= 19960801 */
-  case T_TSIG:
-    return "TSIG"; /* 250 ... */
-  case T_IXFR:
-    return "IXFR";
-  case T_AXFR:
-    return "AXFR";
-  case T_MAILB:
-    return "MAILB";
-  case T_MAILA:
-    return "MAILA";
-  case T_ANY:
-    return "ANY"; /* ... 255 */
-#endif /* __BIND >= 19950621 */
   default:
     snprintf(buf, sizeof(buf), "#%i", t);
     return buf;
@@ -938,65 +863,46 @@ const char *opcode_str(int o) {
 
 const char *rcode_str(int rcode) {
   static char buf[32];
+  /* RFC2136 rcodes */
+  // clang-format off
+  /*
+  Built (with minor cleanup) from glibc-2.29 by
+    cat resolv/arpa/nameser.h | grep "ns_r_" | \
+    perl -ne '/ns_r_(\S+)\ =\ (\d+)/; print "  case $2:\n    return \"".uc($1)."\";\n";'
+
+  https://tools.ietf.org/html/rfc2671 assigns EDNS Extended RCODE "16" to "BADVERS"
+  https://tools.ietf.org/html/rfc2845 declares 0..15 as DNS RCODE and 16 is BADSIG.
+  */
+  // clang-format on
   switch (rcode) {
-#if (defined(__NAMESER)) && (__NAMESER >= 19991006)
-  case ns_r_noerror:
-    return "NOERROR";
-  case ns_r_formerr:
+  case 1:
     return "FORMERR";
-  case ns_r_servfail:
+  case 2:
     return "SERVFAIL";
-  case ns_r_nxdomain:
+  case 3:
     return "NXDOMAIN";
-  case ns_r_notimpl:
+  case 4:
     return "NOTIMPL";
-  case ns_r_refused:
+  case 5:
     return "REFUSED";
-  case ns_r_yxdomain:
+  case 6:
     return "YXDOMAIN";
-  case ns_r_yxrrset:
+  case 7:
     return "YXRRSET";
-  case ns_r_nxrrset:
+  case 8:
     return "NXRRSET";
-  case ns_r_notauth:
+  case 9:
     return "NOTAUTH";
-  case ns_r_notzone:
+  case 10:
     return "NOTZONE";
-  case ns_r_max:
+  case 11:
     return "MAX";
-  case ns_r_badsig:
+  case 16:
     return "BADSIG";
-  case ns_r_badkey:
+  case 17:
     return "BADKEY";
-  case ns_r_badtime:
+  case 18:
     return "BADTIME";
-/* #endif __NAMESER >= 19991006 */
-#elif (defined(__BIND)) && (__BIND >= 19950621)
-  case NOERROR:
-    return "NOERROR";
-  case FORMERR:
-    return "FORMERR";
-  case SERVFAIL:
-    return "SERVFAIL";
-  case NXDOMAIN:
-    return "NXDOMAIN";
-  case NOTIMP:
-    return "NOTIMP";
-  case REFUSED:
-    return "REFUSED";
-#if defined(YXDOMAIN) && defined(NXRRSET)
-  case YXDOMAIN:
-    return "YXDOMAIN";
-  case YXRRSET:
-    return "YXRRSET";
-  case NXRRSET:
-    return "NXRRSET";
-  case NOTAUTH:
-    return "NOTAUTH";
-  case NOTZONE:
-    return "NOTZONE";
-#endif /* RFC2136 rcodes */
-#endif /* __BIND >= 19950621 */
   default:
     snprintf(buf, sizeof(buf), "RCode%i", rcode);
     return buf;
index 9d9b75f..9cc49b6 100644 (file)
@@ -38,7 +38,6 @@
 
 #include "config.h"
 
-#include <arpa/nameser.h>
 #include <stdint.h>
 
 #if HAVE_PCAP_H