--- BUILD/scotty-2.1.10/tnm/snmp/tnmSnmpRecv.c	Fri Jun 26 17:04:38 1998
+++ /u/orbis/tnmSnmpRecv.c	Fri Sep 22 19:40:46 2000
@@ -48,7 +48,8 @@
  */
 
 static int
-Authentic		_ANSI_ARGS_((SNMP_Session *session,
+Authentic		_ANSI_ARGS_((int need_wc,
+				     SNMP_Session *session,
 				     Message *msg, SNMP_PDU *pdu,
 				     u_char *packet, int packetlen,
 				     u_int **snmpStatPtr));
@@ -259,7 +260,7 @@
 		*reqid = pdu->request_id;
 	    }
 
-	    if (! Authentic(session, msg, pdu, packet, packetlen, NULL)) {
+	    if (! Authentic(0, session, msg, pdu, packet, packetlen, NULL)) {
 		Tcl_SetResult(interp, "authentication failure", TCL_STATIC);
 		Tcl_DStringFree(&pdu->varbind);
 		return TCL_CONTINUE;
@@ -288,7 +289,7 @@
 
 	    session = request->session;
 
-	    if (! Authentic(session, msg, pdu, packet, packetlen, NULL)) {
+	    if (! Authentic(0, session, msg, pdu, packet, packetlen, NULL)) {
 		Tcl_SetResult(interp, "authentication failure", TCL_STATIC);
 		Tcl_DStringFree(&pdu->varbind);
 		return TCL_CONTINUE;
@@ -341,7 +342,7 @@
 	    }
 	    if (session->version == TNM_SNMPv1 && bindPtr && bindPtr->command
 		&& (! session->agentSocket)
-		&& Authentic(session, msg, pdu, packet, packetlen, NULL)) {
+		&& Authentic(0, session, msg, pdu, packet, packetlen, NULL)) {
 		char *com = session->readCommunity;
 		session->readCommunity = ckalloc(msg->comLen+1);
 		memcpy(session->readCommunity, msg->com, msg->comLen);
@@ -360,7 +361,7 @@
 	    }
 	    if ((session->version & TNM_SNMPv2) && bindPtr && bindPtr->command
 		&& (! session->agentSocket)
-		&& Authentic(session, msg, pdu, packet, packetlen, NULL)) {
+		&& Authentic(0, session, msg, pdu, packet, packetlen, NULL)) {
 #ifdef TNM_SNMPv2C
 		char *com = session->readCommunity;
 		if (session->version == TNM_SNMPv2C) {
@@ -386,7 +387,7 @@
                 bindPtr = bindPtr->nextPtr;
             }
 	    if ((session->version & TNM_SNMPv2) && bindPtr && bindPtr->command
-                && Authentic(session, msg, pdu, packet, packetlen, NULL)) {
+                && Authentic(0, session, msg, pdu, packet, packetlen, NULL)) {
 #ifdef TNM_SNMPv2C
 		char *com = session->readCommunity;
 		if (session->version == TNM_SNMPv2C) {
@@ -419,8 +420,11 @@
 	  case TNM_SNMP_SET: 
 	    {
 		u_int *statPtr;
+		int need_write_community;
 		if (! session->agentSocket) break;
-		if (Authentic(session, msg, pdu, packet, packetlen, &statPtr)) {
+		need_write_community = (pdu->type == TNM_SNMP_SET);
+		if (Authentic(need_write_community, session, msg, pdu, packet,
+		    packetlen, &statPtr)) {
 		    if (Tnm_SnmpAgentRequest(interp, session, pdu) != TCL_OK) {
 			Tcl_DStringFree(&pdu->varbind);
 			return TCL_ERROR;
@@ -467,7 +471,8 @@
  */
 
 static int
-Authentic(session, msg, pdu, packet, packetlen, snmpStatPtr)
+Authentic(need_wc, session, msg, pdu, packet, packetlen, snmpStatPtr)
+    int need_wc;
     SNMP_Session *session;
     Message *msg;
     SNMP_PDU *pdu;
@@ -504,8 +509,10 @@
 	    break;
 	}
 	
-	authentic = ((strlen(community) == msg->comLen) &&
-		     (memcmp(community, msg->com, msg->comLen) == 0));
+	if (!need_wc) {
+		authentic = ((strlen(community) == msg->comLen) &&
+			     (memcmp(community, msg->com, msg->comLen) == 0));
+	}
 
 	/*
 	 * XXX
