HomeFreeBSD

libbsnmp: make binding of client UNIX socket optional and configurable

Description

libbsnmp: make binding of client UNIX socket optional and configurable

Before this change snmp_open(3) would always bind(2) client socket to a
random "/tmp/snmpXXXXXXXXXXXXXX" name. However, this binding is not
required for SOCK_STREAM transport. Also, any attempt to specify a
different name would fail, as open_client_local() would blindly rewrite
the name to the default.

Make this binding optional. If application had initialized
snmp_client.local_path, then try to bind to the specified pathname,
otherwise perform the random name binding only if we are in the
SOCK_DGRAM mode.

While here change snmp_client.local_path size to SUNPATHLEN, so that any
legitimate local socket name can be used. This requires library version
bump.

Note that this code has been broken by 81e0e7b9e36d for three years, thus
it is known not to be widely used.

Reviewed by: harti
Differential Revision: https://reviews.freebsd.org/D51070

Details

Provenance
glebiusAuthored on Jul 25 2025, 8:10 PM
Reviewer
harti
Differential Revision
D51070: libbsnmp: make binding of client UNIX socket optional and configurable
Parents
rGb9fa99600a78: bsnmpd: fix unix/stream socket operation
Branches
Unknown
Tags
Unknown