OpenBSD CVS

CVS log for src/usr.sbin/snmpd/traphandler.c


[BACK] Up to [local] / src / usr.sbin / snmpd

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.27 / (download) - annotate - [select for diffs], Tue Feb 6 15:36:11 2024 UTC (4 months ago) by martijn
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, HEAD
Changes since 1.26: +6 -7 lines
Diff to previous 1.26 (colored)

Let the config parser make use of the mib_string2oid().
If a descriptor is not found in the loaded MIB files it falls back to
the old smi_oid2string(), which then throws a deprecation warning. This
won't trigger for most cases in the default install, but the
UCD-DISKIO-MIB and dependencies aren't included (yet?) (which can be
fixed by manually including them via "mib directory") and there's a
couple of misspellings (e.g. mib_2 vs mib-2, and
usmStatsNotInTimeWindow vs usmStatsNotInTimeWindows).

Feedback and OK tb@

Revision 1.26 / (download) - annotate - [select for diffs], Tue Feb 6 12:44:28 2024 UTC (4 months ago) by martijn
Branch: MAIN
Changes since 1.25: +8 -4 lines
Diff to previous 1.25 (colored)

Replace most smi_oid2string() calls with the new mib_oid2string().
smi_oid2string() is still called from trap handle context to not break
any existing scripts.

OK tb@

Revision 1.25 / (download) - annotate - [select for diffs], Thu Dec 21 12:43:31 2023 UTC (5 months, 2 weeks ago) by martijn
Branch: MAIN
Changes since 1.24: +7 -12 lines
Diff to previous 1.24 (colored)

Clean up snmpd's header situation.

With the help of tb@ and include-what-you-use.

OK tb@

Revision 1.24 / (download) - annotate - [select for diffs], Wed Dec 28 21:30:19 2022 UTC (17 months, 1 week ago) by jmc
Branch: MAIN
CVS Tags: OPENBSD_7_4_BASE, OPENBSD_7_4, OPENBSD_7_3_BASE, OPENBSD_7_3
Changes since 1.23: +2 -2 lines
Diff to previous 1.23 (colored)

spelling fixes; from paul tagliamonte
any parts of his diff not taken are noted on tech

Revision 1.23 / (download) - annotate - [select for diffs], Thu Jun 30 09:42:19 2022 UTC (23 months, 1 week ago) by martijn
Branch: MAIN
CVS Tags: OPENBSD_7_2_BASE, OPENBSD_7_2
Changes since 1.22: +2 -2 lines
Diff to previous 1.22 (colored)

Rewrite smi_print_element to be more concise and complete.
Keep the old implementation around as smi_print_element_legacy for the
trap handler scripts, so these don't break.

Should help with request tracing.

OK sthen@

Revision 1.22 / (download) - annotate - [select for diffs], Thu Oct 21 08:17:34 2021 UTC (2 years, 7 months ago) by martijn
Branch: MAIN
CVS Tags: OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.21: +2 -2 lines
Diff to previous 1.21 (colored)

Sync ober_oid_cmp with ax_oid_cmp from libagentx.
This flips the returned signedness and adds the weight of 2 for
parent-child relationship in both direction.

This makes ober_oid_cmp consistent with the rest of the *_cmp based
functions.

OK tb@

Revision 1.21 / (download) - annotate - [select for diffs], Mon Feb 22 11:31:09 2021 UTC (3 years, 3 months ago) by martijn
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0, OPENBSD_6_9_BASE, OPENBSD_6_9
Changes since 1.20: +7 -8 lines
Diff to previous 1.20 (colored)

Make use of the new '$' feature of ober_scanf_elements to enforce stricter
ASN.1 verification.

OK claudio@

Revision 1.20 / (download) - annotate - [select for diffs], Fri Jan 22 06:33:27 2021 UTC (3 years, 4 months ago) by martijn
Branch: MAIN
Changes since 1.19: +39 -189 lines
Diff to previous 1.19 (colored)

Remove the traphandler process, which was nothing more then a sham.
It did nothing more then receive a message over UDP, do some basic ber
and ASN.1 parsing and forward the packet to the parent process. snmpe can
do/does the same thing but with a far more thorough ASN.1 validation.
Because we move trap receiving to snmpe we get trap over tcp for free.

However, to make sure that a normal snmp port doesn't automatically start
handling traps a new set of "listen on" flags are introduced: read, write,
and notify. To enable trap handling either let snmpd listen on port 162
without flags, or add the notify flag. Only a flag without port results in
listening on port 162.

To keep current behaviour copy all UDP-based "listen on" lines without port
and add the notify keyword:
listen on 127.0.0.1 port 666
becomes
listen on 127.0.0.1 port 666
listen on 127.0.0.1 notify

This change also enforces snmpd to honor trap community on receiving a
trap, where previously no community was checked before handling a packet.

OK denis@, rob@

