Description: snmptrapd: compile against mariadb 10.2+
 MariaDB 10.2 and above broke the init API
Author: Josef Ridky
Origin: backport, https://sourceforge.net/p/net-snmp/bugs/2782/
Bug: https://sourceforge.net/p/net-snmp/bugs/2782/
Applied-Upstream: 4.8
Reviewed-by: Craig Small <csmall@debian.org>
Last-Update: 2019-01-04
--- a/apps/snmptrapd_sql.c
+++ b/apps/snmptrapd_sql.c
@@ -54,6 +54,7 @@
 #include <my_sys.h>
 #include <mysql.h>
 #include <errmsg.h>
+#include <mysql_version.h>
 
 netsnmp_feature_require(container_fifo)
 
@@ -437,6 +438,7 @@
         return -1;
     }
 
+#if MYSQL_VERSION_ID < 100000
 #ifdef HAVE_BROKEN_LIBMYSQLCLIENT
     my_init();
 #else
@@ -445,6 +447,7 @@
 
     /** load .my.cnf values */
     load_defaults ("my", _sql.groups, &not_argc, &not_argv);
+#endif
     for(i=0; i < not_argc; ++i) {
         if (NULL == not_argv[i])
             continue;
@@ -542,6 +545,10 @@
         return -1;
     }
 
+#if MYSQL_VERSION_ID > 100000
+    mysql_options(_sql.conn, MYSQL_READ_DEFAULT_GROUP, "snmptrapd");
+#endif
+
     /** try to connect; we'll try again later if we fail */
     (void) netsnmp_mysql_connect();
 
--- a/configure.d/config_os_libs2
+++ b/configure.d/config_os_libs2
@@ -479,8 +479,8 @@
       [AC_MSG_RESULT(no)
        AC_DEFINE([HAVE_BROKEN_LIBMYSQLCLIENT], 1,
                  [Define if using MY_INIT() causes a linker error])])
-  CPPFLAGS="${_cppflags}"
-  LIBS="${_libs}"
+#  CPPFLAGS="${_cppflags}"
+#  LIBS="${_libs}"
   AC_MSG_CACHE_ADD(MYSQL Trap Logging:         enabled)
 else
   AC_MSG_CACHE_ADD(MYSQL Trap Logging:         unavailable)
