diff --git a/cmake/modules/FindOpenLdap.cmake b/cmake/modules/FindOpenLdap.cmake index 42b3edd01d612..20bf8fa118758 100644 --- a/cmake/modules/FindOpenLdap.cmake +++ b/cmake/modules/FindOpenLdap.cmake @@ -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( diff --git a/configure.ac b/configure.ac index b95b8e9708a3d..758789f65f313 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 06cca427c9838..46f5bd1458915 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 diff --git a/src/rgw/Makefile.am b/src/rgw/Makefile.am index b65fe1974ddd0..c96e8c5d16411 100644 --- a/src/rgw/Makefile.am +++ b/src/rgw/Makefile.am @@ -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 diff --git a/src/rgw/rgw_ldap.h b/src/rgw/rgw_ldap.h index 6cc40f6ab3d22..62c901a9bf5fe 100644 --- a/src/rgw/rgw_ldap.h +++ b/src/rgw/rgw_ldap.h @@ -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 */