php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22723 snmp set does not work properly for shortened OID
Submitted: 2003-03-15 02:25 UTC Modified: 2003-05-02 17:26 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: jamuel at my740il dot com Assigned:
Status: Not a bug Package: SNMP related
PHP Version: 4.3.2RC1 OS: Linux 2.4.18
Private report: No CVE-ID: None
 [2003-03-15 02:25 UTC] jamuel at my740il dot com
with Net-SNMP v5.0.9pre1

snmpset always fails for shortened textual OIDs even though the same smmpset cmd (built from the netsnmp library) works correctly from the linux shell.  (Makes me think the problem is in PHP vs in Net-SNMP)

The failure text is:
Warning: snmpset() [http://www.php.net/function.snmpset]: Invalid object identifier: sysContact.0 in /var/www/html/set-test.php on line 16

Warning: snmpset() [http://www.php.net/function.snmpset]: Error in packet: (noSuchName) There is no such variable name in this MIB. in /var/www/html/set-test.php on line 16

Warning: snmpset() [http://www.php.net/function.snmpset]: This name does not exist: SNMPv2-SMI::internet in /var/www/html/set-test.php on line 16

(Please note the value is not set as well.)

Also, full text OIDs from the ".iso.org.dod . . ." root work just fine with snmpset (and so do full numeric OIDs).

FWIW, the shortened text OIDs *do* work correctly with snmpget.

Here's the line in php that fails:
echo snmpset ('10.1.1.1', 'private', 'sysContact.0', 's', 'My Name');

Thanks for your help . . .

JPS

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-03-15 23:04 UTC] sniper@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments
to the existing bug instead.

Thank you for your interest in PHP.

See Bug #22529

 [2003-03-19 17:40 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:42 UTC] jamuel at my740il dot com
that patch argument should be -p0 (a zero not an "oh").
 [2003-03-19 18:01 UTC] sniper@php.net
Please, leave this bogus and add any comments to the other report..
 [2003-05-02 16:11 UTC] jamuel at my740il dot com
This should be set to Duplicate not Bogus.
 [2003-05-02 17:26 UTC] derick@php.net
That is for *us* to decide, leave it bogus.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Jun 01 20:01:24 2020 UTC