add rpm 5.1.6

git-svn-id: https://svn.disconnected-by-peer.at/svn/linamh/trunk/linamh@523 6952d904-891a-0410-993b-d76249ca496b
This commit is contained in:
geos_one 2008-11-04 07:24:58 +00:00
parent e1011a0260
commit b8d0b4e9e4
21 changed files with 2078 additions and 0 deletions

2
app-arch/rpm/Manifest Normal file
View File

@ -0,0 +1,2 @@
DIST rpm-5.1.6.tar.gz 8305612 RMD160 88645f4a7c2e25fffaa5628d267e86eaac137b35 SHA1 3ab7d1edf333102c748c22e9144ab90d9719ab0b SHA256 82ee1a737bd77ddd90b0fe1e9a2f478c46033e451fac3881d00ab9e166951799
EBUILD rpm-5.1.6.ebuild 2951 RMD160 1052b2f14972a43386465b13d2014b56f7575c67 SHA1 d7d7c2774abb8fb20c82e1585c81bb95c755d478 SHA256 fe358050f2138c6899e2846674299435c44a40bab562e271fe0c25b273e2e08b

View File

@ -0,0 +1,111 @@
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-arch/rpm/rpm-5.0.3.ebuild,v 1.2 2008/09/25 09:54:44 aballier Exp $
inherit multilib distutils python
MY_P=${P/_alpha/a}
MY_P=${P/_beta/b}
DESCRIPTION="RPM Package Manager"
HOMEPAGE="http://rpm5.org/"
SRC_URI="http://rpm5.org/files/rpm/rpm-5.1/${MY_P}.tar.gz"
LICENSE="GPL-2 LGPL-2"
SLOT="0"
KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~x86-fbsd"
IUSE="berkdb bzip2 doc file lua neon nls pcre perl python selinux sqlite"
# dmalloc? ( dev-libs/dmalloc )
# efence? ( dev-util/efence )
# keyutils? ( sys-apps/keyutils )
# xar? ( app-arch/xar )
RDEPEND="dev-libs/beecrypt
dev-libs/popt
berkdb? ( sys-libs/db )
bzip2? ( app-arch/bzip2 )
lua? ( dev-lang/lua )
neon? ( net-misc/neon )
pcre? ( dev-libs/libpcre )
perl? ( dev-lang/perl )
python? ( dev-lang/python )
selinux? ( sys-libs/libselinux )
sqlite? ( dev-db/sqlite )"
# comes bundled with modified zlib
# >=sys-libs/zlib-1.2.3-r1
DEPEND="${RDEPEND}
doc? ( app-doc/doxygen )
nls? ( sys-devel/gettext )"
S=${WORKDIR}/${MY_P}
pkg_setup () {
ewarn "If you are upgrading from an rpm version of 5.0.0 or lower, "
ewarn "your database will not be updated. Please back up your "
ewarn "database and run: "
ewarn " rpm --initdb"
}
src_unpack() {
unpack ${A}
cd "${S}"
rm -rf file xar #db
sed -i \
-e '/^pkgconfigdir/s:=.*:=$(libdir)/pkgconfig:' \
scripts/Makefile.in || die
}
src_compile() {
# $(use_with dmalloc) \
# $(use_with efence) \
# $(use_with keyutils) \
# $(use_with xar) \
# --with-libelf
use python && python_version
econf \
$(use_with berkdb db) \
$(use_with bzip2) \
$(use_with doc apidocs) \
$(use_with file) \
$(use_with lua) \
$(use_with neon) \
$(use_with nls) \
$(use_with pcre) \
$(use_with perl) \
$(use_with python) \
$(use_with selinux) \
$(use_with sqlite) \
$(use berkdb || use sqlite || echo --with-db) \
--with-path-lib="/usr/$(get_libdir)/rpm" \
--with-python-lib-dir="/usr/$(get_libdir)/python${PYVER}" \
|| die "econf failed"
emake || die "emake failed"
}
src_install() {
emake DESTDIR="${D}" install || die "emake install failed"
dodoc CHANGES CREDITS NEWS README TODO
}
pkg_preinst() {
enewgroup rpm 37
enewuser rpm 37 /bin/sh /var/lib/rpm rpm
}
pkg_postinst() {
chown -R rpm:rpm "${ROOT}"/usr/$(get_libdir)/rpm
chown -R rpm:rpm "${ROOT}"/var/lib/rpm
chown rpm:rpm "${ROOT}"/usr/bin/rpm{,2cpio,build,constant}
if [[ ${ROOT} == "/" ]] ; then
if [[ -f ${ROOT}/var/lib/rpm/Packages ]] ; then
einfo "RPM database found... Rebuilding database (may take a while)..."
"${ROOT}"/usr/bin/rpm --rebuilddb --root="${ROOT}"
else
einfo "No RPM database found... Creating database..."
"${ROOT}"/usr/bin/rpm --initdb --root="${ROOT}"
fi
fi
chown rpm:rpm "${ROOT}"/var/lib/rpm/*
distutils_pkg_postinst
}

View File

@ -0,0 +1,21 @@
AUX net-snmp-5.1.2-snmpconf-selinux.patch 286 RMD160 c78fd9d2a563ebafd21aa85a582b989a805eb645 SHA1 159990e855cfeb50ac3657d1b97eda181d4ffb9e SHA256 70b4bdaa243efd5ae5703b3272063314fc56b6e2333f7c650b635ddab141f874
AUX net-snmp-5.4-exec-crash.patch 567 RMD160 fe110ace0ae451a8cf25d18d4133fb0d85dcaf5c SHA1 4a4538958e4c805981e1f0da4d6f1980a03aeab6 SHA256 2c4d3d281380d394d0d349c37839bb89f3d82d3e1c43513e042d24126441741c
AUX net-snmp-5.4-makefile.patch 597 RMD160 90f8e6db0a05fd21c06e98b65b4bbd377f931fe9 SHA1 2ff51b2ab2df2224dd34ca1af16430fbf0b97927 SHA256 fd8c6ceda9c5d99cd92f81a7977d2134960ee14fac3ab9f1f8c6d03c6a69edb1
AUX net-snmp-5.4.1-CVE-2008-2292.patch 6212 RMD160 79b2e05df4623972dbaea2dd92dea4a46975c566 SHA1 7fe5f5e9785deeaa1852de76fcba17cbbf9781dc SHA256 10908598aa445bad84708af3ebba1e6a6d985a8008e0c4be42df556851f6a48d
AUX net-snmp-5.4.1-clientaddr-fix.patch 4013 RMD160 52c45d7dd34b5aadcfd7ef48c445d47b5491936d SHA1 714fc3fccc65516ae2a6d836ce181edfd4dc83c3 SHA256 15a8f05e47eb337d8963ed2b1fd81ecb00fe9b631d3281507bdc1b17c5d542cb
AUX net-snmp-5.4.1-incorrect-hrFSStorageIndex.patch 16053 RMD160 1d33a23b165946f7dd4e97b329c79d27c42ec913 SHA1 c4a107c35cf96b3c52a3156ab9f999b46582b693 SHA256 2d3aad8d76046e11a520d45bc5d3304b1ceff91c6d5a5510dc020aae47506b3d
AUX net-snmp-5.4.1-ipAddressTable-crash-with-double-free.patch 4740 RMD160 305f962976c6afc39b0ee37706f34d05ea768874 SHA1 93b806c407048cba4f5c63137df1e819c83d0010 SHA256 0872a11f48106f1a2a9c4a8a894abe31b04ee607bdfd44b8207c8e659213ef31
AUX net-snmp-5.4.1-perl-asneeded.patch 1219 RMD160 caced600c35165603069e62a17a664d7a0180586 SHA1 89bedb2424d65176a9bfba8c9b318b1d50b5b3ed SHA256 42640b545363cd5c6c7eef6b17b10c1d256e189ceb7b7c874baa4041de24e151
AUX net-snmp-5.4.1-process-count-race.patch 1489 RMD160 221f218270b83afec95d1efd260109b8baf05626 SHA1 3986f4789c145dd7182bf5f7d94a1cda0504ce5c SHA256 74a6e001de7a855079be988dd0cb23190095082e1a9adaefb9a9cac677ffa116
AUX net-snmp-5.4.1-suppresssuppress-annoying.patch 800 RMD160 aa23a30241ae64aeed6a08a630326fd7c2e0f9fe SHA1 2b99c56d1f659f324c5676d48ab257ea3b55467f SHA256 f5249b782079be96256ab6e7a0d398c04dfbcabffa7f4c716fe1abd39897aabe
AUX net-snmp-5.4.1.1-rpm5-1.patch 2258 RMD160 e29716d03c86874579c1fb2f3edafd5867991286 SHA1 3a403ef15bb2edf151531b5fd291df6937ef216e SHA256 ad958fcf18565930e428027e6ea60546865947b149255b2e166e9fe2a8726ee5
AUX net-snmp-lm_sensors.patch 13686 RMD160 b2e67c6f5a5347442fbaa97c9ce209f1d9bed194 SHA1 3e795339fc93306a4d662feeaa16faca2509a058 SHA256 51dc2363a687d9f4e65b0a59e767b33129d07623a0b4da07b685e406d2576b86
AUX rpm514-netsnmp-5.4.1.1.patch 11813 RMD160 de2ed34c72280d2da308a0f1e0b293d51f2c391c SHA1 5856bc7531c40e7b9be267b5cd117d6ddf7dc043 SHA256 801039ba6a484fe83c7e1940e4227fccafe4c7cf1962f9fcda01e70869abaa28
AUX snmpd.conf 598 RMD160 c72a20fe6d4682ceea533587762782d62906b630 SHA1 51ebdca93c68ca04b7f402fad4f504422ec2c6cf SHA256 1f4f07b831c3227588fd546423137ed5c60a602fbee13b0d66edd801e4e7d598
AUX snmpd.rc7 706 RMD160 137d85e5f2b7cae62e214141aabcec495777007e SHA1 8d94d3bb2d3b43e20604030dc585c735685cf99b SHA256 93337ebeac92ec0073c896db0a4384beebf84ee17365bdc2594285fd33ac7dfe
AUX snmptrapd.conf 635 RMD160 aba7b7196835bd359174156a527e13188f76e248 SHA1 0d296caa01c789455c3cd4c67cd81aca5547681d SHA256 902d73cb44446df060bf20e0c8ef0f8815d5b846f96d93894913d3309a3841b3
AUX snmptrapd.rc7 557 RMD160 e67117fbcb0a6f8668cb1abbc8fcfcb548ebfdb5 SHA1 dcaac6c0f9e086e49f653f100e0c3f9a7f65db1d SHA256 3594345cdf3c9a5a04073ec11a54e4a19881b27288cdbf22874cca5d0a0f624c
DIST net-snmp-5.4.1.1.tar.gz 5123861 RMD160 870b6a3e4eb28df3cbdf0df34d23f46bd7de8961 SHA1 cfeef748f242a7b25ad8eea95977ff277984e368 SHA256 b22ecb5e7f0907c20cc7fc9f1e1f31b1b4b2dd81abdc3e2e0bfddf8d060008a2
EBUILD net-snmp-5.4.1.1-r1.ebuild 6268 RMD160 25fec5abaf38e6e75d14e4f939f4357b0c69303f SHA1 37fdffe833d285f3ea7aaddecfe65b02df58c831 SHA256 90f3bbdfce52ded6cae0435f7b7a703765740110562838f5be94dfdf72be8f0b
MISC ChangeLog 30329 RMD160 bae453b1340aeed203c12bb7431c89f64ed9d90a SHA1 66007bcbf8594293d5a7e7561ce5ed7fda785cfb SHA256 075abce0113f6c73852ee3525ba5492b61d63ec47e716a3975db3a0a6d3efd34
MISC metadata.xml 674 RMD160 102cd7df943ef25f0f462f2520fa77ceac3b5680 SHA1 90b51daab27e161a48feed336a348a8ecf0865c2 SHA256 233feade72f1b013bb5b0739478ab7200727db25a1d06977d0d122862565de24

View File

@ -0,0 +1,12 @@
https://bugzilla.redhat.com/show_bug.cgi?id=248329
--- net-snmp-5.1.2/local/snmpconf.orig 2004-04-20 16:20:51.000000000 +0200
+++ net-snmp-5.1.2/local/snmpconf 2007-07-09 15:34:48.000000000 +0200
@@ -585,6 +585,7 @@
}
}
close(O);
+ system("restorecon $outputf");
}
}

View File

@ -0,0 +1,14 @@
https://bugzilla.redhat.com/show_bug.cgi?id=243536
--- net-snmp-5.4/agent/mibgroup/agent/extend.c.orig 2006-10-18 21:07:35.000000000 +0200
+++ net-snmp-5.4/agent/mibgroup/agent/extend.c 2007-06-27 14:30:08.000000000 +0200
@@ -448,6 +448,9 @@
extension->command = strdup( exec_command );
if (cptr)
extension->args = strdup( cptr );
+ } else {
+ snmp_log(LOG_ERR, "Duplicate MIBOID '%s' detected in exec statement, only the first one will be used.\n", exec_name);
+ return;
}
#ifndef USING_UCD_SNMP_EXTENSIBLE_MODULE

View File

@ -0,0 +1,20 @@
diff -ru net-snmp-5.4~/agent/mibgroup/Makefile.in net-snmp-5.4/agent/mibgroup/Makefile.in
--- net-snmp-5.4~/agent/mibgroup/Makefile.in 2006-11-26 16:43:18.000000000 +0100
+++ net-snmp-5.4/agent/mibgroup/Makefile.in 2006-11-26 16:44:49.000000000 +0100
@@ -22,9 +22,13 @@
.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
-OBJS = @mib_module_list_o@
-LOBJS = @mib_module_list_lo@
-SRCS = @mib_module_list_c@
+@mib_module_list_o@
+@mib_module_list_lo@
+@mib_module_list_c@
+
+OBJS = $(mib_module_list_o)
+LOBJS = $(mib_module_list_lo)
+SRCS = $(mib_module_list_c)
all: standardall $(LOBJS)

View File

@ -0,0 +1,192 @@
r16770 | dts12 | 2007-12-22 22:22:44 +0300 (Сбт, 22 Дек 2007) | 2 lines
CHANGES: perl: BUG: 1826174: Check for buffer overflow when printing values.
CHANGES: python: BUG: 1826174: Check for buffer overflow when printing values.
Addresses CVE-2008-2292
--- perl/SNMP/SNMP.xs (revision 16769)
+++ perl/SNMP/SNMP.xs (revision 16770)
@@ -470,14 +470,16 @@
if (flag == USE_ENUMS) {
for(ep = tp->enums; ep; ep = ep->next) {
if (ep->value == *var->val.integer) {
- strcpy(buf, ep->label);
+ strncpy(buf, ep->label, buf_len);
+ buf[buf_len-1] = '\0';
len = strlen(buf);
break;
}
}
}
if (!len) {
- sprintf(buf,"%ld", *var->val.integer);
+ snprintf(buf, buf_len, "%ld", *var->val.integer);
+ buf[buf_len-1] = '\0';
len = strlen(buf);
}
break;
@@ -486,21 +488,25 @@
case ASN_COUNTER:
case ASN_TIMETICKS:
case ASN_UINTEGER:
- sprintf(buf,"%lu", (unsigned long) *var->val.integer);
+ snprintf(buf, buf_len, "%lu", (unsigned long) *var->val.integer);
+ buf[buf_len-1] = '\0';
len = strlen(buf);
break;
case ASN_OCTET_STR:
case ASN_OPAQUE:
- memcpy(buf, (char*)var->val.string, var->val_len);
len = var->val_len;
+ if ( len > buf_len )
+ len = buf_len;
+ memcpy(buf, (char*)var->val.string, len);
break;
case ASN_IPADDRESS:
- ip = (u_char*)var->val.string;
- sprintf(buf, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
- len = strlen(buf);
- break;
+ ip = (u_char*)var->val.string;
+ snprintf(buf, buf_len, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
+ buf[buf_len-1] = '\0';
+ len = strlen(buf);
+ break;
case ASN_NULL:
break;
@@ -512,14 +518,14 @@
break;
case SNMP_ENDOFMIBVIEW:
- sprintf(buf,"%s", "ENDOFMIBVIEW");
- break;
+ snprintf(buf, buf_len, "%s", "ENDOFMIBVIEW");
+ break;
case SNMP_NOSUCHOBJECT:
- sprintf(buf,"%s", "NOSUCHOBJECT");
- break;
+ snprintf(buf, buf_len, "%s", "NOSUCHOBJECT");
+ break;
case SNMP_NOSUCHINSTANCE:
- sprintf(buf,"%s", "NOSUCHINSTANCE");
- break;
+ snprintf(buf, buf_len, "%s", "NOSUCHINSTANCE");
+ break;
case ASN_COUNTER64:
#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
@@ -538,19 +544,19 @@
#endif
case ASN_BIT_STR:
- snprint_bitstring(buf, sizeof(buf), var, NULL, NULL, NULL);
+ snprint_bitstring(buf, buf_len, var, NULL, NULL, NULL);
len = strlen(buf);
break;
#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
case ASN_OPAQUE_FLOAT:
- if (var->val.floatVal)
- sprintf(buf,"%f", *var->val.floatVal);
- break;
+ if (var->val.floatVal)
+ snprintf(buf, buf_len, "%f", *var->val.floatVal);
+ break;
case ASN_OPAQUE_DOUBLE:
- if (var->val.doubleVal)
- sprintf(buf,"%f", *var->val.doubleVal);
- break;
+ if (var->val.doubleVal)
+ snprintf(buf, buf_len, "%f", *var->val.doubleVal);
+ break;
#endif
case ASN_NSAP:
--- python/netsnmp/client_intf.c (revision 16961)
+++ python/netsnmp/client_intf.c (revision 16962)
@@ -330,14 +330,15 @@
if (flag == USE_ENUMS) {
for(ep = tp->enums; ep; ep = ep->next) {
if (ep->value == *var->val.integer) {
- strcpy(buf, ep->label);
+ strncpy(buf, ep->label, buf_len);
+ buf[buf_len -1] = 0;
len = STRLEN(buf);
break;
}
}
}
if (!len) {
- sprintf(buf,"%ld", *var->val.integer);
+ snprintf(buf,"%ld", buf_len, *var->val.integer);
len = STRLEN(buf);
}
break;
@@ -346,19 +347,21 @@
case ASN_COUNTER:
case ASN_TIMETICKS:
case ASN_UINTEGER:
- sprintf(buf,"%lu", (unsigned long) *var->val.integer);
+ snprintf(buf, buf_len, "%lu", (unsigned long) *var->val.integer);
len = STRLEN(buf);
break;
case ASN_OCTET_STR:
case ASN_OPAQUE:
- memcpy(buf, (char*)var->val.string, var->val_len);
len = var->val_len;
+ if (len > buf_len)
+ len = buf_len;
+ memcpy(buf, (char*)var->val.string, len);
break;
case ASN_IPADDRESS:
ip = (u_char*)var->val.string;
- sprintf(buf, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
+ snprintf(buf, buf_len, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
len = STRLEN(buf);
break;
@@ -372,13 +375,13 @@
break;
case SNMP_ENDOFMIBVIEW:
- sprintf(buf,"%s", "ENDOFMIBVIEW");
+ snprintf(buf, buf_len, "%s", "ENDOFMIBVIEW");
break;
case SNMP_NOSUCHOBJECT:
- sprintf(buf,"%s", "NOSUCHOBJECT");
+ snprintf(buf, buf_len, "%s", "NOSUCHOBJECT");
break;
case SNMP_NOSUCHINSTANCE:
- sprintf(buf,"%s", "NOSUCHINSTANCE");
+ snprintf(buf, buf_len, "%s", "NOSUCHINSTANCE");
break;
case ASN_COUNTER64:
@@ -398,18 +401,18 @@
#endif
case ASN_BIT_STR:
- snprint_bitstring(buf, sizeof(buf), var, NULL, NULL, NULL);
+ snprint_bitstring(buf, buf_len, var, NULL, NULL, NULL);
len = STRLEN(buf);
break;
#ifdef OPAQUE_SPECIAL_TYPES
case ASN_OPAQUE_FLOAT:
if (var->val.floatVal)
- sprintf(buf,"%f", *var->val.floatVal);
+ snprintf(buf, buf_len, "%f", *var->val.floatVal);
break;
case ASN_OPAQUE_DOUBLE:
if (var->val.doubleVal)
- sprintf(buf,"%f", *var->val.doubleVal);
+ snprintf(buf, buf_len, "%f", *var->val.doubleVal);
break;
#endif

View File

@ -0,0 +1,95 @@
Fix clientaddr functionality. Includes further memory leak and newline fixes.
Previously, the clientaddr option in snmp.conf was parsed, but the actual
clientaddr was used to bind(), yet sendmsg() was still called with 0.0.0.0.
This patch alters:
- netsnmp_udp_fmtaddr: include both sides of addr_pair for debugging.
- netsnmp_udp_transport: Set addr_pair->local_addr in the remote && client_socket path.
- netsnmp_udp_transport: Print a debugging error on failure to bind()
- netsnmp_udp_transport: Print out the full client open addr_pair data.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
Status: Merged in upstream r16654
Tracking-URL: https://sourceforge.net/tracker/?func=detail&atid=312694&aid=1775124&group_id=12694
Further fixes:
Revision 16681
add missing newline in debug msg
Revision 16704
CHANGES: snmplib: BUG: Coverity #183: fix memory leak if IP_PKTINFO fails
Revision 16716
CHANGES: snmplib: Do not leak memory whenever an udp address is formatted.
Fixes bug: bugs.gentoo.org/180266
diff -Naur net-snmp-5.4.1.orig/snmplib/snmpUDPDomain.c net-snmp-5.4.1/snmplib/snmpUDPDomain.c
--- net-snmp-5.4.1.orig/snmplib/snmpUDPDomain.c 2007-06-11 02:15:24.000000000 +0400
+++ net-snmp-5.4.1/snmplib/snmpUDPDomain.c 2007-12-27 18:15:56.000000000 +0300
@@ -104,11 +104,13 @@
char tmp[64];
to = (struct sockaddr_in *) &(addr_pair->remote_addr);
if (to == NULL) {
- return strdup("UDP: unknown");
+ sprintf(tmp, "UDP: [%s]->unknown",
+ inet_ntoa(addr_pair->local_addr));
+ } else {
+ sprintf(tmp, "UDP: [%s]->", inet_ntoa(addr_pair->local_addr));
+ sprintf(tmp + strlen(tmp), "[%s]:%hd",
+ inet_ntoa(to->sin_addr), ntohs(to->sin_port));
}
-
- sprintf(tmp, "UDP: [%s]:%hu",
- inet_ntoa(to->sin_addr), ntohs(to->sin_port));
return strdup(tmp);
}
}
@@ -642,6 +644,7 @@
if (setsockopt(t->sock, SOL_IP, IP_PKTINFO, &sockopt, sizeof sockopt) == -1) {
DEBUGMSGTL(("netsnmp_udp", "couldn't set IP_PKTINFO: %s\n",
strerror(errno)));
+ netsnmp_transport_free(t);
return NULL;
}
DEBUGMSGTL(("netsnmp_udp", "set IP_PKTINFO\n"));
@@ -667,10 +670,24 @@
if (client_socket) {
struct sockaddr_in client_addr;
netsnmp_sockaddr_in2(&client_addr, client_socket, NULL);
+ addr_pair.local_addr = client_addr.sin_addr;
client_addr.sin_port = 0;
- bind(t->sock, (struct sockaddr *)&client_addr,
+ rc = bind(t->sock, (struct sockaddr *)&client_addr,
sizeof(struct sockaddr));
+ if ( rc != 0 ) {
+ DEBUGMSGTL(("netsnmp_udp", "failed to bind for clientaddr: %d %s\n",
+ errno, strerror(errno)));
+ netsnmp_udp_close(t);
+ netsnmp_transport_free(t);
+ return NULL;
+ }
}
+
+ str = netsnmp_udp_fmtaddr(NULL, (void *)&addr_pair,
+ sizeof(netsnmp_udp_addr_pair));
+ DEBUGMSGTL(("netsnmp_udp", "client open %s\n", str));
+ free(str);
+
/*
* Save the (remote) address in the
* transport-specific data pointer for later use by netsnmp_udp_send.
@@ -839,12 +856,12 @@
if (host == NULL) {
DEBUGMSGTL(("netsnmp_sockaddr_in",
"servname not numeric, "
- "check if it really is a destination)"));
+ "check if it really is a destination)\n"));
host = port;
port = NULL;
} else {
DEBUGMSGTL(("netsnmp_sockaddr_in",
- "servname not numeric"));
+ "servname not numeric\n"));
free(peername);
return 0;
}

View File

@ -0,0 +1,538 @@
r16694 | rstory | 2007-09-14 17:11:59 +0400 (Птн, 14 Сен 2007) | 3 lines
Apple patches
- add/fix disk/partition tables on darwin
Also fixes incorrect hrFSStorageIndex
http://bugs.gentoo.org/show_bug.cgi?id=211660
http://sourceforge.net/tracker/index.php?func=detail&aid=1696044&group_id=12694&atid=312694
--- agent/mibgroup/host/hr_partition.c (revision 16693)
+++ agent/mibgroup/host/hr_partition.c (revision 16694)
@@ -1,8 +1,17 @@
-
/*
* Host Resources MIB - partition device group implementation - hr_partition.c
*
*/
+/* Portions of this file are subject to the following copyright(s). See
+ * the Net-SNMP's COPYING file for more details and other copyrights
+ * that may apply:
+ */
+/*
+ * Portions of this file are copyrighted by:
+ * Copyright (C) 2007 Apple, Inc. All rights reserved.
+ * Use is subject to license terms specified in the COPYING file
+ * distributed with the Net-SNMP package.
+ */
#include <net-snmp/net-snmp-config.h>
#include <fcntl.h>
@@ -35,6 +44,9 @@
static int HRP_savedDiskIndex;
static int HRP_savedPartIndex;
static char HRP_savedName[1024];
+#ifdef NETSNMP_CAN_GET_DISK_LABEL
+static char HRP_savedLabel[1024];
+#endif
static int HRP_DiskIndex;
@@ -135,6 +147,7 @@
(name[HRPART_DISK_NAME_LENGTH] &
((1 << HRDEV_TYPE_SHIFT) - 1));
+ DEBUGMSGTL(("host/hr_partition", "... low index %d\n", LowDiskIndex));
while (HRP_DiskIndex < LowDiskIndex) {
Init_HR_Partition(); /* moves to next disk */
if (HRP_DiskIndex == -1)
@@ -144,6 +157,7 @@
for (;;) {
part_idx = Get_Next_HR_Partition();
+ DEBUGMSGTL(("host/hr_partition", "... part index %d\n", part_idx));
if (part_idx == 0)
break;
newname[HRPART_DISK_NAME_LENGTH] =
@@ -225,8 +239,13 @@
long_return = part_idx;
return (u_char *) & long_return;
case HRPART_LABEL:
+#ifdef NETSNMP_CAN_GET_DISK_LABEL
+ *var_len = strlen(HRP_savedLabel);
+ return (u_char *) HRP_savedLabel;
+#else
*var_len = strlen(HRP_savedName);
return (u_char *) HRP_savedName;
+#endif
case HRPART_ID: /* Use the device number */
sprintf(string, "0x%x", (int) stat_buf.st_rdev);
*var_len = strlen(string);
@@ -259,9 +278,11 @@
static void
Init_HR_Partition(void)
{
+ DEBUGMSGTL(("host/hr_partition", "Init_HR_Partition\n"));
HRP_DiskIndex = Get_Next_HR_Disk();
if (HRP_DiskIndex != -1)
HRP_DiskIndex &= ((1 << HRDEV_TYPE_SHIFT) - 1);
+ DEBUGMSGTL(("host/hr_partition", "... %d\n",HRP_DiskIndex));
HRP_index = -1;
}
@@ -272,6 +293,7 @@
char string[1024];
int fd;
+ DEBUGMSGTL(("host/hr_partition", "Get_Next_HR_Partition %d\n",HRP_DiskIndex));
if (HRP_DiskIndex == -1) {
return 0;
}
@@ -309,4 +331,7 @@
HRP_savedDiskIndex = disk_idx;
HRP_savedPartIndex = part_idx;
(void) Get_Next_HR_Disk_Partition(HRP_savedName, sizeof(HRP_savedName), HRP_index);
+#ifdef NETSNMP_CAN_GET_DISK_LABEL
+ (void) Get_HR_Disk_Label(HRP_savedLabel, sizeof(HRP_savedLabel), HRP_savedName);
+#endif
}
Index: agent/mibgroup/host/hr_filesys.c
===================================================================
--- agent/mibgroup/host/hr_filesys.c (revision 16693)
+++ agent/mibgroup/host/hr_filesys.c (revision 16694)
@@ -2,11 +2,25 @@
* Host Resources MIB - File System device group implementation - hr_filesys.c
*
*/
+/* Portions of this file are subject to the following copyright(s). See
+ * the Net-SNMP's COPYING file for more details and other copyrights
+ * that may apply:
+ */
+/*
+ * Portions of this file are copyrighted by:
+ * Copyright (C) 2007 Apple, Inc. All rights reserved.
+ * Use is subject to license terms specified in the COPYING file
+ * distributed with the Net-SNMP package.
+ */
#include <net-snmp/net-snmp-config.h>
+#include <net-snmp/net-snmp-includes.h>
+#include <net-snmp/agent/net-snmp-agent-includes.h>
+#include <net-snmp/agent/hardware/memory.h>
#include "host_res.h"
#include "hr_filesys.h"
#include "hr_storage.h"
+#include "hr_disk.h"
#include <net-snmp/utilities.h>
#if HAVE_MNTENT_H
@@ -535,7 +549,7 @@
long_return = 2; /* others probably aren't */
return (u_char *) & long_return;
case HRFSYS_STOREIDX:
- long_return = fsys_idx + HRS_TYPE_FIXED_MAX;
+ long_return = fsys_idx + NETSNMP_MEM_TYPE_MAX;
return (u_char *) & long_return;
case HRFSYS_FULLDUMP:
return when_dumped(HRFS_entry->HRFS_name, FULL_DUMP, var_len);
Index: agent/mibgroup/host/hr_disk.c
===================================================================
--- agent/mibgroup/host/hr_disk.c (revision 16693)
+++ agent/mibgroup/host/hr_disk.c (revision 16694)
@@ -2,6 +2,16 @@
* Host Resources MIB - disk device group implementation - hr_disk.c
*
*/
+/* Portions of this file are subject to the following copyright(s). See
+ * the Net-SNMP's COPYING file for more details and other copyrights
+ * that may apply:
+ */
+/*
+ * Portions of this file are copyrighted by:
+ * Copyright (C) 2007 Apple, Inc. All rights reserved.
+ * Use is subject to license terms specified in the COPYING file
+ * distributed with the Net-SNMP package.
+ */
#include <net-snmp/net-snmp-config.h>
#include "host_res.h"
@@ -65,6 +75,15 @@
#include <limits.h>
#endif
+#ifdef darwin
+#include <CoreFoundation/CoreFoundation.h>
+#include <IOKit/IOKitLib.h>
+#include <IOKit/storage/IOBlockStorageDriver.h>
+#include <IOKit/storage/IOMedia.h>
+#include <IOKit/IOBSD.h>
+#include <DiskArbitration/DADisk.h>
+#endif
+
#ifdef linux
/*
* define BLKGETSIZE from <linux/fs.h>:
@@ -79,6 +98,27 @@
#define HRD_MONOTONICALLY_INCREASING
+/*************************************************************
+ * constants for enums for the MIB node
+ * hrDiskStorageAccess (INTEGER / ASN_INTEGER)
+ */
+#define HRDISKSTORAGEACCESS_READWRITE 1
+#define HRDISKSTORAGEACCESS_READONLY 2
+
+
+/*************************************************************
+ * constants for enums for the MIB node
+ * hrDiskStorageMedia (INTEGER / ASN_INTEGER)
+ */
+#define HRDISKSTORAGEMEDIA_OTHER 1
+#define HRDISKSTORAGEMEDIA_UNKNOWN 2
+#define HRDISKSTORAGEMEDIA_HARDDISK 3
+#define HRDISKSTORAGEMEDIA_FLOPPYDISK 4
+#define HRDISKSTORAGEMEDIA_OPTICALDISKROM 5
+#define HRDISKSTORAGEMEDIA_OPTICALDISKWORM 6
+#define HRDISKSTORAGEMEDIA_OPTICALDISKRW 7
+#define HRDISKSTORAGEMEDIA_RAMDISK 8
+
/*********************
*
* Kernel & interface information,
@@ -132,6 +172,19 @@
static struct disklabel HRD_info;
#endif
+#ifdef darwin
+static int64_t HRD_cap;
+static int HRD_access;
+static int HRD_type;
+static int HRD_removeble;
+static char HRD_model[40];
+static int HRD_saved_access;
+static int HRD_saved_type;
+static int HRD_saved_removeble;
+static int _get_type_from_protocol( const char *prot );
+static int _get_type_value( const char *str_type );
+#endif
+
static void parse_disk_config(const char *, char *);
static void free_disk_config(void);
@@ -185,6 +238,8 @@
"/dev/rdsk/c%dt%dd0s0", 0, 7);
Add_HR_Disk_entry("/dev/rdsk/c%dd%ds%d", 0, 7, 0, 15,
"/dev/rdsk/c%dd%ds0", 0, 7);
+#elif defined(darwin)
+ Add_HR_Disk_entry("/dev/disk%ds%d", -1, -1, 0, 32, "/dev/disk%d", 1, 32);
#elif defined(freebsd4) || defined(freebsd5)
Add_HR_Disk_entry("/dev/ad%ds%d%c", 0, 1, 1, 4, "/dev/ad%ds%d", 'a', 'h');
Add_HR_Disk_entry("/dev/da%ds%d%c", 0, 1, 1, 4, "/dev/da%ds%d", 'a', 'h');
@@ -484,6 +539,7 @@
Init_HR_Disk();
for (;;) {
disk_idx = Get_Next_HR_Disk();
+ DEBUGMSGTL(("host/hr_disk", "... index %d\n", disk_idx));
if (disk_idx == -1)
break;
newname[HRDISK_ENTRY_NAME_LENGTH] = disk_idx;
@@ -749,7 +805,13 @@
HRD_history[iindex] = 0;
return ((HRDEV_DISK << HRDEV_TYPE_SHIFT) + iindex);
}
+ DEBUGMSGTL(("host/hr_disk",
+ "Get_Next_HR_Disk: can't query %s\n", string));
}
+ else {
+ DEBUGMSGTL(("host/hr_disk",
+ "Get_Next_HR_Disk: can't open %s\n", string));
+ }
HRD_history[iindex] = now;
HRD_index++;
}
@@ -801,6 +863,66 @@
return 0;
}
+#ifdef darwin
+int
+Get_HR_Disk_Label(char *string, size_t str_len, const char *devfull)
+{
+ DASessionRef sess_ref;
+ DADiskRef disk;
+ CFDictionaryRef desc;
+ CFStringRef str_ref;
+ CFStringEncoding sys_encoding = CFStringGetSystemEncoding();
+
+ DEBUGMSGTL(("host/hr_disk", "Disk Label type %s\n", devfull));
+
+ sess_ref = DASessionCreate( NULL );
+ if (NULL == sess_ref) {
+ strncpy(string, devfull, str_len);
+ string[str_len-1] = 0;
+ return -1;
+ }
+
+ disk = DADiskCreateFromBSDName( NULL, sess_ref, devfull );
+ if (NULL == disk) {
+ CFRelease(sess_ref);
+ strncpy(string, devfull, str_len);
+ string[str_len-1] = 0;
+ return -1;
+ }
+
+ desc = DADiskCopyDescription( disk );
+ if (NULL == desc) {
+ snmp_log(LOG_ERR,
+ "diskmgr: couldn't get disk description for %s, skipping\n",
+ devfull);
+ CFRelease(disk);
+ CFRelease(sess_ref);
+ strncpy(string, devfull, str_len);
+ return -1;
+ }
+
+ /** model */
+ str_ref = (CFStringRef)
+ CFDictionaryGetValue(desc, kDADiskDescriptionMediaNameKey);
+ if (str_ref) {
+ strncpy(string, CFStringGetCStringPtr(str_ref, sys_encoding),
+ str_len);
+ string[str_len-1] = 0;
+ DEBUGMSGTL(("verbose:diskmgr:darwin", " name %s\n", string));
+ }
+ else {
+ strncpy(string, devfull, str_len);
+ string[str_len-1] = 0;
+ }
+
+ CFRelease(disk);
+ CFRelease(desc);
+ CFRelease(sess_ref);
+
+ return 0;
+}
+#endif
+
static void
Save_HR_Disk_Specific(void)
{
@@ -822,6 +944,13 @@
#ifdef DIOCGDINFO
HRD_savedCapacity = HRD_info.d_secperunit / 2;
#endif
+#ifdef darwin
+ HRD_savedCapacity = HRD_cap / 1024;
+ HRD_saved_access = HRD_access;
+ HRD_saved_type = HRD_type;
+ HRD_saved_removeble = HRD_removeble;
+#endif
+
}
static void
@@ -845,6 +974,11 @@
sizeof(HRD_savedModel)-1);
HRD_savedModel[ sizeof(HRD_savedModel)-1 ] = 0;
#endif
+#ifdef darwin
+ strncpy(HRD_savedModel, HRD_model,
+ sizeof(HRD_savedModel)-1);
+ HRD_savedModel[ sizeof(HRD_savedModel)-1 ] = 0;
+#endif
}
static const char *
@@ -900,6 +1034,104 @@
result = ioctl(fd, DIOCGDINFO, &HRD_info);
#endif
+#ifdef darwin
+ DASessionRef sess_ref;
+ DADiskRef disk;
+ CFDictionaryRef desc;
+ CFStringRef str_ref;
+ CFNumberRef number_ref;
+ CFBooleanRef bool_ref;
+ CFStringEncoding sys_encoding = CFStringGetSystemEncoding();
+
+ sess_ref = DASessionCreate( NULL );
+ if (NULL == sess_ref)
+ return -1;
+
+ disk = DADiskCreateFromBSDName( NULL, sess_ref, devfull );
+ if (NULL == disk) {
+ CFRelease(sess_ref);
+ return -1;
+ }
+
+ desc = DADiskCopyDescription( disk );
+ if (NULL == desc) {
+ CFRelease(disk);
+ CFRelease(sess_ref);
+ return -1;
+ }
+
+ number_ref = (CFNumberRef)
+ CFDictionaryGetValue(desc, kDADiskDescriptionMediaSizeKey);
+ if (number_ref)
+ CFNumberGetValue(number_ref, kCFNumberSInt64Type, &HRD_cap);
+ else
+ HRD_cap = 0;
+ DEBUGMSGTL(("verbose:diskmgr:darwin", " size %lld\n", HRD_cap));
+
+ /** writable? */
+ bool_ref = (CFBooleanRef)
+ CFDictionaryGetValue(desc, kDADiskDescriptionMediaWritableKey);
+ if (bool_ref) {
+ HRD_access = CFBooleanGetValue(bool_ref);
+ }
+ else
+ HRD_access = 0;
+ DEBUGMSGTL(("verbose:diskmgr:darwin", " writable %d\n",
+ HRD_access));
+
+ /** removable? */
+ bool_ref = (CFBooleanRef)
+ CFDictionaryGetValue(desc, kDADiskDescriptionMediaRemovableKey);
+ if (bool_ref) {
+ HRD_removeble = CFBooleanGetValue(bool_ref);
+ }
+ else
+ HRD_removeble = 0;
+ DEBUGMSGTL(("verbose:diskmgr:darwin", " removable %d\n",
+ HRD_removeble));
+
+ /** get type */
+ str_ref = (CFStringRef)
+ CFDictionaryGetValue(desc, kDADiskDescriptionMediaTypeKey);
+ if (str_ref) {
+ HRD_type = _get_type_value(CFStringGetCStringPtr(str_ref,
+ sys_encoding));
+ DEBUGMSGTL(("verbose:diskmgr:darwin", " type %s / %d\n",
+ CFStringGetCStringPtr(str_ref, sys_encoding),
+ HRD_type));
+ }
+ else {
+ str_ref = (CFStringRef)
+ CFDictionaryGetValue(desc, kDADiskDescriptionDeviceProtocolKey);
+ if (str_ref) {
+ HRD_type =
+ _get_type_from_protocol(CFStringGetCStringPtr(str_ref,
+ sys_encoding));
+ DEBUGMSGTL(("verbose:diskmgr:darwin", " type %s / %d\n",
+ CFStringGetCStringPtr(str_ref, sys_encoding),
+ HRD_type));
+ }
+ else
+ HRD_type = HRDISKSTORAGEMEDIA_UNKNOWN;
+ }
+
+ /** model */
+ str_ref = (CFStringRef)
+ CFDictionaryGetValue(desc, kDADiskDescriptionDeviceModelKey);
+ if (str_ref) {
+ strncpy(HRD_model, CFStringGetCStringPtr(str_ref, sys_encoding),
+ sizeof(HRD_model));
+ HRD_savedModel[ sizeof(HRD_savedModel)-1 ] = 0;
+ DEBUGMSGTL(("verbose:diskmgr:darwin", " model %s\n", HRD_model));
+ }
+ else
+ HRD_model[0] = 0;
+ CFRelease(disk);
+ CFRelease(desc);
+ CFRelease(sess_ref);
+ result = 0;
+#endif
+
return (result);
}
@@ -918,6 +1150,11 @@
return (2); /* read only */
#endif
+#ifdef darwin
+ if (!HRD_access)
+ return (2);
+#endif
+
return (1); /* read-write */
}
@@ -990,6 +1227,9 @@
}
#endif
+#ifdef darwin
+ return HRD_type;
+#endif
return (2); /* Unknown */
}
@@ -1020,5 +1260,63 @@
return (1); /* true */
#endif
+#ifdef darwin
+ if (HRD_removeble)
+ return (1);
+#endif
+
return (2); /* false */
}
+
+#ifdef darwin
+typedef struct type_value_map_s {
+ const char *type;
+ uint32_t value;
+} type_value_map;
+
+static type_value_map media_type_map[] = {
+ { "CD-ROM", HRDISKSTORAGEMEDIA_OPTICALDISKROM},
+ { "DVD-R", HRDISKSTORAGEMEDIA_OPTICALDISKWORM},
+ { "DVD+R", HRDISKSTORAGEMEDIA_OPTICALDISKWORM},
+};
+static int media_types = sizeof(media_type_map)/sizeof(media_type_map[0]);
+
+static int
+_get_type_value( const char *str_type )
+{
+ int i, len;
+
+ if (NULL == str_type)
+ return HRDISKSTORAGEMEDIA_UNKNOWN;
+
+ len = strlen(str_type);
+ for(i=0; i < media_types; ++i) {
+ if (0 == strcmp(media_type_map[i].type, str_type))
+ return media_type_map[i].value;
+ }
+
+ return HRDISKSTORAGEMEDIA_UNKNOWN;
+}
+
+static type_value_map proto_map[] = {
+ { "ATA", HRDISKSTORAGEMEDIA_HARDDISK},
+ { "ATAPI", HRDISKSTORAGEMEDIA_OPTICALDISKROM}
+};
+static int proto_maps = sizeof(proto_map)/sizeof(proto_map[0]);
+
+static int _get_type_from_protocol( const char *prot )
+{
+ int i, len;
+
+ if (NULL == prot)
+ return TV_FALSE;
+
+ len = strlen(prot);
+ for(i=0; i < proto_maps; ++i) {
+ if (0 == strcmp(proto_map[i].type, prot))
+ return proto_map[i].value;
+ }
+
+ return HRDISKSTORAGEMEDIA_UNKNOWN;
+}
+#endif

