The net-snmp service fails to start inside a Solaris zone after updating to the 5.8 version.
The truss output of the snmpd daemon shows the following error during initialization.
4460/1@1: -> libnetsnmpagent:init_agent(0x100002b50, 0xff7f, 0x0, 0x7ff9622
5102bc0)
<snip>
4460/1@1: -> libnetsnmpagent:init_kmem(0x7ff962561d1d8, 0xb, 0xb, 0x8)
4460/1: fstatat(AT_FDCWD, "/lib/64/libkvm.so.1", 0xFFFFFEAAC2780680, 0) </snip>
<snip>
4460/1: i n i t _ k m e m : k v m _ o p e n f a i l e d : N o
s
4460/1: u c h f i l e o r d i r e c t o r y\n
4460/1@1: <- libnetsnmpagent:init_kmem() = 0
<snip>
4460/1@1: <- libnetsnmpagent:init_agent() = -13</snip></snip>
The failure happens in agent/snmp_vars.c
273 int
274 init_agent(const char *app)
275 {
276 int r = 0;
295 #ifdef HAVE_KMEM
296 r = init_kmem("/dev/kmem") ? 0 : -EACCES;
297 #endif
The "init_kmem" invocation is failing inside a zone due to lack of
privileges and "init_agent" fails returning -EACCESS.
This codepath was not being taken in the previous versions as it
was conditional on an undefined macro (NETSNMP_CAN_USE_NLIST).
The macro has been replaced by HAVE_KMEM which is defined in the 5.8 version.
The following change introduced this
https://sourceforge.net/p/net-snmp/code/ci/e835935dbae5ee2dbd9fa13a24e34b2862c7a4bf/
-- a/agent/snmp_vars.c
+++ b/agent/snmp_vars.c
@@ -289,7 +289,7 @@
netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID,
NETSNMP_DS_LIB_ALARM_DONT_USE_SIG, 1);
-#ifdef NETSNMP_CAN_USE_NLIST
+#ifdef HAVE_KMEM
r = init_kmem("/dev/kmem") ? 0 : -EACCES;
#endif
As Solaris doesn't require "/dev/kmem" access, we can undefine this macro in the Solaris
specific header file, net-snmp-5.8/include/net-snmp/system/solaris.h.
I tried out this change and it seems to fix the issue.
Patch attached.
--- net-snmp-5.8.old/include/net-snmp/system/solaris.h 2018-07-16 07:33:40.000000000 +0000
+++ net-snmp-5.8/include/net-snmp/system/solaris.h 2019-07-24 06:37:10.262461840 +0000
@@ -16,6 +16,7 @@
#undef PROC_SYMBOL
#undef TOTAL_MEMORY_SYMBOL
#undef MBSTAT_SYMBOL
+#undef HAVE_KMEM
#define UDP_ADDRESSES_IN_HOST_ORDER 1
#define UDP_PORTS_IN_HOST_ORDER 1