Skip to content

Commit

Permalink
fixed build issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yashwant Sahu committed Feb 23, 2017
1 parent 3a45100 commit eadd95d
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 40 deletions.
4 changes: 3 additions & 1 deletion libmysql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ INCLUDE(CheckIncludeFiles)
CHECK_INCLUDE_FILES(sasl/sasl.h HAVE_SASL_H)
CHECK_INCLUDE_FILES(lber.h HAVE_LBER_H)
IF (HAVE_SASL_H AND HAVE_LBER_H)
ADD_DEFINITIONS(-D AUTHENTICATION_LDAP_SASL)
MESSAGE(STATUS "Adding LDAP authentication SASL client.")
ADD_DEFINITIONS(-DAUTHENTICATION_LDAP_SASL_CLIENT)
ADD_SUBDIRECTORY(authentication_ldap)
LIST(APPEND LIBS authentication_ldap_sasl_client)
ENDIF()
Expand Down Expand Up @@ -365,3 +366,4 @@ IF(DISABLE_SHARED)
ELSE()
TARGET_LINK_LIBRARIES(libmysql_api_test libmysql)
ENDIF()

18 changes: 17 additions & 1 deletion libmysql/authentication_ldap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,25 @@ ELSE()
CROAK_AND_RETURN("Required LBER library is missing.")
ENDIF()

FIND_PATH(
CYRUS_SASL_INCLUDE_DIR NAMES sasl/sasl.h
PATHS /include /usr/include /usr/local/include /usr/share/include /opt/include
DOC "Searching for sasl/sasl.h")

CHECK_SYMBOL_EXISTS(
sasl_client_done
${CYRUS_SASL_INCLUDE_DIR}/sasl/sasl.h
HAVE_SASL_CLIENT_DONE)

IF (HAVE_SASL_CLIENT_DONE)
SET(HAVE_SASL_CLIENT_DONE 1)
ELSE ()
SET(HAVE_SASL_CLIENT_DONE 0)
ENDIF ()

# LDAP authentication SASL client will not build on windows, as windows don't have cyrus sasl.
# IF someone like can build the cyrus sasl library on windows and build LDAP authentication sasl client as well.
SET(HEADERS_CLIENT auth_ldap_sasl_client.h log.h)
SET(PLUGIN_CLIENT_SOURCES auth_ldap_sasl_client.cc log.cc)
ADD_CONVENIENCE_LIBRARY(authentication_ldap_sasl_client ${PLUGIN_CLIENT_SOURCES} ${HEADERS_CLIENT})
TARGET_LINK_LIBRARIES(authentication_ldap_sasl_client sasl2)
TARGET_LINK_LIBRARIES(authentication_ldap_sasl_client sasl2)
34 changes: 5 additions & 29 deletions libmysql/authentication_ldap/auth_ldap_sasl_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
#include <mysql/client_plugin.h>
#include <mysql.h>

#if SASL_VERSION_FULL<0x020118
#define sasl_client_done()
#endif

MYSQL_PLUGIN g_ldap_plugin_info = NULL;
Logger<Log_writer_error> g_logger("");

Expand Down Expand Up @@ -109,32 +105,12 @@ int Sasl_client::de_initilize() {
}

int Sasl_client::sasl_client_done_wrapper() {
const char *impl_version = NULL;
uint32_t version = 0;
uint16_t major = 0;
uint8_t minor = 0;
uint8_t step = 0;
int rc_sasl = SASL_FAIL;
sasl_version(&impl_version, (int*)&version);
major = version >> 24;
minor = (version << 8) >> 24;
step = (version << 24) >> 24;

typedef int (*__sasl_client_done)();
static __sasl_client_done _sasl_client_done = NULL;
typedef void (*__sasl_done)();
static __sasl_done _sasl_done = NULL;

if ((major > 2) || (major == 2 && minor > 1) ||(major == 2 && minor == 1 && step >= 24)) {
_sasl_client_done = &sasl_client_done;
rc_sasl = _sasl_client_done();
log_dbg("sasl_client_done()");
}
else {
_sasl_done = &sasl_done;
_sasl_done();
log_dbg("sasl_done()");
}
#if HAVE_SASL_CLIENT_DONE == 1
rc_sasl = sasl_client_done();
#else
sasl_done();
#endif
return rc_sasl;
}

