Disable MIB loading in forked SNMP child processes
Net-SNMP was crashing (signal 11) on every operation despite fork isolation.
The issue was that init_snmp() tries to load MIB files by default, which can
cause crashes if MIB files are missing, corrupted, or incompatible.
Since we only use numeric OIDs (e.g., "1.3.6.1.2.1.1.1.0"), we don't need
MIB name resolution at all. This change explicitly disables MIB loading in
the child process by:
1. Setting MIBS and MIBDIRS environment variables to empty
2. Calling netsnmp_set_mib_directory("") to disable MIB directory search
3. These must happen BEFORE calling init_snmp()
This should fix the persistent SIGSEGV crashes in SNMP operations.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
7b793b315a
commit
73b75c8aa4
1 changed files with 10 additions and 0 deletions
|
|
@ -596,6 +596,11 @@ void snmp_get_isolated(
|
|||
child_reset_signals();
|
||||
alarm(60); /* watchdog: kill child if stuck */
|
||||
|
||||
/* Disable MIB loading to prevent crashes from missing/corrupt MIB files */
|
||||
setenv("MIBS", "", 1); /* Don't load any MIBs */
|
||||
setenv("MIBDIRS", "", 1); /* Don't search for MIB directories */
|
||||
netsnmp_set_mib_directory(""); /* Explicitly set empty MIB directory */
|
||||
|
||||
/* Initialize net-snmp fresh in child */
|
||||
init_snmp("towerops-child");
|
||||
netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID,
|
||||
|
|
@ -725,6 +730,11 @@ void snmp_walk_isolated(
|
|||
child_reset_signals();
|
||||
alarm(60); /* watchdog */
|
||||
|
||||
/* Disable MIB loading to prevent crashes from missing/corrupt MIB files */
|
||||
setenv("MIBS", "", 1); /* Don't load any MIBs */
|
||||
setenv("MIBDIRS", "", 1); /* Don't search for MIB directories */
|
||||
netsnmp_set_mib_directory(""); /* Explicitly set empty MIB directory */
|
||||
|
||||
/* Initialize net-snmp fresh in child */
|
||||
init_snmp("towerops-child");
|
||||
netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue