From f1291ade13dd694535e6bb16e39f97b27911b166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= Date: Tue, 23 Jan 2024 10:07:49 +0100 Subject: [PATCH] Fix broken build with NSS crypto back end OpenSCAP had 2 alternatives of crypto libraries, GCrypt and NSS. GCrypt is the default backend. We discovered that building with the NSS backend is broken at this moment. This patch fixes the broken build. Use `cmake -DWITH_CRYPTO=nss ..` to configure with NSS. --- CMakeLists.txt | 12 ++++++------ cmake/FindNSS.cmake | 2 -- config.h.in | 4 ++-- tests/API/crypt/CMakeLists.txt | 4 ++-- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d43993bce5..17413b8681 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -176,13 +176,13 @@ check_library_exists(pthread pthread_setname_np "" HAVE_PTHREAD_SETNAME_NP) check_library_exists(pthread pthread_getname_np "" HAVE_PTHREAD_GETNAME_NP) # WITH_CRYPTO -set(WITH_CRYPTO "gcrypt" CACHE STRING "gcrypt|nss3") -if(NOT (${WITH_CRYPTO} EQUAL "nss3")) - # gcrypt - find_package(GCrypt) -else() - # nss3 +set(WITH_CRYPTO "gcrypt" CACHE STRING "gcrypt|nss") +if(${WITH_CRYPTO} STREQUAL "nss") + message("-- Using NSS") find_package(NSS) +else() + message("-- Using GCrypt") + find_package(GCrypt) endif() if(GCRYPT_FOUND OR NSS_FOUND) set(CRYPTO_FOUND TRUE) diff --git a/cmake/FindNSS.cmake b/cmake/FindNSS.cmake index 6f1231578d..f5461a49c7 100644 --- a/cmake/FindNSS.cmake +++ b/cmake/FindNSS.cmake @@ -11,8 +11,6 @@ # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. -include(FindLibraryWithDebug) - if (NSS_LIBRARIES) set(NSS_FIND_QUIETLY TRUE) endif () diff --git a/config.h.in b/config.h.in index 2bba00719c..ad287584f8 100644 --- a/config.h.in +++ b/config.h.in @@ -19,8 +19,8 @@ #cmakedefine HAVE_GCRYCTL_SET_ENFORCED_FIPS_FLAG #endif -#cmakedefine NSS3_FOUND -#if defined(NSS3_FOUND) +#cmakedefine NSS_FOUND +#if defined(NSS_FOUND) #define HAVE_NSS3 #endif diff --git a/tests/API/crypt/CMakeLists.txt b/tests/API/crypt/CMakeLists.txt index 04f3b3834d..9331b9ab05 100644 --- a/tests/API/crypt/CMakeLists.txt +++ b/tests/API/crypt/CMakeLists.txt @@ -3,8 +3,8 @@ set(CRAPI_HEADERS "${CMAKE_SOURCE_DIR}/src/OVAL/probes/crapi/") file(GLOB_RECURSE CRAPI_SOURCES "${CMAKE_SOURCE_DIR}/src/OVAL/probes/crapi/*.c") add_oscap_test_executable(test_crapi_digest "test_crapi_digest.c" ${CRAPI_SOURCES}) add_oscap_test_executable(test_crapi_mdigest "test_crapi_mdigest.c" ${CRAPI_SOURCES}) -target_include_directories(test_crapi_digest PUBLIC ${PROBE_HEADERS} ${CRAPI_HEADERS}) -target_include_directories(test_crapi_mdigest PUBLIC ${PROBE_HEADERS} ${CRAPI_HEADERS}) +target_include_directories(test_crapi_digest PUBLIC ${PROBE_HEADERS} ${CRAPI_HEADERS} ${NSS_INCLUDE_DIRS}) +target_include_directories(test_crapi_mdigest PUBLIC ${PROBE_HEADERS} ${CRAPI_HEADERS} ${NSS_INCLUDE_DIRS}) target_link_libraries(test_crapi_digest openscap) target_link_libraries(test_crapi_mdigest openscap) add_oscap_test("test_api_crypt.sh")