integ/base/net-snmp/patches/0001-rpm-headerGetEntry.patch
Scott Little bab9bb6b69 Internal restructuring of stx-integ
Create new directories:
   ceph
   config
   config-files
   filesystem
   kernel
   kernel/kernel-modules
   ldap
   logging
   strorage-drivers
   tools
   utilities
   virt

Retire directories:
   connectivity
   core
   devtools
   support
   extended

Delete two packages:
   tgt
   irqbalance

Relocated packages:
   base/
      dhcp
      initscripts
      libevent
      lighttpd
      linuxptp
      memcached
      net-snmp
      novnc
      ntp
      openssh
      pam
      procps
      sanlock
      shadow
      sudo
      systemd
      util-linux
      vim
      watchdog

   ceph/
      python-cephclient

   config/
      facter
      puppet-4.8.2
      puppet-modules

   filesystem/
      e2fsprogs
      nfs-utils
      nfscheck

   kernel/
      kernel-std
      kernel-rt

   kernel/kernel-modules/
      mlnx-ofa_kernel

   ldap/
      nss-pam-ldapd
      openldap

   logging/
      syslog-ng
      logrotate

   networking/
      lldpd
      iproute
      mellanox
      python-ryu
      mlx4-config

   python/
      python-2.7.5
      python-django
      python-gunicorn
      python-setuptools
      python-smartpm
      python-voluptuous

   security/
      shim-signed
      shim-unsigned
      tboot

   strorage-drivers/
      python-3parclient
      python-lefthandclient

   virt/
      cloud-init
      libvirt
      libvirt-python
      qemu

   tools/
      storage-topology
      vm-topology

   utilities/
      tis-extensions
      namespace-utils
      nova-utils
      update-motd

Change-Id: I37ade764d873c701b35eac5881eb40412ba64a86
Story: 2002801
Task: 22687
Signed-off-by: Scott Little <scott.little@windriver.com>
2018-08-01 10:06:31 -04:00

149 lines
6.2 KiB
Diff

