Hello.

The attached patche adds an -x <path> option to snmptrapd so that the location
of the agentx socket can be specified.

The reson I needed this is that test T052 fails if there is an master agent
running on the machine, using this I can tell the snmptrapd that the agentx
socket is somewhere else.

Please look at this as a working idea, I suppose the unknown path could be
changed to a better name and I am not certain about the choice of flag
either.

/MF
Index: apps/snmptrapd.c
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/apps/snmptrapd.c,v
retrieving revision 5.36
diff -u -r5.36 snmptrapd.c
--- apps/snmptrapd.c    24 Aug 2004 16:19:11 -0000      5.36
+++ apps/snmptrapd.c    2 Sep 2004 11:46:39 -0000
@@ -337,6 +337,7 @@
     fprintf(stderr, "  -unregister\t\tunregister as a Windows service\n");
 #endif
     fprintf(stderr, "  -v, --version\t\tdisplay version information\n");
+    fprintf(stderr, "  -x SOCKET\t\tname of the agentx socket to use\n");
     fprintf(stderr,
             "  -O <OUTOPTS>\t\ttoggle options controlling output display\n");
     snmp_out_toggle_options_usage("\t\t\t", stderr);
@@ -569,7 +570,7 @@
 main(int argc, char *argv[])
 #endif
 {
-    char            options[128] = "ac:CdD::efF:hHl:L:m:M:no:PqsS:tvO:-:";
+    char            options[128] = "ac:CdD::efF:hHl:L:m:M:no:PqsS:tvx:O:-:";
     netsnmp_session *sess_list = NULL, *ss = NULL;
     netsnmp_transport *transport = NULL;
     int             arg, i = 0;
@@ -840,6 +841,15 @@
             exit(0);
             break;
 
+        case 'x':
+            if (optarg != NULL) {
+                netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID, 
+                                     NETSNMP_DS_AGENT_X_SOCKET, optarg);
+            } else {
+                usage();
+            }
+           break;
+
         default:
             fprintf(stderr, "invalid option: -%c\n", arg);
             usage();
Index: testing/tests/T052snmpv2cinform
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/testing/tests/T052snmpv2cinform,v
retrieving revision 5.2
diff -u -r5.2 T052snmpv2cinform
--- testing/tests/T052snmpv2cinform     16 Apr 2004 23:37:56 -0000      5.2
+++ testing/tests/T052snmpv2cinform     2 Sep 2004 11:46:39 -0000
@@ -10,6 +10,8 @@
 # Begin test
 #
 
+TRAPD_FLAGS="$TRAPD_FLAGS -x /no/such/path"
+
 STARTTRAPD
 
 CAPTURE "snmptrap -Ci -d -v 2c -c testcommunity 
$SNMP_TRANSPORT_SPEC:$SNMP_TEST_DEST$SNMP_SNMPTRAPD_PORT 0 .1.3.6.1.6.3.1.1.5.1 
system.sysContact.0 s blah"

Reply via email to