View File

@ -0,0 +1,134 @@
r16804 | magfr | 2008-02-14 02:37:48 +0300 (Чтв, 14 Фев 2008) | 2 lines
NEWS: snmplib: Change CONTAINER_INSERT to not do partial inserts in containers with multiple indices when one insert fails.
http://sourceforge.net/tracker/index.php?func=detail&aid=1733344&group_id=12694&atid=112694
http://bugs.gentoo.org/show_bug.cgi?id=203127
Index: snmplib/container.c
===================================================================
--- snmplib/container.c (revision 16803)
+++ snmplib/container.c (revision 16804)
@@ -282,31 +282,41 @@
* These functions should EXACTLY match the inline version in
* container.h. If you change one, change them both.
*/
-int CONTAINER_INSERT(netsnmp_container *x, const void *k)
-{
- int rc2, rc = 0;
-
- /** start at first container */
- while(x->prev)
- x = x->prev;
- for(; x; x = x->next) {
- if ((NULL != x->insert_filter) &&
- (x->insert_filter(x,k) == 1))
- continue;
- rc2 = x->insert(x,k);
- if (rc2) {
+int CONTAINER_INSERT_HELPER(netsnmp_container* x, const void* k)
+{
+ while(x && x->insert_filter && x->insert_filter(x,k) == 1)
+ x = x->next;
+ if(x) {
+ int rc = x->insert(x,k);
+ if(rc)
snmp_log(LOG_ERR,"error on subcontainer '%s' insert (%d)\n",
- x->container_name ? x->container_name : "", rc2);
- rc = rc2;
+ x->container_name ? x->container_name : "", rc);
+ else {
+ rc = CONTAINER_INSERT_HELPER(x->next, k);
+ if(rc)
+ x->remove(x,k);
}
+ return rc;
}
- return rc;
+ return 0;
}
/*------------------------------------------------------------------
* These functions should EXACTLY match the inline version in
* container.h. If you change one, change them both.
*/
+int CONTAINER_INSERT(netsnmp_container* x, const void* k)
+{
+ /** start at first container */
+ while(x->prev)
+ x = x->prev;
+ return CONTAINER_INSERT_HELPER(x, k);
+}
+
+/*------------------------------------------------------------------
+ * These functions should EXACTLY match the inline version in
+ * container.h. If you change one, change them both.
+ */
int CONTAINER_REMOVE(netsnmp_container *x, const void *k)
{
int rc2, rc = 0;
Index: include/net-snmp/library/container.h
===================================================================
--- include/net-snmp/library/container.h (revision 16803)
+++ include/net-snmp/library/container.h (revision 16804)
@@ -364,32 +364,43 @@
* container.c. If you change one, change them both.
*/
NETSNMP_STATIC_INLINE /* gcc docs recommend static w/inline */
- int CONTAINER_INSERT(netsnmp_container *x, const void *k)
+ int CONTAINER_INSERT_HELPER(netsnmp_container* x, const void* k)
{
- int rc2, rc = 0;
-
- /** start at first container */
- while(x->prev)
- x = x->prev;
- for(; x; x = x->next) {
- if ((NULL != x->insert_filter) &&
- (x->insert_filter(x,k) == 1))
- continue;
- rc2 = x->insert(x,k);
- if (rc2) {
+ while(x && x->insert_filter && x->insert_filter(x,k) == 1)
+ x = x->next;
+ if(x) {
+ int rc = x->insert(x,k);
+ if(rc)
snmp_log(LOG_ERR,"error on subcontainer '%s' insert (%d)\n",
- x->container_name ? x->container_name : "", rc2);
- rc = rc2;
+ x->container_name ? x->container_name : "", rc);
+ else {
+ rc = CONTAINER_INSERT_HELPER(x->next, k);
+ if(rc)
+ x->remove(x,k);
}
+ return rc;
}
- return rc;
+ return 0;
}
-
+
/*------------------------------------------------------------------
* These functions should EXACTLY match the function version in
* container.c. If you change one, change them both.
*/
NETSNMP_STATIC_INLINE /* gcc docs recommend static w/inline */
+ int CONTAINER_INSERT(netsnmp_container* x, const void* k)
+ {
+ /** start at first container */
+ while(x->prev)
+ x = x->prev;
+ return CONTAINER_INSERT_HELPER(x, k);
+ }
+
+ /*------------------------------------------------------------------
+ * These functions should EXACTLY match the function version in
+ * container.c. If you change one, change them both.
+ */
+ NETSNMP_STATIC_INLINE /* gcc docs recommend static w/inline */
int CONTAINER_REMOVE(netsnmp_container *x, const void *k)
{
int rc2, rc = 0;

View File

@ -0,0 +1,33 @@
Index: net-snmp-5.4.1/configure.in
===================================================================
--- net-snmp-5.4.1.orig/configure.in
+++ net-snmp-5.4.1/configure.in
@@ -2,7 +2,7 @@
# the Net-SNMP's COPYING file for more details and other copyrights
# that may apply:
#
-# Portions Copyright © 2003 Sun Microsystems, Inc. All rights reserved.
+# Portions Copyright © 2003 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms specified in the COPYING file
# distributed with the Net-SNMP package.
#
@@ -3097,8 +3097,8 @@ fi
# check needed functions
if test "x$embed_perl" != "xno" ; then
- OLDLDFLAGS="$LDFLAGS"
- LDFLAGS="$LDFLAGS $netsnmp_perlldopts"
+ OLDLIBS="$LIBS"
+ LIBS="$LIBS $netsnmp_perlldopts"
# newer perl vs older perl call functions
AC_CHECK_FUNCS(eval_pv)
@@ -3109,7 +3109,7 @@ if test "x$embed_perl" != "xno" ; then
AC_CHECK_FUNC(perl_eval_pv, AC_DEFINE(HAVE_PERL_EVAL_PV_LC))
AC_CHECK_FUNC(Perl_eval_pv, AC_DEFINE(HAVE_PERL_EVAL_PV_UC))
- LDFLAGS="$OLDLDFLAGS"
+ LIBS="$OLDLIBS"
if test "x$ac_cv_func_perl_eval_pv" != "xyes" -a "x$ac_cv_func_Perl_eval_pv" != "xyes" -a "x$ac_cv_func_eval_pv" != "xyes" ; then

View File

@ -0,0 +1,52 @@
r16705 | tanders | 2007-09-21 01:55:49 +0400 (Птн, 21 Сен 2007) | 3 lines
CHANGES: snmpd: PATCH: 1746831: from cunnijd: fix process checking race
condition under Linux and platform #ifdefs
--- agent/mibgroup/ucd-snmp/proc.c (revision 16704)
+++ agent/mibgroup/ucd-snmp/proc.c (revision 16705)
@@ -427,7 +427,7 @@
return count;
}
-#elif OSTYPE == NETSNMP_LINUXID
+#elif NETSNMP_OSTYPE == NETSNMP_LINUXID
#include <dirent.h>
#include <fcntl.h>
@@ -452,7 +452,7 @@
#ifdef USE_PROC_CMDLINE /* old method */
/* read /proc/XX/cmdline */
sprintf(cmdline,"/proc/%s/cmdline",ent->d_name);
- if((fd = open(cmdline, O_RDONLY)) < 0) break;
+ if((fd = open(cmdline, O_RDONLY)) < 0) continue;
len = read(fd,cmdline,sizeof(cmdline) - 1);
close(fd);
if(len <= 0) continue;
@@ -464,7 +464,7 @@
/* read /proc/XX/status */
sprintf(cmdline,"/proc/%s/status",ent->d_name);
if ((status = fopen(cmdline, "r")) == NULL)
- break;
+ continue;
if (fgets(cmdline, sizeof(cmdline), status) == NULL) {
fclose(status);
break;
@@ -507,7 +507,7 @@
return total;
}
-#elif OSTYPE == NETSNMP_ULTRIXID
+#elif NETSNMP_OSTYPE == NETSNMP_ULTRIXID
#define NPROCS 32 /* number of proces to read at once */
@@ -688,7 +688,7 @@
return (0);
return (1);
}
-#elif OSTYPE == NETSNMP_SOLARISID
+#elif NETSNMP_OSTYPE == NETSNMP_SOLARISID
#ifdef _SLASH_PROC_METHOD_

View File

@ -0,0 +1,17 @@
NEWS: agent: suppress annoying "registration != duplicate" warning for root oids
(otherwise, you'll get this message on almost every startup)
http://net-snmp.svn.sourceforge.net/viewvc/net-snmp?view=rev&revision=16669
--- branches/V5-4-patches/net-snmp/agent/agent_registry.c 2007/08/20 08:06:42 16668
+++ branches/V5-4-patches/net-snmp/agent/agent_registry.c 2007/08/22 21:56:23 16669
@@ -532,7 +532,8 @@
if (next && (next->namelen == new_sub->namelen) &&
(next->priority == new_sub->priority)) {
- netsnmp_assert(!"registration != duplicate"); /* always false */
+ if (new_sub->namelen != 1) /* ignore root OID dups */
+ netsnmp_assert(!"registration != duplicate"); /* always false */
return MIB_DUPLICATE_REGISTRATION;
}

View File

@ -0,0 +1,59 @@
Submitted By: Mario Fetka (mario dot fetka at gmail dot com)
Date: 2008-11-04
Initial Package Version: 5.4.1.1
Origin: http://wraptastic.org/pub/jbj/rpm514-netsnmp-5.4.1.1.patch
Upstream Status: unknown
Description: hack to compile against rpm 5.1
diff -Naur net-snmp-5.4.1.1.orig/agent/mibgroup/host/hr_swinst.c net-snmp-5.4.1.1/agent/mibgroup/host/hr_swinst.c
--- net-snmp-5.4.1.1.orig/agent/mibgroup/host/hr_swinst.c 2006-12-12 23:55:46.000000000 +0000
+++ net-snmp-5.4.1.1/agent/mibgroup/host/hr_swinst.c 2008-11-03 23:19:29.305010591 +0000
@@ -41,8 +41,10 @@
#endif
#ifdef HAVE_LIBRPM
+#include <stdio.h>
+#include <stdint.h>
#include <rpm/rpmlib.h>
-#include <rpm/header.h>
+#include <rpm/rpm4compat.h>
#include <fcntl.h>
#ifdef HAVE_RPMGETPATH
@@ -465,6 +467,7 @@
if ( headerGetEntry(swi->swi_h, RPMTAG_INSTALLTIME, NULL, (void **) &rpm_data, NULL) ) {
time_t installTime = *rpm_data;
ret = date_n_time(&installTime, var_len);
+ free((void *)rpm_data);
} else {
ret = date_n_time(0, var_len);
}
@@ -661,6 +664,9 @@
NULL);
snprintf(swi->swi_name, sizeof(swi->swi_name), "%s-%s-%s", n, v, r);
swi->swi_name[ sizeof(swi->swi_name)-1 ] = 0;
+ free((void *)n);
+ free((void *)v);
+ free((void *)r);
}
#else
snprintf(swi->swi_name, sizeof(swi->swi_name), swi->swi_dep->d_name);
diff -Naur net-snmp-5.4.1.1.orig/configure.in net-snmp-5.4.1.1/configure.in
--- net-snmp-5.4.1.1.orig/configure.in 2008-05-14 00:49:57.000000000 +0000
+++ net-snmp-5.4.1.1/configure.in 2008-11-03 23:22:44.126003483 +0000
@@ -2760,12 +2760,12 @@
fi
])
-AC_CHECK_HEADERS(rpm/rpmlib.h rpm/header.h)
+AC_CHECK_HEADERS(rpm/rpmlib.h rpm/rpmtag.h)
AC_CHECK_HEADER(rpm/rpmlib.h,rpmlib_h=yes,rpmlib_h=no)
-AC_CHECK_HEADER(rpm/header.h,rpmheader_h=yes,rpmheader_h=no)
+AC_CHECK_HEADER(rpm/rpmtag.h,rpmtag_h=yes,rpmtag_h=no)
-if test "x$rpmheader_h" = "xno" -o "x$rpmlib_h" = "xno" ; then
+if test "x$rpmtag_h" = "xno" -o "x$rpmlib_h" = "xno" ; then
if test "x$with_rpm" = "xyes" ; then
AC_MSG_ERROR([Could not find either the RPM header files needed and was specifically asked to use RPM support])
else

