Bug#389434: /usr/share/snmp/mibs/.index has mode 0666
reassign 389434 net-snmp
tag 389434 patch
thanks
Hi,
let's fix this (at least) in net-snmp, since it seems to be two separate
problems:
(1) As implemented and documented, the MIBs dir (currently
/usr/share/snmp/mibs) is intended for changing/adding MIB data. Index
files (.index) are also always (re-)created by libsnmp. Therefore, it
should go to /var/lib/snmp/mibs. Patch attached
(net-snmp.patch.5.2.3-1). A forward-ported version is included in
net-snmp.patch.5.3.1-2 if you decide to migrate the version currently in
experimental (which will probably happen sooner or later, anyway).
(2) To prevent 0666, we can umask() the written index file properly (see
attached net-snmp.patch.umask). If we also want to "sanitize" old index
files, we could alternatively use fchmod() (_not_ included in the patch,
but trivial).
If necessary (fixing issues separately), please split the bug.
bye,
Roland
diff -ruN net-snmp-5.2.3.orig/debian/libsnmp-base.dirs net-snmp-5.2.3/debian/libsnmp-base.dirs
--- net-snmp-5.2.3.orig/debian/libsnmp-base.dirs 2006-10-15 13:46:02.000000000 +0200
+++ net-snmp-5.2.3/debian/libsnmp-base.dirs 2006-10-15 13:47:39.000000000 +0200
@@ -1 +1 @@
-var/lib/snmp
+var/lib/snmp/mibs
diff -ruN net-snmp-5.2.3.orig/debian/libsnmp-base.files net-snmp-5.2.3/debian/libsnmp-base.files
--- net-snmp-5.2.3.orig/debian/libsnmp-base.files 2006-10-15 13:46:02.000000000 +0200
+++ net-snmp-5.2.3/debian/libsnmp-base.files 2006-10-15 13:47:39.000000000 +0200
@@ -1,3 +1,3 @@
-usr/share/snmp/mibs
+var/lib/snmp/mibs
usr/share/snmp/mib2c-data
usr/share/man/man5/*
diff -ruN net-snmp-5.2.3.orig/debian/libsnmp-base.prerm net-snmp-5.2.3/debian/libsnmp-base.prerm
--- net-snmp-5.2.3.orig/debian/libsnmp-base.prerm 2006-10-15 13:46:02.000000000 +0200
+++ net-snmp-5.2.3/debian/libsnmp-base.prerm 2006-10-15 13:47:39.000000000 +0200
@@ -2,7 +2,7 @@
set -e
-rm -f /usr/share/snmp/mibs/.index
+rm -f /var/lib/snmp/mibs/.index
#DEBHELPER#
diff -ruN net-snmp-5.2.3.orig/debian/patches/07_docfiles.patch net-snmp-5.2.3/debian/patches/07_docfiles.patch
--- net-snmp-5.2.3.orig/debian/patches/07_docfiles.patch 2006-10-15 13:46:02.000000000 +0200
+++ net-snmp-5.2.3/debian/patches/07_docfiles.patch 2006-10-15 13:47:39.000000000 +0200
@@ -62,7 +62,7 @@
Firstly,
- cp MY-MIB.txt /usr/local/share/snmp/mibs
-+ cp MY-MIB.txt /usr/share/snmp/mibs
++ cp MY-MIB.txt /var/lib/snmp/mibs
or
@@ -71,7 +71,7 @@
The first command copies the file defining the new MIB to a
expected location for MIB files. This defaults to
- /usr/local/share/snmp/mibs (or PREFIX/share/snmp/mibs if the the
-+ /usr/share/snmp/mibs (or PREFIX/share/snmp/mibs if the the
++ /var/lib/snmp/mibs (or PREFIX/share/snmp/mibs if the the
suite was installed into a different base location). Some
ready-packaged distributions (such as Linux RPM packages) may look
for MIB files in a different location, such as /etc/snmp/mibs - put
@@ -98,7 +98,7 @@
Alternatively, the tools may be looking in the wrong place.
- The default location for the mib files is /usr/local/share/snmp/mibs.
-+ The default location for the mib files is /usr/share/snmp/mibs.
++ The default location for the mib files is /var/lib/snmp/mibs.
Again, this is set when the suite is first configured and compiled.
This can be changed using the environmental variable 'MIBDIRS'
or the snmp.conf directive 'mibdirs'.
diff -ruN net-snmp-5.2.3.orig/debian/rules net-snmp-5.2.3/debian/rules
--- net-snmp-5.2.3.orig/debian/rules 2006-10-15 13:46:02.000000000 +0200
+++ net-snmp-5.2.3/debian/rules 2006-10-15 13:48:30.000000000 +0200
@@ -60,6 +60,7 @@
--without-rpm --with-libwrap --with-openssl \
--without-dmalloc --without-efence --without-rsaref \
--with-sys-contact="root" --with-sys-location="Unknown" \
+ --with-mibdirs="\$HOME/.snmp/mibs:/var/lib/snmp/mibs" \
--with-mib-modules="$(MIB_MODULES)" \
--enable-mfd-rewrites \
--with-defaults
@@ -109,7 +110,8 @@
$(MAKE) prefix=`pwd`/debian/tmp/usr exec_prefix=`pwd`/debian/tmp/usr \
mandir=`pwd`/debian/tmp/usr/share/man \
persistentdir=`pwd`/debian/tmp/var/lib/snmp \
- PREFIX=`pwd`/debian/tmp/usr install
+ PREFIX=`pwd`/debian/tmp/usr \
+ mibdir=`pwd`/debian/tmp/var/lib/snmp/mibs install
# Install the "broke" headers
cp agent/mibgroup/struct.h debian/tmp/usr/include/net-snmp/agent
cp agent/mibgroup/util_funcs.h debian/tmp/usr/include/net-snmp
diff -ruN net-snmp-5.2.3.orig/debian/snmpd.default net-snmp-5.2.3/debian/snmpd.default
--- net-snmp-5.2.3.orig/debian/snmpd.default 2006-10-15 13:46:02.000000000 +0200
+++ net-snmp-5.2.3/debian/snmpd.default 2006-10-15 13:47:39.000000000 +0200
@@ -1,8 +1,8 @@
# This file controls the activity of snmpd and snmptrapd
-# MIB directories. /usr/share/snmp/mibs is the default, but
+# MIB directories. /var/lib/snmp/mibs is the default, but
# including it here avoids some strange problems.
-export MIBDIRS=/usr/share/snmp/mibs
+export MIBDIRS=/var/lib/snmp/mibs
# snmpd control (yes means start daemon).
SNMPDRUN=yes
diff -ruN net-snmp-5.2.3.orig/debian/snmpd.init net-snmp-5.2.3/debian/snmpd.init
--- net-snmp-5.2.3.orig/debian/snmpd.init 2006-10-15 13:46:02.000000000 +0200
+++ net-snmp-5.2.3/debian/snmpd.init 2006-10-15 13:47:39.000000000 +0200
@@ -5,7 +5,7 @@
test -x /usr/sbin/snmptrapd || exit 0
# Defaults
-export MIBDIRS=/usr/share/snmp/mibs
+export MIBDIRS=/var/lib/snmp/mibs
SNMPDRUN=yes
SNMPDOPTS='-Lsd -Lf /dev/null -p /var/run/snmpd.pid'
TRAPDRUN=no
diff -ruN net-snmp-5.3.1.orig/debian/libsnmp-base.dirs net-snmp-5.3.1/debian/libsnmp-base.dirs
--- net-snmp-5.3.1.orig/debian/libsnmp-base.dirs 2006-10-15 18:59:48.000000000 +0200
+++ net-snmp-5.3.1/debian/libsnmp-base.dirs 2006-10-15 19:00:30.000000000 +0200
@@ -1 +1 @@
-var/lib/snmp
+var/lib/snmp/mibs
diff -ruN net-snmp-5.3.1.orig/debian/libsnmp-base.install net-snmp-5.3.1/debian/libsnmp-base.install
--- net-snmp-5.3.1.orig/debian/libsnmp-base.install 2006-10-15 18:59:48.000000000 +0200
+++ net-snmp-5.3.1/debian/libsnmp-base.install 2006-10-15 19:02:13.000000000 +0200
@@ -1,3 +1,3 @@
-debian/tmp/usr/share/snmp/mibs
+debian/tmp/var/lib/snmp/mibs
debian/tmp/usr/share/snmp/mib2c-data
debian/tmp/usr/share/man/man5/*
diff -ruN net-snmp-5.3.1.orig/debian/libsnmp-base.prerm net-snmp-5.3.1/debian/libsnmp-base.prerm
--- net-snmp-5.3.1.orig/debian/libsnmp-base.prerm 2006-10-15 18:59:48.000000000 +0200
+++ net-snmp-5.3.1/debian/libsnmp-base.prerm 2006-10-15 19:00:32.000000000 +0200
@@ -2,7 +2,7 @@
set -e
-rm -f /usr/share/snmp/mibs/.index
+rm -f /var/lib/snmp/mibs/.index
#DEBHELPER#
diff -ruN net-snmp-5.3.1.orig/debian/patches/07_docfiles.patch net-snmp-5.3.1/debian/patches/07_docfiles.patch
--- net-snmp-5.3.1.orig/debian/patches/07_docfiles.patch 2006-10-15 18:59:48.000000000 +0200
+++ net-snmp-5.3.1/debian/patches/07_docfiles.patch 2006-10-15 19:00:32.000000000 +0200
@@ -62,7 +62,7 @@
Firstly,
- cp MY-MIB.txt /usr/local/share/snmp/mibs
-+ cp MY-MIB.txt /usr/share/snmp/mibs
++ cp MY-MIB.txt /var/lib/snmp/mibs
or
@@ -71,7 +71,7 @@
The first command copies the file defining the new MIB to a
expected location for MIB files. This defaults to
- /usr/local/share/snmp/mibs (or PREFIX/share/snmp/mibs if the the
-+ /usr/share/snmp/mibs (or PREFIX/share/snmp/mibs if the the
++ /var/lib/snmp/mibs (or PREFIX/share/snmp/mibs if the the
suite was installed into a different base location). Some
ready-packaged distributions (such as Linux RPM packages) may look
for MIB files in a different location, such as /etc/snmp/mibs - put
@@ -98,7 +98,7 @@
Alternatively, the tools may be looking in the wrong place.
- The default location for the mib files is /usr/local/share/snmp/mibs.
-+ The default location for the mib files is /usr/share/snmp/mibs.
++ The default location for the mib files is /var/lib/snmp/mibs.
Again, this is set when the suite is first configured and compiled.
This can be changed using the environmental variable 'MIBDIRS'
or the snmp.conf directive 'mibdirs'.
diff -ruN net-snmp-5.3.1.orig/debian/rules net-snmp-5.3.1/debian/rules
--- net-snmp-5.3.1.orig/debian/rules 2006-10-15 18:59:48.000000000 +0200
+++ net-snmp-5.3.1/debian/rules 2006-10-15 19:01:23.000000000 +0200
@@ -27,7 +27,7 @@
DEB_AUTO_UPDATE_AUTOCONF = 2.59
DEB_DH_MAKESHLIBS_ARGS_libsnmp$(LIB_VERSION) := -V"libsnmp$(LIB_VERSION) (>= $(COMPAT_VERSION))"
-DEB_MAKE_INSTALL_TARGET=install INSTALL_PREFIX=$(CURDIR)/debian/tmp DESTDIR=$(CURDIR)/debian/tmp
+DEB_MAKE_INSTALL_TARGET=install INSTALL_PREFIX=$(CURDIR)/debian/tmp DESTDIR=$(CURDIR)/debian/tmp mibdir=/var/lib/snmp/mibs
DEB_MAKE_BUILD_TARGET=LD_RUN_PATH=
DEB_CONFIGURE_EXTRA_FLAGS := --prefix=/usr --sysconfdir=/etc --mandir=/usr/share/man \
--with-persistent-directory=/var/lib/snmp \
@@ -38,6 +38,7 @@
--without-rpm --with-libwrap --with-openssl \
--without-dmalloc --without-efence --without-rsaref \
--with-sys-contact="root" --with-sys-location="Unknown" \
+ --with-mibdirs="\$HOME/.snmp/mibs:/var/lib/snmp/mibs" \
--with-mib-modules="$(MIB_MODULES)" \
--enable-mfd-rewrites \
--with-defaults
diff -ruN net-snmp-5.3.1.orig/debian/snmpd.default net-snmp-5.3.1/debian/snmpd.default
--- net-snmp-5.3.1.orig/debian/snmpd.default 2006-10-15 18:59:48.000000000 +0200
+++ net-snmp-5.3.1/debian/snmpd.default 2006-10-15 19:00:32.000000000 +0200
@@ -1,8 +1,8 @@
# This file controls the activity of snmpd and snmptrapd
-# MIB directories. /usr/share/snmp/mibs is the default, but
+# MIB directories. /var/lib/snmp/mibs is the default, but
# including it here avoids some strange problems.
-export MIBDIRS=/usr/share/snmp/mibs
+export MIBDIRS=/var/lib/snmp/mibs
# snmpd control (yes means start daemon).
SNMPDRUN=yes
diff -ruN net-snmp-5.3.1.orig/debian/snmpd.init net-snmp-5.3.1/debian/snmpd.init
--- net-snmp-5.3.1.orig/debian/snmpd.init 2006-10-15 18:59:48.000000000 +0200
+++ net-snmp-5.3.1/debian/snmpd.init 2006-10-15 19:00:32.000000000 +0200
@@ -5,7 +5,7 @@
test -x /usr/sbin/snmptrapd || exit 0
# Defaults
-export MIBDIRS=/usr/share/snmp/mibs
+export MIBDIRS=/var/lib/snmp/mibs
SNMPDRUN=yes
SNMPDOPTS='-Lsd -Lf /dev/null -p /var/run/snmpd.pid'
TRAPDRUN=no
diff -ruN net-snmp-5.2.3.orig/snmplib/parse.c net-snmp-5.2.3/snmplib/parse.c
--- net-snmp-5.2.3.orig/snmplib/parse.c 2006-01-17 15:49:35.000000000 +0100
+++ net-snmp-5.2.3/snmplib/parse.c 2006-10-15 13:47:39.000000000 +0200
@@ -4708,6 +4708,7 @@
#endif
if ((dir = opendir(dirname))) {
+ mode_t mask = umask(0022); /* save; use mode 0644 */
snprintf(tmpstr, sizeof(tmpstr), "%s/.index", dirname);
tmpstr[ sizeof(tmpstr)-1 ] = 0;
ip = fopen(tmpstr, "w");
@@ -4733,6 +4734,7 @@
closedir(dir);
if (ip)
fclose(ip);
+ umask(mask); /* restore */
return (count);
}
else
Reply to: