Arch Linux

Please read this before reporting a bug:

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!

FS#73552 - [net-snmp] broken `net-snmp-config --create-snmpv3-user`

Attached to Project: Arch Linux
Opened by Noel Kuntze (thermi) - Saturday, 29 January 2022, 23:33 GMT
Last edited by Andreas Radke (AndyRTR) - Friday, 11 February 2022, 19:43 GMT
Task Type Bug Report
Category Packages: Extra
Status Assigned
Assigned To Felix Yan (felixonmars)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 1
Private No



Using `net-snmp-config --create-snmpv3-user` is recommended for adding SNMPv3 users.
However execution of the script fails because of two issues, both easily solvable:

1) broken check for snmpd running:
if -acx | egrep ' snmpd *$' > /dev/null 2>&1 ; then
echo "Apparently at least one snmpd demon is already running."
echo "You must stop them in order to use this command."
exit 1

Here the issue is that if -acx is not valid syntax. This is because in the wide whitespace between `if` and `-acx` there is supposed to be the expansion of $PSPROG which is determined at build time and resolves to `/usr/bin/ps`, but only if it is installed.
`ps` is part of `procps-ng`. The variable is successfully expanded when procps-ng is installed at build time. So please add that to makedepends and depends.

2) broken expansion of ${datarootdir}

The script adds the user to /etc/snmp/snmpd.conf, which fails because ${datarootdir} is not set prior to expansion, thus it's empty, causing the script to try to write /snmp/snmpd.conf, which doesn't exist.
line="$token $user"
echo "adding the following line to $outfile:"
echo " $line"
if test ! -d "$outfile"; then
touch "$outfile"
echo "$line" >> $outfile

Commit 72dee028836d233979e4563ce3c3d5e303e0e042 in the net-snmp repo fixes that:

I tried with the two changes and it fixes the issues.

Steps to reproduce:

1) Have net-snmp installed (sudo pacman -S net-snmp)
2) mkdir /etc/snmp && touch /etc/snmp/snmpd.conf
3) net-snmp-config --create-snmpv3-user -A FOOBAR -X FOOBAR testuser
see execution fail:

[root@rpi2-1 thermi]# LANG=C net-snmp-config --create-snmpv3-user -A FOOBAR -X FOOBAR testuser
/usr/bin/net-snmp-create-v3-user: line 6: -acx: command not found
adding the following line to /var/net-snmp/snmpd.conf:
createUser testuser MD5 "FOOBAR" DES "FOOBAR"
adding the following line to /snmp/snmpd.conf:
rwuser testuser
touch: cannot touch '/snmp/snmpd.conf': No such file or directory
/usr/bin/net-snmp-create-v3-user: line 146: /snmp/snmpd.conf: No such file or directory
This task depends upon

Comment by Noel Kuntze (thermi) - Saturday, 29 January 2022, 23:34 GMT
Disregard the hostname in the output, it's reproducible on my Arch Linux laptop, and version is naturally latest, 5.9.1-3.