I compiled this code and set snmpd.conf to pass an oid to the resulting executable. My /tmp/foo.txt shows the program has executed when I do an snmpget, but the snmpset output is the usual output.
prompt:
snmpset -c private -v1 localhost enterprises.40 i 5
output:
SNMPv2-SMI::enterprises.40 = INTEGER: 5


What am I doing wrong?

#include <stdio.h>

int main(int argc, char* argv[]) {
 FILE* foo = NULL; // write to a file
                            // so we know program
 if( argv[1][1] == 's') { // executed
   foo = fopen("/tmp/foo.txt","a");
   fprintf(foo, "not-writable\n");
   fclose(foo);

   printf("wrong-type");
   fflush(stdout);
 }
 return 1;

}



> Second, how do you return an error?  I've tried exit(4) but no error is
> displayed in the snmpset output.

The snmpd.conf man page isn't quite as clear as it might be, but
under the entry for "pass" SET handling, it says:

      Return  nothing  to  stdout,  and the set will assumed to
      have been successful.  Otherwise, return one of the  fol-
      lowing error strings to signal an error: not-writable, or
      wrong-type and the appropriate  error  response  will  be
      generated instead.

This holds true for "pass_persist" as well.
Anything else will be taken to indicate a successful SET.

You certainly don't want to call 'exit' - since that defeats the
whole point of "pass_persist" over "pass" in the first place!

Dave

_________________________________________________________________
Get ready for school! Find articles, homework help and more in the Back to School Guide! http://special.msn.com/network/04backtoschool.armx




-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
Net-snmp-users mailing list
[EMAIL PROTECTED]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to