Bug 907571 - net-snmp does not honor configuration file look-ups as specified in man
net-snmp does not honor configuration file look-ups as specified in man
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: net-snmp (Show other bugs)
6.3
x86_64 Linux
unspecified Severity medium
: rc
: ---
Assigned To: Jan Safranek
Dalibor Pospíšil
: ManPageChange
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-02-04 13:11 EST by Erinn Looney-Triggs
Modified: 2013-11-21 17:48 EST (History)
4 users (show)

See Also:
Fixed In Version: net-snmp-5.5-45.el6
Doc Type: Bug Fix
Doc Text:
The snmp_config man page was not clear about which files are looked for and reader could get wrong impression that any file with suffix 'conf' or 'local.conf' can be used as snmp configuration file. In this update, we precisely specify in the man page which files are used.
Story Points: ---
Clone Of:
: 978398 (view as bug list)
Environment:
Last Closed: 2013-11-21 17:48:02 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
man page patch (1.12 KB, patch)
2013-02-11 05:58 EST, Jan Safranek
no flags Details | Diff

  None (edit)
Description Erinn Looney-Triggs 2013-02-04 13:11:38 EST
Description of problem:
Looking in 'man snmp_config' it specifies, loosely, that configuration files in /usr/share/snmp/*.local.conf and *.conf should be picked up by snmpd. However, snmpd seems to have been hard coded with paths to configuration files and does not allow *.local.conf or *.conf. 

From strace (filtered for brevity):
open("/etc/snmp/snmpd.conf", O_RDONLY)  = 7
open("/etc/snmp/snmpd.local.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/snmp/snmpd.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/snmp/snmpd.local.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/var/lib/net-snmp/snmpd.0.conf", 0x7fff65f3c1b0) = -1 ENOENT (No such file or directory)
open("/var/lib/net-snmp/snmpd.conf", O_RDONLY) = 7
open("/var/lib/net-snmp/snmpd.local.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/snmp/snmp.conf", O_RDONLY)   = -1 ENOENT (No such file or directory)
open("/etc/snmp/snmp.local.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/snmp/snmp.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/snmp/snmp.local.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/var/lib/net-snmp/snmp.0.conf", 0x7fff65f3c1b0) = -1 ENOENT (No such file or directory)
open("/var/lib/net-snmp/snmp.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/var/lib/net-snmp/snmp.local.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/snmp/agentx.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/snmp/agentx.local.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/snmp/agentx.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/snmp/agentx.local.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/var/lib/net-snmp/agentx.0.conf", 0x7fff65f3c1b0) = -1 ENOENT (No such file or directory)
open("/var/lib/net-snmp/agentx.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/var/lib/net-snmp/agentx.local.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
read(7, " that is configured to turn the "..., 4096) = 4096
open("/etc/snmp/snmpd.conf", O_RDONLY)  = 7
open("/etc/snmp/snmpd.local.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/snmp/snmpd.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/snmp/snmpd.local.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/var/lib/net-snmp/snmpd.0.conf", 0x7fff65f3c1c0) = -1 ENOENT (No such file or directory)
open("/var/lib/net-snmp/snmpd.conf", O_RDONLY) = 7
open("/var/lib/net-snmp/snmpd.local.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/snmp/snmp.conf", O_RDONLY)   = -1 ENOENT (No such file or directory)
open("/etc/snmp/snmp.local.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/snmp/snmp.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/snmp/snmp.local.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/var/lib/net-snmp/snmp.0.conf", 0x7fff65f3c1c0) = -1 ENOENT (No such file or directory)
open("/var/lib/net-snmp/snmp.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/var/lib/net-snmp/snmp.local.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/snmp/agentx.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/snmp/agentx.local.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/snmp/agentx.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/snmp/agentx.local.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/var/lib/net-snmp/agentx.0.conf", 0x7fff65f3c1c0) = -1 ENOENT (No such file or directory)
open("/var/lib/net-snmp/agentx.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/var/lib/net-snmp/agentx.local.conf", O_RDONLY) = -1 ENOENT (No such file or directory)


Version-Release number of selected component (if applicable):
net-snmp-5.5-41.el6_3.1.x86_64

How reproducible:
Place a config file in /usr/share/snmp/tes-snmp.local.conf, according to the man pages it should be picked up, it is not.


Either the man pages should be updated to reflect reality (the man pages are pretty generic to begin with), or that behavior should be allowed. As is only a location like /usr/share/snmpd.local.conf is picked up.

Thanks,
-Erinn
Comment 2 Jan Safranek 2013-02-07 05:52:38 EST
I admit the man page is quite confusing.

What about such text in DIRECTORIES SEARCHED section:

By default, the applications look for configuration files in the following 4
directories, in order: /etc/snmp, /usr/share/snmp, /usr/lib(64)/snmp, and
$HOME/.snmp. In each of these directories, it looks for files named
<type>.conf or <type>.local.conf (reading the second ones last), where <type> is type of the configuration file, e.g. 'snmpd' for configuration of the SNMP daemon or 'snmp' for configuration of client-side parameters.
Comment 3 Erinn Looney-Triggs 2013-02-07 09:26:41 EST
That would seem to be a bit clearer to me at least. However, as I mentioned that isn't actually the behavior that I am experiencing at this point. I placed a config file in /usr/share/snmp/beanstalk-snmp.local.conf and it wasn't picked up. Looking at the strace shown above it is pretty clear that it is searching only for /usr/share/snmp/snmpd.local.conf and such. 

So unless I am missing the meaning of the man page, the code isn't acting like the man page says.

-Erinn
Comment 4 Jan Safranek 2013-02-08 05:10:49 EST
(In reply to comment #3)
> I placed a config file in /usr/share/snmp/beanstalk-snmp.local.conf and it
> wasn't picked up. Looking at the strace shown above it is pretty clear that
> it is searching only for /usr/share/snmp/snmpd.local.conf and such. 

That means the description is not clear at all. It is not supposed to search for *snmp.local.conf. snmp tools (like snmpwalk) look for snmp.conf or snmp.local.conf. No '*' anywhere. snmpd looks for snmpd.conf, snmpd.local.conf, snmp.conf and snmp.local.conf. Again, no '*'. The same with snmptrapd and snmptrapd.conf.

How to rephrase "<type> is type of the configuration file, e.g. 'snmpd'" better?
Comment 5 Erinn Looney-Triggs 2013-02-08 11:54:34 EST
Well re-reading that and understanding what I do know it is clear. I would also say that your rewrite is still a lot clearer than what is in the man page currently, so that is a step forward. 

This may be a bit clearer, or not:

By default, the applications look for configuration files in the following
directories, in order: /etc/snmp, /usr/share/snmp, /usr/lib(64)/snmp, and
$HOME/.snmp. In each of these directories, it looks for files named
snmp.conf and snmpd.conf, as well as snmp.local.conf and snmpd.local.conf, local.conf files are always read last.
Comment 6 Jan Safranek 2013-02-11 04:01:49 EST
There is also snmptrapd.conf, but I get the idea. I'll make sure the man page gets updated.
Comment 7 Jan Safranek 2013-02-11 05:58:54 EST
Created attachment 696033 [details]
man page patch

Checked in upstream as commit 9bd0413bfbdcd845413c135bbff8771fa7130809.
Comment 16 errata-xmlrpc 2013-11-21 17:48:02 EST
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2013-1693.html

Note You need to log in before you can comment on or make changes to this bug.