View File

@ -0,0 +1,475 @@
diff -Naur net-snmp-5.1.1.old/agent/mibgroup/host/hr_sensor.c net-snmp-5.1.1/agent/mibgroup/host/hr_sensor.c
--- net-snmp-5.1.1.old/agent/mibgroup/host/hr_sensor.c 1970-01-01 02:00:00.000000000 +0200
+++ net-snmp-5.1.1/agent/mibgroup/host/hr_sensor.c 2003-10-21 12:49:57.000000000 +0300
@@ -0,0 +1,322 @@
+/* This file was generated by mib2c and is intended for use as a mib module
+ for the ucd-snmp snmpd agent. */
+
+#include <net-snmp/net-snmp-config.h>
+
+#include <stdio.h>
+#if HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#if HAVE_STRING_H
+#include <string.h>
+#else
+#include <strings.h>
+#endif
+
+#include <getopt.h>
+#include <errno.h>
+#include <dlfcn.h>
+
+#include "sensors/sensors.h"
+#include "sensors/error.h"
+
+#include "host_res.h"
+#include "hr_sensor.h"
+
+
+/*
+ * hr_sensor_variables_oid:
+ * this is the top level oid that we want to register under. This
+ * is essentially a prefix, with the suffix appearing in the
+ * variable below.
+ */
+
+
+oid hr_sensor_variables_oid[] = { 1,3,6,1,2,1,25,8 };
+
+
+/*
+ * variable2 hr_sensor_variables:
+ * this variable defines function callbacks and type return information
+ * for the hr_sensor mib section
+ */
+
+
+struct variable2 hr_sensor_variables[] = {
+ /* magic number , variable type , ro/rw , callback fn , L, oidsuffix */
+#define HRSENSORMAPPING 2
+ { HRSENSORMAPPING, ASN_INTEGER , RONLY , var_hr_sensor, 2, { 1,1 } },
+#define HRSENSORNUMBER 3
+ { HRSENSORNUMBER, ASN_INTEGER , RONLY , var_hr_sensor, 2, { 1,2 } },
+#define HRSENSORNAME 4
+ { HRSENSORNAME , ASN_OCTET_STR , RONLY , var_hr_sensor, 2, { 1,3 } },
+#define HRSENSORLABEL 5
+ { HRSENSORLABEL , ASN_OCTET_STR , RONLY , var_hr_sensor, 2, { 1,4 } },
+#define HRSENSORVALUE 6
+ { HRSENSORVALUE , ASN_OCTET_STR , RONLY , var_hr_sensor, 2, { 1,5 } },
+
+};
+/* (L = length of the oidsuffix) */
+
+
+#define DEFAULT_CONFIG_FILE_NAME "sensors.conf"
+
+static char *config_file_name;
+FILE *config_file;
+static const char *config_file_path[] =
+{ "/etc", "/usr/lib/sensors", "/usr/local/lib/sensors", "/usr/lib",
+ "/usr/local/lib", ".", 0 };
+
+static void open_config_file(void);
+static int open_this_config_file(char *filename);
+
+
+/*
+ * functions that are dynamically loaded if the lm_sensors library is
+ * installed.
+ */
+static int (*sensors_get_label_dl)(sensors_chip_name name, int feature,
+ char **result);
+static int (*sensors_init_dl)(FILE *input);
+static int (*sensors_get_feature_dl)(sensors_chip_name name, int feature,
+ double *result);
+static const sensors_feature_data *(*sensors_get_all_features_dl)
+ (sensors_chip_name name, int *nr1,int *nr2);
+static const sensors_chip_name *(*sensors_get_detected_chips_dl)(int *nr);
+
+#define CHIPS_MAX 20
+static sensors_chip_name chips[CHIPS_MAX];
+static int chips_count=0;
+static int do_sets;
+
+/* This examines global var config_file, and leaves the name there too.
+ It also opens config_file. */
+static void open_config_file(void)
+{
+#define MAX_FILENAME_LEN 1024
+ char *filename;
+ char buffer[MAX_FILENAME_LEN];
+ int res,i;
+
+ if (config_file_name && !strcmp(config_file_name,"-")) {
+ config_file = stdin;
+ return;
+ } else if (config_file_name && index(config_file_name,'/')) {
+ if ((res = open_this_config_file(config_file_name))) {
+ fprintf(stderr,"Could not locate or open config file\n");
+ fprintf(stderr,"%s: %s\n",config_file_name,strerror(res));
+ exit(1);
+ }
+ }
+ else {
+ if (config_file_name)
+ filename = config_file_name;
+ else
+ filename = strdup(DEFAULT_CONFIG_FILE_NAME);
+ for (i = 0; config_file_path[i]; i++) {
+ if ((snprintf(buffer,MAX_FILENAME_LEN,
+ "%s/%s",config_file_path[i],filename)) < 1) {
+ fprintf(stderr,
+ "open_config_file: ridiculous long config file name!\n");
+ exit(1);
+ }
+ if (!open_this_config_file(buffer)) {
+ free(config_file_name);
+ config_file_name = strdup(buffer);
+ return;
+ }
+ }
+ fprintf(stderr,"Could not locate or open config file!\n");
+ exit(1);
+ }
+}
+
+static int open_this_config_file(char *filename)
+{
+ config_file = fopen(filename,"r");
+ if (! config_file)
+ return -errno;
+ return 0;
+}
+
+static long *sensor_tbl = 0;
+sensors_chip_name *chip_tbl = 0;
+static int sensor_maxnum = 0;
+
+static void do_register(sensors_chip_name name)
+{
+ const char *algo,*adap;
+
+ {
+ const sensors_feature_data *sensor;
+ const char *map=0;
+ int index0 = 0, index1 = 0;
+
+ printf("%s\n", name);
+
+ while ((sensor = sensors_get_all_features_dl (name, &index0, &index1))
+ != NULL) {
+ if(sensor_tbl = realloc(sensor_tbl, sizeof(long) * (sensor_maxnum+2)))
+ sensor_tbl[sensor_maxnum] = sensor->number;
+ if (chip_tbl = realloc(chip_tbl, sizeof(sensors_chip_name) * (sensor_maxnum+2)))
+ chip_tbl[sensor_maxnum] = name;
+ sensor_maxnum++;
+ }
+ }
+}
+
+/*
+ * init_hr_sensor():
+ * Initialization routine. This is called when the agent starts up.
+ * At a minimum, registration of your variables should take place here.
+ */
+void init_hr_sensor(void) {
+
+ const sensors_chip_name *chip;
+ int chip_nr,i;
+ int c,res;
+ void *sensors_library;
+
+ /* This could probably due with a bit more error reporting. */
+ sensors_library=dlopen("libsensors.so",RTLD_LAZY);
+ if(sensors_library==NULL)
+ return; // return before anything is registered
+
+ sensors_get_label_dl=dlsym(sensors_library,"sensors_get_label");
+ sensors_init_dl=dlsym(sensors_library,"sensors_init");
+ sensors_get_feature_dl=dlsym(sensors_library,"sensors_get_feature");
+ sensors_get_all_features_dl=dlsym(sensors_library,
+ "sensors_get_all_features");
+ sensors_get_detected_chips_dl=dlsym(sensors_library,
+ "sensors_get_detected_chips");
+ if(sensors_get_label_dl==NULL || sensors_init_dl==NULL ||
+ sensors_get_feature_dl==NULL || sensors_get_all_features_dl==NULL ||
+ sensors_get_detected_chips_dl==NULL)
+ return; // return before anything is registered
+
+ /* register ourselves with the agent to handle our mib tree */
+ REGISTER_MIB("hr_sensor", hr_sensor_variables, variable2,
+ hr_sensor_variables_oid);
+
+
+ /* place any other initialization junk you need here */
+
+
+ chips[0].prefix = SENSORS_CHIP_NAME_PREFIX_ANY;
+ chips[0].bus = SENSORS_CHIP_NAME_BUS_ANY;
+ chips[0].addr = SENSORS_CHIP_NAME_ADDR_ANY;
+ chips_count = 1;
+
+ open_config_file();
+
+ if ((res = sensors_init_dl(config_file))) {
+ return;
+ }
+
+ for (chip_nr = 0; (chip = sensors_get_detected_chips_dl(&chip_nr));)
+ do_register (*chip);
+}
+
+
+/*
+ * var_hr_sensor():
+ * This function is called every time the agent gets a request for
+ * a scalar variable that might be found within your mib section
+ * registered above. It is up to you to do the right thing and
+ * return the correct value.
+ * You should also correct the value of "var_len" if necessary.
+ *
+ * Please see the documentation for more information about writing
+ * module extensions, and check out the examples in the examples
+ * and mibII directories.
+ */
+unsigned char *
+var_hr_sensor(struct variable *vp,
+ oid *name,
+ size_t *length,
+ int exact,
+ size_t *var_len,
+ WriteMethod **write_method)
+{
+ /* variables we may use later */
+ static long long_ret;
+ static char *string = 0;
+ static oid objid[MAX_OID_LEN];
+ static struct counter64 c64;
+
+ const sensors_feature_data *sensor;
+ const char *map=0;
+ int index0 = 0, index1 = 0;
+ int sensor_idx = 0, sensor_num = 0;
+ sensors_chip_name chip_name;
+ double value;
+
+
+ if (header_simple_table(vp,name,length,exact,var_len,write_method,sensor_maxnum)
+ == MATCH_FAILED )
+ return NULL;
+
+ sensor_idx = name[*length - 1] - 1;
+ sensor_num = sensor_tbl[sensor_idx];
+ chip_name = chip_tbl[sensor_idx];
+
+ while ((sensor = sensors_get_all_features_dl (chip_name, &index0, &index1))
+ != NULL) {
+ if(sensor_num == sensor->number) {
+ /*
+ * this is where we do the value assignments for the mib results.
+ */
+ switch(vp->magic) {
+
+
+ case HRSENSORMAPPING:
+
+ long_ret = sensor->mapping;
+ return (unsigned char *) &long_ret;
+
+ case HRSENSORNUMBER:
+
+ long_ret = sensor_num;
+ return (unsigned char *) &long_ret;
+
+ case HRSENSORNAME:
+
+ string = malloc(SPRINT_MAX_LEN);
+ strncpy(string, sensor->name, SPRINT_MAX_LEN);
+ *var_len = strlen(string);
+ return (unsigned char *) string;
+
+ case HRSENSORLABEL:
+
+ string = malloc(SPRINT_MAX_LEN);
+
+ if (sensors_get_label_dl (chip_name, sensor->number, &string)) {
+ return 0;
+ }
+
+ *var_len = strlen(string);
+ return (unsigned char *) string;
+
+ case HRSENSORVALUE:
+
+ if (!(sensor->mode & SENSORS_MODE_R)) {
+ return 0;
+ } else if (!(sensor->mode & SENSORS_MODE_R)) {
+ return 0;
+ } else if (sensors_get_feature_dl (chip_name, sensor->number, &value)){
+ return 0;
+ }
+ string = malloc(SPRINT_MAX_LEN);
+ snprintf(string, SPRINT_MAX_LEN, "%f", value);
+ *var_len = strlen(string);
+ return (unsigned char *) string;
+
+ default:
+ ERROR_MSG("");
+ return NULL;
+ }
+ }
+ }
+ return NULL;
+}
+
diff -Naur net-snmp-5.1.1.old/agent/mibgroup/host/hr_sensor.h net-snmp-5.1.1/agent/mibgroup/host/hr_sensor.h
--- net-snmp-5.1.1.old/agent/mibgroup/host/hr_sensor.h 1970-01-01 02:00:00.000000000 +0200
+++ net-snmp-5.1.1/agent/mibgroup/host/hr_sensor.h 2003-10-21 12:47:04.000000000 +0300
@@ -0,0 +1,24 @@
+/* This file was generated by mib2c and is intended for use as a mib module
+ for the ucd-snmp snmpd agent. */
+
+
+#ifndef _MIBGROUP_HRSENSOR_H
+#define _MIBGROUP_HRSENSOR_H
+
+
+/* we may use header_generic and header_simple_table from the util_funcs module */
+
+
+config_require(util_funcs)
+
+
+/* function prototypes */
+
+
+extern void init_hr_sensor(void);
+extern FindVarMethod var_hr_sensor;
+
+
+
+
+#endif /* _MIBGROUP_HRSENSOR_H */
diff -Naur net-snmp-5.1.1.old/agent/mibgroup/host.h net-snmp-5.1.1/agent/mibgroup/host.h
--- net-snmp-5.1.1.old/agent/mibgroup/host.h 2002-04-20 10:30:00.000000000 +0300
+++ net-snmp-5.1.1/agent/mibgroup/host.h 2003-10-21 12:47:04.000000000 +0300
@@ -15,6 +15,7 @@
config_require(host/hr_filesys)
config_require(host/hr_swrun)
config_require(host/hr_swinst)
+ config_require(host/hr_sensor)
/* add the host resources mib to the default mibs to load */
config_add_mib(HOST-RESOURCES-MIB)
diff -Naur net-snmp-5.1.1.old/mibs/HOST-RESOURCES-MIB.txt net-snmp-5.1.1/mibs/HOST-RESOURCES-MIB.txt
--- net-snmp-5.1.1.old/mibs/HOST-RESOURCES-MIB.txt 2002-04-20 10:30:15.000000000 +0300
+++ net-snmp-5.1.1/mibs/HOST-RESOURCES-MIB.txt 2003-10-21 12:47:04.000000000 +0300
@@ -106,6 +106,7 @@
hrSWRunPerf OBJECT IDENTIFIER ::= { host 5 }
hrSWInstalled OBJECT IDENTIFIER ::= { host 6 }
hrMIBAdminInfo OBJECT IDENTIFIER ::= { host 7 }
+hrSensor OBJECT IDENTIFIER ::= { host 8 }
-- textual conventions
@@ -1390,6 +1391,66 @@
(hex)'00 00 01 01 00 00 00 00'."
::= { hrSWInstalledEntry 5 }
+
+hrSensorEntry OBJECT-TYPE
+ SYNTAX hrSensorEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "The CPU temperature sensor settings."
+ INDEX { hrSensor }
+ ::= { hrSensor 1 }
+
+hrSensorEntry ::= SEQUENCE {
+ hrSensorNumber Integer32,
+ hrSensorMapping Integer32,
+ hrSensorName DisplayString,
+ hrSensorLabel DisplayString,
+ hrSensorValue DisplayString
+ }
+
+
+
+hrSensorMapping OBJECT-TYPE
+ SYNTAX Integer32 (1..2147483647)
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The mapping"
+ ::= { hrSensorEntry 1 }
+
+hrSensorNumber OBJECT-TYPE
+ SYNTAX Integer32 (1..2147483647)
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The Number"
+ ::= { hrSensorEntry 2 }
+
+hrSensorName OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The name of the sensor."
+ ::= { hrSensorEntry 3 }
+
+hrSensorLabel OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The label of the sensor."
+ ::= { hrSensorEntry 4 }
+
+hrSensorValue OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The value of the sensor"
+ ::= { hrSensorEntry 5 }
+
-- Conformance information
hrMIBCompliances OBJECT IDENTIFIER ::= { hrMIBAdminInfo 2 }
@@ -1456,6 +1517,13 @@
"The Installed Software Group.
Implementation of this group is at the discretion
of the implementor."
+
+ GROUP hrSensorGroup
+ DESCRIPTION
+ "The Sensors Group.
+ Implementation of this group is at the discretion
+ of the implementor."
+
::= { hrMIBCompliances 1 }
hrSystemGroup OBJECT-GROUP
@@ -1537,4 +1605,17 @@
"The Host Resources Installed Software Group."
::= { hrMIBGroups 6 }
+ hrSensorGroup OBJECT-GROUP
+ OBJECTS {
+ hrSensorEntry,
+ hrSensorNumber,
+ hrSensorMapping,
+ hrSensorName,
+ hrSensorLabel,
+ hrSensorValue
+ }
+ STATUS current
+ DESCRIPTION
+ "The Sensor Resources Group."
+ ::= { hrMIBGroups 7 }
END