diff --git a/agent/mibgroup/host/data_access/swinst_rpm.c b/agent/mibgroup/host/data_access/swinst_rpm.c
index 71595be..e12d3c8 100644
--- a/agent/mibgroup/host/data_access/swinst_rpm.c
+++ b/agent/mibgroup/host/data_access/swinst_rpm.c
@@ -96,14 +96,18 @@ netsnmp_swinst_arch_load( netsnmp_container *container, u_int flags)
rpmdbMatchIterator mi;
Header h;
- char *n, *v, *r, *g;
- int32_t *t;
+ rpmtd td_n, td_v, td_r, td_g, td_t;
time_t install_time;
size_t date_len;
int i = 1;
netsnmp_swinst_entry *entry;
ts = rpmtsCreate();
+ td_n = rpmtdNew();
+ td_v = rpmtdNew();
+ td_r = rpmtdNew();
+ td_g = rpmtdNew();
+ td_t = rpmtdNew();
rpmtsSetVSFlags( ts, (_RPMVSF_NOSIGNATURES|_RPMVSF_NODIGESTS));
mi = rpmtsInitIterator( ts, RPMDBI_PACKAGES, NULL, 0);
@@ -119,21 +123,21 @@ netsnmp_swinst_arch_load( netsnmp_container *container, u_int flags)
CONTAINER_INSERT(container, entry);
h = headerLink( h );
- headerGetEntry( h, RPMTAG_NAME, NULL, (void**)&n, NULL);
- headerGetEntry( h, RPMTAG_VERSION, NULL, (void**)&v, NULL);
- headerGetEntry( h, RPMTAG_RELEASE, NULL, (void**)&r, NULL);
- headerGetEntry( h, RPMTAG_GROUP, NULL, (void**)&g, NULL);
- headerGetEntry( h, RPMTAG_INSTALLTIME, NULL, (void**)&t, NULL);
+ headerGet( h, RPMTAG_NAME, td_n, HEADERGET_EXT);
+ headerGet( h, RPMTAG_VERSION, td_v, HEADERGET_EXT);
+ headerGet( h, RPMTAG_RELEASE, td_r, HEADERGET_EXT);
+ headerGet( h, RPMTAG_GROUP, td_g, HEADERGET_EXT);
+ headerGet( h, RPMTAG_INSTALLTIME, td_t, HEADERGET_EXT);
entry->swName_len = snprintf( entry->swName, sizeof(entry->swName),
- "%s-%s-%s", n, v, r);
+ "%s-%s-%s", rpmtdGetString(td_n), rpmtdGetString(td_v), rpmtdGetString(td_r));
if (entry->swName_len > sizeof(entry->swName))
entry->swName_len = sizeof(entry->swName);
- entry->swType = (NULL != strstr( g, "System Environment"))
+ entry->swType = (NULL != strstr( rpmtdGetString(td_g), "System Environment"))
? 2 /* operatingSystem */
: 4; /* application */
- install_time = *t;
+ install_time = rpmtdGetUint32(td_t);
dt = date_n_time( &install_time, &date_len );
if (date_len != 8 && date_len != 11) {
snmp_log(LOG_ERR, "Bogus length from date_n_time for %s", entry->swName);
@@ -148,6 +152,11 @@ netsnmp_swinst_arch_load( netsnmp_container *container, u_int flags)
}
rpmdbFreeIterator( mi );
rpmtsFree( ts );
+ rpmtdFree(td_t);
+ rpmtdFree(td_g);
+ rpmtdFree(td_r);
+ rpmtdFree(td_v);
+ rpmtdFree(td_n);
DEBUGMSGTL(("swinst:load:arch", "loaded %d entries\n",
(int)CONTAINER_SIZE(container)));
diff --git a/agent/mibgroup/host/hr_swinst.c b/agent/mibgroup/host/hr_swinst.c
index 4aa4593..643d3fe 100644
--- a/agent/mibgroup/host/hr_swinst.c
+++ b/agent/mibgroup/host/hr_swinst.c
@@ -484,15 +484,17 @@ var_hrswinst(struct variable * vp,
}
#else
# ifdef HAVE_LIBRPM
- char *rpm_groups;
- if ( headerGetEntry(swi->swi_h, RPMTAG_GROUP, NULL, (void **) &rpm_groups, NULL) ) {
- if ( strstr(rpm_groups, "System Environment") != NULL )
+ rpmtd td;
+ td = rpmtdNew();
+ if ( headerGet(swi->swi_h, RPMTAG_GROUP, td, HEADERGET_EXT) ) {
+ if ( strstr(rpmtdGetString(td), "System Environment") != NULL )
long_return = 2; /* operatingSystem */
else
long_return = 4; /* applcation */
} else {
long_return = 1; /* unknown */
}
+ rpmtdFree(td);
# else
long_return = 1; /* unknown */
# endif
@@ -503,13 +505,15 @@ var_hrswinst(struct variable * vp,
case HRSWINST_DATE:
{
#ifdef HAVE_LIBRPM
- int32_t *rpm_data;
- if ( headerGetEntry(swi->swi_h, RPMTAG_INSTALLTIME, NULL, (void **) &rpm_data, NULL) ) {
- time_t installTime = *rpm_data;
+ rpmtd td;
+ td = rpmtdNew();
+ if ( headerGet(swi->swi_h, RPMTAG_INSTALLTIME, td, HEADERGET_EXT) ) {
+ time_t installTime = rpmtdGetNumber(td);
ret = date_n_time(&installTime, var_len);
} else {
ret = date_n_time(NULL, var_len);
}
+ rpmtdFree(td);
#else
if (swi->swi_directory != NULL) {
snprintf(string, sizeof(string), "%s/%s",
@@ -662,7 +666,7 @@ Save_HR_SW_info(int ix)
if (1 <= ix && ix <= swi->swi_nrec && ix != swi->swi_prevx) {
int offset;
Header h;
- char *n, *v, *r;
+ rpmtd td_n, td_v, td_r;
offset = swi->swi_recs[ix - 1];
@@ -687,13 +691,21 @@ Save_HR_SW_info(int ix)
swi->swi_h = h;
swi->swi_prevx = ix;
- headerGetEntry(swi->swi_h, RPMTAG_NAME, NULL, (void **) &n, NULL);
- headerGetEntry(swi->swi_h, RPMTAG_VERSION, NULL, (void **) &v,
- NULL);
- headerGetEntry(swi->swi_h, RPMTAG_RELEASE, NULL, (void **) &r,
- NULL);
- snprintf(swi->swi_name, sizeof(swi->swi_name), "%s-%s-%s", n, v, r);
+ td_n = rpmtdNew{};
+ td_v = rpmtdNew{};
+ td_r = rpmtdNew{};
+
+ headerGet(swi->swi_h, RPMTAG_NAME, td_n, HEADERGET_EXT);
+ headerGet(swi->swi_h, RPMTAG_VERSION, td_v, HEADERGET_EXT);
+ headerGet(swi->swi_h, RPMTAG_RELEASE, td_r, HEADERGET_EXT);
+
+ snprintf(swi->swi_name, sizeof(swi->swi_name), "%s-%s-%s", rpmtdGetString(td_n), rpmtdGetNumber(td_v), rpmtdGetNumber(td_r));
swi->swi_name[ sizeof(swi->swi_name)-1 ] = 0;
+
+ rpmtdFree(td_r);
+ rpmtdFree(td_v);
+ rpmtdFree(td_n);
+
}
#else
snprintf(swi->swi_name, sizeof(swi->swi_name), "%s", swi->swi_dep->d_name);