On Tue, 2022-12-20 at 10:28 +0000, Gerhard Roth wrote:
> Hi Martijn,
>
> On Tue, 2022-12-20 at 11:10 +0100, Martijn van Duren wrote:
> > On Tue, 2022-12-20 at 10:21 +0100, Matthias Pitzl wrote:
> > > Hi,
> > >
> > > Since the release of OpenBSD 7.2, snmp mibtree is broken:
> > > > root@host:~# snmp mibtree
> > > > snmp: No securityName specified
> > >
> > > Greetings,
> > > Matthias
> >
> > Apparently no one has used this one in a long time (including me).
> > This got broken in snmpc.c r1.37 on 2021/08/11 when changing snmp(1)'s
> > default to v3.
> >
> > This may not the prettiest solution, but this is the shortest I can come
> > up with.
>
> no sub-command that hasn't 'snmp_app->usecommonopt' set can have any of
> the SNMPv2 or SNMPv3 credentials. Sure, currently 'mibtree' is the only
> one. But for future updates, wouldn't it be better to check
>
> if (!snmp_app->usecommonopt)
>
> instead of
>
> if (strcmp(snmp_app->name, "mibtree") == 0)
>
> Greetings,
>
> Gerhard
>
>
You're right, that's better.
Index: snmpc.c
===================================================================
RCS file: /cvs/src/usr.bin/snmp/snmpc.c,v
retrieving revision 1.38
diff -u -p -r1.38 snmpc.c
--- snmpc.c 21 Oct 2021 08:17:34 -0000 1.38
+++ snmpc.c 20 Dec 2022 10:33:58 -0000
@@ -468,7 +468,9 @@ main(int argc, char *argv[])
argc -= optind;
argv += optind;
- if (version == SNMP_V1 || version == SNMP_V2C) {
+ if (!snmp_app->usecommonopt) {
+ /* No SNMP protocol settings */
+ } else if (version == SNMP_V1 || version == SNMP_V2C) {
if (community == NULL || community[0] == '\0')
errx(1, "No community name specified.");
} else if (version == SNMP_V3) {