php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46065 snmp_set_quick_print() persists between requests
Submitted: 2008-09-12 13:27 UTC Modified: 2014-01-05 18:24 UTC
From: php at painfullscratch dot nl Assigned: lytboris
Status: No Feedback Package: SNMP related
PHP Version: 5.*, 6 OS: *
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2008-09-12 13:27 UTC] php at painfullscratch dot nl
Description:
------------
When PHP runs under Apache and snmp_set_quick_print(TRUE) is issued, the behavior of all SNMP-related functions will be "quick print" for the lifetime of the PID. 

NET-SNMP Support => enabled
NET-SNMP Version => 5.4.1
PHP version: 5.2.4

There are two possibilities:
 1) This behavior is "by design": If this is the case I think the manual page for snmp_set_quick_print() needs a warning for this behavior.
 2) This is a bug: For each PID the behavior should be (re)set to the default behavior after execution of the script.


Reproduce code:
---------------
pet@workmate:/tmp$ sudo /etc/init.d/apache2 restart > /dev/null 2>&1
pet@workmate:/tmp$ for (( i=0; i<5; i++ )) ; do links -dump http://localhost/snmp_get_quick_print.php; done
   snmp_get_quick_print: '' | pid: '9402'
   snmp_get_quick_print: '' | pid: '9403'
   snmp_get_quick_print: '' | pid: '9404'
   snmp_get_quick_print: '' | pid: '9405'
   snmp_get_quick_print: '' | pid: '9406'
pet@workmate:/tmp$ links -dump http://localhost/snmp_set_quick_print.php
   snmp_set_quick_print: '' | pid: '9406'
pet@workmate:/tmp$ for (( i=0; i<5; i++ )) ; do links -dump http://localhost/snmp_get_quick_print.php; done
   snmp_get_quick_print: '' | pid: '9403'
   snmp_get_quick_print: '' | pid: '9404'
   snmp_get_quick_print: '' | pid: '9446'
   snmp_get_quick_print: '' | pid: '9405'
   snmp_get_quick_print: '1' | pid: '9406'


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-24 08:56 UTC] jani@php.net
It's pretty simple issue, propably need to add some netsnmp shutdown function in RINIT which clears all the settings between requests.
 [2009-09-08 21:16 UTC] larryjadams at comcast dot net
The snmp module needs a bit of rededesign.  It should handle many of the commands from the native calls, like multiple OID get's in a single array, in other words, make the OID a mixed type for a get request.

Also, the snmp functions should require a resource (aka snmp session) in order to work, just like is done in the API, for which it would be based.

In that case, to setup a quick print, you start a session, receive a pointer to a (structure/resource) in return and then all subsequent calls need to also pass the resource to the function.  Once you are done, you need to close the sessions.

This will have to be a new class of calls though as simply changing thing around will make life difficult for everyone.

TheWitness
 [2011-01-31 12:58 UTC] lytboris@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: lytboris
 [2011-01-31 12:58 UTC] lytboris@php.net
Please try using this snapshot:

  http://snaps.php.net/php-trunk-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

Please check OO API from trunk. It has an option to specify session-wise OID output format and more.

Sources in trunk can be compiled against downto php 5.2
 [2012-02-25 09:41 UTC] lytboris@php.net
-Status: Feedback +Status: No Feedback
 [2012-02-25 09:41 UTC] lytboris@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 [2014-01-05 15:19 UTC] php at painfullscratch dot nl
Bug still present in "PHP 5.3.10-1ubuntu3.9 with Suhosin-Patch (cli) (built: Dec 12 2013 04:27:25)".

$ cat snmp_get_quick_print.php 
<?php printf("snmp_get_quick_print: '%s' || %d\n", snmp_get_quick_print(), posix_getpid()); ?>

$ cat snmp_set_quick_print.php 
<?php printf("snmp_set_quick_print: '%s' || %d\n", snmp_set_quick_print(true), posix_getpid()); ?>

$ for (( i=0; i<5; i++ )) ; do links -dump http://localhost/snmp_get_quick_print.php; done
   snmp_get_quick_print: '' || 3458
   snmp_get_quick_print: '' || 3459
   snmp_get_quick_print: '' || 3460
   snmp_get_quick_print: '' || 3461
   snmp_get_quick_print: '' || 3462

$ links -dump http://localhost/snmp_set_quick_print.php
   snmp_set_quick_print: '' || 3458

$ for (( i=0; i<5; i++ )) ; do links -dump http://localhost/snmp_get_quick_print.php; done
   snmp_get_quick_print: '' || 3459
   snmp_get_quick_print: '' || 3460
   snmp_get_quick_print: '' || 3461
   snmp_get_quick_print: '' || 3462
   snmp_get_quick_print: '1' || 3458
 [2014-01-05 18:27 UTC] lytboris@php.net
This bug was fixed in branch 5.4 and not backported to any versions prior 5.4.
Please upgrade to 5.4.x or newer, this bug will not be fixed in 5.3.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Mon Apr 21 12:02:07 2014 UTC