Blame SOURCES/net-snmp-5.8-modern-rpm-api.patch

962144
diff -urNp a/agent/mibgroup/host/data_access/swinst_rpm.c b/agent/mibgroup/host/data_access/swinst_rpm.c
962144
--- a/agent/mibgroup/host/data_access/swinst_rpm.c	2018-07-18 16:12:19.583503903 +0200
962144
+++ b/agent/mibgroup/host/data_access/swinst_rpm.c	2018-07-18 16:50:38.599703588 +0200
962144
@@ -102,7 +102,6 @@ netsnmp_swinst_arch_load( netsnmp_contai
962144
     rpmtd                 td_name, td_version, td_release, td_group, td_time;
962144
 #else
962144
     char                 *n, *v, *r, *g;
962144
-    int32_t              *t;
962144
 #endif
962144
     time_t                install_time;
962144
     size_t                date_len;
962144
@@ -146,14 +145,13 @@ netsnmp_swinst_arch_load( netsnmp_contai
962144
         install_time = rpmtdGetNumber(td_time);
962144
         g = rpmtdGetString(td_group);
962144
 #else
962144
-        headerGetEntry( h, RPMTAG_NAME,        NULL, (void**)&n, NULL);
962144
-        headerGetEntry( h, RPMTAG_VERSION,     NULL, (void**)&v, NULL);
962144
-        headerGetEntry( h, RPMTAG_RELEASE,     NULL, (void**)&r, NULL);
962144
-        headerGetEntry( h, RPMTAG_GROUP,       NULL, (void**)&g, NULL);
962144
-        headerGetEntry( h, RPMTAG_INSTALLTIME, NULL, (void**)&t, NULL);
962144
+        n = headerGetString( h, RPMTAG_NAME);
962144
+        v = headerGetString( h, RPMTAG_VERSION);
962144
+        r = headerGetString( h, RPMTAG_RELEASE);
962144
+        g = headerGetString( h, RPMTAG_GROUP);
962144
+        install_time = headerGetNumber( h, RPMTAG_INSTALLTIME);
962144
         entry->swName_len = snprintf( entry->swName, sizeof(entry->swName),
962144
                                       "%s-%s-%s", n, v, r);
962144
-        install_time = *t;
962144
 #endif
962144
         entry->swType = (g && NULL != strstr( g, "System Environment"))
962144
                         ? 2      /* operatingSystem */
962144
diff -urNp a/agent/mibgroup/host/hr_swinst.c b/agent/mibgroup/host/hr_swinst.c
962144
--- a/agent/mibgroup/host/hr_swinst.c	2018-07-18 16:12:19.582503907 +0200
962144
+++ b/agent/mibgroup/host/hr_swinst.c	2018-07-18 17:09:29.716564197 +0200
962144
@@ -479,9 +479,9 @@ var_hrswinst(struct variable * vp,
962144
             }
962144
 #else
962144
 # ifdef HAVE_LIBRPM
962144
-            char *rpm_groups;
962144
-            if ( headerGetEntry(swi->swi_h, RPMTAG_GROUP, NULL, (void **) &rpm_groups, NULL) ) {
962144
-                if ( strstr(rpm_groups, "System Environment") != NULL )
962144
+            const char *rpm_group = headerGetString(swi->swi_h, RPMTAG_GROUP);	
962144
+            if ( NULL != rpm_group ) {
962144
+                if ( strstr(rpm_group, "System Environment") != NULL )
962144
                     long_return = 2;	/* operatingSystem */
962144
                 else
962144
                     long_return = 4;	/* applcation */
962144
@@ -498,9 +498,8 @@ var_hrswinst(struct variable * vp,
962144
     case HRSWINST_DATE:
962144
         {
962144
 #ifdef HAVE_LIBRPM
962144
-            int32_t         *rpm_data;
962144
-            if ( headerGetEntry(swi->swi_h, RPMTAG_INSTALLTIME, NULL, (void **) &rpm_data, NULL) ) {
962144
-                time_t          installTime = *rpm_data;
962144
+            time_t installTime = headerGetNumber(swi->swi_h, RPMTAG_INSTALLTIME);
962144
+            if ( 0 != installTime ) {
962144
                 ret = date_n_time(&installTime, var_len);
962144
             } else {
962144
                 ret = date_n_time(NULL, var_len);
962144
@@ -660,7 +659,7 @@ Save_HR_SW_info(int ix)
962144
     if (1 <= ix && ix <= swi->swi_nrec && ix != swi->swi_prevx) {
962144
         int             offset;
962144
         Header          h;
962144
-        char           *n, *v, *r;
962144
+        const char     *n, *v, *r;
962144
 
962144
         offset = swi->swi_recs[ix - 1];
962144
 
962144
@@ -685,11 +684,9 @@ Save_HR_SW_info(int ix)
962144
         swi->swi_h = h;
962144
         swi->swi_prevx = ix;
962144
 
962144
-        headerGetEntry(swi->swi_h, RPMTAG_NAME, NULL, (void **) &n, NULL);
962144
-        headerGetEntry(swi->swi_h, RPMTAG_VERSION, NULL, (void **) &v,
962144
-                       NULL);
962144
-        headerGetEntry(swi->swi_h, RPMTAG_RELEASE, NULL, (void **) &r,
962144
-                       NULL);
962144
+        n = headerGetString(swi->swi_h, RPMTAG_NAME);
962144
+        v = headerGetString(swi->swi_h, RPMTAG_VERSION);
962144
+        r = headerGetString(swi->swi_h, RPMTAG_RELEASE);
962144
         snprintf(swi->swi_name, sizeof(swi->swi_name), "%s-%s-%s", n, v, r);
962144
         swi->swi_name[ sizeof(swi->swi_name)-1 ] = 0;
962144
     }