Hello.

The attached diff fixes bug 1793545 but it does so at the cost of
fiddling inside the transport so I am uncertain of how good it is.
There is smell coming from that patch.

Do anyone have any comments on it? Should I apply it?

/MF
Index: agent/mibgroup/agentx/master.c
===================================================================
--- agent/mibgroup/agentx/master.c	(revision 16698)
+++ agent/mibgroup/agentx/master.c	(working copy)
@@ -169,6 +169,41 @@
                 netsnmp_sess_log_error(LOG_WARNING, buf, &sess);
             }
         } else {
+#ifdef NETSNMP_TRANSPORT_UNIX_DOMAIN
+            if (t->domain == netsnmp_UnixDomain && t->local != NULL) {
+                char name[sizeof(struct sockaddr_un) + 1];
+                memcpy(name, t->local, t->local_length);
+                name[t->local_length] = '\0';
+                /*
+                 * Apply any settings to the ownership/permissions of the
+                 * AgentX socket
+                 */
+                agentx_sock_perm =
+                    netsnmp_ds_get_int(NETSNMP_DS_APPLICATION_ID,
+                                       NETSNMP_DS_AGENT_X_SOCK_PERM);
+                agentx_sock_user =
+                    netsnmp_ds_get_int(NETSNMP_DS_APPLICATION_ID,
+                                       NETSNMP_DS_AGENT_X_SOCK_USER);
+                agentx_sock_group =
+                    netsnmp_ds_get_int(NETSNMP_DS_APPLICATION_ID,
+                                       NETSNMP_DS_AGENT_X_SOCK_GROUP);
+
+                if (agentx_sock_perm != 0)
+                    chmod(name, agentx_sock_perm);
+
+                if (agentx_sock_user || agentx_sock_group) {
+                    /*
+                     * If either of user or group haven't been set,
+                     *  then leave them unchanged.
+                     */
+                    if (agentx_sock_user == 0 )
+                        agentx_sock_user = -1;
+                    if (agentx_sock_group == 0 )
+                        agentx_sock_group = -1;
+                    chown(name, agentx_sock_user, agentx_sock_group);
+                }
+            }
+#endif
             session =
                 snmp_add_full(&sess, t, NULL, agentx_parse, NULL, NULL,
                               agentx_realloc_build, agentx_check_packet, NULL);
@@ -176,32 +211,6 @@
         if (session == NULL) {
             netsnmp_transport_free(t);
         }
-
-#ifdef NETSNMP_TRANSPORT_UNIX_DOMAIN
-        /*
-         * Apply any settings to the ownership/permissions of the AgentX socket
-         */
-        agentx_sock_perm = netsnmp_ds_get_int(NETSNMP_DS_APPLICATION_ID,
-                                              NETSNMP_DS_AGENT_X_SOCK_PERM);
-        agentx_sock_user = netsnmp_ds_get_int(NETSNMP_DS_APPLICATION_ID,
-                                              NETSNMP_DS_AGENT_X_SOCK_USER);
-        agentx_sock_group = netsnmp_ds_get_int(NETSNMP_DS_APPLICATION_ID,
-                                               NETSNMP_DS_AGENT_X_SOCK_GROUP);
-
-        if (agentx_sock_perm != 0)
-            chmod(sess.peername, agentx_sock_perm);
-        if (agentx_sock_user || agentx_sock_group) {
-            /*
-             * If either of user or group haven't been set,
-             *  then leave them unchanged.
-             */
-            if (agentx_sock_user == 0 )
-                agentx_sock_user = -1;
-            if (agentx_sock_group == 0 )
-                agentx_sock_group = -1;
-            chown(sess.peername, agentx_sock_user, agentx_sock_group);
-        }
-#endif
     }
 
     SNMP_FREE(agentx_sockets);
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to