View File

@ -0,0 +1,17 @@
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-analyzer/net-snmp/files/snmpd.conf,v 1.8 2006/11/26 21:37:22 cedk Exp $
# Initial (empty) options.
SNMPD_FLAGS=""
# Enable connection logging.
#SNMPD_FLAGS="${SNMPD_FLAGS} -a"
# Enable syslog and disable file log.
#SNMPD_FLAGS="${SNMPD_FLAGS} -Lsd -Lf /dev/null"
# Enable agentx socket as /var/agentx/master
# *NOTE* Before uncommenting this, make sure
# the /var/agentx directory exists.
#SNMPD_FLAGS="${SNMPD_FLAGS} -x /var/agentx/master"

View File

@ -0,0 +1,30 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-analyzer/net-snmp/files/snmpd.rc7,v 1.1 2006/11/26 21:37:22 cedk Exp $
depend() {
use logger
need net
}
checkconfig() {
if [ ! -e /etc/snmp/snmpd.conf ] ; then
eerror "You need an /etc/snmp/snmpd.conf config file to run snmpd"
return 1
fi
}
start() {
checkconfig || return 1
ebegin "Starting net-snmpd"
start-stop-daemon --start --quiet --exec /usr/sbin/snmpd \
-- -p /var/run/snmpd.pid ${SNMPD_FLAGS}
eend $?
}
stop() {
ebegin "Stopping net-snmpd"
start-stop-daemon --stop --quiet --pidfile /var/run/snmpd.pid
eend $?
}

