Before this change snmp_open(3) would always bind(2) client socket to a
random "/tmp/snmpXXXXXXXXXXXXXX" name. THowever, this binding isn't used fors not
anything required for SOCK_STREAM transport. Also, since server doesn't do getpeername(2) on client sockets.any attempt to specify a
Indeed different name would fail, getpeername(2) won't provide any useful information that can beas open_client_local() would blindly rewrite
used as a security check. The whole purpose of binding client socket to a the name to the default.
pathname is unclear. 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 do not bind at all.
This changes snmp_client.local_path from an array to a pointer and thatperforma the random name binding only if we are in the
requires library version bump. I rejected an alternative to preserve ABI SOCK_DGRAM mode.
and reuse the array for this purpose on the basis that the array was much
While here change snmp_client.local_path size to SUNPATHLEN, so that any
smaller than SUNPATHLEN and if we actually want to provide an optional legitimate local socket name can be used. This requires library version
binding path, that should support as long path as unix(4) socket can.
bump.
Note that this code has been broken by 81e0e7b9e36d for three years, thus
it is known not to be widely used.