History log of /freebsd-10-stable/contrib/bsnmp/snmpd/main.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 315612 20-Mar-2017 ngie

MFC r315206:

bsnmpd: fix segfault when trans_insert_port(..) is called with multiple
out of order addresses

Move `port->transport` initialization before the TAILQ_FOREACH(..) loop
to ensure that the value is properly initialized before it's inserted
into the TAILQ.

PR: 217760


# 312265 16-Jan-2017 ngie

MFC r310655:

Fix bsnmpd sending/receiving with multi-homed configurations or INADDR_ANY used
as the listening address in snmpd_input(..)

Stash the IPv4 address of the receiver via the recv(..) callback and use it in
the send(..) callback for the transport by specifying IP_SENDSRCADDR for the
control message type.

Add sendmsg logic to the UDP transport's send(..) callback and use the
respective send(..) callback for the transport instead of calling sendto in
snmpd_input(..).

Obtained from: Isilon OneFS (^/onefs/branches/BR_8_0_0_DEV@r507595)


# 312058 13-Jan-2017 ngie

MFC r310586,r310587,r310588,r311381:

r310586:

Refactor transport sources a bit to facilitate changes coming down pipeline

Add recv callback to transport layer to better facilitate code reuse and
readability and for symmetry with send callback. Move recv_dgram and
recv_stream to udp_recv and lsock_recv, respectively, and make the
beforementioned functions recv callbacks for the udp and lsock transports,
respectively.

Consolidate the check_priv* functions in their relevant trans*.c source to
limit scope/use.

Note: this code is roughly based content from the submitter, although this
was modified to be more of a direct move from snmpd/main.c to the trans_*.c
sources, and to reduce unnecessary static function declarations.

r310587:

Fix definition for recv_dgram(..); it should be "ssize_t", not "int"

I'm not sure why this wasn't flagged as an issue by the compiler, yet

r310588:

Fix return type for `ret` (recv callback) and sort variables by alignment

Again, for reasons I don't yet understand, this is not being flagged by the
compiler. Unlike the issue addressed in r310587, this problem existed prior
to r310586

r311381:

lsock_init_port: address issues with initializing sockaddr_un object

- Use strlcpy to ensure p->name doesn't overflow sa.sun_path [*].
- Use SUN_LEN(..) instead of spelling out calculation longhand (inspired
by comment by jmallett).

Tested with: dgram and stream support with both bsnmpwalk and snmpwalk

CID: 1006825


# 312054 13-Jan-2017 ngie

MFC r311378:

lm_load: fix string copying issues

- Ensure `section` doesn't overrun section by using strlcpy instead of
strcpy [*].
- Use strdup instead of malloc + strcpy (this wasn't flagged by Coverity,
but is an opportunistic change).

CID: 1006826 [*]


# 311597 07-Jan-2017 ngie

MFC r310957,r310958,r310960:

r310957:

Use strlcpy when copying `com` to pdu->community to avoid potential
buffer overruns

CID: 1006823, 1006824

r310958:

Initialize ret to SNMPD_INPUT_OK at the top of snmp_input_start(..) to
avoid returning an uninitialized value

There are some really complicated, snakey if-statements combined with
switch statements that could result in an invalid value being returned
as `ret`

CID: 1006551

r310960:

Similar to r310954, set .len to 0 on malloc failure and to `len` only
on success


# 310991 01-Jan-2017 ngie

MFstable/11 r310990:

MFC r310498,r310591:

r310498:

Allow SNMPv3 authNoPriv and noAuthNoPriv protocols to discover snmpEngineTime
as discussed in RFC-5343

This fixes interoperability with net-snmp.

Tested with the following invocations of snmpwalk (from net-snmp):

- noAuthNoPriv:

% snmpwalk -v 3 -n '' -u public localhost snmpEngineTime

- authNoPriv:

% snmpwalk -v 3 -n '' -u bsnmp -A bsnmptest -l authNoPriv -a sha localhost \
localhost snmpEngineTime

- authPriv:

% snmpwalk -v 3 -n '' -u bsnmp -A bsnmptest -l authPriv -a sha -x des \
-X bsnmptest localhost snmpEngineTime

Obtained from: Isilon OneFS (5ec6d772cacbc, with minor tweaks)

r310591:

Update engine time using update_snmpd_engine_time(..)


# 310903 31-Dec-2016 ngie

MFstable/11 r310901:

MFC r310648:

style(9): clean up trailing whitespace


# 310878 31-Dec-2016 ngie

MFstable/11 r310877:

MFC r310455:

Clarify failure in snmp_output(..) with call to snmp_pdu_decode

- Explicitly test snmp_pdu_encode against SNMP_CODE_OK instead of assuming
any non-zero value is bad.
- Print out the code before calling abort() to give the end-user something
actionable to debug without having to recompile the binary, since the
core might not have these details.


# 300561 24-May-2016 ngie

MFC r299465,r299807,r299808,r299817,r299831,r299832,r300167:

r299465 (by cem):

bsnmp: Don't overrun privkey buffer by copying wrong size

The 'priv_key' array is SNMP_PRIV_KEY_SIZ bytes, not SNMP_AUTH_KEY_SIZ.

CIDs: 1008326, 1009675

r299807:

Replace QUADFMT with %ju and QUADXFMT with %jx and cast values with uintmax_t

This will cure some -Wformat warnings

r299808:

Use sizeof(..)s for the destination buffers instead of hardcoded values corresponding
to the destination buffer sizes

r299817:

Use SNMPD_INPUT_FAILED instead of SNMP_CODE_FAILED

SNMPD_INPUT_FAILED is `enum snmpd_input_err` type (which matches the return
code from the function). SNMP_CODE_FAILED is `enum snmp_code` type.

r299831:

