Skip to content

Commit 5e23c92

Browse files
committed
Make SNMP shut up properly
1 parent 7270a8b commit 5e23c92

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

ext/snmp/snmp.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,6 +1997,13 @@ PHP_MINIT_FUNCTION(snmp)
19971997
{
19981998
netsnmp_log_handler *logh;
19991999

2000+
/* Disable logging, use exit status'es and related variabled to detect errors */
2001+
shutdown_snmp_logging();
2002+
logh = netsnmp_register_loghandler(NETSNMP_LOGHANDLER_NONE, LOG_ERR);
2003+
if (logh) {
2004+
logh->pri_max = LOG_ERR;
2005+
}
2006+
20002007
init_snmp("snmpapp");
20012008
/* net-snmp corrupts the CTYPE locale during initialization. */
20022009
zend_reset_lc_ctype_locale();
@@ -2006,13 +2013,6 @@ PHP_MINIT_FUNCTION(snmp)
20062013
netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_PERSIST_STATE, 1);
20072014
#endif
20082015

2009-
/* Disable logging, use exit status'es and related variabled to detect errors */
2010-
shutdown_snmp_logging();
2011-
logh = netsnmp_register_loghandler(NETSNMP_LOGHANDLER_NONE, LOG_ERR);
2012-
if (logh) {
2013-
logh->pri_max = LOG_ERR;
2014-
}
2015-
20162016
memcpy(&php_snmp_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
20172017
php_snmp_object_handlers.read_property = php_snmp_read_property;
20182018
php_snmp_object_handlers.write_property = php_snmp_write_property;

ext/snmp/tests/skipif.inc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,5 @@ require_once (dirname(__FILE__).'/snmp_include.inc');
66
//snmpget ( string $hostname , string $community ,
77
//string $object_id [, int $timeout [, int $retries ]] )
88

9-
// net-snmp will just log to STDERR without asking. Close STDERR to prevent
10-
// the error output from marking the SKIPIF section as BORKed.
11-
fclose(STDERR);
129
if (@snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout) === false)
1310
die('skip NO SNMPD on this host or community invalid');

0 commit comments

Comments
 (0)