~ubuntu-branches/ubuntu/trusty/net-snmp/trusty

« back to all changes in this revision

Viewing changes to agent/mibgroup/agentx/master.c

  • Committer: Bazaar Package Importer
  • Author(s): Jochen Friedrich
  • Date: 2009-11-12 16:17:40 UTC
  • mto: (1.4.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 32.
  • Revision ID: james.westby@ubuntu.com-20091112161740-t2xvix834vmtxa9f
Tags: upstream-5.4.2.1~dfsg
ImportĀ upstreamĀ versionĀ 5.4.2.1~dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
169
169
                netsnmp_sess_log_error(LOG_WARNING, buf, &sess);
170
170
            }
171
171
        } else {
 
172
#ifdef NETSNMP_TRANSPORT_UNIX_DOMAIN
 
173
            if (t->domain == netsnmp_UnixDomain && t->local != NULL) {
 
174
                char name[sizeof(struct sockaddr_un) + 1];
 
175
                memcpy(name, t->local, t->local_length);
 
176
                name[t->local_length] = '\0';
 
177
                /*
 
178
                 * Apply any settings to the ownership/permissions of the
 
179
                 * AgentX socket
 
180
                 */
 
181
                agentx_sock_perm =
 
182
                    netsnmp_ds_get_int(NETSNMP_DS_APPLICATION_ID,
 
183
                                       NETSNMP_DS_AGENT_X_SOCK_PERM);
 
184
                agentx_sock_user =
 
185
                    netsnmp_ds_get_int(NETSNMP_DS_APPLICATION_ID,
 
186
                                       NETSNMP_DS_AGENT_X_SOCK_USER);
 
187
                agentx_sock_group =
 
188
                    netsnmp_ds_get_int(NETSNMP_DS_APPLICATION_ID,
 
189
                                       NETSNMP_DS_AGENT_X_SOCK_GROUP);
 
190
 
 
191
                if (agentx_sock_perm != 0)
 
192
                    chmod(name, agentx_sock_perm);
 
193
 
 
194
                if (agentx_sock_user || agentx_sock_group) {
 
195
                    /*
 
196
                     * If either of user or group haven't been set,
 
197
                     *  then leave them unchanged.
 
198
                     */
 
199
                    if (agentx_sock_user == 0 )
 
200
                        agentx_sock_user = -1;
 
201
                    if (agentx_sock_group == 0 )
 
202
                        agentx_sock_group = -1;
 
203
                    chown(name, agentx_sock_user, agentx_sock_group);
 
204
                }
 
205
            }
 
206
#endif
172
207
            session =
173
208
                snmp_add_full(&sess, t, NULL, agentx_parse, NULL, NULL,
174
209
                              agentx_realloc_build, agentx_check_packet, NULL);
176
211
        if (session == NULL) {
177
212
            netsnmp_transport_free(t);
178
213
        }
179
 
 
180
 
#ifdef NETSNMP_TRANSPORT_UNIX_DOMAIN
181
 
        /*
182
 
         * Apply any settings to the ownership/permissions of the AgentX socket
183
 
         */
184
 
        agentx_sock_perm = netsnmp_ds_get_int(NETSNMP_DS_APPLICATION_ID,
185
 
                                              NETSNMP_DS_AGENT_X_SOCK_PERM);
186
 
        agentx_sock_user = netsnmp_ds_get_int(NETSNMP_DS_APPLICATION_ID,
187
 
                                              NETSNMP_DS_AGENT_X_SOCK_USER);
188
 
        agentx_sock_group = netsnmp_ds_get_int(NETSNMP_DS_APPLICATION_ID,
189
 
                                               NETSNMP_DS_AGENT_X_SOCK_GROUP);
190
 
 
191
 
        if (agentx_sock_perm != 0)
192
 
            chmod(sess.peername, agentx_sock_perm);
193
 
        if (agentx_sock_user || agentx_sock_group) {
194
 
            /*
195
 
             * If either of user or group haven't been set,
196
 
             *  then leave them unchanged.
197
 
             */
198
 
            if (agentx_sock_user == 0 )
199
 
                agentx_sock_user = -1;
200
 
            if (agentx_sock_group == 0 )
201
 
                agentx_sock_group = -1;
202
 
            chown(sess.peername, agentx_sock_user, agentx_sock_group);
203
 
        }
204
 
#endif
205
214
    }
206
215
 
207
216
    SNMP_FREE(agentx_sockets);
338
347
        ret = 0;
339
348
        for (request = requests, i = 1; request;
340
349
             request = request->next, i++) {
341
 
            if (request->index == pdu->errindex) {
 
350
            if (i == pdu->errindex) {
342
351
                /*
343
 
                 * mark this one as the one generating the error
 
352
                 * Mark this varbind as the one generating the error.
 
353
                 * Note that the AgentX errindex may not match the
 
354
                 * position in the original SNMP PDU (request->index)
344
355
                 */
345
356
                netsnmp_set_request_error(cache->reqinfo, request,
346
357
                                          err);
443
454
    netsnmp_request_info *request = requests;
444
455
    netsnmp_pdu    *pdu;
445
456
    void           *cb_data;
 
457
    int             result;
446
458
 
447
459
    DEBUGMSGTL(("agentx/master",
448
460
                "agentx master handler starting, mode = 0x%02x\n",
605
617
     */
606
618
    DEBUGMSGTL(("agentx", "sending pdu (req=0x%x,trans=0x%x,sess=0x%x)\n",
607
619
                pdu->reqid,pdu->transid, pdu->sessid));
608
 
    snmp_async_send(ax_session, pdu, agentx_got_response, cb_data);
 
620
    result = snmp_async_send(ax_session, pdu, agentx_got_response, cb_data);
 
621
 
 
622
    if (result == 0 ) {
 
623
        snmp_free_pdu( pdu );
 
624
    }
609
625
 
610
626
    return SNMP_ERR_NOERROR;
611
627
}