View File

@ -0,0 +1,16 @@
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-analyzer/net-snmp/files/snmptrapd.conf,v 1.1 2005/01/28 11:19:25 ka0ttic Exp $
# extra flags to pass to snmptrapd
SNMPTRAPD_FLAGS=""
# ignore authentication failure traps
#SNMPTRAPD_FLAGS="${SNMPTRAPD_FLAGS} -a"
# log messages to specified file
#SNMPTRAPD_FLAGS="${SNMPTRAPD_FLAGS} -Lf /var/log/snmptrapd.log"
# log messages to syslog with the specified facility
# where facility is: 'd' = LOG_DAEMON, 'u' = LOG_USER, [0-7] = LOG_LOCAL[0-7]
#SNMPTRAPD_FLAGS="${SNMPTRAPD_FLAGS} -Ls d"

View File

@ -0,0 +1,22 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-analyzer/net-snmp/files/snmptrapd.rc7,v 1.1 2006/11/26 21:37:22 cedk Exp $
depend() {
use logger
need net
}
start() {
ebegin "Starting snmptrapd"
start-stop-daemon --start --quiet --exec /usr/sbin/snmptrapd \
-- -p /var/run/snmptrapd.pid ${SNMPTRAPD_FLAGS}
eend $?
}
stop() {
ebegin "Stopping snmptrapd"
start-stop-daemon --stop --quiet --pidfile /var/run/snmptrapd.pid
eend $?
}

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<herd>netmon</herd>
<use>
<flag name='diskio'>Enable the use of diskio mibs</flag>
<flag name='elf'>Enable the use of elf utils to check uptime on some sytems</flag>
<flag name='extensible'>build deprecated extensible mib module (extend is successor)</flag>
<flag name='mfd-rewrites'>Use MFD rewrites of mib modules where available</flag>
<flag name='rpm'>Enable the rpm snmp probing</flag>
<flag name='sendmail'>Enable sendmail statistics monitoring</flag>
<flag name='smux'>Enable the smux MIBS module</flag>
</use>
</pkgmetadata>

