Re: [PATCH for master / request for votes] configure.ac: Fix recently introduced autoreconf warnings

2018-05-07 Thread Niels Baggesen via Net-snmp-coders

Den 07-05-2018 kl. 06:13 skrev Bart Van Assche:

A recent patch introduced an invocation of AC_CHECK_HEADER before AC_AIX.
However, AC_AIX must be invoked before AC_CHECK_HEADER. Hence move AC_AIX
from configure.d/config_os_progs into configure.ac. Additionally, since
AC_AIX is obsolete, use AC_USE_SYSTEM_EXTENSIONS instead. This patch fixes
all instances of the following autoreconf warnings:


+1

/Niels

--
Niels Baggesen - @home - Ã…rhus - Denmark - n...@users.sourceforge.net
The purpose of computing is insight, not numbers   ---   R W Hamming

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders


Re: FreeBSD pkg HOST-RESOURCES-MIB::hrSWInstalled stops working

2018-05-07 Thread Robert Story
On Mon, 07 May 2018 11:44:59 -0500 Mark wrote:
MF> The HOST-RESOURCES-MIB::hrSWInstalled support for FreeBSD pkg
MF> stops working after so many queries and requires an snmpd
MF> process restart. I have been observing this for quite some time
MF> and have only recently started to debug it. The code in
MF> question is at:
MF> 
MF> agent/mibgroup/host/data_access/swinst_pkginfo.c
MF> 
MF> When debugging I see it throw either:
MF> 
MF> snmp_log( LOG_ERR, "SWInst: error initializing pkgng db\n" );
MF> 
MF> or
MF> 
MF> snmp_log( LOG_ERR, "SWInst: error opening pkgng db\n" );
MF> 
MF> neither of which should be true as nothing on the system
MF> changes. After seeing one of these for a few times there are no
MF> further messages [...]

Can you run with "-Dswinst:load:arch --logTimestamp=yes", and
then run "grep -i swinst" on the log file and send it?

MF> Could anyone provide any possible insight or ideas on what
MF> could be the issue here? I have compared the code with that
MF> used internally in FreeBSD pkg tool and it's nearly identical.
MF> The only thing that I felt was missing was declaring a readonly
MF> lock on the database but even adding that into the snmp code
MF> had no effect...

There are quite a few places that don't clean up properly before
returning, but that should only affect error paths.

You can also try this patch to see if you get more useful debug
info:

diff --git a/agent/mibgroup/host/data_access/swinst_pkginfo.c 
b/agent/mibgroup/host/data_access/swinst_pkginfo.c
index 861d79f0f..de2abf19b 100644
--- a/agent/mibgroup/host/data_access/swinst_pkginfo.c
+++ b/agent/mibgroup/host/data_access/swinst_pkginfo.c
@@ -118,12 +118,15 @@ netsnmp_swinst_arch_load( netsnmp_container *container, 
u_int flags)

 if (pkgdb_open(, PKGDB_DEFAULT) != EPKG_OK) {
snmp_log( LOG_ERR, "SWInst: error opening pkgng db\n" );
+pkg_shutdown();
return 1;
 }

 if (pkg_status(NULL) == PKG_STATUS_ACTIVE) {
pkgng = 1;
 } else {
+pkgdb_close(db);
+pkg_shutdown();
snmp_log( LOG_INFO, "SWInst: not a pkgng system\n" );
 }

