From c9ba348e1a7fa99a0b41a0e53f251309f2768187 Mon Sep 17 00:00:00 2001 From: Giuseppe Foti Date: Mon, 31 Jul 2023 11:23:22 +0200 Subject: [PATCH] Fix: automagic dependency on netsnmp that is not required. (#1463) When building openvas-scanner Cmake searches for SNMP and links to it but the dependency is not defined as required: https://github.com/greenbone/openvas-scanner/blob/d1b7268a05eb81b5deab0febe7ac472a730815c0/nasl/CMakeLists.txt#L73-L80) In source-based distributions (like gentoo) this can create an issue on system update. Reading here you can have a more detailed description of the issue: https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Automagic_dependencies#Why_automagic_dependencies_are_wrong Please add a BUILD_WITH_NETSNMP variable in openvas-scanner/CMakeLists.txt and openvas-scanner/nasl/CMakeLists.txt as suggested here: https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Automagic_dependencies#CMake --- CMakeLists.txt | 4 ++++ nasl/CMakeLists.txt | 18 +++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1389e9b75..9bc95ff57 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,6 +145,10 @@ if (NOT OPENVAS_RUN_DIR) set (OPENVAS_RUN_DIR "/run/ospd") endif (NOT OPENVAS_RUN_DIR) +if (NOT BUILD_WITH_NETSNMP) + set (BUILD_WITH_NETSNMP TRUE) +endif (NOT BUILD_WITH_NETSNMP) + set (OPENVAS_DATA_DIR "${DATADIR}/openvas") set (OPENVAS_STATE_DIR "${LOCALSTATEDIR}/lib/openvas") diff --git a/nasl/CMakeLists.txt b/nasl/CMakeLists.txt index fa51196fe..975154ae9 100644 --- a/nasl/CMakeLists.txt +++ b/nasl/CMakeLists.txt @@ -70,14 +70,18 @@ if (NOT GPGME_FOUND) OUTPUT_STRIP_TRAILING_WHITESPACE) endif (NOT GPGME_FOUND) -message (STATUS "Looking for netsnmp...") -find_library (SNMP netsnmp) -message (STATUS "Looking for netsnmp... ${SNMP}") -if (SNMP) +if (BUILD_WITH_NETSNMP) + message (STATUS "Looking for netsnmp...") + find_library (NETSNMP netsnmp) + message (STATUS "Looking for netsnmp... ${NETSNMP}") +else (BUILD_WITH_NETSNMP) + message (STATUS "Netsnmp support disabled") +endif (BUILD_WITH_NETSNMP) +if (NETSNMP) execute_process (COMMAND net-snmp-config --libs OUTPUT_VARIABLE SNMP_LDFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE) -endif (SNMP) +endif (NETSNMP) message (STATUS "Looking for libgcrypt...") find_library (GCRYPT gcrypt) @@ -103,9 +107,9 @@ endif (NOT GCRYPT) ## Library -if (SNMP) +if (NETSNMP) add_definitions (-DHAVE_NETSNMP) -endif (SNMP) +endif (NETSNMP) # The "-fno-strict-aliasing" silences warnings caused by macros defined in byteorder.h.