View File

@ -0,0 +1,204 @@
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-analyzer/net-snmp/net-snmp-5.4.1.1.ebuild,v 1.9 2008/06/23 18:59:58 ranger Exp $
inherit fixheadtails flag-o-matic perl-module python autotools
DESCRIPTION="Software for generating and retrieving SNMP data"
HOMEPAGE="http://net-snmp.sourceforge.net/"
SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz"
LICENSE="as-is BSD"
SLOT="0"
KEYWORDS="alpha amd64 ~arm hppa ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86"
IUSE="diskio doc elf ipv6 lm_sensors mfd-rewrites minimal perl python rpm selinux smux ssl tcpd X sendmail extensible"
DEPEND="ssl? ( >=dev-libs/openssl-0.9.6d )
tcpd? ( >=sys-apps/tcp-wrappers-7.6 )
rpm? (
app-arch/rpm
dev-libs/popt
app-arch/bzip2
>=sys-libs/zlib-1.1.4
)
elf? ( dev-libs/elfutils )
lm_sensors? ( sys-apps/lm_sensors )
python? ( dev-python/setuptools )"
RDEPEND="${DEPEND}
perl? (
X? ( dev-perl/perl-tk )
!minimal? ( dev-perl/TermReadKey )
)
selinux? ( sec-policy/selinux-snmpd )"
# Dependency on autoconf due to bug #225893
DEPEND="${DEPEND}
>=sys-devel/autoconf-2.61-r2
>=sys-apps/sed-4
doc? ( app-doc/doxygen )"
src_unpack() {
unpack ${A}
cd "${S}"
# fix access violation in make check
sed -i -e 's/\(snmpd.*\)-Lf/\1-l/' testing/eval_tools.sh || \
die "sed eval_tools.sh failed"
# fix path in fixproc
sed -i -e 's|\(database_file =.*\)/local\(.*\)$|\1\2|' local/fixproc || \
die "sed fixproc failed"
if use python ; then
python_version
PYTHON_MODNAME="netsnmp"
PYTHON_DIR=/usr/$(get_libdir)/python${PYVER}/site-packages
sed -i -e "s:\(install --basedir=\$\$dir\):\1 --root='${D}':" Makefile.in || die "sed python failed"
fi
# snmpd crashes when snmpd.conf contains more than one "exec shelltest" line
epatch "${FILESDIR}"/${PN}-5.4-exec-crash.patch
# agent: suppress annoying "registration != duplicate" warning for root oids
epatch "${FILESDIR}"/${PN}-5.4.1-suppresssuppress-annoying.patch
# Crash when more then one interface have the same IP, bug 203127
epatch "${FILESDIR}"/${PN}-5.4.1-ipAddressTable-crash-with-double-free.patch
# snmpconf generates config files with proper selinux context
use selinux && epatch "${FILESDIR}"/${PN}-5.1.2-snmpconf-selinux.patch
epatch "${FILESDIR}"/${PN}-5.4.1-clientaddr-fix.patch #180266
epatch "${FILESDIR}"/${PN}-5.4.1-CVE-2008-2292.patch #222265
epatch "${FILESDIR}"/${PN}-5.4.1-process-count-race.patch #213415
epatch "${FILESDIR}"/${PN}-5.4.1-incorrect-hrFSStorageIndex.patch #211660
epatch "${FILESDIR}"/${PN}-5.4.1-perl-asneeded.patch #224251
use rpm && epatch "${FILESDIR}"/${PN}-5.4.1.1-rpm5-1.patch #202399
# Fix version number to report 5.4.1.1:
sed -i -e 's:NetSnmpVersionInfo = "5.4.1":NetSnmpVersionInfo = "5.4.1.1":' snmplib/snmp_version.c
eautoreconf
ht_fix_all
}
src_compile() {
local mibs
strip-flags
mibs="host ucd-snmp/dlmod"
use smux && mibs="${mibs} smux"
use sendmail && mibs="${mibs} mibII/mta_sendmail"
use lm_sensors && mibs="${mibs} ucd-snmp/lmSensors"
use diskio && mibs="${mibs} ucd-snmp/diskio"
use extensible && mibs="${mibs} ucd-snmp/extensible"
use rpm && export CPPFLAGS="-I /usr/include/rpm ${CPPFLAGS}"
econf \
--with-install-prefix="${D}" \
--with-sys-location="Unknown" \
--with-sys-contact="root@Unknown" \
--with-default-snmp-version="3" \
--with-mib-modules="${mibs}" \
--with-logfile="/var/log/net-snmpd.log" \
--with-persistent-directory="/var/lib/net-snmp" \
--enable-ucd-snmp-compatibility \
--enable-shared \
--enable-as-needed \
$(use_enable mfd-rewrites) \
$(use_enable perl embedded-perl) \
$(use_enable ipv6) \
$(use_enable !ssl internal-md5) \
$(use_with ssl openssl) \
$(use_with tcpd libwrap) \
$(use_with rpm) \
$(use_with rpm bzip2) \
$(use_with rpm zlib) \
$(use_with elf) \
$(use_with python python-modules) \
|| die "econf failed"
emake -j1 || die "emake failed"
if use perl ; then
emake perlmodules || die "compile perl modules problem"
fi
if use python ; then
emake pythonmodules || die "compile python modules problem"
fi
if use doc ; then
einfo "Building HTML Documentation"
make docsdox || die "failed to build docs"
fi
}
src_test() {
cd testing
if ! make test ; then
echo
einfo "Don't be alarmed if a few tests FAIL."
einfo "This could happen for several reasons:"
einfo " - You don't already have a working configuration."
einfo " - Your ethernet interface isn't properly configured."
echo
fi
}
src_install () {
make DESTDIR="${D}" install || die "make install failed"
if use perl ; then
make DESTDIR="${D}" perlinstall || die "make perlinstall failed"
fixlocalpod
use X || rm -f "${D}/usr/bin/tkmib"
else
rm -f "${D}/usr/bin/mib2c" "${D}/usr/bin/tkmib" "${D}/usr/bin/snmpcheck"
fi
if use python ; then
mkdir -p "${D}/${PYTHON_DIR}" || die "Couldn't make $PYTHON_DIR"
make pythoninstall || die "make pythoninstall failed"
fi
dodoc AGENT.txt ChangeLog FAQ INSTALL NEWS PORTING README* TODO
newdoc EXAMPLE.conf.def EXAMPLE.conf
use doc && dohtml docs/html/*
keepdir /etc/snmp /var/lib/net-snmp
newinitd "${FILESDIR}"/snmpd.rc7 snmpd
newconfd "${FILESDIR}"/snmpd.conf snmpd
newinitd "${FILESDIR}"/snmptrapd.rc7 snmptrapd
newconfd "${FILESDIR}"/snmptrapd.conf snmptrapd
# Remove everything, keeping only the snmpd, snmptrapd, MIBs, libs, and includes.
if use minimal; then
elog "USE=minimal is set. Cleaning up excess cruft for a embedded/minimal/server only install."
rm -rf
"${D}"/usr/bin/{encode_keychange,snmp{get,getnext,set,usm,walk,bulkwalk,table,trap,bulkget,translate,status,delta,test,df,vacm,netstat,inform,snmpcheck}}
rm -rf "${D}"/usr/share/snmp/snmpconf-data "${D}"/usr/share/snmp/*.conf
rm -rf "${D}"/usr/bin/{fixproc,traptoemail} "${D}"/usr/bin/snmpc{heck,onf}
find "${D}" -name '*.pl' -exec rm -f '{}' \;
use ipv6 || rm -rf "${D}"/usr/share/snmp/mibs/IPV6*
fi
# bug 113788, install example config
insinto /etc/snmp
newins "${S}"/EXAMPLE.conf snmpd.conf.example
}
pkg_postrm() {
if use python ; then
python_mod_cleanup
fi
}
pkg_postinst() {
elog "An example configuration file has been installed in"
elog "/etc/snmp/snmpd.conf.example."
}