Remove NO_WERROR and add WARNS?= 6

This now compiles cleanly on all architectures

Tested with: clang 3.8, gcc 4.2.1, gcc 4.5, make tinderbox

r299832:

Remove trailing whitespace in license tort

r300167 (by glebius):

Revert r299830, it has couple of fatal errors.

The CMSG_ family of macros take care of alignment, so we don't need r299830
at all, even if it was correct. Put NO_WCAST_ALIGN into Makefile.

Together with: peter


# 299018 03-May-2016 ngie

MFC r298448,r298464:

r298448:

Don't leak `string` in parse_define(..) when a macro has been found
and the parser token != TOK_ASSIGN

CID: 1007187, 1007188
Obtained from: Isilon OneFS (part of r445479)

r298464:

Use `sizeof(*uuser)` instead of `sizeof(struct usm_user)` for consistency with
the rest of the users in the file

No functional change


# 293141 04-Jan-2016 ngie

MFC r292815:

Staticize several variables that are used exclusively in bsnmpd/main.c and
bsnmpd/trap.c

This fixes several -Wmissing-variable-declaration warnings noted by clang


# 256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 240734 20-Sep-2012 glebius

Re-do r240271:
- Set IP_RECVDSTADDR sockopt on the socket only in case if
it is INADDR_ANY bound.
- Supply IP_SENDSRCADDR control message only if we did receive
IP_RECVDSTADDR control message.

This fixes operation of snmpd bound to a specific local IP address.

PR: bin/171279


# 240271 09-Sep-2012 glebius

For UDP transport set IP_RECVDSTADDR sockopt on the socket, and provide
IP_SENDSRCADDR control with datagram message we reply with. This makes
bsnmpd reply from exactly same address that request was sent to, thus
successfully bypassing stateful firewalls or other kinds of strict checking.

PR: bin/171279


# 240234 08-Sep-2012 glebius

The first part of check_priv() function, that attempts to obtain creds
from the control message, actually never worked. This means check_priv()
didn't work for local dgram sockets.

The SCM_CREDS control messages is received only in two cases:

1) If we did setsockopt(LOCAL_CREDS) on our socket, and in this case
the message is struct sockcred.
2) If sender did supplied SCM_CREDS control message in his sendmsg()
syscall. In this case the message is struct cmsgcred.

We can't rely on 2), so we will use 1) for dgram sockets. For stream
sockets it is more reliable to obtain accept-time credentials, since
SCM_CREDS control message is attached only on first read. Thus:

o Do setsockopt(LOCAL_CREDS) on local dgram sockets.
o Split check_priv() into check_priv_stream() and check_priv_dgram(),
and call them from recv_stream() and recv_dgram() respectively.
o Don't provide space for SCM_CREDS control message in recv_stream().
o Provide space for SCM_CREDS control message in recv_dgram(), but there
is no need to initialize anything in it.
o In recv_dgram() do not blindly expect that first message is SCM_CREDS,
instead use correct search cycle through control messages.


# 233128 18-Mar-2012 harti

memset() wants the size of the structure to clear, not the size
of the pointer to it.

Submitted by: Pawel Worach


# 220882 20-Apr-2011 ru

Don't spam syslog with "inet_ntop(): Address family not supported
by protocol family" when processing requests received from the
UNIX domain socket.

MFC after: 3 days


# 216594 20-Dec-2010 syrinx

Bring in a SNMP module that allows configuration of SNMPv3 Notification targets.

Sponsored by: The FreeBSD Foundation
Reviewed by: philip
Approved by: philip


# 216294 08-Dec-2010 syrinx

In bsnmpd(1) add support for SNMPv3 message processing model, including message authentication, packet encryption & view-based access control (RFC 3412, 3414, 3415).

Sponsored by: The FreeBSD Foundation
Reviewed by: philip@ (mostly)
Approved by: philip@


# 176893 07-Mar-2008 syrinx

This commit was generated by cvs2svn to compensate for changes in r176892,
which included commits to RCS files with non-trunk default branches.


# 176892 07-Mar-2008 syrinx

Vendor patch: Prevent bsnmpd from dumping core when a module's init hook
returns an error.

Approved by: bz (mentor), harti


# 156066 27-Feb-2006 harti

Virgin import of bsnmpd 1.12


# 155094 31-Jan-2006 harti

Vendor patch: prevent a core dump when the trace option is not followed
by an option value.

Submitted by: Shteryana Shopova <shteryana@yahoo.com>


# 154180 10-Jan-2006 harti

Vendor fix: make the default read and write communities NULL. This
basically disables any access unless other strings are set in the config
file. Note, that there is no way to set the communities back to NULL once
they're set to something not NULL.


# 150974 05-Oct-2005 harti

Vendor fix for the build problem of snmp_pf. Move the fallback definitions
for U?INT32_{MAX,MIN} from asn1.h into the .c files that actually require
them (the .h file doesn't refer to these macros).


# 150920 04-Oct-2005 harti

Virgin import of bsnmpd 1.11


# 146525 23-May-2005 harti

Virgin import of bsnmpd 1.10


# 145673 29-Apr-2005 harti

Vendor patch: fix a bug that was introduced when moving from libisc to
libbegemot: the rpoll_start_timer function needs the timeout value in
milli-seconds, not the absolute time when the timer should tick.


# 145557 26-Apr-2005 harti

Virgin import of bsnmp 1.9


# 142810 28-Feb-2005 harti

Virgin import of bsnmpd 1.8


# 133211 06-Aug-2004 harti

Virgin import of bsnmpd 1.7


# 128237 14-Apr-2004 harti

Import of bsnmpd 1.6


# 124861 23-Jan-2004 harti

Virgin import of bsnmpd 1.5a


# 122394 10-Nov-2003 harti

Virgin import of bsnmp 1.4