Subject: | Net-SNMP doesn't error properly when snmp connection credentials are incorrect |
From: | anexiole [...] gmail.com |
this is further describing https://rt.cpan.org/Public/Bug/Display.html?id=124733.
When given a set of connection credentials (ie. community string, user id, auth/priv protocols(v3), and so forth), the package
1) Does not return an error , nor does it die (thus allowing for error exceptions to be caught)
When I was working on an snmp v3 device, I purposedly configured the privProtocol to be AES and I tried to createa SNMP session using this package with priv protocol of DES. Result?
The session object was still passed back and when I did snmp gets, it passed by just giving back an empty ''.
This should not been the case because the session should have failed in the first place due to a faulty credential attribute (being the privProtocol).
I then put in debugging statements into the SNMP.pm file and found that it was PDU errors which were masked off.
Please fix.
2) It clears its errors unnecessarily ..
Take for example in Session.pm's constructor, look at lines 356 - 369:
356 # We must validate the object type to prevent blocking and
357 # non-blocking object from existing at the same time.
358
359 if (!defined $this->_object_type_validate()) {
360 return wantarray ? (undef, $this->{_error}) : undef;
361 }
362
363 # Create a Security Model object
364
365 ($this->{_security}, $this->{_error}) = Net::SNMP::Security->new(%argv);
366 if (!defined $this->{_security}) {
367 return wantarray ? (undef, $this->{_error}) : undef;
368 }
369 $this->_error_clear();
370
371 # Return the object and empty error message (in list context)
372 return wantarray ? ($this, q{}) : $this;
373 }
why are we even clearing the error in line 369? If there was an error, it would have been returned by line 367 .