From f22bcde7fad4f472877d83cca0d951f22e6f10fc Mon Sep 17 00:00:00 2001 From: jvdias Date: Wed, 3 May 2006 00:13:59 +0000 Subject: [PATCH] fix bug 190432; fix upstream bugs 4955 4956 4968 4978 4983 4984 4986 5017 --- pegasus-2.5.1-initscript.patch | 9 +- pegasus-2.5.1-obz4955.patch | 605 +++++++++++++ pegasus-2.5.1-obz4956.patch | 92 ++ pegasus-2.5.1-obz4968_upcalls_oop.patch | 65 ++ pegasus-2.5.1-obz4978.patch | 313 +++++++ pegasus-2.5.1-obz4983.patch | 18 + pegasus-2.5.1-obz4984.patch | 269 ++++++ pegasus-2.5.1-obz4986.patch | 1032 +++++++++++++++++++++++ pegasus-2.5.1-warnings.patch | 4 +- tog-pegasus.spec | 35 +- 10 files changed, 2433 insertions(+), 9 deletions(-) create mode 100644 pegasus-2.5.1-obz4955.patch create mode 100644 pegasus-2.5.1-obz4956.patch create mode 100644 pegasus-2.5.1-obz4968_upcalls_oop.patch create mode 100644 pegasus-2.5.1-obz4978.patch create mode 100644 pegasus-2.5.1-obz4983.patch create mode 100644 pegasus-2.5.1-obz4984.patch create mode 100644 pegasus-2.5.1-obz4986.patch diff --git a/pegasus-2.5.1-initscript.patch b/pegasus-2.5.1-initscript.patch index 67b9bd2..084c3ba 100644 --- a/pegasus-2.5.1-initscript.patch +++ b/pegasus-2.5.1-initscript.patch @@ -1,6 +1,6 @@ --- pegasus/rpm/tog-pegasus.rc.initscript 2006-01-30 11:16:24.000000000 -0500 -+++ pegasus/rpm/tog-pegasus.rc 2006-04-11 13:57:31.000000000 -0400 -@@ -1,80 +1,85 @@ ++++ pegasus/rpm/tog-pegasus.rc 2006-05-02 18:44:18.000000000 -0400 +@@ -1,80 +1,84 @@ -#//%2006//////////////////////////////////////////////////////////////////////// -#// -#// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development @@ -113,8 +113,7 @@ - [ "$RETVAL" -eq 0 ] && log_success_msg $"$prog stop" || log_failure_msg $"$prog stop" + if [ "$RETVAL" -eq 0 ]; then + rm -f $LOCKFILE; -+ rm -f /var/run/tog-pegasus/socket/*; -+ rm -f /var/run/tog-pegasus/cimserver.pid; ++ rm -f /var/run/tog-pegasus/*; + success; + else + failure; @@ -140,7 +139,7 @@ condrestart) pid=`pidofproc $CIMSERVER_BIN` RETVAL=$? -@@ -83,13 +88,18 @@ +@@ -83,13 +87,18 @@ RETVAL=$?; fi; ;; diff --git a/pegasus-2.5.1-obz4955.patch b/pegasus-2.5.1-obz4955.patch new file mode 100644 index 0000000..c9e029b --- /dev/null +++ b/pegasus-2.5.1-obz4955.patch @@ -0,0 +1,605 @@ +--- pegasus/src/Providers/ManagedSystem/OperatingSystem/OperatingSystem_Linux.cpp.obz4955 2006-01-30 11:18:48.000000000 -0500 ++++ pegasus/src/Providers/ManagedSystem/OperatingSystem/OperatingSystem_Linux.cpp 2006-05-02 14:43:14.000000000 -0400 +@@ -96,59 +96,75 @@ + + + /** +- getName method of the Linux implementation for the OS Provider +- +- Calls uname() to get the operating system name. ++ getVendorInfo method for Linux implementation of OS Provider + ++ Gets the system text from vendor's release file + */ +-Boolean OperatingSystem::getName(String& osName) ++static void getVendorInfo( ++ String& releaseText, ++ String& nameText ) + { +- String s, buffer_s; +- Uint32 buffer_index; // rexex match index ++ static const Uint32 MAX_RELEASE_STRING_LEN=128; + char info_file[MAXPATHLEN]; +- char buffer[MAXPATHLEN]; ++ char buffer[MAX_RELEASE_STRING_LEN]; + struct stat statBuf; +- FILE *vf; + +- s.clear(); ++ + for (int ii = 0; LINUX_VENDOR_INFO[ii].vendor_name != NULL ; ii++) + { +- memset(info_file, 0, MAXPATHLEN); +- strcat(info_file, "/etc/"); +- strcat(info_file, LINUX_VENDOR_INFO[ii].determining_filename); +- ++ sprintf(info_file, "/etc/%s", ++ LINUX_VENDOR_INFO[ii].determining_filename ); + + // If the file exists in /etc, we know what distro we're in + if (!stat(info_file, &statBuf)) + { +- s.assign(LINUX_VENDOR_INFO[ii].vendor_name); +- s.append(" Distribution"); ++ // Set the default OS name ++ nameText.assign(LINUX_VENDOR_INFO[ii].vendor_name); ++ nameText.append(" Distribution"); + if (LINUX_VENDOR_INFO[ii].optional_string == NULL) + { +- // try to set s to a more descript value from the etc file +- vf = fopen(info_file, "r"); ++ // try to set text to a more descriptive value from the etc file ++ FILE *vf = fopen(info_file, "r"); + if (vf) + { +- if (fgets(buffer, MAXPATHLEN, vf) != NULL) +- { +- buffer_s.assign(buffer); +- +- // parse the text to extract Distribution Name +- buffer_index = buffer_s.find(" release"); +- if ( buffer_index != PEG_NOT_FOUND ) +- { +- // then we have found a valid index into the config file +- s.assign(buffer_s.subString(0,buffer_index)); +- } ++ if (fgets(buffer, MAX_RELEASE_STRING_LEN, vf) != NULL) ++ { ++ String buffer_s = buffer; ++ ++ // parse the text to extract first line ++ Uint32 buffer_index = buffer_s.find( '\n' ); ++ if ( buffer_index != PEG_NOT_FOUND ) ++ { ++ // We have found a valid index into the ++ // release string. Now get just the OS name. ++ releaseText = buffer_s.subString(0,buffer_index); ++ buffer_index = releaseText.find( " release" ); ++ if ( buffer_index != PEG_NOT_FOUND ) ++ { ++ nameText.assign( releaseText.subString(0,buffer_index) ); ++ } ++ } + } + fclose(vf); + } + } ++ break; + } + } +- osName.assign(s); +- return true; ++} ++ ++/** ++ getName method of the Linux implementation for the OS Provider ++ ++ Calls getVendorInfo() to get the operating system name. + ++ */ ++Boolean OperatingSystem::getName(String& osName) ++{ ++ String releaseText; ++ getVendorInfo( releaseText, osName ); ++ ++ return true; + } + + /** +@@ -204,23 +220,24 @@ + /** + getCaption method for Linux implementation of OS Provider + +- Uses a string constant for the Caption. ++ Gets the text from the system's release file. + */ + Boolean OperatingSystem::getCaption(String& caption) + { +- +- caption.assign("The current Operating System"); +- ++ String osName; ++ getVendorInfo( caption, osName ); + return true; + } + ++/** ++ getDescription method for Linux implementation of OS Provider ++ ++ Gets the text from the system's release file. ++ */ + Boolean OperatingSystem::getDescription(String& description) + { +- +- description.assign("This instance reflects the Operating System" +- " on which the CIMOM is executing (as distinguished from instances" +- " of other installed operating systems that could be run)."); +- ++ String osName; ++ getVendorInfo( description, osName ); + return true; + } + +--- pegasus/src/Providers/ManagedSystem/OperatingSystem/tests/OSTestClient/OSTestClient.cpp.obz4955 2006-01-30 11:18:49.000000000 -0500 ++++ pegasus/src/Providers/ManagedSystem/OperatingSystem/tests/OSTestClient/OSTestClient.cpp 2006-05-02 14:45:05.000000000 -0400 +@@ -61,6 +61,8 @@ + # include "OSTestClient_VMS.cpp" + #elif defined (PEGASUS_OS_SOLARIS) + # include "OSTestClient_Solaris.cpp" ++#elif defined (PEGASUS_OS_LINUX) ++# include "OSTestClient_Linux.cpp" + # else + # include "OSTestClient_Stub.cpp" + #endif +--- pegasus/src/Providers/ManagedSystem/OperatingSystem/tests/OSTestClient/OSTestClient_Linux.cpp.obz4955 2006-05-02 14:46:08.000000000 -0400 ++++ pegasus/src/Providers/ManagedSystem/OperatingSystem/tests/OSTestClient/OSTestClient_Linux.cpp 2006-05-02 14:38:31.000000000 -0400 +@@ -0,0 +1,449 @@ ++//%2006//////////////////////////////////////////////////////////////////////// ++// ++// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development ++// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. ++// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.; ++// IBM Corp.; EMC Corporation, The Open Group. ++// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; ++// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. ++// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; ++// EMC Corporation; VERITAS Software Corporation; The Open Group. ++// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.; ++// EMC Corporation; Symantec Corporation; The Open Group. ++// ++// Permission is hereby granted, free of charge, to any person obtaining a copy ++// of this software and associated documentation files (the "Software"), to ++// deal in the Software without restriction, including without limitation the ++// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or ++// sell copies of the Software, and to permit persons to whom the Software is ++// furnished to do so, subject to the following conditions: ++// ++// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN ++// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED ++// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT ++// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR ++// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ++// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ++// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION ++// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++// ++//============================================================================== ++// ++// ++//%///////////////////////////////////////////////////////////////////////////// ++ ++ ++// This file has the OS-specific routines that will be called to get ++// a validation of the CIM information vs. the current test system ++ ++#include "OSTestClient.h" ++ ++PEGASUS_USING_PEGASUS; ++PEGASUS_USING_STD; ++ ++ ++static const struct ++{ ++ const char *vendor_name; ++ const char *determining_filename; ++ const char *optional_string; ++} LINUX_VENDOR_INFO[] = { ++ { "Caldera", "coas", "Caldera Linux" }, ++ { "Corel", "environment.corel", "Corel Linux" }, ++ { "Debian GNU/Linux", "debian_version", NULL }, ++ { "Mandrake", "mandrake-release", NULL }, ++ { "Red Hat", "redhat-release", NULL }, ++ { "SuSE", "SuSE-release", NULL }, ++ { "Turbolinux", "turbolinux-release", NULL }, ++ { NULL, NULL, NULL } ++}; ++ ++ ++/** ++ getVendorInfo method for Linux implementation of OS Provider ++ ++ Gets the system text from vendor's release file ++ */ ++static void getVendorInfo( ++ String& releaseText, ++ String& nameText ) ++{ ++ static const Uint32 MAX_RELEASE_STRING_LEN=128; ++ char info_file[MAXPATHLEN]; ++ char buffer[MAX_RELEASE_STRING_LEN]; ++ struct stat statBuf; ++ ++ ++ for (int ii = 0; LINUX_VENDOR_INFO[ii].vendor_name != NULL ; ii++) ++ { ++ sprintf(info_file, "/etc/%s", ++ LINUX_VENDOR_INFO[ii].determining_filename ); ++ ++ // If the file exists in /etc, we know what distro we're in ++ if (!stat(info_file, &statBuf)) ++ { ++ // Set the default OS name ++ nameText.assign(LINUX_VENDOR_INFO[ii].vendor_name); ++ nameText.append(" Distribution"); ++ if (LINUX_VENDOR_INFO[ii].optional_string == NULL) ++ { ++ // try to set text to a more descriptive value from the etc file ++ FILE *vf = fopen(info_file, "r"); ++ if (vf) ++ { ++ if (fgets(buffer, MAX_RELEASE_STRING_LEN, vf) != NULL) ++ { ++ String buffer_s = buffer; ++ ++ // parse the text to extract first line ++ Uint32 buffer_index = buffer_s.find( '\n' ); ++ if ( buffer_index != PEG_NOT_FOUND ) ++ { ++ // We have found a valid index into the ++ // release string. Now get just the OS name. ++ releaseText = buffer_s.subString(0,buffer_index); ++ buffer_index = releaseText.find( " release" ); ++ if ( buffer_index != PEG_NOT_FOUND ) ++ { ++ nameText.assign( releaseText.subString(0,buffer_index) ); ++ } ++ } ++ } ++ fclose(vf); ++ } ++ } ++ break; ++ } ++ } ++} ++ ++/** ++ goodCSCreationClassName method for the OS Provider Test Client ++ ++ Checks the specified value against the expected value and ++ returns TRUE if valid, else FALSE. ++ */ ++Boolean OSTestClient::goodCSCreationClassName(const String &cs_ccn, ++ Boolean verbose) ++{ ++ // This assumes the only right answer is CIM_UnitaryComputerSystem ++ // replace with approprate check for the given OS/Provider ++ ++ if (verbose) ++ cout<<"Checking " < 0) + { +- Uint32 capacity = (Uint32)(_contentLength + _contentOffset + 1); +- _incomingBuffer.reserveCapacity(capacity); +- data = (char *)_incomingBuffer.getData(); +- data[capacity-1] = 0; ++ try ++ { ++ Uint32 capacity = (Uint32)(_contentLength + _contentOffset + 1); ++ _incomingBuffer.reserveCapacity(capacity); ++ data = (char *)_incomingBuffer.getData(); ++ data[capacity-1] = 0; ++ }catch(const PEGASUS_STD(bad_alloc)&) ++ { ++ _throwEventFailure(HTTP_STATUS_REQUEST_TOO_LARGE, ++ "Error reserving space for non-chunked message"); ++ }catch(...) ++ { ++ _throwEventFailure(httpStatusInternal, "unexpected exception"); ++ } + } + + break; +--- pegasus/src/Pegasus/Common/String.cpp.obz4956 2006-05-02 14:27:39.000000000 -0400 ++++ pegasus/src/Pegasus/Common/String.cpp 2006-05-02 15:12:59.000000000 -0400 +@@ -51,6 +51,10 @@ + #include + #endif + ++#ifndef PEGASUS_CHECK_FOR_OVERFLOW ++#define PEGASUS_CHECK_FOR_OVERFLOW(capacity) { if (capacity > 0x3FFFFFFF) throw PEGASUS_STD(bad_alloc)(); } ++#endif ++ + PEGASUS_NAMESPACE_BEGIN + + //============================================================================== +@@ -166,8 +170,7 @@ + { + #ifndef PEGASUS_STRING_NO_THROW + +- if (x > 0x0FFFFFFF) +- throw PEGASUS_STD(bad_alloc)(); ++ PEGASUS_CHECK_FOR_OVERFLOW(x); + + #endif + +@@ -545,9 +548,7 @@ + { + #ifndef PEGASUS_STRING_NO_THROW + +- // Any string bigger than this is seriously suspect. +- if (cap > 0x0FFFFFFF) +- throw PEGASUS_STD(bad_alloc)(); ++ PEGASUS_CHECK_FOR_OVERFLOW(cap); + + #endif + +--- pegasus/src/Pegasus/Common/Buffer.cpp.obz4956 2006-03-17 13:59:03.000000000 -0500 ++++ pegasus/src/Pegasus/Common/Buffer.cpp 2006-05-02 15:06:06.000000000 -0400 +@@ -43,11 +43,17 @@ + + static const size_t MIN_CAPACITY = 2048; + ++#ifndef PEGASUS_CHECK_FOR_OVERFLOW ++#define PEGASUS_CHECK_FOR_OVERFLOW(capacity) { if (capacity > 0x3FFFFFFF) throw PEGASUS_STD(bad_alloc)(); } ++#endif ++ + static Uint32 _next_pow_2(Uint32 x) + { + if (x < MIN_CAPACITY) + return MIN_CAPACITY; + ++ PEGASUS_CHECK_FOR_OVERFLOW(x); ++ + x--; + x |= (x >> 1); + x |= (x >> 2); +@@ -132,7 +138,10 @@ + _rep->size = 0; + } + else ++ { ++ PEGASUS_CHECK_FOR_OVERFLOW(_rep->cap); + _rep = _reallocate(_rep, _rep->cap ? (2 * _rep->cap) : MIN_CAPACITY); ++ } + } + + void Buffer::insert(size_t pos, const char* data, size_t size) diff --git a/pegasus-2.5.1-obz4968_upcalls_oop.patch b/pegasus-2.5.1-obz4968_upcalls_oop.patch new file mode 100644 index 0000000..0109ee2 --- /dev/null +++ b/pegasus-2.5.1-obz4968_upcalls_oop.patch @@ -0,0 +1,65 @@ +--- pegasus/src/Pegasus/ProviderManager2/CMPI/CMPI_Broker.cpp.obz4968_upcalls_oop 2006-03-15 07:53:08.000000000 -0500 ++++ pegasus/src/Pegasus/ProviderManager2/CMPI/CMPI_Broker.cpp 2006-05-02 14:29:16.000000000 -0400 +@@ -313,8 +313,18 @@ + CM_ObjectPath(cop)->getNameSpace(), + CM_ObjectPath(cop)->getClassName()); + if (rc) CMSetStatus(rc,CMPI_RC_OK); +- CMPI_Object *obj = +- new CMPI_Object(new CMPI_OpEnumeration(new Array(en))); ++ ++ // When running out of process the returned instances don't contain ++ // a name space. Create a writable copy of the array and add the ++ // namespace from the input parameters. ++ Array * aObj = new Array(en); ++ for (unsigned int index=0;index < aObj->size(); index++) ++ { ++ (*aObj)[index].setNameSpace(CM_ObjectPath(cop)->getNameSpace()); ++ } ++ ++ CMPI_Object *obj = new CMPI_Object(new CMPI_OpEnumeration(aObj)); ++ + return (CMPI_OpEnumeration *)obj->getHdl(); + + } +@@ -408,8 +418,18 @@ + role ? String(role) : String::EMPTY, + resultRole ? String(resultRole) : String::EMPTY); + if (rc) CMSetStatus(rc,CMPI_RC_OK); +- CMPI_Object *obj = +- new CMPI_Object(new CMPI_OpEnumeration(new Array(en))); ++ ++ // When running out of process the returned instances don't contain ++ // a name space. Create a writable copy of the array and add the ++ // namespace from the input parameters. ++ Array * aObj = new Array(en); ++ for (unsigned int index=0;index < aObj->size(); index++) ++ { ++ (*aObj)[index].setNameSpace(CM_ObjectPath(cop)->getNameSpace()); ++ } ++ ++ CMPI_Object *obj = new CMPI_Object(new CMPI_OpEnumeration(aObj)); ++ + return (CMPI_OpEnumeration *)obj->getHdl(); + } + catch (const CIMException &e) { +@@ -493,8 +513,18 @@ + resultClass ? CIMName(resultClass) : CIMName(), + role ? String(role) : String::EMPTY); + if (rc) CMSetStatus(rc,CMPI_RC_OK); +- CMPI_Object *obj = +- new CMPI_Object(new CMPI_OpEnumeration(new Array(en))); ++ ++ // When running out of process the returned instances don't contain ++ // a name space. Create a writable copy of the array and add the ++ // namespace from the input parameters. ++ Array * aObj = new Array(en); ++ for (unsigned int index=0;index < aObj->size(); index++) ++ { ++ (*aObj)[index].setNameSpace(CM_ObjectPath(cop)->getNameSpace()); ++ } ++ ++ CMPI_Object *obj = new CMPI_Object(new CMPI_OpEnumeration(aObj)); ++ + return (CMPI_OpEnumeration *)obj->getHdl(); + } + catch (const CIMException &e) { diff --git a/pegasus-2.5.1-obz4978.patch b/pegasus-2.5.1-obz4978.patch new file mode 100644 index 0000000..ee6e6a2 --- /dev/null +++ b/pegasus-2.5.1-obz4978.patch @@ -0,0 +1,313 @@ +--- pegasus/src/Pegasus/Handler/snmpIndicationHandler/snmpIndicationHandler.cpp.obz4978 2006-01-30 11:17:54.000000000 -0500 ++++ pegasus/src/Pegasus/Handler/snmpIndicationHandler/snmpIndicationHandler.cpp 2006-05-02 15:23:37.000000000 -0400 +@@ -62,9 +62,54 @@ + + PEGASUS_USING_STD; + ++#ifdef HPUX_EMANATE ++ static snmpDeliverTrap_emanate snmpTrap; ++#elif defined (PEGASUS_USE_NET_SNMP) ++ static snmpDeliverTrap_netsnmp snmpTrap; ++#else ++ static snmpDeliverTrap_stub snmpTrap; ++#endif ++ ++snmpIndicationHandler::snmpIndicationHandler() ++{ ++ PEG_METHOD_ENTER (TRC_IND_HANDLER, ++ "snmpIndicationHandler::snmpIndicationHandler"); ++ PEG_METHOD_EXIT(); ++} ++ + void snmpIndicationHandler::initialize(CIMRepository* repository) + { ++ PEG_METHOD_ENTER (TRC_IND_HANDLER, ++ "snmpIndicationHandler::initialize"); ++ + _repository = repository; ++ ++#ifdef PEGASUS_USE_NET_SNMP ++ snmpTrap.initialize(); ++#endif ++ ++ PEG_METHOD_EXIT(); ++} ++ ++void snmpIndicationHandler::terminate() ++{ ++ PEG_METHOD_ENTER (TRC_IND_HANDLER, ++ "snmpIndicationHandler::terminate"); ++ ++#ifdef PEGASUS_USE_NET_SNMP ++ snmpTrap.terminate(); ++#endif ++ ++ PEG_METHOD_EXIT(); ++} ++ ++snmpIndicationHandler::~snmpIndicationHandler() ++{ ++ PEG_METHOD_ENTER (TRC_IND_HANDLER, ++ "snmpIndicationHandler::~snmpIndicationHandler"); ++ ++ ++ PEG_METHOD_EXIT(); + } + + // l10n - note: ignoring indication language +@@ -153,14 +198,6 @@ + // trap destination and SNMP type are defined in handlerInstance + // and passing this instance as it is to deliverTrap() call + +-#ifdef HPUX_EMANATE +- static snmpDeliverTrap_emanate emanateTrap; +-#elif defined (PEGASUS_USE_NET_SNMP) +- static snmpDeliverTrap_netsnmp emanateTrap; +-#else +- static snmpDeliverTrap_stub emanateTrap; +-#endif +- + Uint32 targetHostPos = handler.findProperty(CIMName ("TargetHost")); + Uint32 targetHostFormatPos = handler.findProperty(CIMName ("TargetHostFormat")); + Uint32 otherTargetHostFormatPos = handler.findProperty(CIMName ( +@@ -263,7 +300,7 @@ + handler.getProperty(engineIDPos).getValue().get(engineID); + } + +- emanateTrap.deliverTrap( ++ snmpTrap.deliverTrap( + trapOid, + securityName, + targetHost, +@@ -315,6 +352,8 @@ + MessageLoaderParms("Handler.snmpIndicationHandler.snmpIndicationHandler.FAILED_TO_DELIVER_TRAP", + "Failed to deliver trap.")); + } ++ ++ PEG_METHOD_EXIT(); + } + + // This is the dynamic entry point into this dynamic module. The name of +--- pegasus/src/Pegasus/Handler/snmpIndicationHandler/snmpDeliverTrap_netsnmp.cpp.obz4978 2006-01-30 11:17:54.000000000 -0500 ++++ pegasus/src/Pegasus/Handler/snmpIndicationHandler/snmpDeliverTrap_netsnmp.cpp 2006-05-02 15:23:37.000000000 -0400 +@@ -41,6 +41,49 @@ + + PEGASUS_NAMESPACE_BEGIN + ++void snmpDeliverTrap_netsnmp::initialize() ++{ ++ ++ PEG_METHOD_ENTER (TRC_IND_HANDLER, ++ "snmpDeliverTrap_netsnmp::initialize"); ++ ++ // Defined default MIB modules (in net-snmp-config.h) do not need to be ++ // loaded and loading them can cause some stderr; ++ // use environment variable MIBS to override the default MIB modules. ++ // If there is no MIBS environment variable, add it in. ++ char *envVar; ++ envVar = getenv("MIBS"); ++ ++ if (envVar == NULL) ++ { ++ putenv("MIBS="); ++ } ++ ++ // Initialize the mib reader ++ netsnmp_set_mib_directory(""); ++ init_mib(); ++ ++ // Initializes the SNMP library ++ init_snmp("snmpIndicationHandler"); ++ ++ // windows32 specific initialization (is a NOOP on unix) ++ SOCK_STARTUP; ++ ++ PEG_METHOD_EXIT (); ++ ++} ++ ++void snmpDeliverTrap_netsnmp::terminate() ++{ ++ ++ PEG_METHOD_ENTER (TRC_IND_HANDLER, ++ "snmpDeliverTrap_netsnmp::terminate"); ++ ++ SOCK_CLEANUP; ++ ++ PEG_METHOD_EXIT (); ++} ++ + void snmpDeliverTrap_netsnmp::deliverTrap( + const String& trapOid, + const String& securityName, +@@ -59,12 +102,12 @@ + "snmpDeliverTrap_netsnmp::deliverTrap"); + + void *sessionHandle; +- struct snmp_session snmpSession, *sessionPtr; ++ struct snmp_session *sessionPtr; + + struct snmp_pdu *snmpPdu; + + // Creates a SNMP session +- _createSession(targetHost, portNumber, securityName, snmpSession, ++ _createSession(targetHost, portNumber, securityName, + sessionHandle, sessionPtr); + + try +@@ -138,7 +181,6 @@ + const String & targetHost, + Uint32 portNumber, + const String & securityName, +- snmp_session & snmpSession, + void *&sessionHandle, + snmp_session *&sessionPtr) + { +@@ -148,34 +190,13 @@ + Sint32 libErr, sysErr; + char *errStr; + String exceptionStr; ++ ++ struct snmp_session snmpSession; + +- // Defined default MIB modules (in net-snmp-config.h) do not need to be +- // loaded and loading them can cause some stderr; +- // use environment variable MIBS to override the default MIB modules. +- // If there is no MIBS environment variable, add it in. +- +- char *envVar; +- envVar = getenv("MIBS"); +- +- if (envVar == NULL) + { +- putenv("MIBS="); +- } +- +- // Initialize the mib reader +- netsnmp_set_mib_directory(""); +- init_mib(); +- +- // Initializes the SNMP library +- init_snmp("snmpIndicationHandler"); +- +- // Prepares a struct snmp_session that will be used for a set of +- // SNMP transactions ++ AutoMutex autoMut(_sessionInitMutex); + snmp_sess_init(&snmpSession); + +- // windows32 specific initialization (is a NOOP on unix) +- SOCK_STARTUP; +- + CString targetHostCStr = targetHost.getCString(); + + // peername has format: targetHost:portNumber +@@ -183,7 +204,9 @@ + 1+32)); + sprintf(snmpSession.peername, "%s:%u", (const char*)targetHostCStr, + portNumber); ++ + sessionHandle = snmp_sess_open(&snmpSession); ++ } + + if (sessionHandle == NULL) + { +@@ -196,8 +219,6 @@ + + free(errStr); + +- SOCK_CLEANUP; +- + PEG_METHOD_EXIT (); + + throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED, +@@ -276,8 +297,6 @@ + + snmp_sess_close(sessionHandle); + +- SOCK_CLEANUP; +- + PEG_METHOD_EXIT (); + } + +--- pegasus/src/Pegasus/Handler/snmpIndicationHandler/snmpIndicationHandler.h.obz4978 2006-01-30 11:17:54.000000000 -0500 ++++ pegasus/src/Pegasus/Handler/snmpIndicationHandler/snmpIndicationHandler.h 2006-05-02 15:23:37.000000000 -0400 +@@ -50,19 +50,13 @@ + + CIMRepository* _repository; + +- snmpIndicationHandler() +- { +- } +- +- virtual ~snmpIndicationHandler() +- { +- } ++ snmpIndicationHandler(); ++ ++ virtual ~snmpIndicationHandler(); + + void initialize(CIMRepository* repository); + +- void terminate() +- { +- } ++ void terminate(); + + void handleIndication( + const OperationContext& context, +@@ -71,6 +65,7 @@ + CIMInstance& handler, + CIMInstance& subscription, + ContentLanguageList& contentLanguages); ++ + }; + + PEGASUS_NAMESPACE_END +--- pegasus/src/Pegasus/Handler/snmpIndicationHandler/snmpDeliverTrap_netsnmp.h.obz4978 2006-01-30 11:17:54.000000000 -0500 ++++ pegasus/src/Pegasus/Handler/snmpIndicationHandler/snmpDeliverTrap_netsnmp.h 2006-05-02 15:23:37.000000000 -0400 +@@ -37,6 +37,7 @@ + + #include + ++#include + #include + #include + #include "snmpDeliverTrap.h" +@@ -120,6 +121,10 @@ + { + public: + ++ void initialize(); ++ ++ void terminate(); ++ + void deliverTrap( + const String& trapOid, + const String& securityName, +@@ -135,6 +140,10 @@ + + private: + ++ // Mutex is needed before a session is created. Sessions created ++ // using the Single API do not interact with other SNMP sessions. ++ Mutex _sessionInitMutex; ++ + /** + Creates a SNMP session. + +@@ -143,7 +152,6 @@ + to receive a trap + @param portNumber the port number to receive a trap + @param securityName the human readable community name +- @param snmpSession the SNMP session + @param sessionHandle an opaque pointer of the SNMP session + @param sessionPtr the SNMP session pointer to its associated + struct snmp_session +@@ -153,7 +161,6 @@ + void _createSession(const String & targetHost, + Uint32 portNumber, + const String & securityName, +- struct snmp_session & snmpSession, + void *&sessionHandle, + struct snmp_session *&sessionPtr); + diff --git a/pegasus-2.5.1-obz4983.patch b/pegasus-2.5.1-obz4983.patch new file mode 100644 index 0000000..70cbabb --- /dev/null +++ b/pegasus-2.5.1-obz4983.patch @@ -0,0 +1,18 @@ +--- pegasus/src/Pegasus/ProviderManager2/ProviderAgent/ProviderAgent.cpp.obz4983 2006-02-28 14:53:31.000000000 -0500 ++++ pegasus/src/Pegasus/ProviderManager2/ProviderAgent/ProviderAgent.cpp 2006-05-02 15:30:34.000000000 -0400 +@@ -589,6 +589,7 @@ + + // Send request back to the server to process + _providerAgent->_writeResponse(message); ++ delete message; + + PEG_METHOD_EXIT(); + } +@@ -601,6 +602,7 @@ + + // Send request back to the server to process + _providerAgent->_writeResponse(response); ++ delete response; + + PEG_METHOD_EXIT(); + } diff --git a/pegasus-2.5.1-obz4984.patch b/pegasus-2.5.1-obz4984.patch new file mode 100644 index 0000000..e275795 --- /dev/null +++ b/pegasus-2.5.1-obz4984.patch @@ -0,0 +1,269 @@ +--- pegasus/src/Pegasus/ProviderManager2/OOPProviderManagerRouter.cpp.obz4980 2006-03-15 16:28:36.000000000 -0500 ++++ pegasus/src/Pegasus/ProviderManager2/OOPProviderManagerRouter.cpp 2006-05-02 15:34:36.000000000 -0400 +@@ -523,6 +523,28 @@ + //Out of provider support for OS400 goes here when needed. + + #else ++ ++# ifndef PEGASUS_DISABLE_PROV_USERCTXT ++ // Get and save the effective user name and the uid/gid for the user ++ // context of the agent process ++ ++ String effectiveUserName = System::getEffectiveUserName(); ++ PEGASUS_UID_T newUid = (PEGASUS_UID_T) -1; ++ PEGASUS_GID_T newGid = (PEGASUS_GID_T) -1; ++ if (_userName != effectiveUserName) ++ { ++ if (!System::lookupUserId(_userName.getCString(), newUid, newGid)) ++ { ++ throw PEGASUS_CIM_EXCEPTION_L( ++ CIM_ERR_FAILED, ++ MessageLoaderParms( ++ "ProviderManager.OOPProviderManagerRouter." ++ "USER_CONTEXT_CHANGE_FAILED", ++ "Unable to change user context to \"$0\".", _userName)); ++ } ++ } ++# endif ++ + pid_t pid = fork(); + if (pid < 0) + { +@@ -558,11 +580,11 @@ + pipeToAgent->exportReadHandle(readHandle); + pipeFromAgent->exportWriteHandle(writeHandle); + +-#ifndef PEGASUS_DISABLE_PROV_USERCTXT ++# ifndef PEGASUS_DISABLE_PROV_USERCTXT + // Set the user context of the Provider Agent process +- if (_userName != System::getEffectiveUserName()) ++ if (_userName != effectiveUserName) + { +- if (!System::changeUserContext(_userName.getCString())) ++ if (!System::changeUserContext(newUid, newGid)) + { + Tracer::trace(TRC_DISCARDED_DATA, Tracer::LEVEL2, + "System::changeUserContext() failed. userName = %s.", +@@ -575,7 +597,7 @@ + _exit(1); + } + } +-#endif ++# endif + + execl(agentCommandPathCString, agentCommandPathCString, + readHandle, writeHandle, +@@ -1667,7 +1689,7 @@ + request->operationContext.get(IdentityContainer::NAME); + userName = ic.getUserName(); + } +- catch (Exception& e) ++ catch (Exception&) + { + // If no IdentityContainer is present, default to the CIM + // Server's user context +--- pegasus/src/Pegasus/Common/SystemVms.cpp.obz4980 2006-01-30 11:17:08.000000000 -0500 ++++ pegasus/src/Pegasus/Common/SystemVms.cpp 2006-05-02 15:34:36.000000000 -0400 +@@ -674,7 +674,10 @@ + + #endif + +-Boolean System::changeUserContext(const char *userName) ++Boolean System::lookupUserId( ++ const char* userName, ++ PEGASUS_UID_T& uid, ++ PEGASUS_GID_T& gid) + { + const unsigned int PWD_BUFF_SIZE = 1024; + struct passwd pwd; +@@ -697,18 +700,28 @@ + return false; + } + ++ uid = pwd.pw_uid; ++ gid = pwd.pw_gid; ++ ++ return true; ++} ++ ++Boolean System::changeUserContext( ++ const PEGASUS_UID_T& uid, ++ const PEGASUS_GID_T& gid) ++{ + Tracer::trace(TRC_OS_ABSTRACTION, Tracer::LEVEL4, + "Changing user context to: uid = %d, gid = %d", +- (int) pwd.pw_uid, (int) pwd.pw_gid); ++ (int) uid, (int) gid); + +- if (setgid(pwd.pw_gid) != 0) ++ if (setgid(gid) != 0) + { + PEG_TRACE_STRING(TRC_OS_ABSTRACTION, Tracer::LEVEL2, + String("setgid failed: ") + String(strerror(errno))); + return false; + } + +- if (setuid(pwd.pw_uid) != 0) ++ if (setuid(uid) != 0) + { + PEG_TRACE_STRING(TRC_OS_ABSTRACTION, Tracer::LEVEL2, + String("setuid failed: ") + String(strerror(errno))); +--- pegasus/src/Pegasus/Common/SystemWindows.cpp.obz4980 2006-02-08 15:50:59.000000000 -0500 ++++ pegasus/src/Pegasus/Common/SystemWindows.cpp 2006-05-02 15:34:36.000000000 -0400 +@@ -838,7 +838,18 @@ + return retVal; + } + +-Boolean System::changeUserContext(const char* userName) ++Boolean System::lookupUserId( ++ const char* userName, ++ PEGASUS_UID_T& uid, ++ PEGASUS_GID_T& gid) ++{ ++ // ATTN: Implement this method to look up the specified user ++ return false; ++} ++ ++Boolean System::changeUserContext( ++ const PEGASUS_UID_T& uid, ++ const PEGASUS_GID_T& gid) + { + // ATTN: Implement this method to change the process user context to the + // specified user +--- pegasus/src/Pegasus/Common/SystemNsk.cpp.obz4980 2006-01-30 11:17:08.000000000 -0500 ++++ pegasus/src/Pegasus/Common/SystemNsk.cpp 2006-05-02 15:34:36.000000000 -0400 +@@ -157,7 +157,18 @@ + return true; + } + +-Boolean System::changeUserContext(const char* userName) ++Boolean System::lookupUserId( ++ const char* userName, ++ PEGASUS_UID_T& uid, ++ PEGASUS_GID_T& gid) ++{ ++ // ATTN: Implement this method to look up the specified user ++ return false; ++} ++ ++Boolean System::changeUserContext( ++ const PEGASUS_UID_T& uid, ++ const PEGASUS_GID_T& gid) + { + // ATTN: Implement this method to change the process user context to the + // specified user +--- pegasus/src/Pegasus/Common/SystemUnix.cpp.obz4980 2006-01-30 11:17:08.000000000 -0500 ++++ pegasus/src/Pegasus/Common/SystemUnix.cpp 2006-05-02 15:34:36.000000000 -0400 +@@ -1097,8 +1097,12 @@ + + return retVal; + } ++ + #ifndef PEGASUS_OS_OS400 +-Boolean System::changeUserContext(const char* userName) ++Boolean System::lookupUserId( ++ const char* userName, ++ PEGASUS_UID_T& uid, ++ PEGASUS_GID_T& gid) + { + const unsigned int PWD_BUFF_SIZE = 1024; + struct passwd pwd; +@@ -1129,18 +1133,28 @@ + return false; + } + ++ uid = pwd.pw_uid; ++ gid = pwd.pw_gid; ++ ++ return true; ++} ++ ++Boolean System::changeUserContext( ++ const PEGASUS_UID_T& uid, ++ const PEGASUS_GID_T& gid) ++{ + Tracer::trace(TRC_OS_ABSTRACTION, Tracer::LEVEL4, + "Changing user context to: uid = %d, gid = %d", +- (int)pwd.pw_uid, (int)pwd.pw_gid); ++ (int)uid, (int)gid); + +- if (setgid(pwd.pw_gid) != 0) ++ if (setgid(gid) != 0) + { + PEG_TRACE_STRING(TRC_OS_ABSTRACTION, Tracer::LEVEL2, + String("setgid failed: ") + String(strerror(errno))); + return false; + } + +- if (setuid(pwd.pw_uid) != 0) ++ if (setuid(uid) != 0) + { + PEG_TRACE_STRING(TRC_OS_ABSTRACTION, Tracer::LEVEL2, + String("setuid failed: ") + String(strerror(errno))); +@@ -1150,6 +1164,7 @@ + return true; + } + #endif ++ + Uint32 System::getPID() + { + // +--- pegasus/src/Pegasus/Common/System.h.obz4980 2006-01-30 11:17:08.000000000 -0500 ++++ pegasus/src/Pegasus/Common/System.h 2006-05-02 15:34:36.000000000 -0400 +@@ -57,6 +57,16 @@ + #endif + #endif + ++#ifdef PEGASUS_OS_TYPE_UNIX ++# ifndef PEGASUS_OS_OS400 ++# include ++# endif ++# define PEGASUS_UID_T uid_t ++# define PEGASUS_GID_T gid_t ++#else ++# define PEGASUS_UID_T Uint32 ++# define PEGASUS_GID_T Uint32 ++#endif + + // + // Protocal Type +@@ -246,16 +256,33 @@ + static Boolean isGroupMember(const char* userName, const char* groupName); + + /** +- Changes the process user context to the specified user. +- +- @param userName User name to set as the process user context. ++ Gets the user and group IDs associated with the specified user. ++ @param userName User name for which to look up user and group IDs. ++ @param uid User ID for the specified user name. ++ @param gid Group ID for the specified user name. ++ @return True if the user and group IDs were retrieved ++ successfully, false otherwise. ++ */ ++#ifndef PEGASUS_OS_OS400 ++ static Boolean lookupUserId( ++ const char* userName, ++ PEGASUS_UID_T& uid, ++ PEGASUS_GID_T& gid); ++#endif + +- @return True if the user context is successfully changed, +- false otherwise. ++ /** ++ Changes the process user context to the specified user and group ID. ++ @param uid User ID to set as the process user context. ++ @param gid Group ID to set as the process group context. ++ @return True if the user context is successfully changed, ++ false otherwise. + */ + #ifndef PEGASUS_OS_OS400 +- static Boolean changeUserContext(const char* userName); ++ static Boolean changeUserContext( ++ const PEGASUS_UID_T& uid, ++ const PEGASUS_GID_T& gid); + #endif ++ + /** + This function is used to get the process ID of the calling process. + diff --git a/pegasus-2.5.1-obz4986.patch b/pegasus-2.5.1-obz4986.patch new file mode 100644 index 0000000..b6eb27f --- /dev/null +++ b/pegasus-2.5.1-obz4986.patch @@ -0,0 +1,1032 @@ +diff -Nur pegasus.orig/src/Pegasus/Handler/snmpIndicationHandler/tests/testclient/Makefile pegasus/src/Pegasus/Handler/snmpIndicationHandler/tests/testclient/Makefile +--- pegasus.orig/src/Pegasus/Handler/snmpIndicationHandler/tests/testclient/Makefile 1969-12-31 19:00:00.000000000 -0500 ++++ pegasus/src/Pegasus/Handler/snmpIndicationHandler/tests/testclient/Makefile 2006-05-02 15:45:49.000000000 -0400 +@@ -0,0 +1,63 @@ ++#//%2006//////////////////////////////////////////////////////////////////////// ++#// ++#// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development ++#// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. ++#// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.; ++#// IBM Corp.; EMC Corporation, The Open Group. ++#// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; ++#// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. ++#// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; ++#// EMC Corporation; VERITAS Software Corporation; The Open Group. ++#// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.; ++#// EMC Corporation; Symantec Corporation; The Open Group. ++#// ++#// Permission is hereby granted, free of charge, to any person obtaining a copy ++#// of this software and associated documentation files (the "Software"), to ++#// deal in the Software without restriction, including without limitation the ++#// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or ++#// sell copies of the Software, and to permit persons to whom the Software is ++#// furnished to do so, subject to the following conditions: ++#// ++#// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN ++#// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED ++#// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT ++#// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR ++#// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ++#// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ++#// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION ++#// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++#// ++#//============================================================================== ++ ++ROOT = ../../../../../.. ++DIR = Pegasus/Handler/snmpIndicationHandler/tests/testclient ++include $(ROOT)/mak/config.mak ++ ++LIBRARIES = \ ++ pegclient \ ++ pegcommon ++ ++EXTRA_INCLUDES = $(SYS_INCLUDES) ++ ++LOCAL_DEFINES = -DPEGASUS_INTERNALONLY ++ ++PROGRAM = TestSnmpHandler ++ ++SOURCES = testSnmpHandler.cpp ++ ++include $(ROOT)/mak/program.mak ++ ++tests: ++ ++poststarttests: ++ifdef PEGASUS_USE_NET_SNMP ++ $(MAKE) wql_4_2 ++else ++ @ $(ECHO) +++++ PEGASUS_USE_NET_SNMP is not set, test can not be run ++endif ++ ++wql_4_2: ++ $(PROGRAM) setup WQL ++ $(PROGRAM) run 4 2 ++ $(PROGRAM) cleanup ++ $(PROGRAM) removelog +diff -Nur pegasus.orig/src/Pegasus/Handler/snmpIndicationHandler/tests/testclient/testSnmpHandler.cpp pegasus/src/Pegasus/Handler/snmpIndicationHandler/tests/testclient/testSnmpHandler.cpp +--- pegasus.orig/src/Pegasus/Handler/snmpIndicationHandler/tests/testclient/testSnmpHandler.cpp 1969-12-31 19:00:00.000000000 -0500 ++++ pegasus/src/Pegasus/Handler/snmpIndicationHandler/tests/testclient/testSnmpHandler.cpp 2006-05-02 15:46:12.000000000 -0400 +@@ -0,0 +1,961 @@ ++//%2006//////////////////////////////////////////////////////////////////////// ++// ++// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development ++// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. ++// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.; ++// IBM Corp.; EMC Corporation, The Open Group. ++// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; ++// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. ++// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; ++// EMC Corporation; VERITAS Software Corporation; The Open Group. ++// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.; ++// EMC Corporation; Symantec Corporation; The Open Group. ++// ++// Permission is hereby granted, free of charge, to any person obtaining a copy ++// of this software and associated documentation files (the "Software"), to ++// deal in the Software without restriction, including without limitation the ++// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or ++// sell copies of the Software, and to permit persons to whom the Software is ++// furnished to do so, subject to the following conditions: ++// ++// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN ++// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED ++// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT ++// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR ++// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ++// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ++// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION ++// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++// ++//============================================================================== ++// ++// Author: Yi Zhou, Hewlett-Packard Company (Yi.Zhou@hp.com) ++// ++// Modified By: ++// ++//%///////////////////////////////////////////////////////////////////////////// ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++PEGASUS_USING_PEGASUS; ++PEGASUS_USING_STD; ++ ++const CIMNamespaceName INTEROP_NAMESPACE = CIMNamespaceName ("root/PG_InterOp"); ++const CIMNamespaceName SOURCE_NAMESPACE = ++ CIMNamespaceName ("root/SampleProvider"); ++ ++const String INDICATION_CLASS_NAME = String ("RT_TestIndication"); ++ ++const String SNMPV1_HANDLER_NAME = String ("SNMPHandler01"); ++const String SNMPV2C_HANDLER_NAME = String ("SNMPHandler02"); ++const String FILTER_NAME = String ("IPFilter01"); ++ ++enum SNMPVersion {_SNMPV1_TRAP = 2, _SNMPV2C_TRAP = 3}; ++enum TargetHostFormat {_HOST_NAME = 2, _IPV4_ADDRESS = 3}; ++ ++#define PORT_NUMBER 2006 ++ ++Uint32 indicationSendCountTotal = 0; ++ ++AtomicInt errorsEncountered(0); ++ ++//////////////////////////////////////////////////////////////////////////////// ++// ++// Thread Parameters Class ++// ++//////////////////////////////////////////////////////////////////////////////// ++ ++class T_Parms{ ++ public: ++ AutoPtr client; ++ Uint32 indicationSendCount; ++ Uint32 uniqueID; ++}; ++ ++/////////////////////////////////////////////////////////////////////////// ++ ++CIMObjectPath _getFilterObjectPath ++ (const String & name) ++{ ++ Array keyBindings; ++ keyBindings.append (CIMKeyBinding ("SystemCreationClassName", ++ System::getSystemCreationClassName (), CIMKeyBinding::STRING)); ++ keyBindings.append (CIMKeyBinding ("SystemName", ++ System::getFullyQualifiedHostName (), CIMKeyBinding::STRING)); ++ keyBindings.append (CIMKeyBinding ("CreationClassName", ++ PEGASUS_CLASSNAME_INDFILTER.getString(), CIMKeyBinding::STRING)); ++ keyBindings.append (CIMKeyBinding ("Name", name, ++ CIMKeyBinding::STRING)); ++ return(CIMObjectPath("", CIMNamespaceName (), ++ PEGASUS_CLASSNAME_INDFILTER, keyBindings)); ++} ++ ++CIMObjectPath _getHandlerObjectPath ++ (const String & name) ++{ ++ Array keyBindings; ++ keyBindings.append (CIMKeyBinding ("SystemCreationClassName", ++ System::getSystemCreationClassName (), CIMKeyBinding::STRING)); ++ keyBindings.append (CIMKeyBinding ("SystemName", ++ System::getFullyQualifiedHostName (), CIMKeyBinding::STRING)); ++ keyBindings.append (CIMKeyBinding ("CreationClassName", ++ PEGASUS_CLASSNAME_INDHANDLER_SNMP.getString(), ++ CIMKeyBinding::STRING)); ++ keyBindings.append (CIMKeyBinding ("Name", name, ++ CIMKeyBinding::STRING)); ++ return(CIMObjectPath("", CIMNamespaceName (), ++ PEGASUS_CLASSNAME_INDHANDLER_SNMP, keyBindings)); ++} ++ ++CIMObjectPath _getSubscriptionObjectPath ++ (const String & filterName, ++ const String & handlerName) ++{ ++ CIMObjectPath filterObjectPath = _getFilterObjectPath(filterName); ++ ++ CIMObjectPath handlerObjectPath = _getHandlerObjectPath(handlerName); ++ ++ Array subscriptionKeyBindings; ++ subscriptionKeyBindings.append (CIMKeyBinding ("Filter", ++ CIMValue(filterObjectPath))); ++ subscriptionKeyBindings.append (CIMKeyBinding ("Handler", ++ CIMValue(handlerObjectPath))); ++ return(CIMObjectPath("", CIMNamespaceName (), ++ PEGASUS_CLASSNAME_INDSUBSCRIPTION, subscriptionKeyBindings)); ++} ++ ++CIMObjectPath _createHandlerInstance ++ (CIMClient & client, ++ const String & name, ++ const String & targetHost, ++ const String & securityName, ++ const Uint16 targetHostFormat, ++ const Uint16 snmpVersion) ++{ ++ CIMInstance handlerInstance (PEGASUS_CLASSNAME_INDHANDLER_SNMP); ++ handlerInstance.addProperty (CIMProperty (CIMName ++ ("SystemCreationClassName"), System::getSystemCreationClassName ())); ++ handlerInstance.addProperty (CIMProperty (CIMName ("SystemName"), ++ System::getFullyQualifiedHostName ())); ++ handlerInstance.addProperty (CIMProperty (CIMName ("CreationClassName"), ++ PEGASUS_CLASSNAME_INDHANDLER_SNMP.getString ())); ++ handlerInstance.addProperty (CIMProperty (CIMName ("Name"), name)); ++ handlerInstance.addProperty (CIMProperty (CIMName ("TargetHost"), ++ targetHost)); ++ handlerInstance.addProperty (CIMProperty (CIMName ("TargetHostFormat"), ++ CIMValue ((Uint16) targetHostFormat))); ++ handlerInstance.addProperty (CIMProperty (CIMName ("SNMPSecurityName"), ++ securityName)); ++ handlerInstance.addProperty (CIMProperty (CIMName ("SnmpVersion"), ++ CIMValue ((Uint16) snmpVersion))); ++ handlerInstance.addProperty (CIMProperty (CIMName ("PortNumber"), ++ CIMValue ((Uint32) PORT_NUMBER))); ++ ++ return(client.createInstance (INTEROP_NAMESPACE, handlerInstance)); ++} ++ ++CIMObjectPath _createFilterInstance ++ (CIMClient & client, ++ const String & name, ++ const String & query, ++ const String & qlang) ++{ ++ CIMInstance filterInstance (PEGASUS_CLASSNAME_INDFILTER); ++ filterInstance.addProperty (CIMProperty (CIMName ++ ("SystemCreationClassName"), System::getSystemCreationClassName ())); ++ filterInstance.addProperty (CIMProperty (CIMName ("SystemName"), ++ System::getFullyQualifiedHostName ())); ++ filterInstance.addProperty (CIMProperty (CIMName ("CreationClassName"), ++ PEGASUS_CLASSNAME_INDFILTER.getString ())); ++ filterInstance.addProperty (CIMProperty (CIMName ("Name"), name)); ++ filterInstance.addProperty (CIMProperty (CIMName ("Query"), query)); ++ filterInstance.addProperty (CIMProperty (CIMName ("QueryLanguage"), ++ String (qlang))); ++ filterInstance.addProperty (CIMProperty (CIMName ("SourceNamespace"), ++ SOURCE_NAMESPACE.getString ())); ++ ++ return(client.createInstance (INTEROP_NAMESPACE, filterInstance)); ++} ++ ++CIMObjectPath _createSubscriptionInstance ++ (CIMClient & client, ++ const CIMObjectPath & filterPath, ++ const CIMObjectPath & handlerPath) ++{ ++ CIMInstance subscriptionInstance (PEGASUS_CLASSNAME_INDSUBSCRIPTION); ++ subscriptionInstance.addProperty (CIMProperty (CIMName ("Filter"), ++ filterPath, 0, PEGASUS_CLASSNAME_INDFILTER)); ++ subscriptionInstance.addProperty (CIMProperty (CIMName ("Handler"), ++ handlerPath, 0, PEGASUS_CLASSNAME_INDHANDLER_SNMP)); ++ subscriptionInstance.addProperty (CIMProperty ++ (CIMName ("SubscriptionState"), CIMValue ((Uint16) 2))); ++ ++ return(client.createInstance (INTEROP_NAMESPACE, subscriptionInstance)); ++} ++ ++void _sendTestIndication(CIMClient* client, const CIMName & methodName, ++ Uint32 indicationSendCount) ++{ ++ // ++ // Invoke method to send test indication ++ // ++ Array inParams; ++ Array outParams; ++ Array keyBindings; ++ Sint32 result; ++ ++ CIMObjectPath className (String::EMPTY, CIMNamespaceName (), ++ CIMName ("RT_TestIndication"), keyBindings); ++ ++ inParams.append(CIMParamValue(String("indicationSendCount"), ++ CIMValue(indicationSendCount))); ++ ++ CIMValue retValue = client->invokeMethod ++ (SOURCE_NAMESPACE, ++ className, ++ methodName, ++ inParams, ++ outParams); ++ ++ retValue.get (result); ++ PEGASUS_TEST_ASSERT (result == 0); ++} ++ ++void _deleteSubscriptionInstance ++ (CIMClient & client, ++ const String & filterName, ++ const String & handlerName) ++{ ++ CIMObjectPath subscriptionObjectPath = ++ _getSubscriptionObjectPath(filterName, handlerName); ++ client.deleteInstance (INTEROP_NAMESPACE, subscriptionObjectPath); ++} ++ ++void _deleteHandlerInstance ++ (CIMClient & client, ++ const String & name) ++{ ++ CIMObjectPath handlerObjectPath = _getHandlerObjectPath(name); ++ client.deleteInstance (INTEROP_NAMESPACE, handlerObjectPath); ++} ++ ++void _deleteFilterInstance ++ (CIMClient & client, ++ const String & name) ++{ ++ CIMObjectPath filterObjectPath = _getFilterObjectPath(name); ++ client.deleteInstance (INTEROP_NAMESPACE, filterObjectPath); ++} ++ ++void _usage () ++{ ++ cerr << endl ++ << "Usage:" << endl ++ << " TestSnmpHandler setup [ WQL | DMTF:CQL ]\n" ++ << " TestSnmpHandler run " ++ << "[]\n" ++ << " where: " << endl ++ << " is the number of indications to\n" ++ << " generate and has to be greater than zero." << endl ++ << " is an optional number of client threads to\n" ++ << " create, default is one." << endl ++ << " TestSnmpHandler cleanup\n" ++ << " TestSnmpHandler removelog" ++ << endl << endl; ++} ++ ++void _setup (CIMClient & client, const String& qlang) ++{ ++ CIMObjectPath filterObjectPath; ++ CIMObjectPath snmpv1HandlerObjectPath; ++ CIMObjectPath snmpv2HandlerObjectPath; ++ ++ try ++ { ++ filterObjectPath = _createFilterInstance (client, FILTER_NAME, ++ String ("SELECT * FROM RT_TestIndication"), ++ qlang); ++ } ++ catch (CIMException& e) ++ { ++ if (e.getCode() == CIM_ERR_ALREADY_EXISTS) ++ { ++ filterObjectPath = _getFilterObjectPath(FILTER_NAME); ++ cerr << "----- Warning: Filter Instance Not Created: " ++ << e.getMessage () << endl; ++ } ++ else ++ { ++ cerr << "----- Error: Filter Instance Not Created: " << endl; ++ throw; ++ } ++ } ++ ++ try ++ { ++ // Create SNMPv1 trap handler ++ snmpv1HandlerObjectPath = _createHandlerInstance (client, ++ SNMPV1_HANDLER_NAME, ++ System::getFullyQualifiedHostName(), ++ "", ++ _HOST_NAME, ++ _SNMPV1_TRAP); ++ } ++ catch (CIMException& e) ++ { ++ if (e.getCode() == CIM_ERR_ALREADY_EXISTS) ++ { ++ snmpv1HandlerObjectPath = _getHandlerObjectPath( ++ SNMPV1_HANDLER_NAME); ++ cerr << "----- Warning: SNMPv1 Trap Handler Instance Not Created: " ++ << e.getMessage () << endl; ++ } ++ else ++ { ++ cerr << "----- Error: SNMPv1 Trap Handler Instance Not Created: " ++ << endl; ++ throw; ++ } ++ } ++ ++ try ++ { ++ _createSubscriptionInstance (client, filterObjectPath, ++ snmpv1HandlerObjectPath); ++ } ++ catch (CIMException& e) ++ { ++ if (e.getCode() == CIM_ERR_ALREADY_EXISTS) ++ { ++ cerr << "----- Warning: Client Subscription Instance: " ++ << e.getMessage () << endl; ++ } ++ else ++ { ++ cerr << "----- Error: Client Subscription Instance: " << endl; ++ throw; ++ } ++ } ++ ++ try ++ { ++ // Create SNMPv2 trap handler ++ snmpv2HandlerObjectPath = _createHandlerInstance (client, ++ SNMPV2C_HANDLER_NAME, ++ System::getHostIP(System::getFullyQualifiedHostName ()), ++ "public", ++ _IPV4_ADDRESS, ++ _SNMPV2C_TRAP); ++ } ++ catch (CIMException& e) ++ { ++ if (e.getCode() == CIM_ERR_ALREADY_EXISTS) ++ { ++ snmpv2HandlerObjectPath = _getHandlerObjectPath( ++ SNMPV2C_HANDLER_NAME); ++ cerr << "----- Warning: SNMPv2c Trap Handler Instance Not Created: " ++ << e.getMessage () << endl; ++ } ++ else ++ { ++ cerr << "----- Error: SNMPv2c Trap Handler Instance Not Created: " ++ << endl; ++ throw; ++ } ++ } ++ ++ try ++ { ++ _createSubscriptionInstance (client, filterObjectPath, ++ snmpv2HandlerObjectPath); ++ } ++ catch (CIMException& e) ++ { ++ if (e.getCode() == CIM_ERR_ALREADY_EXISTS) ++ { ++ cerr << "----- Warning: Client Subscription Instance: " ++ << e.getMessage () << endl; ++ } ++ else ++ { ++ cerr << "----- Error: Client Subscription Instance: " << endl; ++ throw; ++ } ++ } ++} ++ ++void _cleanup (CIMClient & client) ++{ ++ try ++ { ++ _deleteSubscriptionInstance (client, FILTER_NAME, ++ SNMPV1_HANDLER_NAME); ++ } ++ catch (CIMException& e) ++ { ++ if (e.getCode() != CIM_ERR_NOT_FOUND) ++ { ++ cerr << "----- Error: deleteSubscriptionInstance failure: " ++ << endl; ++ throw; ++ } ++ } ++ try ++ { ++ _deleteSubscriptionInstance (client, FILTER_NAME, ++ SNMPV2C_HANDLER_NAME); ++ } ++ catch (CIMException& e) ++ { ++ if (e.getCode() != CIM_ERR_NOT_FOUND) ++ { ++ cerr << "----- Error: deleteSubscriptionInstance failure: " ++ << endl; ++ throw; ++ } ++ } ++ try ++ { ++ _deleteFilterInstance (client, FILTER_NAME); ++ } ++ catch (CIMException& e) ++ { ++ if (e.getCode() != CIM_ERR_NOT_FOUND) ++ { ++ cerr << "----- Error: deleteFilterInstance failure: " << endl; ++ throw; ++ } ++ } ++ ++ try ++ { ++ _deleteHandlerInstance (client, SNMPV1_HANDLER_NAME); ++ } ++ catch (CIMException& e) ++ { ++ if (e.getCode() != CIM_ERR_NOT_FOUND) ++ { ++ cerr << "----- Error: deleteHandlerInstance failure: " << endl; ++ throw; ++ } ++ } ++ try ++ { ++ _deleteHandlerInstance (client, SNMPV2C_HANDLER_NAME); ++ } ++ catch (CIMException& e) ++ { ++ if (e.getCode() != CIM_ERR_NOT_FOUND) ++ { ++ cerr << "----- Error: deleteHandlerInstance failure: " << endl; ++ throw; ++ } ++ } ++} ++ ++static void _testEnd(const String& uniqueID, const double elapsedTime) ++{ ++ cout << "+++++ thread" << uniqueID << ": passed in " << elapsedTime ++ << " seconds" << endl; ++} ++ ++PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL _executeTests(void *parm) ++{ ++ Thread *my_thread = (Thread *)parm; ++ T_Parms *parms = (T_Parms *)my_thread->get_parm(); ++ CIMClient *client = parms->client.get(); ++ Uint32 indicationSendCount = parms->indicationSendCount; ++ Uint32 id = parms->uniqueID; ++ char id_[4]; ++ memset(id_,0x00,sizeof(id_)); ++ sprintf(id_,"%i",id); ++ String uniqueID = "_"; ++ uniqueID.append(id_); ++ ++ try ++ { ++ Stopwatch elapsedTime; ++ ++ elapsedTime.start(); ++ try ++ { ++ _sendTestIndication (client, CIMName ("SendTestIndicationTrap"), ++ indicationSendCount); ++ } ++ catch (Exception & e) ++ { ++ cerr << "----- sendTestIndication failed: " << e.getMessage () << endl; ++ exit (-1); ++ } ++ elapsedTime.stop(); ++ _testEnd(uniqueID, elapsedTime.getElapsed()); ++ } ++ catch(Exception & e) ++ { ++ cout << e.getMessage() << endl; ++ } ++ my_thread->exit_self((PEGASUS_THREAD_RETURN)1); ++ return(0); ++} ++ ++Thread * _runTestThreads( ++ CIMClient* client, ++ Uint32 indicationSendCount, ++ Uint32 uniqueID) ++{ ++ // package parameters, create thread and run... ++ AutoPtr parms(new T_Parms()); ++ parms->client.reset(client); ++ parms->indicationSendCount = indicationSendCount; ++ parms->uniqueID = uniqueID; ++ AutoPtr t(new Thread(_executeTests, (void*)parms.release(), false)); ++ t->run(); ++ return t.release(); ++} ++ ++String _getLogFile() ++{ ++ return("trapLogFile"); ++} ++ ++Uint32 _getReceivedTrapCount(Uint16 snmpVersion) ++{ ++ String trap1 = "Trap Info: TRAP, SNMP v1, community public"; ++ String trap2 = "Trap Info: TRAP2, SNMP v2c, community public"; ++ ++ Uint32 receivedTrap1Count = 0; ++ Uint32 receivedTrap2Count = 0; ++ ++ ifstream ifs(_getLogFile().getCString()); ++ if (!ifs) ++ { ++ return (0); ++ } ++ ++ String line; ++ while (GetLine(ifs, line)) ++ { ++ if (String::compare(line, trap1) == 0) ++ { ++ receivedTrap1Count++; ++ } ++ if (String::compare(line, trap2) == 0) ++ { ++ receivedTrap2Count++; ++ } ++ } ++ ++ ifs.close(); ++ ++ switch (snmpVersion) ++ { ++ case _SNMPV1_TRAP: ++ { ++ return (receivedTrap1Count); ++ } ++ case _SNMPV2C_TRAP: ++ { ++ return (receivedTrap2Count); ++ } ++ default: ++ { ++ return (0); ++ } ++ } ++ ++} ++ ++#ifdef PEGASUS_USE_NET_SNMP ++// Stop snmptrapd process if it is running and remove ++// procIdFile file if it exists ++// ++void _stopSnmptrapd() ++{ ++ String procIdFileName = "procIdFile"; ++ ++ Uint32 receiverPid; ++ FILE *fd; ++ if ((fd = fopen(procIdFileName.getCString(), "r")) != NULL) ++ { ++ fscanf(fd, "%d\n", &receiverPid); ++ ++ kill(receiverPid, SIGTERM); ++ ++ fclose(fd); ++ } ++ ++ if (FileSystem::exists(procIdFileName)) ++ { ++ FileSystem::removeFile(procIdFileName); ++ } ++} ++ ++static Boolean _startSnmptrapd( ++ FILE **trapInfo) ++{ ++ String snmptrapdCmd; ++ ++ Uint32 portNumber = PORT_NUMBER; ++ char portNumberStr[32]; ++ sprintf(portNumberStr, "%lu", (unsigned long) portNumber); ++ ++ // ++ // build snmptrapd cmd options ++ // ++ ++ // Specify logging incoming traps to trapLogFile ++ // Save the process ID of the snmptrapd in procIdFile ++ snmptrapdCmd.append( ++ "/usr/sbin/snmptrapd -f -Lf trapLogFile -p procIdFile"); ++ ++ // Specify incoming trap format ++ snmptrapdCmd.append( " -F \"\nTrap Info: %P\nVariable: %v\n\""); ++ ++ // Specify listening address ++ snmptrapdCmd.append(" UDP:"); ++ snmptrapdCmd.append(System::getFullyQualifiedHostName ()); ++ ++ snmptrapdCmd.append(":"); ++ snmptrapdCmd.append(portNumberStr); ++ ++ if ((*trapInfo = popen(snmptrapdCmd.getCString(), "r")) == NULL) ++ { ++ throw Exception ("snmptrapd can not be started"); ++ } ++ ++#define MAX_ITERATIONS 300 ++#define SLEEP_SEC 1 ++ ++ Uint32 iterations = 0; ++ ++ // Wait until snmptrapd startted ++ while (iterations < MAX_ITERATIONS) ++ { ++ iterations++; ++ if (FileSystem::exists("procIdFile")) ++ { ++ return (true); ++ } ++ else ++ { ++ System::sleep(SLEEP_SEC); ++ ++ } ++ } ++ ++ throw Exception ("snmptrapd can not be started"); ++} ++#endif ++ ++void _removeTrapLogFile () ++{ ++ String logFile = _getLogFile(); ++ ++ // if trapLogFile exists, remove it ++ if (FileSystem::exists(logFile)) ++ { ++ FileSystem::removeFile(logFile); ++ } ++} ++ ++int _beginTest(CIMClient& workClient, ++ Uint32 indicationSendCount, ++ Uint32 runClientThreadCount) ++{ ++ ++#ifdef PEGASUS_USE_NET_SNMP ++ ++ // Stop snmptrapd process if it is running ++ _stopSnmptrapd(); ++ ++ // if trapLogFile exists, remove it ++ _removeTrapLogFile(); ++ ++ FILE * trapInfo; ++ ++ try ++ { ++ _startSnmptrapd(&trapInfo); ++ } ++ catch (Exception & e) ++ { ++ cerr << e.getMessage() << endl; ++ return (-1); ++ } ++#else ++ cerr << "Cannot create a trap receiver." << endl; ++ return (-1); ++#endif ++ ++ CIMClient * clientConnections = new CIMClient[runClientThreadCount]; ++ ++ // determine total number of indication send count ++ indicationSendCountTotal = indicationSendCount * runClientThreadCount; ++ ++ // calculate the timeout based on the total send count allowing ++ // using the MSG_PER_SEC rate ++ // allow 20 seconds of test overhead for very small tests ++ ++#define MSG_PER_SEC 4 ++ ++ Uint32 testTimeout = 20000+(indicationSendCountTotal/MSG_PER_SEC)*1000; ++ ++ // connect the clients ++ for(Uint32 i = 0; i < runClientThreadCount; i++) ++ { ++ clientConnections[i].setTimeout(testTimeout); ++ clientConnections[i].connectLocal(); ++ } ++ ++ // run tests ++ Thread ** clientThreads = new Thread *[runClientThreadCount]; ++ ++ Stopwatch trapReceiverElapsedTime; ++ ++ trapReceiverElapsedTime.start(); ++ ++ for(Uint32 i = 0; i < runClientThreadCount; i++) ++ { ++ clientThreads[i] = _runTestThreads(&clientConnections[i], ++ indicationSendCount, i); ++ } ++ ++ for(Uint32 i=0; i< runClientThreadCount; i++) ++ { ++ clientThreads[i]->join(); ++ } ++ ++ delete[] clientConnections; ++ delete[] clientThreads; ++ ++ // ++ // Allow time for the trap to be received ++ // Wait in SLEEP_SEC second intervals. ++ // Put msg out every MSG_SEC intervals ++ // ++ ++#define SLEEP_SEC 1 ++#define COUT_TIME_INTERVAL 30 ++#define MAX_NO_CHANGE_ITERATIONS COUT_TIME_INTERVAL*3 ++ ++ Uint32 noChangeIterations = 0; ++ Uint32 priorReceivedTrap1Count = 0; ++ Uint32 priorReceivedTrap2Count = 0; ++ Uint32 currentReceivedTrap1Count = 0; ++ Uint32 currentReceivedTrap2Count = 0; ++ Uint32 totalIterations = 0; ++ ++ // ++ // Wait for the trap receiver to receive the expected ++ // number of Indication traps, indicationSendCountTotal. ++ // ++ // We will continue to wait until either indicationSendCountTotal ++ // Indications have been received by the trap receiver or no new ++ // Indications have been received in the previous ++ // MAX_NO_CHANGE_ITERATIONS. ++ // iterations. ++ // ++ ++ Boolean receivedTrapCountComplete = false; ++ Boolean receiverTrap1NoChange = true; ++ Boolean receiverTrap2NoChange = true; ++ ++ while (noChangeIterations <= MAX_NO_CHANGE_ITERATIONS) ++ { ++ totalIterations++; ++ ++ currentReceivedTrap1Count = _getReceivedTrapCount(_SNMPV1_TRAP); ++ currentReceivedTrap2Count = _getReceivedTrapCount(_SNMPV2C_TRAP); ++ ++ if (totalIterations % COUT_TIME_INTERVAL == 1 && ++ !(receivedTrapCountComplete)) ++ { ++ cout << "++++ The trap receiver has received " ++ << currentReceivedTrap1Count << " of " ++ << indicationSendCountTotal << " SNMPv1 trap." ++ << endl; ++ cout << "++++ The trap receiver has received " ++ << currentReceivedTrap2Count << " of " ++ << indicationSendCountTotal << " SNMPv2c trap." ++ << endl; ++ } ++ ++ if ((indicationSendCountTotal == currentReceivedTrap1Count) && ++ (indicationSendCountTotal == currentReceivedTrap2Count)) ++ { ++ receivedTrapCountComplete = true; ++ trapReceiverElapsedTime.stop(); ++ } ++ if (!(receiverTrap1NoChange = ++ (priorReceivedTrap1Count == currentReceivedTrap1Count))) ++ { ++ priorReceivedTrap1Count = currentReceivedTrap1Count; ++ } ++ ++ if (!(receiverTrap2NoChange = ++ (priorReceivedTrap2Count == currentReceivedTrap2Count))) ++ { ++ priorReceivedTrap2Count = currentReceivedTrap2Count; ++ } ++ ++ if (receivedTrapCountComplete) ++ { ++ cout << "++++ The trap receiver has received " ++ << currentReceivedTrap1Count << " of " ++ << indicationSendCountTotal << " SNMPv1 trap." ++ << endl; ++ cout << "++++ The trap receiver has received " ++ << currentReceivedTrap2Count << " of " ++ << indicationSendCountTotal << " SNMPv2c trap." ++ << endl; ++ ++ break; ++ } ++ if (receiverTrap1NoChange || receiverTrap2NoChange) ++ { ++ noChangeIterations++; ++ } ++ else ++ { ++ noChangeIterations = 0; ++ } ++ ++ System::sleep (SLEEP_SEC); ++ } ++ ++ if (!receivedTrapCountComplete) ++ { ++ trapReceiverElapsedTime.stop(); ++ } ++ ++ // assert that all indications sent have been received. ++ PEGASUS_TEST_ASSERT(indicationSendCountTotal == ++ currentReceivedTrap1Count); ++ PEGASUS_TEST_ASSERT(indicationSendCountTotal == ++ currentReceivedTrap2Count); ++ ++#ifdef PEGASUS_USE_NET_SNMP ++ // Stop snmptrapd process if it is running and remove procIdFile ++ _stopSnmptrapd(); ++ ++ pclose(trapInfo); ++#endif ++ ++ // if error encountered then fail the test. ++ if (errorsEncountered.get()) ++ { ++ cout << "+++++ test failed" << endl; ++ return (-1); ++ } ++ else ++ { ++ cout << "+++++ passed all tests" << endl; ++ } ++ ++ return 0; ++} ++ ++int main (int argc, char** argv) ++{ ++ // This client connection is used solely to create and delete subscriptions. ++ CIMClient workClient; ++ try ++ { ++ workClient.connectLocal(); ++ ++ if (argc <= 1 || argc > 4) ++ { ++ cerr << "Invalid argument count: " << argc << endl; ++ _usage(); ++ return 1; ++ } ++ else if (strcmp(argv[1], "setup") == 0) ++ { ++ if (argc < 3) ++ { ++ cerr << "Missing query language" << endl; ++ _usage(); ++ return -1; ++ } ++ ++ if ((strcmp(argv[2], "WQL") != 0) && ++ (strcmp(argv[2], "DMTF:CQL") != 0)) ++ { ++ cerr << "Invalid query language: '" << argv[2] << "'" << endl; ++ _usage(); ++ return -1; ++ } ++ ++ _setup(workClient, argv[2]); ++ ++ cout << "+++++ setup completed successfully" << endl; ++ return 0; ++ } ++ else if (String::equalNoCase(argv[1], "run")) ++ { ++ if (argc < 3) ++ { ++ cerr << "Invalid indicationSendCount." << endl; ++ _usage (); ++ return -1; ++ } ++ ++ Uint32 indicationSendCount = atoi(argv[2]); ++ ++ Uint32 runClientThreadCount = 1; ++ ++ if (argc == 4) ++ { ++ runClientThreadCount = atoi(argv[3]); ++ } ++ ++ int rc = _beginTest(workClient, indicationSendCount, ++ runClientThreadCount); ++ return rc; ++ } ++ else if (String::equalNoCase(argv[1], "cleanup")) ++ { ++ if (argc > 2) ++ { ++ cerr << "Invalid argument count." << endl; ++ _usage (); ++ return -1; ++ } ++ ++ _cleanup (workClient); ++ ++ cout << "+++++ cleanup completed successfully" << endl; ++ return 0; ++ } ++ else if (String::equalNoCase(argv[1], "removelog")) ++ { ++ if (argc > 2) ++ { ++ cerr << "Invalid argument count." << endl; ++ _usage (); ++ return -1; ++ } ++ ++ _removeTrapLogFile (); ++ cout << "+++++ removelog completed successfully" << endl; ++ return 0; ++ } ++ else ++ { ++ cerr << "Invalid option: " << argv[1] << endl; ++ _usage (); ++ return -1; ++ } ++ } ++ catch (Exception & e) ++ { ++ cerr << "Error: " << e.getMessage() << endl; ++ } ++ ++ PEGASUS_UNREACHABLE( return 0; ) ++} diff --git a/pegasus-2.5.1-warnings.patch b/pegasus-2.5.1-warnings.patch index 446efc6..e8fd620 100644 --- a/pegasus-2.5.1-warnings.patch +++ b/pegasus-2.5.1-warnings.patch @@ -45,13 +45,13 @@ inline void Packer::packReal32(Buffer& out, Real32 x) { - packUint32(out, *((Uint32*)&x)); -+ packUint32(out, (Uint32)x); ++ packUint32(out, *(reinterpret_cast(&x))); } inline void Packer::packReal64(Buffer& out, Real64 x) { - packUint64(out, *((Uint64*)&x)); -+ packUint64(out, (Uint64)x); ++ packUint64(out, *(reinterpret_cast(&x))); } inline void Packer::packChar16(Buffer& out, Char16 x) diff --git a/tog-pegasus.spec b/tog-pegasus.spec index b171adf..19fe966 100644 --- a/tog-pegasus.spec +++ b/tog-pegasus.spec @@ -31,7 +31,7 @@ %define pegasus_uid 66 Version: 2.5.1 -Release: 3%{?LINUX_VERSION:.%{LINUX_VERSION}} +Release: 4%{?LINUX_VERSION:.%{LINUX_VERSION}} Epoch: 2 # Summary: OpenPegasus WBEM Services for Linux @@ -66,6 +66,13 @@ Patch14: pegasus-2.5.1-obz4945.patch Patch15: pegasus-2.5.1-PATH_MAX.patch Patch16: pegasus-2.5.1-HOSTNAME_MAX.patch Patch17: pegasus-2.5.1-fix_repupgrade.patch +Patch18: pegasus-2.5.1-obz4968_upcalls_oop.patch +Patch19: pegasus-2.5.1-obz4955.patch +Patch20: pegasus-2.5.1-obz4956.patch +Patch21: pegasus-2.5.1-obz4978.patch +Patch22: pegasus-2.5.1-obz4983.patch +Patch23: pegasus-2.5.1-obz4984.patch +Patch24: pegasus-2.5.1-obz4986.patch # Conflicts: openwbem Provides: tog-pegasus-cimserver @@ -132,12 +139,20 @@ The OpenPegasus WBEM tests for the OpenPegasus %{version} Linux rpm. %patch9 -p1 -b .parallel-make %patch10 -p1 -b .fix-zseries-flags %patch11 -p1 -b .fix-tests -%patch12 -p1 -b .AutoPtr-Core +#%patch12 -p1 -b .AutoPtr-Core +#^- now fixed with upstream obz4968 patch %patch13 -p1 -b .obz4934 %patch14 -p1 -b .obz4945 %patch15 -p1 -b .PATH_MAX %patch16 -p1 -b .HOSTNAME_MAX %patch17 -p1 -b .fix_repupgrade +%patch18 -p1 -b .obz4968_upcalls_oop +%patch19 -p1 -b .obz4955 +%patch20 -p1 -b .obz4956 +%patch21 -p1 -b .obz4978 +%patch22 -p1 -b .obz4983 +%patch23 -p1 -b .obz4984 +%patch24 -p1 -b .obz4986 %build rm -rf ${RPM_BUILD_ROOT} || :; @@ -163,6 +178,9 @@ make -f RedHat.OpenPegasus.Makefile install prefix=$RPM_BUILD_ROOT libdir=%{_lib %files %defattr(0750, root, pegasus, 0750) +%if !%{NODEBUGINFO} +%exclude /usr/lib/debug +%endif /usr/%{_lib}/* /usr/sbin/* /usr/bin/* @@ -272,6 +290,19 @@ fi :; %changelog +* Tue May 02 2006 Jason Vas Dias - 2:2.5.1-4 +- fix bug 190432: %exclude /usr/lib/debug from RPM +- fix upstream OpenPegasus '2.5.2_APPROVED' bugs, applying upstream patches: + o 4955 : Bogus Description property for OperatingSystem provider + o 4956 : reserveCapacity method may cause size overflow on invalid input + o 4968 : CMPI provider up-calls cause failure with out-of-process + o 4978 : snmpDeliverTrap_netsnmp::_createSession function is not thread safe + o 4983 : Memory leak in OOP indication generation + o 4984 : Forked process hangs in system call + o 4986 : Adding automated test for snmpIndication Handler + ( http://cvs.opengroup.org/bugzilla/show_bug.cgi?id=? ) +- apply upstream update to 'pegasus-2.5.1-warnings.patch' + * Mon Apr 17 2006 Jason Vas Dias - 2:2.5.1-3 - Fix repupgrade (make it use correct paths)