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

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