Revision 1.19 / (download) - annotate - [select for diffs], Tue Jan 5 18:12:15 2021 UTC (3 years, 5 months ago) by martijn
Branch: MAIN
Changes since 1.18: +208 -95 lines
Diff to previous 1.18 (colored)

Refactor how traphandler verifies the code.
Two things of note:
1) traphandler_v1translate now translates v1 traps to v2 traps in line with
   RFC3584 section 3.1 before handing them over to the "command". This can
   cause compatibility issues if you still receive v1 traps.
2) sysUpTime and snmpTrapOID are now always taken from the varbindlist,
   which means that if you run snmpd with -N the names will now show up
   numerical in the script, instead of by their full symbolic name.

lots of feedback and OK rob@

Revision 1.18 / (download) - annotate - [select for diffs], Sun Sep 6 15:51:28 2020 UTC (3 years, 9 months ago) by martijn
Branch: MAIN
CVS Tags: OPENBSD_6_8_BASE, OPENBSD_6_8
Changes since 1.17: +13 -5 lines
Diff to previous 1.17 (colored)

Split "trap receiver" into its own trap_address struct and clean up the
code surrounding this struct and struct address.

No functional change intended, except that trap receiver's source-address
may now be a resolvable hostname.

Tweaks and OK jan@

Revision 1.17 / (download) - annotate - [select for diffs], Sun Aug 23 07:39:57 2020 UTC (3 years, 9 months ago) by martijn
Branch: MAIN
Changes since 1.16: +10 -14 lines
Diff to previous 1.16 (colored)

Merge listen_sock into address, since there's a 1:1 correlation. Save some
overhead and 18LoC.

OK jan@

Revision 1.16 / (download) - annotate - [select for diffs], Wed Mar 11 06:53:42 2020 UTC (4 years, 3 months ago) by martijn
Branch: MAIN
CVS Tags: OPENBSD_6_7_BASE, OPENBSD_6_7
Changes since 1.15: +6 -3 lines
Diff to previous 1.15 (colored)

Make traphandler_parse also set vbinds for SNMPv1 traps.
This also prevents the access of an initialized pointer in
traphandler_fork_handler as found by jan@.

OK jan@

Revision 1.14.2.1 / (download) - annotate - [select for diffs], Sun Oct 27 20:05:13 2019 UTC (4 years, 7 months ago) by tb
Branch: OPENBSD_6_6
Changes since 1.14: +15 -15 lines
Diff to previous 1.14 (colored) next main 1.15 (colored)

The ber_* namespace is used by liblber since time immemorial,
so move our BER API to the unused ober_* prefix to avoid some
breakage in ports.

Problem diagnosed by jmatthew with ber_free() in samba, but
there are many others as pointed out by sthen.

tests & ok rob
ok sthen (who had an almost identical diff for libutil)
"go head hit it" deraadt

OpenBSD 6.6 errata 002

Revision 1.15 / (download) - annotate - [select for diffs], Thu Oct 24 12:39:27 2019 UTC (4 years, 7 months ago) by tb
Branch: MAIN
Changes since 1.14: +15 -15 lines
Diff to previous 1.14 (colored)

The ber_* namespace is used by liblber since time immemorial,
so move our BER API to the unused ober_* prefix to avoid some
breakage in ports.

Problem diagnosed by jmatthew with ber_free() in samba, but
there are many others as pointed out by sthen.

tests & ok rob
ok sthen (who had an almost identical diff for libutil)
"go head hit it" deraadt

Revision 1.14 / (download) - annotate - [select for diffs], Wed Aug 14 04:43:32 2019 UTC (4 years, 9 months ago) by martijn
Branch: MAIN
CVS Tags: OPENBSD_6_6_BASE
Branch point for: OPENBSD_6_6
Changes since 1.13: +5 -4 lines
Diff to previous 1.13 (colored)

Fix ber_scanf_elements for traphandler:
- pdu header has 3 elements, not 4
- additional varbinds are optional.

This is needed to make ber_scanf_elements stricter.

Note that people using "trap handle" in their snmpd.conf and expect a trap
without additional varbinds to show the trapoid to appear twice will have
to adjust their "command".

OK rob@

Revision 1.13 / (download) - annotate - [select for diffs], Sat May 11 17:46:02 2019 UTC (5 years, 1 month ago) by rob
Branch: MAIN
Changes since 1.12: +2 -2 lines
Diff to previous 1.12 (colored)

The BER API is currently used by ldap, ldapd, ldapctl, ypldap, snmpd, and
snmpctl. Separate copies of ber.[ch] have existed and been maintained in sync
in ldap, ldapd, ypldap and snmpd.

This commit moves the BER API into /usr/lib/libutil. All current consumers
already link libutil. ldapd and snmpd regress passes, and release builds.

With help from tb@ and guenther@.

ok deraadt@, tb@

Revision 1.12 / (download) - annotate - [select for diffs], Sun Apr 15 11:57:29 2018 UTC (6 years, 1 month ago) by mpf
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5, OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.11: +5 -2 lines
Diff to previous 1.11 (colored)

