[tncfhh/f19] Implemented support for dlopen

avesh avesh at fedoraproject.org
Thu Sep 12 16:52:10 UTC 2013


commit d26a5b14acb4998e8277baa5e0b53fb521d66315
Author: Avesh Agarwal <avagarwa at redhat.com>
Date:   Thu Sep 12 12:52:08 2013 -0400

    Implemented support for dlopen
    
    - Removed libtool support
    - Fixed imv and imc build issues arising from a
      previous upstream patch
    - Fixed a few coverity scan error issues

 imcv-build-issue.patch      |  162 ----------------------------------------
 tncfhh-dlopen-support.patch |  172 +++++++++++++++++++++++++++++++++++++++++++
 tncfhh.spec                 |   15 +++-
 3 files changed, 183 insertions(+), 166 deletions(-)
---
diff --git a/tncfhh-dlopen-support.patch b/tncfhh-dlopen-support.patch
new file mode 100644
index 0000000..542c089
--- /dev/null
+++ b/tncfhh-dlopen-support.patch
@@ -0,0 +1,172 @@
+diff -urNp tncfhh-0.8.3-patched/imcv/attestation/imc/src/AttestationIMC.cpp tncfhh-0.8.3-current/imcv/attestation/imc/src/AttestationIMC.cpp
+--- tncfhh-0.8.3-patched/imcv/attestation/imc/src/AttestationIMC.cpp	2013-09-12 12:05:09.192184453 -0400
++++ tncfhh-0.8.3-current/imcv/attestation/imc/src/AttestationIMC.cpp	2013-09-12 12:00:32.438166255 -0400
+@@ -275,7 +275,7 @@ TNC_Result AttestationIMC::receiveMessag
+ 
+ 		bitMaskLength = ntohs(*(UINT16*)message);
+ 
+-		if ((2 + bitMaskLength + 20) != length) {
++		if ((TNC_UInt32)(2 + bitMaskLength + 20) != length) {
+ 			LOG4CXX_FATAL(logger, "Message length is wrong!!!");
+ 			return TNC_RESULT_INVALID_PARAMETER;
+ 		}
+@@ -428,6 +428,8 @@ int AttestationIMC::doQuote(PcrSelection
+ 			TNC_MESSAGETYPE_FHH_ATTESTATION);
+ 
+ 	Tspi_Context_FreeMemory(hContext, valid.rgbValidationData);
++	
++	return 0;
+ }
+ 
+ TNC_Result AttestationIMC::batchEnding()
+diff -urNp tncfhh-0.8.3-patched/imunit/src/imunit/IMUnitLibrary.cpp tncfhh-0.8.3-current/imunit/src/imunit/IMUnitLibrary.cpp
+--- tncfhh-0.8.3-patched/imunit/src/imunit/IMUnitLibrary.cpp	2013-09-12 12:03:48.251179131 -0400
++++ tncfhh-0.8.3-current/imunit/src/imunit/IMUnitLibrary.cpp	2013-09-12 12:00:32.440166255 -0400
+@@ -53,7 +53,7 @@ IMUnitLibrary::IMUnitLibrary()
+ {
+     // Set up a simple configuration that logs on the console.
+ 	// only when no configuration exists
+-	if (!checkLog4cxxInitialized())
++	//if (!checkLog4cxxInitialized())
+ 	{
+ 		// try to use config file
+ 		const char* log4cxxConfigurationEnv = getenv("LOG4CXX_CONFIGURATION");
+diff -urNp tncfhh-0.8.3-patched/shared/cmake_modules/FindDL.cmake tncfhh-0.8.3-current/shared/cmake_modules/FindDL.cmake
+--- tncfhh-0.8.3-patched/shared/cmake_modules/FindDL.cmake	1969-12-31 19:00:00.000000000 -0500
++++ tncfhh-0.8.3-current/shared/cmake_modules/FindDL.cmake	2013-09-12 12:00:32.440166255 -0400
+@@ -0,0 +1,26 @@
++# Find the DL includes and library
++#
++# This module defines
++#  DL_INCLUDE_DIR, where to find dlfcn.h, etc.
++#  DL_LIBRARY, where to find the DL library.
++#  DL_FOUND, If false, do not try to use DL.
++ 
++FIND_PATH(DL_INCLUDE_DIR dlfcn.h)
++
++FIND_LIBRARY(DL_LIBRARY dl) 
++
++IF (DL_INCLUDE_DIR AND DL_LIBRARY)
++   SET(DL_FOUND TRUE)
++ELSE(DL_INCLUDE_DIR AND DL_LIBRARY)
++   SET(DL_FOUND FALSE)
++ENDIF (DL_INCLUDE_DIR AND DL_LIBRARY)
++
++IF (DL_FOUND)
++   IF (NOT DL_FIND_QUIETLY)
++      MESSAGE(STATUS "Found DL: ${DL_LIBRARY}")
++   ENDIF (NOT DL_FIND_QUIETLY)
++ELSE (DL_FOUND)
++   IF (DL_FIND_REQUIRED)
++      MESSAGE(FATAL_ERROR "Could not find DL")
++   ENDIF (DL_FIND_REQUIRED)
++ENDIF (DL_FOUND)
+diff -urNp tncfhh-0.8.3-patched/tncs/CMakeLists.txt tncfhh-0.8.3-current/tncs/CMakeLists.txt
+--- tncfhh-0.8.3-patched/tncs/CMakeLists.txt	2013-09-12 12:03:48.245179130 -0400
++++ tncfhh-0.8.3-current/tncs/CMakeLists.txt	2013-09-12 12:00:32.440166255 -0400
+@@ -23,8 +23,8 @@ include_directories(${CMAKE_CURRENT_SOUR
+ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../tncxacml/src/)
+ 
+ # find additionally required libraries 
+-find_package(LTDL REQUIRED)
+-include_directories(${LTDL_INCLUDE_DIR})
++find_package(DL REQUIRED)
++include_directories(${DL_INCLUDE_DIR})
+ 
+ find_package(XercesC 2.8 REQUIRED)
+ include_directories(${XercesC_INCLUDE_DIR})
+@@ -59,7 +59,7 @@ set(src ${src} src/tncs/iel/tnc1/TNC1Pro
+ add_library(${PROJECT_NAME} SHARED ${src})
+ 
+ # add libraries
+-target_link_libraries(${PROJECT_NAME} ${LTDL_LIBRARY} ${XercesC_LIBRARY} ${Log4cxx_LIBRARY} tncutil tncxacml)
++target_link_libraries(${PROJECT_NAME} ${DL_LIBRARY} ${XercesC_LIBRARY} ${Log4cxx_LIBRARY} tncutil tncxacml)
+ 
+ # set version
+ SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${TNCFHH_VERSION_MAJOR}.${TNCFHH_VERSION_MINOR}.${TNCFHH_VERSION_PATCH}  SOVERSION 0)
+diff -urNp tncfhh-0.8.3-patched/tncs/src/tncs/iel/IMVProperties.cpp tncfhh-0.8.3-current/tncs/src/tncs/iel/IMVProperties.cpp
+--- tncfhh-0.8.3-patched/tncs/src/tncs/iel/IMVProperties.cpp	2013-09-12 12:03:48.244179130 -0400
++++ tncfhh-0.8.3-current/tncs/src/tncs/iel/IMVProperties.cpp	2013-09-12 12:00:32.441166255 -0400
+@@ -51,17 +51,13 @@ IMVProperties::IMVProperties(TNC_IMVID i
+ {
+ 	LOG4CXX_DEBUG(logger, "Create IMVProperties " << id << ":\"" << name << "\" file:\"" << file + "\"");
+ 
+-	// initialize libtool
+-	int libtoolInit = lt_dlinit();
+-	// check for errors
+-	if(libtoolInit)
+-		throw std::runtime_error(std::string("Error while initializing libtool. ") + lt_dlerror());
+-
+ 	// open libIMV.so
+-	this->handle = lt_dlopen(file.c_str());
++	this->handle = dlopen(file.c_str(), RTLD_LAZY | RTLD_GLOBAL);
++
+ 	// check for errors
+-	if(!this->handle)
+-		throw std::runtime_error(std::string("Error while loading ") + file + ". " + lt_dlerror());
++	if(!this->handle) {
++		throw std::runtime_error(std::string("Error while loading ") + file + ". " + dlerror());
++	}
+ 
+ 
+ 	/* retrieve function pointers */
+@@ -404,11 +400,11 @@ void IMVProperties::reportMessageTypes(T
+  *        * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *        *
+  *                                                                           *
+  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+-lt_ptr IMVProperties::getSymbol(lt_dlhandle handle, const char *name) throw (std::runtime_error)
++void *IMVProperties::getSymbol(void *handle, const char *name) throw (std::runtime_error)
+ {
+-	lt_ptr ret = lt_dlsym(handle, name);
++	void *ret = dlsym(handle, name);
+ 	if(ret == NULL){
+-		throw std::runtime_error(std::string("Failed to resolve symbol ") + name + ":" + lt_dlerror());
++		throw std::runtime_error(std::string("Failed to resolve symbol ") + name + ":" + dlerror());
+ 	}
+ 	return ret;
+ }
+@@ -516,10 +512,11 @@ void IMVProperties::handleFatalError()
+ 
+     LOG4CXX_INFO(logger, "Try to unload IMV " << this->name);
+     // shutdown libIMV.so
+-    int libtoolClose = lt_dlclose(this->handle);
++    int libtoolClose = dlclose(this->handle);
+ 
+-    if(libtoolClose)
+-        LOG4CXX_ERROR(logger, "Error while unloading module. " << lt_dlerror());
++    if(libtoolClose) {
++        LOG4CXX_ERROR(logger, "Error while unloading module. " << dlerror());
++    }
+ 
+ //    // shutdown libtool
+ //    int libtoolExit = lt_dlexit();
+diff -urNp tncfhh-0.8.3-patched/tncs/src/tncs/iel/IMVProperties.h tncfhh-0.8.3-current/tncs/src/tncs/iel/IMVProperties.h
+--- tncfhh-0.8.3-patched/tncs/src/tncs/iel/IMVProperties.h	2013-09-12 12:03:48.243179130 -0400
++++ tncfhh-0.8.3-current/tncs/src/tncs/iel/IMVProperties.h	2013-09-12 12:00:32.441166255 -0400
+@@ -142,7 +142,7 @@
+ #define TNCS_IMVPROPERTIES_H_
+ 
+ #include <tcg/tnc/tncifimv.h>
+-#include <ltdl.h>
++#include <dlfcn.h>
+ #include <string>
+ #include <list>
+ #include <stdexcept>
+@@ -259,7 +259,7 @@ private:
+ 	/**
+ 	 * Handle to libIMV.so
+ 	 */
+-	lt_dlhandle handle;
++	void *handle;
+ 
+ 	/**
+ 	 * Wrapper function for lt_dlsym
+@@ -269,7 +269,7 @@ private:
+ 	 *
+ 	 * @return A pointer to the desired function.
+ 	 */
+-	lt_ptr getSymbol(lt_dlhandle handle, const char *name)
++	void *getSymbol(void *handle, const char *name)
+ 			throw (std::runtime_error);
+ 
+ 	/**
diff --git a/tncfhh.spec b/tncfhh.spec
index f469f9b..bb78707 100644
--- a/tncfhh.spec
+++ b/tncfhh.spec
@@ -4,7 +4,7 @@ Summary: An open source implementation of the Trusted Network Connect (TNC) fram
 Name: tncfhh
 Version: 0.8.3
 
-Release: 12%{?dist}
+Release: 13%{?dist}
 License: GPLv2
 Url: http://trust.inform.fh-hannover.de/joomla/index.php/projects/tncfhh
 Source0: http://trust.inform.fh-hannover.de/download/tncfhh/tncfhh-%{version}.tar.gz
@@ -19,9 +19,9 @@ Patch2: tncfhh-0.8.3-issues-2.patch
 Patch3: tncutil-build-issue.patch
 Patch4: tnc-platidimv-issue.patch
 Patch5: tnc-hostscannerimv-issue.patch
-Patch6: imcv-build-issue.patch
-Patch7: tncfhh-0.8.3-issues-3.patch
-Patch8: tncfhh-985785.patch
+Patch6: tncfhh-0.8.3-issues-3.patch
+Patch7: tncfhh-985785.patch
+Patch8: tncfhh-dlopen-support.patch
 
 %description
 The TNC at FHH project is an open source implementation of the Trusted Network
@@ -173,6 +173,13 @@ rm -rf $RPM_BUILD_ROOT
 %{_libdir}/libtncutil.so.?.?.?
 
 %changelog
+* Thu Sep 12 2013 Avesh Agarwal <avagarwa at redhat.com> - 0.8.3-13
+- Implemented support for dlopen
+- Removed libtool support
+- Fixed imv and imc build issues arising from a
+  previous upstream patch
+- Fixed a few coverity scan error issues
+
 * Tue Jul 30 2013 Avesh Agarwal <avagarwa at redhat.com> - 0.8.3-12
 - Fixes for rhbz #985785 to fix crash issue in Filecert manager
   in platidimv.


More information about the scm-commits mailing list