php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22529 snmpset is not working
Submitted: 2003-03-04 00:22 UTC Modified: 2003-07-15 23:55 UTC
Votes:5
Avg. Score:4.8 ± 0.4
Reproduced:5 of 5 (100.0%)
Same Version:1 (20.0%)
Same OS:1 (20.0%)
From: mb at solstaden dot net Assigned:
Status: Closed Package: SNMP related
PHP Version: 4CVS-2003-03-04 (stable) OS: FreeBSD 4.8 Prerelease
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mb at solstaden dot net
New email:
PHP Version: OS:

 

 [2003-03-04 00:22 UTC] mb at solstaden dot net
I tried a verey simple php script:

echo snmpget( "81.26.237.10", "public", "system.sysContact.0" );

snmpset( "81.26.237.10", "private", "system.sysContact.0", "s", "kalle" );

snmpget works:

snmpset fails:

ouput as follows:

STRING: mb@solstaden.net
Warning: snmpset() [function.snmpset]: Invalid object identifier: system.sysContact.0 in /usr/local/www/data/snmp.php on line 17

Warning: snmpset() [function.snmpset]: Error in packet: (noSuchName) There is no such variable name in this MIB. in /usr/local/www/data/snmp.php on line 17

Warning: snmpset() [function.snmpset]: This name does not exist: SNMPv2-SMI::mib-2 in /usr/local/www/data/snmp.php on line 17

I did a tcpdump:

07:04:22.160998 gk.s.port80.se.1556 > as1-1-1--11.eklandahage4.molndal.bostream.net.snmp:  GetRequest(28)  system.sysDescr.0
07:04:22.179314 as1-1-1--11.eklandahage4.molndal.bostream.net.snmp > gk.s.port80.se.1556:  GetResponse(39)  system.sysDescr.0="Ericsson DR"
07:04:22.180077 gk.s.port80.se.1557 > as1-1-1--11.eklandahage4.molndal.bostream.net.snmp:  GetRequest(28)  system.sysContact.0
07:04:22.194298 as1-1-1--11.eklandahage4.molndal.bostream.net.snmp > gk.s.port80.se.1557:  GetResponse(39)  system.sysContact.0="mb@solstade"
07:04:22.194991 gk.s.port80.se.1558 > as1-1-1--11.eklandahage4.molndal.bostream.net.snmp:  C=private SetRequest(30)  ="kalle"
07:04:22.209407 as1-1-1--11.eklandahage4.molndal.bostream.net.snmp > gk.s.port80.se.1558:  C=private GetResponse(30)  noSuchName@1 ="kalle"

Am I doing anything wrong? Normally it is my fault.
If u think I have found a bug, I will do my best to
help u.

Magnus Benngard






Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-03-04 04:12 UTC] mb at solstaden dot net
Hi!

I found out that, instead of typing in the OID as a string,

system.sysContact.0, u type it as numeric, .1.3.6.1.2.1.1.4.0

then it snmpset works.

Does not help me much but maybe some smarter person.

/Magnus
 [2003-03-05 00:21 UTC] mb at solstaden dot net
I did upgrade!

Sorry to say, same error.
I tried with system.sysContact.0 and sysCobtact.0

Warning: snmpset() [function.snmpset]: Invalid object identifier: system.sysContact.0 in /usr/local/www/data/snmp.php on line 27

Warning: snmpset() [function.snmpset]: Error in packet: (noSuchName) There is no such variable name in this MIB. in /usr/local/www/data/snmp.php on line 27

Warning: snmpset() [function.snmpset]: This name does not exist: SNMPv2-SMI::mib-2 in /usr/local/www/data/snmp.php on line 27

Magnus
 [2003-03-12 16:06 UTC] jamuel at my740il dot com
I am getting the same error message with the latest (today's) 4.3 snap
shot.  From a php script I can either specify the entire OID
numerically or the entire symbolic OID--I just can't use the shortened
symbolic OID:

snmpset("10.1.1.1", "private", ".1.3.6.1.2.1.1.5.0", "s", "MyBox") <--
works OK

snmpset("10.1.1.1", "private",
".iso.org.dod.internet.mgmt.mib-2.system.sysName.0", "s", "MyBox") <--
works OK

snmpset("10.1.1.1", "private", "system.sysName.0", "s", "MyBox") <--
BROKEN

snmpset("10.1.1.1", "private", "sysName.0", "s", "MyBox") <-- BROKEN

Linux 2.4
NetSNMP 5.0.8-pre1
PHP 4.3.2-dev [from phpinfo()]

Any help would be appreciated.

Regards,

JPS
 [2003-03-19 17:38 UTC] jamuel at my740il dot com
Ok so the following patch resolves the issue on my system.  Not really sure why the existing function call fails but regardless snmpset now works correctly with shortened textual oids, full textual oids, and full numeric oids.  I also tested snmpget and it works fine as well.

--- snmp.c      Fri Feb 21 02:42:01 2003
+++ snmp.c      Tue Mar 18 13:58:48 2003
@@ -217,7 +217,7 @@ static void php_snmp_internal(INTERNAL_F
        if (st >= 2) { /* walk */
                rootlen = MAX_NAME_LEN;
                if (strlen(objid)) { /* on a walk, an empty string means top of tree
- no error */
-                       if (read_objid(objid, root, &rootlen)) {
+                       if (snmp_parse_oid(objid, root, &rootlen)) {
                                gotroot = 1;
                        } else {
                                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid
object identifier: %s", objid);


Do a patch -po -l from the ../ext/snmp directory and paste the above patch-text into patch, press <CTRL-D> twice to exit patch and you should see "patching file snmp.c".  cd back to the root of the PHP-4 source directory, make clean, make all, make install and you should be in business!

BTW, no really sure how this form will mangle the patch-text but it's really only a one line change.  So you could just manually edit the snmp.c file and look for line 220 and make the change from read_objid to snmp_parse_oid (the parameters remain unchanged.)

Hope that helps . . .


Cheers,

JPS
 [2003-03-19 17:44 UTC] jamuel at my740il dot com
That patch argument should be -p0 (a zero not an "oh").

FWIW, the diff was from PHP-4.3.2 RC1

Cheers,

JPS
 [2003-07-12 23:45 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip

And if it fails, try the patch above.

 [2003-07-15 23:55 UTC] sniper@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 22:01:29 2024 UTC