From fbd8c713cce9a711f2ca7addacd9045509e72b11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20=C5=98=C3=ADdk=C3=BD?= Date: Mon, 23 Oct 2023 17:04:10 +0200 Subject: [PATCH] Resolves: RHEL-6854 - add support for SQLite db background of rpmdb --- net-snmp-5.9-rpmdb.patch | 42 ++++++++++++++++++++++++++++++++++++++++ net-snmp.spec | 7 ++++++- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 net-snmp-5.9-rpmdb.patch diff --git a/net-snmp-5.9-rpmdb.patch b/net-snmp-5.9-rpmdb.patch new file mode 100644 index 0000000..55a1f85 --- /dev/null +++ b/net-snmp-5.9-rpmdb.patch @@ -0,0 +1,42 @@ +diff -urNp a/agent/mibgroup/host/data_access/swinst_rpm.c b/agent/mibgroup/host/data_access/swinst_rpm.c +--- a/agent/mibgroup/host/data_access/swinst_rpm.c 2023-10-23 16:59:37.392368620 +0200 ++++ b/agent/mibgroup/host/data_access/swinst_rpm.c 2023-10-23 17:01:59.760640169 +0200 +@@ -73,15 +73,21 @@ netsnmp_swinst_arch_init(void) + #endif + + snprintf( pkg_directory, SNMP_MAXPATH, "%s/Packages", dbpath ); ++ if (-1 == stat( pkg_directory, &stat_buf )) { ++ ++ /* check for SQLite DB backend */ ++ snprintf( pkg_directory, SNMP_MAXPATH, "%s/rpmdb.sqlite", dbpath ); ++ ++ if (-1 == stat( pkg_directory, &stat_buf )) { ++ snmp_log(LOG_ERR, "Can't find directory of RPM packages\n"); ++ pkg_directory[0] = '\0'; ++ } ++ } + SNMP_FREE(rpmdbpath); + dbpath = NULL; + #ifdef HAVE_RPMGETPATH + rpmFreeRpmrc(); + #endif +- if (-1 == stat( pkg_directory, &stat_buf )) { +- snmp_log(LOG_ERR, "Can't find directory of RPM packages"); +- pkg_directory[0] = '\0'; +- } + } + + void +diff -urNp a/agent/mibgroup/host/hr_swinst.c b/agent/mibgroup/host/hr_swinst.c +--- a/agent/mibgroup/host/hr_swinst.c 2023-10-23 16:59:37.391368611 +0200 ++++ b/agent/mibgroup/host/hr_swinst.c 2023-10-23 17:02:47.159063503 +0200 +@@ -229,6 +229,9 @@ init_hr_swinst(void) + snprintf(path, sizeof(path), "%s/Packages", swi->swi_dbpath); + if (stat(path, &stat_buf) == -1) + snprintf(path, sizeof(path), "%s/packages.rpm", swi->swi_dbpath); ++ /* check for SQLite DB backend */ ++ if (stat(path, &stat_buf) == -1) ++ snprintf(path, sizeof(path), "%s/rpmdb.sqlite", swi->swi_dbpath); + path[ sizeof(path)-1 ] = 0; + swi->swi_directory = strdup(path); + #ifdef HAVE_RPMGETPATH diff --git a/net-snmp.spec b/net-snmp.spec index 533bfb9..3aba2de 100644 --- a/net-snmp.spec +++ b/net-snmp.spec @@ -10,7 +10,7 @@ Summary: A collection of SNMP protocol tools and libraries Name: net-snmp Version: 5.9.1 -Release: 12%{?dist} +Release: 13%{?dist} Epoch: 1 License: BSD @@ -56,6 +56,7 @@ Patch26: net-snmp-5.9-CVE-2022-44792-44793.patch Patch27: net-snmp-5.9-ipv6-disable-leak.patch Patch28: net-snmp-5.9-sendmsg-error-code.patch Patch29: net-snmp-5.9-message-severity.patch +Patch30: net-snmp-5.9-rpmdb.patch # Modern RPM API means at least EL6 Patch101: net-snmp-5.8-modern-rpm-api.patch @@ -237,6 +238,7 @@ cp %{SOURCE10} . %patch27 -p1 -b .ipv6-disable-leak %patch28 -p1 -b .sendmsg-error-code %patch29 -p1 -b .message-severity +%patch30 -p1 -b .rpmdb %patch101 -p1 -b .modern-rpm-api %patch102 -p1 @@ -506,6 +508,9 @@ LD_LIBRARY_PATH=%{buildroot}/%{_libdir} make test %{_libdir}/libnetsnmptrapd*.so.%{soname}* %changelog +* Thu Oct 19 2023 Josef Ridky - 1:5.9.1-13 +- add support for SQLite db background of rpm (RHEL-6854) + * Thu Oct 19 2023 Josef Ridky - 1:5.9.1-12 - fix message severity issue (RHEL-13960)