Expand Down
12 changes: 6 additions & 6 deletions libmysql/authentication_ldap/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <my_dbug.h>

extern MYSQL_PLUGIN g_ldap_plugin_info;
//#define LDAP_SERVER_PLUGIN

struct log_type {
typedef enum {
Expand Down Expand Up @@ -96,7 +97,7 @@ template<class LOGGER_TYPE>
template<log_type::type type>
void Logger<LOGGER_TYPE>::log(std::string msg) {
std::stringstream header;
#ifdef MYSQL_SERVER
#ifdef LDAP_SERVER_PLUGIN
int plugin_error_level = MY_INFORMATION_LEVEL;
#endif
switch (type) {
Expand All @@ -107,7 +108,7 @@ void Logger<LOGGER_TYPE>::log(std::string msg) {
header << "[DBG] ";
break;
case log_type::LOG_INFO:
#ifdef MYSQL_SERVER
#ifdef LDAP_SERVER_PLUGIN
plugin_error_level = MY_INFORMATION_LEVEL;
#endif
if (LOG_LEVEL_ERROR_WARNING_INFO > m_log_level) {
Expand All @@ -116,7 +117,7 @@ void Logger<LOGGER_TYPE>::log(std::string msg) {
header << "[Note] ";
break;
case log_type::LOG_WARNING:
#ifdef MYSQL_SERVER
#ifdef LDAP_SERVER_PLUGIN
plugin_error_level = MY_WARNING_LEVEL;
#endif
if (LOG_LEVEL_ERROR_WARNING > m_log_level) {
Expand All @@ -125,7 +126,7 @@ void Logger<LOGGER_TYPE>::log(std::string msg) {
header << "[Warning] ";
break;
case log_type::LOG_ERROR:
#ifdef MYSQL_SERVER
#ifdef LDAP_SERVER_PLUGIN
plugin_error_level = MY_ERROR_LEVEL;
#endif
if (LOG_LEVEL_NONE >= m_log_level) {
Expand All @@ -145,9 +146,8 @@ void Logger<LOGGER_TYPE>::log(std::string msg) {
}

WRITE_SERVER_LOG:
#ifdef MYSQL_SERVER
#ifdef LDAP_SERVER_PLUGIN
if (g_ldap_plugin_info && (type != log_type::LOG_DBG)) {
DBUG_PRINT("");
my_plugin_log_message(&g_ldap_plugin_info,
(plugin_log_level) plugin_error_level, msg.c_str());
}
Expand Down
4 changes: 2 additions & 2 deletions sql-common/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -3179,7 +3179,7 @@ static auth_plugin_t sha256_password_client_plugin=
extern auth_plugin_t win_auth_client_plugin;
#endif

#ifdef AUTHENTICATION_LDAP_SASL
#ifdef AUTHENTICATION_LDAP_SASL_CLIENT
extern auth_plugin_t ldap_auth_client_plugin;
#endif
/*
Expand All @@ -3203,7 +3203,7 @@ struct st_mysql_client_plugin *mysql_client_builtins[]=
#ifdef AUTHENTICATION_WIN
(struct st_mysql_client_plugin *)&win_auth_client_plugin,
#endif
#ifdef AUTHENTICATION_LDAP_SASL
#ifdef AUTHENTICATION_LDAP_SASL_CLIENT
(struct st_mysql_client_plugin *)&ldap_auth_client_plugin,
#endif
#if defined(CLIENT_PROTOCOL_TRACING) \
Expand Down
7 changes: 6 additions & 1 deletion sql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,12 @@ ENDIF()
#
# authentication LDAP SASL client
#
IF(NOT WIN32)
INCLUDE(CheckIncludeFiles)
CHECK_INCLUDE_FILES(sasl/sasl.h HAVE_SASL_H)
CHECK_INCLUDE_FILES(lber.h HAVE_LBER_H)
IF (HAVE_SASL_H AND HAVE_LBER_H)
MESSAGE(STATUS "Adding LDAP authentication SASL client. link.")
ADD_DEFINITIONS(-DAUTHENTICATION_LDAP_SASL_CLIENT)
TARGET_LINK_LIBRARIES(sql authentication_ldap_sasl_client)
ENDIF()

Expand Down

0 comments on commit eadd95d

Please sign in to comment.