Add TCP support to snmpd.

This implements RFC 3430, with the exception of processing multiple
incoming requests in parallel (Section 2.1). This required too much
code and is optional anyway.

Initial review by reyk@, very thorough reviews by jca@. Thanks!

OK jca@, gerhard@

Revision 1.11 / (download) - annotate - [select for diffs], Thu Feb 8 18:02:06 2018 UTC (6 years, 4 months ago) by jca
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE, OPENBSD_6_3
Changes since 1.10: +1 -2 lines
Diff to previous 1.10 (colored)

Kill ber.c support for direct fd read/writes

This mechanism is already unused and annotated with lots of XXX's, no
need to keep it around.  ok claudio@

Revision 1.10 / (download) - annotate - [select for diffs], Fri Jan 5 08:13:32 2018 UTC (6 years, 5 months ago) by mpi
Branch: MAIN
Changes since 1.9: +1 -2 lines
Diff to previous 1.9 (colored)

Remove useless <sys/socketvar.h> includes.

ok kettenis@, visa@, claudio@, deraadt@

Revision 1.9 / (download) - annotate - [select for diffs], Sat Aug 12 04:29:57 2017 UTC (6 years, 10 months ago) by rob
Branch: MAIN
CVS Tags: OPENBSD_6_2_BASE, OPENBSD_6_2
Changes since 1.8: +4 -1 lines
Diff to previous 1.8 (colored)

Initial pledge for snmpd. snmpe remains unpledged. Regression tests pass.

Ok benno@, jca@.

Revision 1.8 / (download) - annotate - [select for diffs], Mon Jan 9 14:49:22 2017 UTC (7 years, 5 months ago) by reyk
Branch: MAIN
CVS Tags: OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.7: +8 -4 lines
Diff to previous 1.7 (colored)

Stop accessing verbose and debug variables from log.c directly.

This replaces log_verbose() and "extern int verbose" with the two functions
log_setverbose() and log_getverbose().

Pointed out by benno@
OK krw@ eric@ gilles@ (OK gilles@ for the snmpd bits as well)

Revision 1.7 / (download) - annotate - [select for diffs], Fri Nov 18 16:16:39 2016 UTC (7 years, 6 months ago) by jca
Branch: MAIN
Changes since 1.6: +30 -11 lines
Diff to previous 1.6 (colored)

Add support for multiple listening sockets

One can now specify multiple "listen on" statements. The default is to
listen on 0.0.0.0 and ::, which means better handling of dual-stack
setups.  ok sthen@ on a previous version, input and ok reyk@.

Revision 1.6 / (download) - annotate - [select for diffs], Fri Oct 28 09:07:08 2016 UTC (7 years, 7 months ago) by rzalamena
Branch: MAIN
Changes since 1.5: +3 -4 lines
Diff to previous 1.5 (colored)

Sync snmpd(8) with other daemons proc.c and teach him how to fork+exec.

ok jca@, reyk@

Revision 1.5 / (download) - annotate - [select for diffs], Tue Aug 16 18:41:57 2016 UTC (7 years, 9 months ago) by tedu
Branch: MAIN
Changes since 1.4: +1 -2 lines
Diff to previous 1.4 (colored)

stop including sys/param.h for nitems. define locally as needed.
ok natano reyk

Revision 1.4 / (download) - annotate - [select for diffs], Mon Dec 7 12:33:08 2015 UTC (8 years, 6 months ago) by reyk
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0, OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.3: +3 -3 lines
Diff to previous 1.3 (colored)

Sync proc.c, use proc_composev()

Revision 1.3 / (download) - annotate - [select for diffs], Sun Nov 22 13:27:13 2015 UTC (8 years, 6 months ago) by reyk
Branch: MAIN
Changes since 1.2: +5 -2 lines
Diff to previous 1.2 (colored)

Update log.c: change fatal() and fatalx() into variadic functions,
include the process name, and replace all calls of fatal*(NULL) with
fatal(__func__) for better debugging.

OK benno@

Revision 1.2 / (download) - annotate - [select for diffs], Fri Jan 16 00:05:13 2015 UTC (9 years, 4 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8, OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.1: +2 -2 lines
Diff to previous 1.1 (colored)

first batch of cleanup to programs based upon the namespace cleanups
in net/pfvar.h sys/proc.h sys/ucred.h arpa/nameser.h
change to PATH_MAX, reduce use of MIN() and MAX(), HOST_NAME_MAX+1,
LOGIN_NAME_MAX, etc etc
ok millert guenther, some review by doug

Revision 1.1 / (download) - annotate - [select for diffs], Fri Apr 25 06:57:11 2014 UTC (10 years, 1 month ago) by blambert
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE, OPENBSD_5_6

Support running user-defined actions on receipt of snmp traps.

testing sthen@
much man page guidance jmc@
ok reyk@

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.