From 0427d99226b9d4a76232a05bb4874584daa50933 Mon Sep 17 00:00:00 2001
From: Sebastião Guerra <sebastiao.luiz.guerra@gmail.com>
Date: Tue, 22 Sep 2026 20:54:06 -0300
Subject: Make the SLAPI ACL updater optional
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Sebastião Guerra <sebastiao.luiz.guerra@gmail.com>
---
 CMakeLists.txt                        |  9 ++++++---
 ConfigureChecks.cmake                 | 34 +++++++++++++++++-----------------
 confskel/openldap/ldif/CMakeLists.txt |  8 ++++++++
 3 files changed, 31 insertions(+), 20 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 50d0917..6542e67 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -43,9 +43,10 @@ tde_setup_paths( )
 
 ##### optional stuff
 
-option( WITH_ALL_OPTIONS    "Enable all optional support" OFF )
-option( WITH_GCC_VISIBILITY "Enable fvisibility and fvisibility-inlines-hidden" ${WITH_ALL_OPTIONS} )
+option( WITH_ALL_OPTIONS    "Enable all optional support" ON )
+option( WITH_SLAPI          "Build the OpenLDAP SLAPI ACL updater plugin" ${WITH_ALL_OPTIONS} )
 
+option( WITH_GCC_VISIBILITY "Enable fvisibility and fvisibility-inlines-hidden" ${WITH_ALL_OPTIONS} )
 
 ##### user requested modules
 
@@ -82,7 +83,9 @@ set( CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined"
 ##### directories
 
 add_subdirectory( src          )
-add_subdirectory( acl-updater  )
+if( WITH_SLAPI )
+  add_subdirectory( acl-updater )
+endif( )
 add_subdirectory( cert-updater )
 add_subdirectory( confskel     )
 add_subdirectory( pics         )
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 670f59a..4c51e69 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -27,7 +27,6 @@ endif( WITH_GCC_VISIBILITY )
 
 ##### check for headers
 
-check_include_file( "slapi-plugin.h" HAVE_SLAPI_PLUGIN_H )
 check_include_file( "sys/types.h" HAVE_SYS_TYPES_H )
 check_include_file( "stdint.h" HAVE_STDINT_H )
 
@@ -44,25 +43,26 @@ endif( HAVE_LIBLDAP )
 
 ##### check for openldap-server
 
-if( NOT DEFINED SLAPI_LIBRARIES )
+if( WITH_SLAPI )
+  check_include_file( "slapi-plugin.h" HAVE_SLAPI_PLUGIN_H )
   message( STATUS "Looking for slapi library" )
   find_library( HAVE_SLAPI slapi )
   if( HAVE_SLAPI )
-     set( SLAPI_LIBRARIES slapi )
-    else()
-     get_filename_component( LDAP_LIBDIR ${HAVE_LIBLDAP} PATH CACHE )
-     file( GLOB LIBSLAPI_FILES
-           ${LDAP_LIBDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}slapi-[0-9]*${CMAKE_SHARED_LIBRARY_SUFFIX}
-           ${LDAP_LIBDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}slapi-[0-9]*${CMAKE_SHARED_LIBRARY_SUFFIX}.[0-9]*
-           /usr/lib/${CMAKE_SHARED_LIBRARY_PREFIX}slapi-[0-9]*${CMAKE_SHARED_LIBRARY_SUFFIX}
-           /usr/lib/${CMAKE_SHARED_LIBRARY_PREFIX}slapi-[0-9]*${CMAKE_SHARED_LIBRARY_SUFFIX}.[0-9]*
-     )
-     if( LIBSLAPI_FILES )
-       list( GET LIBSLAPI_FILES 0 SLAPI_LIBRARIES )
-      else( )
-       tde_message_fatal( "The slapi library ( openldap-server ) is required, but was not found on your system" )
-     endif( )
-  endif( HAVE_SLAPI )
+    set( SLAPI_LIBRARIES slapi )
+  else()
+    get_filename_component( LDAP_LIBDIR ${HAVE_LIBLDAP} PATH CACHE )
+    file( GLOB LIBSLAPI_FILES
+      ${LDAP_LIBDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}slapi-[0-9]*${CMAKE_SHARED_LIBRARY_SUFFIX}
+      ${LDAP_LIBDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}slapi-[0-9]*${CMAKE_SHARED_LIBRARY_SUFFIX}.[0-9]*
+      /usr/lib/${CMAKE_SHARED_LIBRARY_PREFIX}slapi-[0-9]*${CMAKE_SHARED_LIBRARY_SUFFIX}
+      /usr/lib/${CMAKE_SHARED_LIBRARY_PREFIX}slapi-[0-9]*${CMAKE_SHARED_LIBRARY_SUFFIX}.[0-9]*
+    )
+    if( LIBSLAPI_FILES )
+      list( GET LIBSLAPI_FILES 0 SLAPI_LIBRARIES )
+    else( )
+      tde_message_fatal( "The slapi library ( openldap-server ) is required, but was not found on your system" )
+    endif( )
+  endif( )
   message( STATUS "Looking for slapi library - found ${SLAPI_LIBRARIES}" )
 endif( )
 
diff --git a/confskel/openldap/ldif/CMakeLists.txt b/confskel/openldap/ldif/CMakeLists.txt
index c7d84fa..96d839a 100644
--- a/confskel/openldap/ldif/CMakeLists.txt
+++ b/confskel/openldap/ldif/CMakeLists.txt
@@ -1,5 +1,13 @@
 file( GLOB _ldifs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.ldif )
 
+if( NOT WITH_SLAPI )
+  list( REMOVE_ITEM _ldifs olcDatabase.ldif )
+  file( READ "${CMAKE_CURRENT_SOURCE_DIR}/olcDatabase.ldif" _olc_database )
+  string( REGEX REPLACE "^[ \t]*olcPlugin:.*\\n" "" _olc_database "${_olc_database}" )
+  file( WRITE "${CMAKE_CURRENT_BINARY_DIR}/olcDatabase.ldif" "${_olc_database}" )
+  list( APPEND _ldifs "${CMAKE_CURRENT_BINARY_DIR}/olcDatabase.ldif" )
+endif( )
+
 install(
     FILES ${_ldifs}
     DESTINATION ${DATA_INSTALL_DIR}/${PROJECT_NAME}/skel/openldap/ldif
-- 
cgit v1.2.3

