diff options
author | harti <harti@FreeBSD.org> | 2004-04-14 16:20:14 +0000 |
---|---|---|
committer | harti <harti@FreeBSD.org> | 2004-04-14 16:20:14 +0000 |
commit | 2dce00c891322ea0439dacc8b83fa1965ba5c2dc (patch) | |
tree | 4ab07393a68643de15ecd9eb3d4baa678839c746 /contrib/bsnmp/snmpd | |
parent | c1b6f5303fde40ed2a5a4dfd652664a790b6d77d (diff) | |
download | FreeBSD-src-2dce00c891322ea0439dacc8b83fa1965ba5c2dc.zip FreeBSD-src-2dce00c891322ea0439dacc8b83fa1965ba5c2dc.tar.gz |
Import of bsnmpd 1.6
Diffstat (limited to 'contrib/bsnmp/snmpd')
-rw-r--r-- | contrib/bsnmp/snmpd/BEGEMOT-SNMPD.txt | 10 | ||||
-rw-r--r-- | contrib/bsnmp/snmpd/action.c | 53 | ||||
-rw-r--r-- | contrib/bsnmp/snmpd/bsnmpd.1 | 10 | ||||
-rw-r--r-- | contrib/bsnmp/snmpd/config.c | 4 | ||||
-rw-r--r-- | contrib/bsnmp/snmpd/main.c | 10 | ||||
-rw-r--r-- | contrib/bsnmp/snmpd/snmpd.config | 8 | ||||
-rw-r--r-- | contrib/bsnmp/snmpd/snmpmod.3 | 4 | ||||
-rw-r--r-- | contrib/bsnmp/snmpd/trans_lsock.c | 44 | ||||
-rw-r--r-- | contrib/bsnmp/snmpd/trap.c | 21 |
9 files changed, 69 insertions, 95 deletions
diff --git a/contrib/bsnmp/snmpd/BEGEMOT-SNMPD.txt b/contrib/bsnmp/snmpd/BEGEMOT-SNMPD.txt index 76fcbd5..039b4fe 100644 --- a/contrib/bsnmp/snmpd/BEGEMOT-SNMPD.txt +++ b/contrib/bsnmp/snmpd/BEGEMOT-SNMPD.txt @@ -30,7 +30,7 @@ -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- --- $Begemot: bsnmp/snmpd/BEGEMOT-SNMPD.txt,v 1.21 2003/12/09 12:28:52 hbb Exp $ +-- $Begemot: bsnmp/snmpd/BEGEMOT-SNMPD.txt,v 1.22 2004/04/13 15:21:46 novo Exp $ -- -- Begemot Private SNMPd MIB. -- @@ -38,7 +38,7 @@ BEGEMOT-SNMPD-MIB DEFINITIONS ::= BEGIN IMPORTS MODULE-IDENTITY, OBJECT-TYPE, OBJECT-IDENTITY, Counter32, - Unsigned32 + Unsigned32, IpAddress FROM SNMPv2-SMI TEXTUAL-CONVENTION, TruthValue, RowStatus FROM SNMPv2-TC @@ -144,7 +144,7 @@ begemotSnmpdVersionEnable OBJECT-TYPE 0x00000001 - SNMPv1 0x00000002 - SNMPv2c" - DEFVAL { 0x3 } + DEFVAL { 3 } ::= { begemotSnmpdConfig 5 } -- @@ -475,7 +475,7 @@ begemotSnmpdLocalPortEntry OBJECT-TYPE BegemotSnmpdLocalPortEntry ::= SEQUENCE { begemotSnmpdLocalPortPath OCTET STRING, - begemotSnmpdLocalPortStatus INTEGER + begemotSnmpdLocalPortStatus INTEGER, begemotSnmpdLocalPortType INTEGER } @@ -536,7 +536,7 @@ begemotSnmpdTransportEntry OBJECT-TYPE BegemotSnmpdTransportEntry ::= SEQUENCE { begemotSnmpdTransportName OCTET STRING, - begemotSnmpdTransportStatus INTEGER + begemotSnmpdTransportStatus INTEGER, begemotSnmpdTransportOid OBJECT IDENTIFIER } diff --git a/contrib/bsnmp/snmpd/action.c b/contrib/bsnmp/snmpd/action.c index 0fee3b9..521a5ae 100644 --- a/contrib/bsnmp/snmpd/action.c +++ b/contrib/bsnmp/snmpd/action.c @@ -30,7 +30,7 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Begemot: bsnmp/snmpd/action.c,v 1.56 2003/12/09 12:28:52 hbb Exp $ + * $Begemot: bsnmp/snmpd/action.c,v 1.57 2004/04/13 14:58:46 novo Exp $ * * Variable access for SNMPd */ @@ -730,26 +730,6 @@ struct module_dep { struct lmodule *m; }; -static void -finish_unload(struct snmp_context *ctx __unused, int fail, void *arg) -{ - struct lmodule *m = arg; - - if (!fail) { - lm_unload(m); - } -} - -static void -finish_load(struct snmp_context *ctx __unused, int fail, void *arg) -{ - struct lmodule *m = arg; - - if (!fail) { - lm_start(m); - } -} - static int dep_modules(struct snmp_context *ctx, struct snmp_dependency *dep, enum snmp_depop op) @@ -762,31 +742,44 @@ dep_modules(struct snmp_context *ctx, struct snmp_dependency *dep, if (mdep->path == NULL) { /* unload - find the module */ TAILQ_FOREACH(mdep->m, &lmodules, link) - if (strcmp(mdep->m->section, mdep->section) == 0) + if (strcmp(mdep->m->section, + mdep->section) == 0) break; if (mdep->m == NULL) + /* no such module - that's ok */ return (SNMP_ERR_NOERROR); - if (snmp_set_atfinish(ctx, finish_unload, mdep->m)) - return (SNMP_ERR_RES_UNAVAIL); + + /* handle unloading in the finalizer */ return (SNMP_ERR_NOERROR); } /* load */ - if ((mdep->m = lm_load(mdep->path, mdep->section)) == NULL) - return (SNMP_ERR_RES_UNAVAIL); - if (snmp_set_atfinish(ctx, finish_load, mdep->m)) { - lm_unload(mdep->m); + if ((mdep->m = lm_load(mdep->path, mdep->section)) == NULL) { + /* could not load */ return (SNMP_ERR_RES_UNAVAIL); } + /* start in finalizer */ return (SNMP_ERR_NOERROR); case SNMP_DEPOP_ROLLBACK: if (mdep->path == NULL) { - /* rollback unload - the finish function takes care */ + /* rollback unload - the finalizer takes care */ return (SNMP_ERR_NOERROR); } /* rollback load */ lm_unload(mdep->m); return (SNMP_ERR_NOERROR); + + case SNMP_DEPOP_FINISH: + if (mdep->path == NULL) { + if (mdep->m != NULL && ctx->code == SNMP_RET_OK) + lm_unload(mdep->m); + } else { + if (mdep->m != NULL && ctx->code == SNMP_RET_OK && + community != COMM_INITIALIZE) + lm_start(mdep->m); + free(mdep->path); + } + return (SNMP_ERR_NOERROR); } abort(); } @@ -900,8 +893,6 @@ op_modules(struct snmp_context *ctx, struct snmp_value *value, return (SNMP_ERR_NOERROR); case SNMP_OP_ROLLBACK: - /* must be module path */ - free(ctx->scratch->ptr1); case SNMP_OP_COMMIT: return (SNMP_ERR_NOERROR); diff --git a/contrib/bsnmp/snmpd/bsnmpd.1 b/contrib/bsnmp/snmpd/bsnmpd.1 index 334ac18..81562b7 100644 --- a/contrib/bsnmp/snmpd/bsnmpd.1 +++ b/contrib/bsnmp/snmpd/bsnmpd.1 @@ -30,7 +30,7 @@ .\" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, .\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.\" $Begemot: bsnmp/snmpd/bsnmpd.1,v 1.1 2003/12/03 10:08:33 hbb Exp $ +.\" $Begemot: bsnmp/snmpd/bsnmpd.1,v 1.3 2004/04/13 17:01:31 novo Exp $ .\" .Dd August 15, 2002 .Dt SNMPD 1 @@ -239,9 +239,9 @@ is Default pid file. .It Pa /etc:/usr/etc/:/usr/local/etc This is the default search path for system include files. -.It Pa /usr/local/share/snmp/mibs/FOKUS-MIB.txt -.It Pa /usr/local/share/snmp/mibs/BEGEMOT-MIB.txt -.It Pa /usr/local/share/snmp/mibs/BEGEMOT-SNMPD.txt +.It Pa @MIBSPATH@FOKUS-MIB.txt +.It Pa @MIBSPATH@BEGEMOT-MIB.txt +.It Pa @MIBSPATH@BEGEMOT-SNMPD.txt The definitions for the MIBs implemented in the daemon. .El .Sh SEE ALSO @@ -251,6 +251,6 @@ The .Nm conforms to the applicable IETF RFCs. .Sh AUTHORS -.An Hartmut Brandt Aq brandt@fokus.gmd.de +.An Hartmut Brandt Aq harti@freebsd.org .Sh BUGS Sure. diff --git a/contrib/bsnmp/snmpd/config.c b/contrib/bsnmp/snmpd/config.c index 4001156..223c675 100644 --- a/contrib/bsnmp/snmpd/config.c +++ b/contrib/bsnmp/snmpd/config.c @@ -30,7 +30,7 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Begemot: bsnmp/snmpd/config.c,v 1.19 2003/12/03 10:08:47 hbb Exp $ + * $Begemot: bsnmp/snmpd/config.c,v 1.20 2004/04/13 14:58:46 novo Exp $ * * Parse configuration file. */ @@ -1328,6 +1328,8 @@ read_config(const char *fname, struct lmodule *lodmod) } do_commit(); + snmp_dep_finish(snmp_ctx); + macro_free_all(); free(snmp_ctx); diff --git a/contrib/bsnmp/snmpd/main.c b/contrib/bsnmp/snmpd/main.c index 1a528ac..df879fe 100644 --- a/contrib/bsnmp/snmpd/main.c +++ b/contrib/bsnmp/snmpd/main.c @@ -30,7 +30,7 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Begemot: bsnmp/snmpd/main.c,v 1.82 2003/12/09 12:28:52 hbb Exp $ + * $Begemot: bsnmp/snmpd/main.c,v 1.85 2004/04/14 15:39:14 novo Exp $ * * SNMPd main stuff. */ @@ -840,7 +840,7 @@ recv_dgram(struct port_input *pi) cmsg.hdr.cmsg_type = SCM_CREDS; } else { msg.msg_control = NULL; - msg.msg_controllen = NULL; + msg.msg_controllen = 0; } msg.msg_flags = 0; @@ -2015,14 +2015,14 @@ tree_merge(const struct snmp_node *ntree, u_int nsize, struct lmodule *mod) xtree = realloc(tree, sizeof(*tree) * (tree_size + nsize)); if (xtree == NULL) { - syslog(LOG_ERR, "lm_load: %m"); + syslog(LOG_ERR, "tree_merge: %m"); return (-1); } tree = xtree; memcpy(&tree[tree_size], ntree, sizeof(*tree) * nsize); for (i = 0; i < nsize; i++) - tree[tree_size + i].data = mod; + tree[tree_size + i].tree_data = mod; tree_size += nsize; @@ -2040,7 +2040,7 @@ tree_unmerge(struct lmodule *mod) u_int s, d; for(s = d = 0; s < tree_size; s++) - if (tree[s].data != mod) { + if (tree[s].tree_data != mod) { if (s != d) tree[d] = tree[s]; d++; diff --git a/contrib/bsnmp/snmpd/snmpd.config b/contrib/bsnmp/snmpd/snmpd.config index 3b2e2f5..62bcb57 100644 --- a/contrib/bsnmp/snmpd/snmpd.config +++ b/contrib/bsnmp/snmpd/snmpd.config @@ -30,7 +30,7 @@ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -# $Begemot: bsnmp/snmpd/snmpd.config,v 1.12 2003/12/03 10:08:47 hbb Exp $ +# $Begemot: bsnmp/snmpd/snmpd.config,v 1.13 2004/04/13 15:00:00 novo Exp $ # # Example configuration file. # @@ -68,9 +68,9 @@ begemotSnmpdPortStatus.127.0.0.1.161 = 1 begemotSnmpdLocalPortStatus."/var/run/snmpd.sock" = 1 # send traps to the traphost -begemotTrapSinkStatus[$(traphost)].$(trapport) = 4 -begemotTrapSinkVersion[$(traphost)].$(trapport) = 2 -begemotTrapSinkComm[$(traphost)].$(trapport) = $(trap) +begemotTrapSinkStatus.[$(traphost)].$(trapport) = 4 +begemotTrapSinkVersion.[$(traphost)].$(trapport) = 2 +begemotTrapSinkComm.[$(traphost)].$(trapport) = $(trap) sysContact = $(contact) sysLocation = $(location) diff --git a/contrib/bsnmp/snmpd/snmpmod.3 b/contrib/bsnmp/snmpd/snmpmod.3 index be0136c..9877673 100644 --- a/contrib/bsnmp/snmpd/snmpmod.3 +++ b/contrib/bsnmp/snmpd/snmpmod.3 @@ -30,7 +30,7 @@ .\" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, .\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.\" $Begemot: bsnmp/snmpd/snmpmod.3,v 1.5 2003/12/08 16:55:58 hbb Exp $ +.\" $Begemot: bsnmp/snmpd/snmpmod.3,v 1.6 2004/04/13 15:22:52 novo Exp $ .\" .Dd August 16, 2002 .Dt snmpmod 3 @@ -864,4 +864,4 @@ beginning at position This implementation conforms to the applicable IETF RFCs and ITU-T recommendations. .Sh AUTHORS -.An Hartmut Brandt Aq brandt@fokus.gmd.de +.An Hartmut Brandt Aq harti@freebsd.org diff --git a/contrib/bsnmp/snmpd/trans_lsock.c b/contrib/bsnmp/snmpd/trans_lsock.c index 1e0da59..ad1826b 100644 --- a/contrib/bsnmp/snmpd/trans_lsock.c +++ b/contrib/bsnmp/snmpd/trans_lsock.c @@ -30,7 +30,7 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Begemot: bsnmp/snmpd/trans_lsock.c,v 1.3 2003/12/09 12:28:53 hbb Exp $ + * $Begemot: bsnmp/snmpd/trans_lsock.c,v 1.4 2004/04/13 14:58:46 novo Exp $ * * Local domain socket transport */ @@ -90,7 +90,7 @@ lsock_stop(int force) if (my_trans != NULL) { if (!force && trans_first_port(my_trans) != NULL) return (SNMP_ERR_GENERR); - trans_iter_port(my_trans, lsock_remove, NULL); + trans_iter_port(my_trans, lsock_remove, 0); return (trans_unregister(my_trans)); } return (SNMP_ERR_NOERROR); @@ -117,10 +117,9 @@ lsock_open_port(u_char *name, size_t namelen, struct lsock_port **pp, int err; struct sockaddr_un sa; - if (namelen == 0 || namelen + 1 > sizeof(sa.sun_path)) { - free(name); + if (namelen == 0 || namelen + 1 > sizeof(sa.sun_path)) return (SNMP_ERR_BADVALUE); - } + switch (type) { case LOCP_DGRAM_UNPRIV: is_stream = 0; @@ -143,25 +142,21 @@ lsock_open_port(u_char *name, size_t namelen, struct lsock_port **pp, break; default: - free(name); return (SNMP_ERR_BADVALUE); } - if ((port = malloc(sizeof(*port))) == NULL) { - free(name); + if ((port = malloc(sizeof(*port))) == NULL) return (SNMP_ERR_GENERR); - } + memset(port, 0, sizeof(*port)); if (!is_stream) { if ((peer = malloc(sizeof(*peer))) == NULL) { - free(name); free(port); return (SNMP_ERR_GENERR); } memset(peer, 0, sizeof(*peer)); } if ((port->name = malloc(namelen + 1)) == NULL) { - free(name); free(port); if (!is_stream) free(peer); @@ -444,18 +439,7 @@ struct lsock_dep { #define LD_TYPE 0x01 #define LD_STATUS 0x02 #define LD_CREATE 0x04 /* rollback create */ - -/* - * Finish handler for deleting a port - this cannot fail :-) - */ -static void -lsock_del(struct snmp_context *ctx __unused, int fail, void *arg) -{ - struct lsock_dep *ld = (struct lsock_dep *)(void *)arg; - - if (!fail) - lsock_close_port(&ld->port->tport); -} +#define LD_DELETE 0x08 /* rollback delete */ /* * dependency handler for lsock ports @@ -484,16 +468,12 @@ lsock_func(struct snmp_context *ctx, struct snmp_dependency *dep, ld->set |= LD_CREATE; } } else if (!ld->status) { - /* delete - hard to roll back so defer to - * finish handler */ - if (snmp_set_atfinish(ctx, lsock_del, ld->port)) - err = SNMP_ERR_RES_UNAVAIL; + /* delete - hard to roll back so defer to finalizer */ + ld->set |= LD_DELETE; } else /* modify - read-only */ err = SNMP_ERR_READONLY; - free(ld->path); - ld->path = NULL; return (err); case SNMP_DEPOP_ROLLBACK: @@ -502,6 +482,12 @@ lsock_func(struct snmp_context *ctx, struct snmp_dependency *dep, lsock_close_port(&ld->port->tport); } return (SNMP_ERR_NOERROR); + + case SNMP_DEPOP_FINISH: + if ((ld->set & LD_DELETE) && ctx->code == SNMP_RET_OK) + lsock_close_port(&ld->port->tport); + free(ld->path); + return (SNMP_ERR_NOERROR); } abort(); } diff --git a/contrib/bsnmp/snmpd/trap.c b/contrib/bsnmp/snmpd/trap.c index 2dd6b82..40f7cf6 100644 --- a/contrib/bsnmp/snmpd/trap.c +++ b/contrib/bsnmp/snmpd/trap.c @@ -30,7 +30,7 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Begemot: bsnmp/snmpd/trap.c,v 1.6 2003/12/03 10:08:47 hbb Exp $ + * $Begemot: bsnmp/snmpd/trap.c,v 1.7 2004/04/13 14:58:46 novo Exp $ * * TrapSinkTable */ @@ -202,21 +202,10 @@ trapsink_unmodify(struct trapsink *t, struct trapsink_dep *tdep) return (SNMP_ERR_NOERROR); } -static void -trapsink_finish(struct snmp_context *ctx __unused, int fail, void *arg) -{ - struct trapsink *t = arg; - - if (!fail) - trapsink_free(t); -} - static int -trapsink_destroy(struct snmp_context *ctx, struct trapsink *t, +trapsink_destroy(struct snmp_context *ctx __unused, struct trapsink *t, struct trapsink_dep *tdep) { - if (snmp_set_atfinish(ctx, trapsink_finish, t)) - return (SNMP_ERR_RES_UNAVAIL); t->status = TRAPSINK_DESTROY; tdep->rb_status = t->status; tdep->rb |= TDEP_DESTROY; @@ -277,6 +266,12 @@ trapsink_dep(struct snmp_context *ctx, struct snmp_dependency *dep, if(tdep->rb & TDEP_DESTROY) return (trapsink_undestroy(t, tdep)); return (SNMP_ERR_NOERROR); + + case SNMP_DEPOP_FINISH: + if ((tdep->rb & TDEP_DESTROY) && t != NULL && + ctx->code == SNMP_RET_OK) + trapsink_free(t); + return (SNMP_ERR_NOERROR); } abort(); } |