I've created two patches (one for pass.c and the other for pass_persist.c) for the Net-SNMP version 5.4.pre4 files (but to be considered for a future 5.4.x release).

Basically I created the function check_set_error() which checks for possible error strings in response to a pass-through set request and that function is used for both pass and pass_persist.  I have added that function in pass.c as there are some other functions declared there that are common to both pass.c and pass_persist.c (such as asc2bin, bin2asc, etc).  I am not sure whether some error codes (for example "tooBig") make sense or will ever be used by a pass-through script/executable.  But I have included all the possible error codes for completeness.  Feel free to remove any which are defintely not applicable and should not be included.  And obviously feel free to add/modify/delete anything else as required.

The two patches are as follows.


*** net-snmp-5.4.pre4/agent/mibgroup/ucd-snmp/pass.c    Thu Aug 18 02:44:02 2005
--- patched/pass.c    Thu Oct 26 15:38:08 2006
***************
*** 151,156 ****
--- 151,203 ----
      return 3 * n - 1;
  }
 
+ /*
+  * This is also called from pass_persist.c
+  */
+ int
+ check_set_error(const char *buf)
+ {
+     if (!strncasecmp(buf, "too-big", 7)) {
+         return SNMP_ERR_TOOBIG;
+     } else if (!strncasecmp(buf, "no-such-name", 12)) {
+         return SNMP_ERR_NOSUCHNAME;
+     } else if (!strncasecmp(buf, "bad-value", 9)) {
+         return SNMP_ERR_BADVALUE;
+     } else if (!strncasecmp(buf, "read-only", 9)) {
+         return SNMP_ERR_READONLY;
+     } else if (!strncasecmp(buf, "gen-error", 9)) {
+         return SNMP_ERR_GENERR;
+     } else if (!strncasecmp(buf, "no-access", 9)) {
+         return SNMP_ERR_NOACCESS;
+     } else if (!strncasecmp(buf, "wrong-type", 10)) {
+         return SNMP_ERR_WRONGTYPE;
+     } else if (!strncasecmp(buf, "wrong-length", 12)) {
+         return SNMP_ERR_WRONGLENGTH;
+     } else if (!strncasecmp(buf, "wrong-encoding", 14)) {
+         return SNMP_ERR_WRONGENCODING;
+     } else if (!strncasecmp(buf, "wrong-value", 11)) {
+         return SNMP_ERR_WRONGVALUE;
+     } else if (!strncasecmp(buf, "no-creation", 11)) {
+         return SNMP_ERR_NOCREATION;
+     } else if (!strncasecmp(buf, "inconsistent-value", 18)) {
+         return SNMP_ERR_INCONSISTENTVALUE;
+     } else if (!strncasecmp(buf, "resource-unavailable", 20)) {
+         return SNMP_ERR_RESOURCEUNAVAILABLE;
+     } else if (!strncasecmp(buf, "commit-failed", 13)) {
+         return SNMP_ERR_COMMITFAILED;
+     } else if (!strncasecmp(buf, "undo-failed", 11)) {
+         return SNMP_ERR_UNDOFAILED;
+     } else if (!strncasecmp(buf, "authorization-error", 19)) {
+         return SNMP_ERR_AUTHORIZATIONERROR;
+     } else if (!strncasecmp(buf, "not-writable", 12)) {
+         return SNMP_ERR_NOTWRITABLE;
+     } else if (!strncasecmp(buf, "inconsistent-name", 17)) {
+         return SNMP_ERR_INCONSISTENTNAME;
+     }
+
+     return SNMP_ERR_NOERROR;
+ }
+
  void
  init_pass(void)
  {
***************
*** 514,525 ****
              exec_command(passthru);
              DEBUGMSGTL(("ucd-snmp/pass", "pass-running returned: %s",
                          passthru->output));
!             if (!strncasecmp(passthru->output, "not-writable", 12)) {
!                 return SNMP_ERR_NOTWRITABLE;
!             } else if (!strncasecmp(passthru->output, "wrong-type", 10)) {
!                 return SNMP_ERR_WRONGTYPE;
!             }
!             return SNMP_ERR_NOERROR;
          }
      }
      if (snmp_get_do_debugging()) {
--- 561,568 ----
              exec_command(passthru);
              DEBUGMSGTL(("ucd-snmp/pass", "pass-running returned: %s",
                          passthru->output));
!
!             return check_set_error(buf);
          }
      }
      if (snmp_get_do_debugging()) {


*** net-snmp-5.4.pre4/agent/mibgroup/ucd-snmp/pass_persist.c    Wed Oct 18 04:59:10 2006
--- patched/pass_persist.c    Thu Oct 26 15:40:40 2006
***************
*** 63,68 ****
--- 63,69 ----
  extern int      bin2asc(char *p, size_t n);
  extern int      snmp_oid_min_compare(const oid *, size_t, const oid *,
                                       size_t);
+ extern int      check_set_error(const char *buf);
 
  /*
   * the relocatable extensible commands variables
***************
*** 492,509 ****
                  return SNMP_ERR_NOTWRITABLE;
              }
 
!             if (!strncasecmp(buf, "not-writable", 12)) {
!                 return SNMP_ERR_NOTWRITABLE;
!             } else if (!strncasecmp(buf, "wrong-type", 10)) {
!                 return SNMP_ERR_WRONGTYPE;
!             } else if (!strncasecmp(buf, "wrong-length", 12)) {
!                 return SNMP_ERR_WRONGLENGTH;
!             } else if (!strncasecmp(buf, "wrong-value", 11)) {
!                 return SNMP_ERR_WRONGVALUE;
!             } else if (!strncasecmp(buf, "inconsistent-value", 18)) {
!                 return SNMP_ERR_INCONSISTENTVALUE;
!             }
!             return SNMP_ERR_NOERROR;
          }
      }
      if (snmp_get_do_debugging()) {
--- 493,499 ----
                  return SNMP_ERR_NOTWRITABLE;
              }
 
!             return check_set_error(buf);
          }
      }
      if (snmp_get_do_debugging()) {

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to