Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F137889784
D51070.id157679.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D51070.id157679.diff
View Options
diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc
--- a/ObsoleteFiles.inc
+++ b/ObsoleteFiles.inc
@@ -51,6 +51,9 @@
# xargs -n1 | sort | uniq -d;
# done
+# 20250625: libbsnmp bumped to version 7
+OLD_LIBS+=usr/lib/libbsnmp.so.6
+
# 20250623: fscandir() renamed to fdscandir()
OLD_FILES+=usr/share/man/man3/fscandir.3.gz
OLD_FILES+=usr/share/man/man3/fscandir_b.3.gz
diff --git a/contrib/bsnmp/lib/bsnmpclient.3 b/contrib/bsnmp/lib/bsnmpclient.3
--- a/contrib/bsnmp/lib/bsnmpclient.3
+++ b/contrib/bsnmp/lib/bsnmpclient.3
@@ -31,7 +31,7 @@
.\"
.\" $Begemot: bsnmp/lib/bsnmpclient.3,v 1.12 2005/10/04 08:46:50 brandt_h Exp $
.\"
-.Dd March 31, 2020
+.Dd June 24, 2025
.Dt BSNMPCLIENT 3
.Os
.Sh NAME
@@ -155,7 +155,7 @@
snmp_timeout_start_f timeout_start;
snmp_timeout_stop_f timeout_stop;
- char local_path[sizeof(SNMP_LOCAL_PATH)];
+ char *local_path;
};
.Ed
.Pp
@@ -285,8 +285,8 @@
.Fn timeout_start
function.
.It Va local_path
-If in local socket mode, the name of the clients socket.
-Not needed by the application.
+If in local socket mode, optional path name the client socket shall be bound
+to before connecting to the server.
.El
.Pp
In the current implementation there is a global variable
diff --git a/contrib/bsnmp/lib/snmpclient.h b/contrib/bsnmp/lib/snmpclient.h
--- a/contrib/bsnmp/lib/snmpclient.h
+++ b/contrib/bsnmp/lib/snmpclient.h
@@ -41,8 +41,6 @@
#define SNMP_STRERROR_LEN 200
-#define SNMP_LOCAL_PATH "/tmp/snmpXXXXXXXXXXXXXX"
-
/*
* transport methods
*/
@@ -110,7 +108,7 @@
snmp_timeout_start_f timeout_start;
snmp_timeout_stop_f timeout_stop;
- char local_path[sizeof(SNMP_LOCAL_PATH)];
+ char *local_path;
};
/* the global context */
diff --git a/contrib/bsnmp/lib/snmpclient.c b/contrib/bsnmp/lib/snmpclient.c
--- a/contrib/bsnmp/lib/snmpclient.c
+++ b/contrib/bsnmp/lib/snmpclient.c
@@ -977,7 +977,10 @@
static int
open_client_local(const char *path)
{
- struct sockaddr_un sa;
+ struct sockaddr_un sa = {
+ .sun_family = AF_LOCAL,
+ .sun_len = sizeof(sa),
+ };
char *ptr;
int stype;
@@ -1009,43 +1012,40 @@
return (-1);
}
- snprintf(snmp_client.local_path, sizeof(snmp_client.local_path),
- "%s", SNMP_LOCAL_PATH);
+ if (snmp_client.local_path != NULL) {
- if (mktemp(snmp_client.local_path) == NULL) {
- seterr(&snmp_client, "%s", strerror(errno));
- (void)close(snmp_client.fd);
- snmp_client.fd = -1;
- return (-1);
+ if (strlcpy(sa.sun_path, snmp_client.local_path,
+ sizeof(sa.sun_path)) >= sizeof(sa.sun_path)) {
+ seterr(&snmp_client, "%s",
+ "Local socket pathname too long");
+ goto fail;
+ }
+ if (bind(snmp_client.fd, (struct sockaddr *)&sa, sizeof(sa)) ==
+ -1) {
+ seterr(&snmp_client, "%s", strerror(errno));
+ goto fail;
+ }
+ atexit(remove_local);
}
- sa.sun_family = AF_LOCAL;
- sa.sun_len = sizeof(sa);
- strcpy(sa.sun_path, snmp_client.local_path);
-
- if (bind(snmp_client.fd, (struct sockaddr *)&sa, sizeof(sa)) == -1) {
- seterr(&snmp_client, "%s", strerror(errno));
- (void)close(snmp_client.fd);
- snmp_client.fd = -1;
- (void)remove(snmp_client.local_path);
- return (-1);
+ if (strlcpy(sa.sun_path, snmp_client.chost, sizeof(sa.sun_path)) >=
+ sizeof(sa.sun_path)) {
+ seterr(&snmp_client, "%s", "Server socket pathname too long");
+ goto fail;
}
- atexit(remove_local);
-
- sa.sun_family = AF_LOCAL;
- sa.sun_len = offsetof(struct sockaddr_un, sun_path) +
- strlen(snmp_client.chost);
- strncpy(sa.sun_path, snmp_client.chost, sizeof(sa.sun_path) - 1);
- sa.sun_path[sizeof(sa.sun_path) - 1] = '\0';
if (connect(snmp_client.fd, (struct sockaddr *)&sa, sa.sun_len) == -1) {
seterr(&snmp_client, "%s", strerror(errno));
- (void)close(snmp_client.fd);
- snmp_client.fd = -1;
- (void)remove(snmp_client.local_path);
- return (-1);
+ goto fail;
}
return (0);
+
+fail:
+ (void)close(snmp_client.fd);
+ snmp_client.fd = -1;
+ if (snmp_client.local_path != NULL)
+ (void)remove(snmp_client.local_path);
+ return (-1);
}
/*
@@ -1097,7 +1097,7 @@
seterr(&snmp_client, "%s", strerror(errno));
(void)close(snmp_client.fd);
snmp_client.fd = -1;
- if (snmp_client.local_path[0] != '\0')
+ if (snmp_client.local_path != NULL)
(void)remove(snmp_client.local_path);
return (-1);
}
@@ -1130,7 +1130,7 @@
if (snmp_client.fd != -1) {
(void)close(snmp_client.fd);
snmp_client.fd = -1;
- if (snmp_client.local_path[0] != '\0')
+ if (snmp_client.local_path != NULL)
(void)remove(snmp_client.local_path);
}
while(!LIST_EMPTY(&sent_pdus)){
diff --git a/lib/libbsnmp/libbsnmp/Makefile b/lib/libbsnmp/libbsnmp/Makefile
--- a/lib/libbsnmp/libbsnmp/Makefile
+++ b/lib/libbsnmp/libbsnmp/Makefile
@@ -7,7 +7,7 @@
.PATH: ${CONTRIB}
LIB= bsnmp
-SHLIB_MAJOR= 6
+SHLIB_MAJOR= 7
LD_FATAL_WARNINGS= no
CFLAGS+= -I${CONTRIB} -DHAVE_ERR_H -DHAVE_GETADDRINFO -DHAVE_STRLCPY
diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc
--- a/tools/build/mk/OptionalObsoleteFiles.inc
+++ b/tools/build/mk/OptionalObsoleteFiles.inc
@@ -461,7 +461,7 @@
OLD_FILES+=usr/include/bsnmp/snmpmod.h
OLD_FILES+=usr/lib/libbsnmp.a
OLD_FILES+=usr/lib/libbsnmp.so
-OLD_LIBS+=usr/lib/libbsnmp.so.6
+OLD_LIBS+=usr/lib/libbsnmp.so.7
OLD_FILES+=usr/lib/libbsnmp_p.a
OLD_FILES+=usr/lib/libbsnmptools.a
OLD_FILES+=usr/lib/libbsnmptools.so
diff --git a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c
--- a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c
+++ b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c
@@ -890,12 +890,7 @@
{
assert(opt_arg != NULL);
- if (sizeof(opt_arg) > sizeof(SNMP_LOCAL_PATH)) {
- warnx("Filename too long - %s", opt_arg);
- return (-1);
- }
-
- strlcpy(snmp_client.local_path, opt_arg, sizeof(SNMP_LOCAL_PATH));
+ snmp_client.local_path = opt_arg;
return (2);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 27, 10:26 PM (1 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
26264527
Default Alt Text
D51070.id157679.diff (5 KB)
Attached To
Mode
D51070: libbsnmp: make binding of client UNIX socket optional and configurable
Attached
Detach File
Event Timeline
Log In to Comment