On 2/12/20 7:48 AM, Martijn van Duren wrote:
> Hello tech@,
>
> Working on something else, this bit of code is somewhat in my way and it
> feels like an early testing feature instead of actually being useful.
>
> Is anyone actually using this, or can it be removed?
>
> martijn@
>
One reply so far saying that it's not used in their setup.
Unless someone complains I'll probably commit the diff below somewhere
early next week. Diff below is previous with additional manpage and
examples cleanup.
Explicit OKs also welcome.
martijn@
Index: etc/examples/snmpd.conf
===================================================================
RCS file: /cvs/src/etc/examples/snmpd.conf,v
retrieving revision 1.1
diff -u -p -r1.1 snmpd.conf
--- etc/examples/snmpd.conf 11 Jul 2014 21:20:10 -0000 1.1
+++ etc/examples/snmpd.conf 27 Feb 2020 07:54:28 -0000
@@ -14,10 +14,6 @@ listen on $listen_addr
#system location "Rack A1-24, Room 13"
system services 74
-# Provide static user-defined SNMP OIDs
-oid 1.3.6.1.4.1.30155.42.3.1 name testStringValue read-only string "Test"
-oid 1.3.6.1.4.1.30155.42.3.4 name testIntValue read-write integer 1
-
# Enable SNMPv3 USM with authentication, encryption and two defined users
#seclevel enc
#user "user1" authkey "password123" enc aes enckey "321drowssap"
Index: usr.sbin/snmpd/mps.c
===================================================================
RCS file: /cvs/src/usr.sbin/snmpd/mps.c,v
retrieving revision 1.28
diff -u -p -r1.28 mps.c
--- usr.sbin/snmpd/mps.c 24 Oct 2019 12:39:27 -0000 1.28
+++ usr.sbin/snmpd/mps.c 27 Feb 2020 07:54:28 -0000
@@ -51,17 +51,6 @@ struct ber_oid *
extern void control_event_add(struct ctl_conn *, int, int, struct timeval *);
/* XXX */
int
-mps_getstr(struct oid *oid, struct ber_oid *o, struct ber_element **elm)
-{
- char *s = oid->o_data;
-
- if (s == NULL)
- return (-1);
- *elm = ober_add_string(*elm, s);
- return (0);
-}
-
-int
mps_setstr(struct oid *oid, struct ber_oid *o, struct ber_element **elm)
{
struct ber_element *ber = *elm;
@@ -88,18 +77,6 @@ int
mps_getint(struct oid *oid, struct ber_oid *o, struct ber_element **elm)
{
*elm = ober_add_integer(*elm, oid->o_val);
- return (0);
-}
-
-int
-mps_setint(struct oid *oid, struct ber_oid *o, struct ber_element **elm)
-{
- long long i;
-
- if (ober_get_integer(*elm, &i) == -1)
- return (-1);
- oid->o_val = i;
-
return (0);
}
Index: usr.sbin/snmpd/parse.y
===================================================================
RCS file: /cvs/src/usr.sbin/snmpd/parse.y,v
retrieving revision 1.57
diff -u -p -r1.57 parse.y
--- usr.sbin/snmpd/parse.y 2 Jan 2020 10:55:53 -0000 1.57
+++ usr.sbin/snmpd/parse.y 27 Feb 2020 07:54:28 -0000
@@ -138,8 +138,8 @@ typedef struct {
%token <v.number> NUMBER
%type <v.string> hostcmn
%type <v.string> srcaddr
-%type <v.number> optwrite yesno seclevel socktype proto
-%type <v.data> objtype cmd
+%type <v.number> yesno seclevel socktype proto
+%type <v.data> cmd
%type <v.oid> oid hostoid trapoid
%type <v.auth> auth
%type <v.enc> enc
@@ -152,7 +152,6 @@ grammar : /* empty */
| grammar varset '\n'
| grammar main '\n'
| grammar system '\n'
- | grammar mib '\n'
| grammar error '\n' { file->errors++; }
;
@@ -349,61 +348,6 @@ sysmib : CONTACT STRING {
struct ber_oid o = OID(MIB_sysServices);
mps_set(&o, NULL, $2);
}
- ;
-
-mib : OBJECTID oid NAME STRING optwrite objtype {
- struct oid *oid;
- if ((oid = (struct oid *)
- calloc(1, sizeof(*oid))) == NULL) {
- yyerror("calloc");
- free($2);
- free($6.data);
- YYERROR;
- }
-
- smi_oidlen($2);
- bcopy($2, &oid->o_id, sizeof(struct ber_oid));
- free($2);
- oid->o_name = $4;
- oid->o_data = $6.data;
- oid->o_val = $6.value;
- switch ($6.type) {
- case 1:
- oid->o_get = mps_getint;
- oid->o_set = mps_setint;
- break;
- case 2:
- oid->o_get = mps_getstr;
- oid->o_set = mps_setstr;
- break;
- }
- oid->o_flags = OID_RD|OID_DYNAMIC;
- if ($5)
- oid->o_flags |= OID_WR;
-
- if (smi_insert(oid) == -1) {
- yyerror("duplicate oid");
- free(oid->o_name);
- free(oid->o_data);
- YYERROR;
- }
- }
- ;
-
-objtype : INTEGER NUMBER {
- $$.type = 1;
- $$.data = NULL;
- $$.value = $2;
- }
- | OCTETSTRING STRING {
- $$.type = 2;
- $$.data = $2;
- $$.value = strlen($2);
- }
- ;
-
-optwrite : READONLY { $$ = 0; }
- | READWRITE { $$ = 1; }
;
oid : STRING {
Index: usr.sbin/snmpd/snmpd.conf.5
===================================================================
RCS file: /cvs/src/usr.sbin/snmpd/snmpd.conf.5,v
retrieving revision 1.42
diff -u -p -r1.42 snmpd.conf.5
--- usr.sbin/snmpd/snmpd.conf.5 10 Feb 2020 13:18:22 -0000 1.42
+++ usr.sbin/snmpd/snmpd.conf.5 27 Feb 2020 07:54:28 -0000
@@ -38,8 +38,6 @@ Global runtime settings for
.Xr snmpd 8 .
.It Sy User Configuration
USM user definitions.
-.It Sy OID Configuration
-Custom configuration of SNMP object identifiers and values.
.El
.Pp
The current line can be extended over multiple lines using a backslash
@@ -279,25 +277,6 @@ and defaults to
Any user account that has encryption enabled requires authentication to
be enabled too.
.El
-.Sh OID CONFIGURATION
-It is possible to specify user-defined OIDs in the configuration file:
-.Bl -tag -width Ds
-.It Xo
-.Ic oid Ar oid-string
-.Ic name Ar name
-.Op Ic read-only | read-write
-.Op Ar type
-.Ar value
-.Xc
-Return the specified value to the client for this OID.
-The
-.Ic read-write
-option may allow the client to override it,
-and the type is either
-.Ic string
-or
-.Ic integer .
-.El
.Sh FILES
.Bl -tag -width /etc/examples/snmpd.conf -compact
.It Pa /etc/snmpd.conf
@@ -309,15 +288,12 @@ Example configuration file.
The following example will tell
.Xr snmpd 8
to listen on localhost, override the default system OID, set the
-magic services value and provides some custom OID values:
+magic services value:
.Bd -literal -offset indent
listen on 127.0.0.1
system oid 1.3.6.1.4.1.30155.23.2
system services 74
-
-oid 1.3.6.1.4.1.30155.42.1 name myName read-only string "humppa"
-oid 1.3.6.1.4.1.30155.42.2 name myStatus read-only integer 1
.Ed
.Pp
The next example will enforce SNMPv3 with authenticated and encrypted
Index: usr.sbin/snmpd/snmpd.h
===================================================================
RCS file: /cvs/src/usr.sbin/snmpd/snmpd.h,v
retrieving revision 1.86
diff -u -p -r1.86 snmpd.h
--- usr.sbin/snmpd/snmpd.h 2 Jan 2020 10:55:53 -0000 1.86
+++ usr.sbin/snmpd/snmpd.h 27 Feb 2020 07:54:29 -0000
@@ -689,13 +689,9 @@ int mps_getbulkreq(struct snmp_message
int mps_setreq(struct snmp_message *, struct ber_element *,
struct ber_oid *);
int mps_set(struct ber_oid *, void *, long long);
-int mps_getstr(struct oid *, struct ber_oid *,
- struct ber_element **);
int mps_setstr(struct oid *, struct ber_oid *,
struct ber_element **);
int mps_getint(struct oid *, struct ber_oid *,
- struct ber_element **);
-int mps_setint(struct oid *, struct ber_oid *,
struct ber_element **);
int mps_getts(struct oid *, struct ber_oid *,
struct ber_element **);