]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw-ldap: conditional build 8168/head
authorMatt Benjamin <mbenjamin@redhat.com>
Wed, 16 Mar 2016 17:56:36 +0000 (13:56 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Wed, 16 Mar 2016 20:31:20 +0000 (16:31 -0400)
Permit building without LDAP support--support is enabled by default.
Tested with CMake and autotools standalone builds.

Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
cmake/modules/FindOpenLdap.cmake
configure.ac
src/CMakeLists.txt
src/rgw/Makefile.am
src/rgw/rgw_ldap.h

index 42b3edd01d612d8fa124467c0045f0a147bd608d..20bf8fa118758c0c392150da523650821822e28b 100644 (file)
@@ -31,6 +31,7 @@ else (OPENLDAP_FOUND)
   endif (NOT OPENLDAP_INCLUDE_DIR)
 endif (OPENLDAP_FOUND)
 
+add_definitions(-DHAVE_OPENLDAP)
 set(OPENLDAP_LIBS ${LIBLDAP} ${LIBLBER})
 
 mark_as_advanced(
index b95b8e9708a3dbd5492c171656e2c832a37f325f..758789f65f313f93b651e1d335486a97b1176388 100644 (file)
@@ -1279,6 +1279,19 @@ AS_IF([test "x$with_eventfd" != xno],
                      [AC_DEFINE(HAVE_EVENTFD, 1, [Have eventfd extension.])])])
 AM_CONDITIONAL(WITH_EVENTFD, [ test "$with_eventfd" = "yes" ])
 
+# disable OpenLDAP support
+AC_ARG_WITH([openldap],
+            [AS_HELP_STRING([--without-openldap], [Disable OpenLDAP support (RGW)])])
+if test "x$with_openldap" != "xno"; then
+   AC_CHECK_HEADER([ldap.h], [],
+      AC_MSG_ERROR([ldap.h not found (openldap-dev, openldap-devel)]))
+    AC_CHECK_LIB([ldap], [ldap_initialize], [true],
+      AC_MSG_FAILURE([libldap not found]))
+   AC_DEFINE([HAVE_OPENLDAP], [1], [Defined if OpenLDAP enabled])
+   have_openldap="yes"
+fi
+AM_CONDITIONAL(WITH_OPENLDAP, [ test "$have_openldap" = "yes" ])
+
 # Checks for typedefs, structures, and compiler characteristics.
 #AC_HEADER_STDBOOL
 #AC_C_CONST
index 06cca427c9838c3ff74b787e2e67e23ef3216e1a..46f5bd14589150a0095098cdd1a5d07d3886800e 100644 (file)
@@ -1124,6 +1124,11 @@ if(${WITH_KVS})
 endif(${WITH_KVS})
 
 if(${WITH_RADOSGW})
+
+  if(${HAVE_OPENLDAP})
+    set(rgw_ldap_srcs rgw/rgw_ldap.cc)
+  endif(${HAVE_OPENLDAP})
+
   set(rgw_a_srcs
     rgw/rgw_acl.cc
     rgw/rgw_acl_s3.cc
@@ -1145,7 +1150,7 @@ if(${WITH_RADOSGW})
     rgw/rgw_http_client.cc
     rgw/rgw_json_enc.cc
     rgw/rgw_keystone.cc
-    rgw/rgw_ldap.cc
+    ${rgw_ldap_srcs}
     rgw/rgw_loadgen.cc
     rgw/rgw_log.cc
     rgw/rgw_metadata.cc
index b65fe1974ddd0a2b4fbc49c18d26535c4d1e71d0..c96e8c5d164115d363b206290bd9d1fe4ebcfe28 100644 (file)
@@ -44,7 +44,6 @@ librgw_la_SOURCES = \
        rgw/rgw_http_client.cc \
        rgw/rgw_json_enc.cc \
        rgw/rgw_keystone.cc \
-       rgw/rgw_ldap.cc \
        rgw/rgw_loadgen.cc \
        rgw/rgw_log.cc \
        rgw/rgw_metadata.cc \
@@ -92,6 +91,10 @@ librgw_la_SOURCES = \
        rgw/rgw_xml_enc.cc \
        rgw/rgw_website.cc
 
+if WITH_OPENLDAP
+librgw_la_SOURCES += rgw/rgw_ldap.cc
+endif
+
 librgw_la_CXXFLAGS = -Woverloaded-virtual -fPIC -I$(srcdir)/xxHash \
        ${AM_CXXFLAGS}
 # noinst_LTLIBRARIES += librgw.la
index 6cc40f6ab3d22788a5d62d25ea19775864bbaa32..62c901a9bf5fe8740e688df36c53170ecf3cf276 100644 (file)
@@ -15,6 +15,8 @@
 
 namespace rgw {
 
+#if defined(HAVE_OPENLDAP)
+
   class LDAPHelper
   {
     std::string uri;
@@ -80,7 +82,35 @@ namespace rgw {
        ldap_unbind(ldap);
     }
 
-  };
+  }; /* LDAPHelper */
+
+#else
+
+  class LDAPHelper
+  {
+  public:
+    LDAPHelper(std::string _uri, std::string _binddn, std::string _searchdn,
+             std::string _dnattr)
+      {}
+
+    int init() {
+      return -ENOTSUP;
+    }
+
+    int bind() {
+      return -ENOTSUP;
+    }
+
+    int auth(const std::string uid, const std::string pwd) {
+      return -EACCES;
+    }
+
+    ~LDAPHelper() {}
+
+  }; /* LDAPHelper */
+
+
+#endif /* HAVE_OPENLDAP */
 
 } /* namespace rgw */