php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38613 SNMP issues via Apache but ok via PHP CLI
Submitted: 2006-08-27 02:26 UTC Modified: 2007-04-10 01:00 UTC
Votes:3
Avg. Score:4.0 ± 0.8
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: neil at fissure dot net Assigned:
Status: No Feedback Package: SNMP related
PHP Version: 5.1.5 OS: CentOS release 4.3
Private report: No CVE-ID: None
 [2006-08-27 02:26 UTC] neil at fissure dot net
Description:
------------
Similar to bug:
#32680	PHP_MSHUTDOWN PHP_MINIT

PHP gives errors when used as an Apache Module, but the 
same source code works via PHP CLI

Reproduce code:
---------------
error_reporting(E_ALL);

$host = "xxx";
$community = "xxx";

$syscontact = snmpget($host, $community, "system.sysName.0");

PRINT "<BR>$syscontact\n";

Expected result:
----------------
<BR>STRING: 7200

Actual result:
--------------
Warning: snmpget() [function.snmpget]: Could not open 
snmp connection: Unknown host in /usr/local/apache/
htdocs/xxx/snmpwalk.php3 on line 9

I'm running:
PHP Version 5.1.6
'./configure' '--with-mysql' '--with-mysqli' '--enable-
mbstring' '--with-zlib-dir=/usr' '--with-curl' '--with-
snmp' '--with-apache=../apache_1.3.37' '--enable-ucd-
snmp-hack'

('--enable-ucd-snmp-hack' was added in troubleshooting)

Using:
Name   : net-snmp
Arch   : i386
Version: 5.1.2
Release: 11.EL4.6

Once, but only once stracing the httpd process, I saw:
write(2, "No support for requested transpo"..., 48) = 48
which I believe came from net-snmp

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-28 06:22 UTC] tony2001@php.net
Why do you think it's a PHP issue?

 [2006-08-30 16:56 UTC] neil at fissure dot net
I figured it was a PHP issue as it matched a similar bug 
report which was acknowledged to be due to a code change 
in PHP.

In that bug, sniper AT php.net, who make the change, 
said they were using Apache 2 (and would test with 
Apache 1.x if they got a chance). So I'm figuring this 
issue lies with PHP and Apache 1.x

I'm happy to do any requested testing/diagnostics if you 
can give me some pointers.

I'm getting the same errors as in bug 32680 (which was 
acknowledged to be a PHP issue, not say an Apache 
issue).

Thanks for your time, Neil.
 [2006-08-30 17:52 UTC] neil at fissure dot net
Commenting out this line, in the 
PHP_MSHUTDOWN_FUNCTION(snmp) function of:
src/web/php-5.1.6/ext/snmp/snmp.c

diff snmp.c snmp.c.orig 
223c223
< /*    snmp_shutdown("snmpapp"); */
---
>       snmp_shutdown("snmpapp");

but possibly at the risk of re-introducing the memory 
leak it was added to combat?
 [2007-04-02 22:07 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip


 [2007-04-10 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2008-07-29 09:57 UTC] cinek at xo dot pl
This bug is still in PHP 5.2.6 

Works perfectly with commented line, in the 
PHP_MSHUTDOWN_FUNCTION(snmp) function of:
ext/snmp/snmp.c
 [2009-09-26 00:28 UTC] adam-phpbugs at adam dot gs
Hello,
This bug is still in PHP-5.2.9 and PHP-5.3.0.

I can confirm that disabling snmp_shutdown() in 
PHP_MSHUTDOWN_FUNCTION(snmp) corrects the issue with no apparent side 
effects.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC