Page MenuHomeFreeBSD

libbsnmp: make binding of client UNIX socket optional and configurable
ClosedPublic

Authored by glebius on Jun 26 2025, 7:56 PM.
Tags
None
Referenced Files
F132376332: D51070.id.diff
Thu, Oct 16, 8:54 AM
Unknown Object (File)
Wed, Oct 15, 10:56 AM
Unknown Object (File)
Wed, Oct 15, 10:56 AM
Unknown Object (File)
Wed, Oct 15, 12:00 AM
Unknown Object (File)
Mon, Oct 13, 7:35 AM
Unknown Object (File)
Sat, Oct 4, 3:41 AM
Unknown Object (File)
Thu, Sep 18, 12:57 AM
Unknown Object (File)
Tue, Sep 16, 11:19 PM
Subscribers

Details

Summary
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 performa 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.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 65123
Build 62006: arc lint + arc unit

Event Timeline

Note: the binding is actually needed when we run in SOCK_DGRAM mode. So this isn't a final revision.

Make mktemp+bind optional only for the SOCK_STREAM case.

This revision is now accepted and ready to land.Jul 17 2025, 8:29 AM