]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
3856. [bug] Configuring libjson without also configuring libxml
authorMark Andrews <marka@isc.org>
Wed, 21 May 2014 02:06:00 +0000 (12:06 +1000)
committerMark Andrews <marka@isc.org>
Wed, 21 May 2014 02:06:31 +0000 (12:06 +1000)
                        resulting in a REQUIRE assertion when retrieving
                        statistics using json. [RT #36009]

CHANGES
bin/named/statschannel.c
configure
configure.in

diff --git a/CHANGES b/CHANGES
index 16aac4da19278d1ca3c5ba973efc5c47b25878d2..e67bc002e5cc8597ce7ba09badf35991f42bf48c 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+3856.  [bug]           Configuring libjson without also configuring libxml
+                       resulting in a REQUIRE assertion when retrieving
+                       statistics using json. [RT #36009]
+
 3855.  [bug]           Limit smoothed round trip time aging to no more than
                        once a second. [RT #32909]
 
index 09e180c21d47d858e9a290c9e25f9691dd0a03dd..6e2fe3a3c3aa9155f005e4d1fc02869eed51d1e2 100644 (file)
@@ -79,6 +79,12 @@ stats_dumparg {
 
 static isc_once_t once = ISC_ONCE_INIT;
 
+#if defined(HAVE_LIBXML2) || defined(HAVE_JSON)
+#define EXTENDED_STATS
+#else
+#undef EXTENDED_STATS
+#endif
+
 /*%
  * Statistics descriptions.  These could be statistically initialized at
  * compile time, but we configure them run time in the init_desc() function
@@ -90,7 +96,7 @@ static const char *adbstats_desc[dns_adbstats_max];
 static const char *zonestats_desc[dns_zonestatscounter_max];
 static const char *sockstats_desc[isc_sockstatscounter_max];
 static const char *dnssecstats_desc[dns_dnssecstats_max];
-#ifdef HAVE_LIBXML2
+#if defined(EXTENDED_STATS)
 static const char *nsstats_xmldesc[dns_nsstatscounter_max];
 static const char *resstats_xmldesc[dns_resstatscounter_max];
 static const char *adbstats_xmldesc[dns_adbstats_max];
@@ -104,7 +110,7 @@ static const char *dnssecstats_xmldesc[dns_dnssecstats_max];
 #define zonestats_xmldesc NULL
 #define sockstats_xmldesc NULL
 #define dnssecstats_xmldesc NULL
-#endif /* HAVE_LIBXML2 */
+#endif /* EXTENDED_STATS */
 
 #define TRY0(a) do { xmlrc = (a); if (xmlrc < 0) goto error; } while(0)
 
@@ -125,13 +131,13 @@ set_desc(int counter, int maxcounter, const char *fdesc, const char **fdescs,
         const char *xdesc, const char **xdescs)
 {
        REQUIRE(counter < maxcounter);
-       REQUIRE(fdescs[counter] == NULL);
-#ifdef HAVE_LIBXML2
-       REQUIRE(xdescs[counter] == NULL);
+       REQUIRE(fdescs != NULL && fdescs[counter] == NULL);
+#if defined(EXTENDED_STATS)
+       REQUIRE(xdescs != NULL && xdescs[counter] == NULL);
 #endif
 
        fdescs[counter] = fdesc;
-#ifdef HAVE_LIBXML2
+#if defined(EXTENDED_STATS)
        xdescs[counter] = xdesc;
 #else
        UNUSED(xdesc);
@@ -146,7 +152,7 @@ init_desc(void) {
        /* Initialize name server statistics */
        for (i = 0; i < dns_nsstatscounter_max; i++)
                nsstats_desc[i] = NULL;
-#ifdef HAVE_LIBXML2
+#if defined(EXTENDED_STATS)
        for (i = 0; i < dns_nsstatscounter_max; i++)
                nsstats_xmldesc[i] = NULL;
 #endif
@@ -241,7 +247,7 @@ init_desc(void) {
        /* Initialize resolver statistics */
        for (i = 0; i < dns_resstatscounter_max; i++)
                resstats_desc[i] = NULL;
-#ifdef  HAVE_LIBXML2
+#if defined(EXTENDED_STATS)
        for (i = 0; i < dns_resstatscounter_max; i++)
                resstats_xmldesc[i] = NULL;
 #endif
@@ -326,7 +332,7 @@ init_desc(void) {
        /* Initialize adb statistics */
        for (i = 0; i < dns_adbstats_max; i++)
                adbstats_desc[i] = NULL;
-#ifdef  HAVE_LIBXML2
+#if defined(EXTENDED_STATS)
        for (i = 0; i < dns_adbstats_max; i++)
                adbstats_xmldesc[i] = NULL;
 #endif
@@ -348,7 +354,7 @@ init_desc(void) {
        /* Initialize zone statistics */
        for (i = 0; i < dns_zonestatscounter_max; i++)
                zonestats_desc[i] = NULL;
-#ifdef  HAVE_LIBXML2
+#if defined(EXTENDED_STATS)
        for (i = 0; i < dns_zonestatscounter_max; i++)
                zonestats_xmldesc[i] = NULL;
 #endif
@@ -381,7 +387,7 @@ init_desc(void) {
        /* Initialize socket statistics */
        for (i = 0; i < isc_sockstatscounter_max; i++)
                sockstats_desc[i] = NULL;
-#ifdef  HAVE_LIBXML2
+#if defined(EXTENDED_STATS)
        for (i = 0; i < isc_sockstatscounter_max; i++)
                sockstats_xmldesc[i] = NULL;
 #endif
@@ -500,7 +506,7 @@ init_desc(void) {
        /* Initialize DNSSEC statistics */
        for (i = 0; i < dns_dnssecstats_max; i++)
                dnssecstats_desc[i] = NULL;
-#ifdef  HAVE_LIBXML2
+#if defined(EXTENDED_STATS)
        for (i = 0; i < dns_dnssecstats_max; i++)
                dnssecstats_xmldesc[i] = NULL;
 #endif
@@ -537,7 +543,7 @@ init_desc(void) {
                INSIST(sockstats_desc[i] != NULL);
        for (i = 0; i < dns_dnssecstats_max; i++)
                INSIST(dnssecstats_desc[i] != NULL);
-#ifdef  HAVE_LIBXML2
+#if defined(EXTENDED_STATS)
        for (i = 0; i < dns_nsstatscounter_max; i++)
                INSIST(nsstats_xmldesc[i] != NULL);
        for (i = 0; i < dns_resstatscounter_max; i++)
@@ -581,7 +587,7 @@ dump_counters(isc_stats_t *stats, isc_statsformat_t type, void *arg,
        json_object *job, *cat, *counter;
 #endif
 
-#if !defined(HAVE_LIBXML2) && !defined(HAVE_JSON)
+#if !defined(EXTENDED_STATS)
        UNUSED(category);
 #endif
 
@@ -2353,7 +2359,7 @@ ns_statschannels_configure(ns_server_t *server, const cfg_obj_t *config,
         * address-in-use error.
         */
        if (statschannellist != NULL) {
-#if !defined(HAVE_LIBXML2) && !defined(HAVE_JSON)
+#ifndef EXTENDED_STATS
                isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
                              NS_LOGMODULE_SERVER, ISC_LOG_WARNING,
                              "statistics-channels specified but not effective "
index e10309fc2c2fa1155930c7b15bf27c3648b28b90..bcd3d18ffdda1e026a7691ca525afa5a805d37a4 100755 (executable)
--- a/configure
+++ b/configure
@@ -16339,15 +16339,26 @@ case "$use_libjson" in
                libjson_libs=""
                ;;
        auto|yes)
-               if test -f "/usr/include/json/json.h"
-               then
-                       libjson_cflags="-I /usr/include/json"
-                       have_libjson="yes"
-               elif test -f "/usr/include/json-c/json.h"
-               then
-                       libjson_cflags="-I /usr/include/json-c"
-                       have_libjson="yes"
-               fi
+               for d in /usr /usr/local /opt/local
+               do
+                       if test -f "${d}/include/json/json.h"
+                       then
+                               libjson_cflags="-I ${d}/include/json"
+                               if test ${d} != /usr
+                               then
+                                       LIBS="$LIBS -L${d}/lib"
+                               fi
+                               have_libjson="yes"
+                       elif test -f "${d}/include/json-c/json.h"
+                       then
+                               libjson_cflags="-I ${d}/include/json-c"
+                               if test ${d} != /usr
+                               then
+                                       LIBS="$LIBS -L${d}/lib"
+                               fi
+                               have_libjson="yes"
+                       fi
+               done
                ;;
        *)
                if test -f "${use_libjson}/include/json/json.h"
@@ -16425,11 +16436,13 @@ if test "$ac_res" != no; then :
   test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
 
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: found libjson include but not library." >&5
-$as_echo "$as_me: WARNING: found libjson include but not library." >&2;}
+  as_fn_error $? "found libjson include but not library." "$LINENO" 5
                        have_libjson=""
 fi
 
+elif test "X$use_libjson" = Xyes
+then
+       as_fn_error $? "include/json{,-c}/json.h not found." "$LINENO" 5
 else
        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
index 977193b179d5231018cc617ffffedbbfab87299e..db425813747e141d8bef16ea04f990aa7cd9c3d5 100644 (file)
@@ -2041,15 +2041,26 @@ case "$use_libjson" in
                libjson_libs=""
                ;;
        auto|yes)
-               if test -f "/usr/include/json/json.h"
-               then
-                       libjson_cflags="-I /usr/include/json"
-                       have_libjson="yes"
-               elif test -f "/usr/include/json-c/json.h"
-               then
-                       libjson_cflags="-I /usr/include/json-c"
-                       have_libjson="yes"
-               fi
+               for d in /usr /usr/local /opt/local
+               do
+                       if test -f "${d}/include/json/json.h"
+                       then
+                               libjson_cflags="-I ${d}/include/json"
+                               if test ${d} != /usr
+                               then
+                                       LIBS="$LIBS -L${d}/lib"
+                               fi
+                               have_libjson="yes"
+                       elif test -f "${d}/include/json-c/json.h"
+                       then
+                               libjson_cflags="-I ${d}/include/json-c"
+                               if test ${d} != /usr
+                               then
+                                       LIBS="$LIBS -L${d}/lib"
+                               fi
+                               have_libjson="yes"
+                       fi
+               done
                ;;
        *)
                if test -f "${use_libjson}/include/json/json.h"
@@ -2072,8 +2083,11 @@ if test "X${have_libjson}" != "X"
 then
        AC_MSG_RESULT(yes)
        AC_SEARCH_LIBS([json_object_new_int64], [json json-c], [],
-                      [AC_MSG_WARN([found libjson include but not library.])
+                      [AC_MSG_ERROR([found libjson include but not library.])
                        have_libjson=""])
+elif test "X$use_libjson" = Xyes
+then
+       AC_MSG_ERROR([include/json{,-c}/json.h not found.])
 else
        AC_MSG_RESULT(no)
 fi