snmpd(8) remove OID CONFIGURATION

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

snmpd(8) remove OID CONFIGURATION

Martijn van Duren-5
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@

Index: mps.c
===================================================================
RCS file: /cvs/src/usr.sbin/snmpd/mps.c,v
retrieving revision 1.28
diff -u -p -r1.28 mps.c
--- mps.c 24 Oct 2019 12:39:27 -0000 1.28
+++ mps.c 12 Feb 2020 06:47:36 -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: parse.y
===================================================================
RCS file: /cvs/src/usr.sbin/snmpd/parse.y,v
retrieving revision 1.57
diff -u -p -r1.57 parse.y
--- parse.y 2 Jan 2020 10:55:53 -0000 1.57
+++ parse.y 12 Feb 2020 06:47:36 -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: 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
--- snmpd.conf.5 10 Feb 2020 13:18:22 -0000 1.42
+++ snmpd.conf.5 12 Feb 2020 06:47:36 -0000
@@ -279,25 +279,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
Index: snmpd.h
===================================================================
RCS file: /cvs/src/usr.sbin/snmpd/snmpd.h,v
retrieving revision 1.86
diff -u -p -r1.86 snmpd.h
--- snmpd.h 2 Jan 2020 10:55:53 -0000 1.86
+++ snmpd.h 12 Feb 2020 06:47:36 -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 **);