Skip to content

Commit

Permalink
rgw-ldap: conditional build
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mattbenjamin committed Mar 16, 2016
1 parent a028989 commit 1539d90
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 3 deletions.
1 change: 1 addition & 0 deletions cmake/modules/FindOpenLdap.cmake
Expand Up @@ -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(
Expand Down
13 changes: 13 additions & 0 deletions configure.ac
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion src/CMakeLists.txt
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/rgw/Makefile.am
Expand Up @@ -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 \
Expand Down Expand Up @@ -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
Expand Down
32 changes: 31 additions & 1 deletion src/rgw/rgw_ldap.h
Expand Up @@ -15,6 +15,8 @@

namespace rgw {

#if defined(HAVE_OPENLDAP)

class LDAPHelper
{
std::string uri;
Expand Down Expand Up @@ -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 */

Expand Down

0 comments on commit 1539d90

Please sign in to comment.