@@ -131,9 +134,12 @@ netsnmp_swinst_arch_load( netsnmp_container *container, 
u_int flags)
 if (pkgng) {
 if ((it = pkgdb_query(db, NULL, MATCH_ALL)) == NULL) {
 snmp_log( LOG_ERR, "SWInst: error querying pkgng db\n" );
+pkgdb_close(db);
+pkg_shutdown();
 return 1;
 }

+DEBUGMSGTL(("swinst:load:arch"," pkgdb available\n"));
 while (pkgdb_it_next(it, , PKG_LOAD_BASIC) == EPKG_OK) {
 pkg_snprintf(pkgname, sizeof(pkgname), "%n-%v", pkg, pkg);
 pkg_snprintf(pkgdate, sizeof(pkgdate), "%t", pkg);
@@ -162,13 +168,18 @@ netsnmp_swinst_arch_load( netsnmp_container *container, 
u_int flags)
 } else {
 #endif /* HAVE_LIBPKG */
 if ( !pkg_directory[0] ) {
+NETSNMP_LOGONCE(LOG_ERR, "SWInst: no pkg_directory available\n");
 return 1;/* Can't report installed packages
  if there isn't a list of them! */
 }

+DEBUGMSGTL(("swinst:load:arch"," pkgdb available\n"));
 d = opendir( pkg_directory );
-if (!d)
+if (!d) {
+snmp_log( LOG_ERR, "SWInst: error querying pkg_directory %s\n",
+  pkg_directory );
 return 1;
+}

 while ((dp = readdir(d)) != NULL) {
 if ( '.' == dp->d_name[0] )

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders


FreeBSD pkg HOST-RESOURCES-MIB::hrSWInstalled stops working

2018-05-07 Thread Mark Felder
Hello all,

The HOST-RESOURCES-MIB::hrSWInstalled support for FreeBSD pkg stops working 
after so many queries and requires an snmpd process restart. I have been 
observing this for quite some time and have only recently started to debug it. 
The code in question is at:

agent/mibgroup/host/data_access/swinst_pkginfo.c

When debugging I see it throw either:

snmp_log( LOG_ERR, "SWInst: error initializing pkgng db\n" );

or

snmp_log( LOG_ERR, "SWInst: error opening pkgng db\n" );

neither of which should be true as nothing on the system changes. After seeing 
one of these for a few times there are no further messages at which point I 
believe it's having issues before it hits 

/* if we are using FreeBSD's pkgng */
if (pkgng) {
if ((it = pkgdb_query(db, NULL, MATCH_ALL)) == NULL) {
snmp_log( LOG_ERR, "SWInst: error querying pkgng db\n" );
return 1;
}


It seems that if the system has fewer packages installed it can be queried more 
times before it stops working. I was able to reproduce the issue every time at 
19 queries on one test host.

Could anyone provide any possible insight or ideas on what could be the issue 
here? I have compared the code with that used internally in FreeBSD pkg tool 
and it's nearly identical. The only thing that I felt was missing was declaring 
a readonly lock on the database but even adding that into the snmp code had no 
effect...


Thanks


-- 
  Mark Felder
  ports-secteam & portmgr member
  f...@freebsd.org

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders


Re: Configuration files are not resilient to power failure

2018-05-07 Thread Josef Ridky
Thanks a lot.

Josef 

- Original Message -
| From: "Robert Story" 
| To: "Josef Ridky" 
| Cc: net-snmp-coders@lists.sourceforge.net
| Sent: Saturday, May 5, 2018 7:00:23 AM
| Subject: Re: Configuration files are not resilient to power failure
| 
| I've added a call to fsync in 5-7-patches and master.
| 
| On Mon, 15 Jan 2018 04:18:57 -0500 (EST) Josef wrote:
| JR> net-snmp's configuration files are not resilient to power
| JR> failure.
| JR>
| JR> following a power failure event users created with
| JR> net-snmp-create-v3-user are missing from /etc/snmp/snmpd.conf
| JR> and that /var/lib/net-snmp/snmpd.conf is empty.
| JR>
| JR> Steps to Reproduce:
| JR>
| JR>   [root@rhel73 ~]# cat /etc/fstab
| JR>   UUID=8c3e7419-f4b9-425a-b535-b6849a6e68bf / xfs defaults 0 0
| JR>   [root@rhel73 ~]# grep
| JR> testuser /etc/snmp/snmpd.conf /var/lib/net-snmp/snmpd.conf
| JR> [root@rhel73 ~]# ls
| JR> -l /etc/snmp/snmpd.conf /var/lib/net-snmp/snmpd.conf
| JR> -rw---. 1 root root 18891 Dec  4 22:32 /etc/snmp/snmpd.conf
| JR> -rw---. 1 root root  1073 Dec  5
| JR> 00:04 /var/lib/net-snmp/snmpd.conf
| JR>
| JR>   [root@rhel73 ~]# systemctl stop snmpd
| JR>   [root@rhel73 ~]# /usr/bin/net-snmp-create-v3-user -A testpass
| JR> testuser
| JR>
| JR>   [root@rhel73 ~]# ls
| JR> -l /etc/snmp/snmpd.conf /var/lib/net-snmp/snmpd.conf
| JR> -rw---. 1 root root 18877 Dec  5 00:09 /etc/snmp/snmpd.conf
| JR> -rw---. 1 root root  1112 Dec  5
| JR> 00:09 /var/lib/net-snmp/snmpd.con [root@rhel73 ~]# grep
| JR> testuser /etc/snmp/snmpd.conf /var/lib/net-snmp/snmpd.conf
| /etc/snmp/snmpd.conf:rwuser
| JR> testuser /var/lib/net-snmp/snmpd.conf:createUser testuser MD5
| JR> "testpass" DES
| JR>
| JR>   [root@rhel73 ~]# systemctl start snmpd
| JR>
| JR> Force power off and reconnect.
| JR>
| JR>   [root@rhel73 ~]#  grep
| JR> testuser /etc/snmp/snmpd.conf /var/lib/net-snmp/snmpd.conf
| JR> [root@rhel73 ~]#  ls
| JR> -l /etc/snmp/snmpd.conf /var/lib/net-snmp/snmpd.conf
| JR> -rw---. 1 root root 18861 Dec  5 00:09 /etc/snmp/snmpd.conf
| JR> -rw---. 1 root root 0 Dec  5
| JR> 00:09 /var/lib/net-snmp/snmpd.conf
| JR>
| JR> Actual results:
| JR>
| JR>   The added user has been lost from the configuration.
| JR>   The entire /var/lib/net-snmp/snmpd.conf has been lost.
| JR>
| JR> Expected results:
| JR>
| JR>   /etc/snmp/snmpd.conf contains the newly added user.
| JR>   /var/lib/net-snmp/snmpd.conf  is not destroyed.
| JR>
| JR> Additional info:
| JR>
| JR>   This was observed for XFS root filesystems, it may be that
| JR> the default Ext's data=ordered mode behaves differently.
| JR> Running this under strace snmpd is doing a rename/rewrite of
| JR> the file. But it never calls fsync, so for the XFS case the
| JR> dirty buffers are still in memory when the box is powered off,
| JR> only the rename and create have hit the disk.
| 

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders