Skip to content

Commit bd9c260

Browse files
Tor Didriksendahlerlend
authored andcommitted
WL#13758 MySQL 5.7: Support linking with 3rd party OpenLDAP and Cyrus SASL
We have recently upgraded to build with OpenSSL 1.1.1 on several platforms. This means that the "system" versions of libraries like LDAP and SASL can no longer be used (they link with other versions of SSL) This patch is for 5.7: add cmake options WITH_LDAP and WITH_SASL, assuming these have been built with the same version of SSL libraries used for the server. Look up static (.a) libraries for LDAP, LBER, and SASL, and link these into appropriate plugins. We also enable some tests which were previously skipped because of bad feature tests. Change-Id: If5deba8ae593b2c666ce12fab6ac7827e41b4f99
1 parent 6b188e1 commit bd9c260

File tree

15 files changed

+403
-135
lines changed

15 files changed

+403
-135
lines changed

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ IF(WITH_DEFAULT_FEATURE_SET)
229229
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/build_configurations/feature_set.cmake)
230230
ENDIF()
231231

232+
INCLUDE(CMakePushCheckState)
233+
232234
# Add macros
233235
INCLUDE(character_sets)
234236
INCLUDE(cpu_info)
@@ -237,6 +239,7 @@ INCLUDE(lz4)
237239
INCLUDE(libevent)
238240
INCLUDE(ssl)
239241
INCLUDE(sasl)
242+
INCLUDE(ldap)
240243
INCLUDE(rpc)
241244
INCLUDE(readline)
242245
INCLUDE(protobuf)
@@ -273,6 +276,9 @@ ENDIF()
273276
IF(NOT WITHOUT_SERVER)
274277
OPTION (WITH_UNIT_TESTS "Compile MySQL with unit tests" ON)
275278
ENDIF()
279+
OPTION(WITH_AUTHENTICATION_LDAP
280+
"Report error if the LDAP authentication plugin cannot be built." OFF)
281+
276282
OPTION(FORCE_UNSUPPORTED_COMPILER "Disable compiler version checks" OFF)
277283
MARK_AS_ADVANCED(WITHOUT_SERVER DISABLE_SHARED FORCE_UNSUPPORTED_COMPILER)
278284

@@ -579,6 +585,8 @@ MYSQL_CHECK_LIBEVENT()
579585
MYSQL_CHECK_LZ4()
580586
# Add SASL library
581587
MYSQL_CHECK_SASL()
588+
# Add LDAP library
589+
MYSQL_CHECK_LDAP()
582590
# Add protoc and libprotobuf
583591
IF(NOT WITHOUT_SERVER)
584592
MYSQL_CHECK_PROTOBUF()

cmake/ldap.cmake

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
2+
#
3+
# This program is free software; you can redistribute it and/or modify
4+
# it under the terms of the GNU General Public License, version 2.0,
5+
# as published by the Free Software Foundation.
6+
#
7+
# This program is also distributed with certain software (including
8+
# but not limited to OpenSSL) that is licensed under separate terms,
9+
# as designated in a particular file or component or in included license
10+
# documentation. The authors of MySQL hereby grant you an additional
11+
# permission to link the program and your derivative works with the
12+
# separately licensed software that they have included with MySQL.
13+
#
14+
# This program is distributed in the hope that it will be useful,
15+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
# GNU General Public License, version 2.0, for more details.
18+
#
19+
# You should have received a copy of the GNU General Public License
20+
# along with this program; if not, write to the Free Software
21+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22+
23+
# cmake -DWITH_LDAP=system|</path/to/custom/installation>
24+
# system is the default
25+
26+
INCLUDE (CheckIncludeFile)
27+
INCLUDE (CheckIncludeFiles)
28+
29+
SET(WITH_LDAP_DOC "\nsystem (use the OS ldap library)")
30+
STRING_APPEND(WITH_LDAP_DOC ", \n</path/to/custom/installation>")
31+
32+
STRING(REPLACE "\n" "| " WITH_LDAP_DOC_STRING "${WITH_LDAP_DOC}")
33+
34+
MACRO(FIND_SYSTEM_LDAP)
35+
IF(WIN32)
36+
SET(LDAP_SYSTEM_LIBRARY Wldap32 CACHE INTERNAL
37+
"LDAP library is /c/Windows/system32/Wldap32.dll"
38+
)
39+
ELSE()
40+
FIND_LIBRARY(LDAP_SYSTEM_LIBRARY
41+
NAMES ldap_r ldap
42+
)
43+
FIND_LIBRARY(LBER_SYSTEM_LIBRARY
44+
NAMES lber
45+
)
46+
ENDIF()
47+
IF(LDAP_SYSTEM_LIBRARY AND (WIN32 OR LBER_SYSTEM_LIBRARY))
48+
SET(LDAP_LIBRARY ${LDAP_SYSTEM_LIBRARY})
49+
SET(LBER_LIBRARY ${LBER_SYSTEM_LIBRARY})
50+
MESSAGE(STATUS "LBER_LIBRARY ${LBER_LIBRARY}")
51+
MESSAGE(STATUS "LDAP_LIBRARY ${LDAP_LIBRARY}")
52+
ENDIF()
53+
54+
IF(WIN32)
55+
# LDAP system header is Winldap.h and is in some Windows SDK
56+
ELSE()
57+
CMAKE_PUSH_CHECK_STATE()
58+
59+
# For Solaris 11.3 we need to explicitly search here:
60+
IF(SOLARIS)
61+
INCLUDE_DIRECTORIES(BEFORE SYSTEM /usr/include/openldap)
62+
SET(CMAKE_REQUIRED_INCLUDES "/usr/include/openldap")
63+
ENDIF()
64+
65+
CHECK_INCLUDE_FILE(lber.h HAVE_LBER_H)
66+
CHECK_INCLUDE_FILE(ldap.h HAVE_LDAP_H)
67+
CMAKE_POP_CHECK_STATE()
68+
ENDIF()
69+
70+
ENDMACRO()
71+
72+
MACRO(FIND_CUSTOM_LDAP)
73+
FIND_PATH(LDAP_INCLUDE_DIR
74+
NAMES ldap.h
75+
PATHS ${WITH_LDAP_PATH}/include
76+
NO_DEFAULT_PATH
77+
NO_CMAKE_ENVIRONMENT_PATH
78+
NO_SYSTEM_ENVIRONMENT_PATH
79+
)
80+
81+
# On mac this list is <.dylib;.so;.a>
82+
# We prefer static libraries, so we reverse it here.
83+
LIST(REVERSE CMAKE_FIND_LIBRARY_SUFFIXES)
84+
85+
FIND_LIBRARY(LDAP_CUSTOM_LIBRARY
86+
NAMES ldap_r ldap
87+
PATHS ${WITH_LDAP_PATH}/lib
88+
NO_DEFAULT_PATH
89+
NO_CMAKE_ENVIRONMENT_PATH
90+
NO_SYSTEM_ENVIRONMENT_PATH
91+
)
92+
FIND_LIBRARY(LBER_CUSTOM_LIBRARY
93+
NAMES lber
94+
PATHS ${WITH_LDAP_PATH}/lib
95+
NO_DEFAULT_PATH
96+
NO_CMAKE_ENVIRONMENT_PATH
97+
NO_SYSTEM_ENVIRONMENT_PATH
98+
)
99+
100+
LIST(REVERSE CMAKE_FIND_LIBRARY_SUFFIXES)
101+
102+
IF(LDAP_INCLUDE_DIR)
103+
INCLUDE_DIRECTORIES(BEFORE SYSTEM ${LDAP_INCLUDE_DIR})
104+
105+
CMAKE_PUSH_CHECK_STATE()
106+
SET(CMAKE_REQUIRED_INCLUDES ${LDAP_INCLUDE_DIR})
107+
CHECK_INCLUDE_FILE(lber.h HAVE_LBER_H)
108+
CHECK_INCLUDE_FILE(ldap.h HAVE_LDAP_H)
109+
CMAKE_POP_CHECK_STATE()
110+
ENDIF()
111+
112+
IF(LDAP_CUSTOM_LIBRARY AND LBER_CUSTOM_LIBRARY)
113+
SET(LDAP_LIBRARY ${LDAP_CUSTOM_LIBRARY})
114+
SET(LBER_LIBRARY ${LBER_CUSTOM_LIBRARY})
115+
GET_FILENAME_COMPONENT(LDAP_LIBRARY_EXT ${LDAP_LIBRARY} EXT)
116+
IF(LDAP_LIBRARY_EXT STREQUAL ".a")
117+
SET(STATIC_LDAP_LIBRARY 1)
118+
ENDIF()
119+
MESSAGE(STATUS "LDAP_LIBRARY ${LDAP_LIBRARY}")
120+
MESSAGE(STATUS "LBER_LIBRARY ${LBER_LIBRARY}")
121+
ENDIF()
122+
ENDMACRO()
123+
124+
MACRO(MYSQL_CHECK_LDAP)
125+
IF(NOT WITH_LDAP)
126+
SET(WITH_LDAP "system" CACHE STRING ${WITH_LDAP_DOC_STRING} FORCE)
127+
ENDIF()
128+
129+
# See if WITH_LDAP is of the form </path/to/custom/installation>
130+
FILE(GLOB WITH_LDAP_HEADER ${WITH_LDAP}/include/ldap.h)
131+
IF (WITH_LDAP_HEADER)
132+
FILE(TO_CMAKE_PATH "${WITH_LDAP}" WITH_LDAP)
133+
SET(WITH_LDAP_PATH ${WITH_LDAP})
134+
ENDIF()
135+
136+
IF(WITH_LDAP STREQUAL "system")
137+
FIND_SYSTEM_LDAP()
138+
ELSE()
139+
FIND_CUSTOM_LDAP()
140+
ENDIF()
141+
142+
IF(WIN32 AND WITH_LDAP STREQUAL "system")
143+
SET(LDAP_FOUND 1)
144+
ELSEIF(HAVE_LBER_H AND HAVE_LDAP_H AND LDAP_LIBRARY AND LBER_LIBRARY)
145+
SET(LDAP_FOUND 1)
146+
ELSE()
147+
SET(LDAP_FOUND 0)
148+
ENDIF()
149+
150+
ENDMACRO()

cmake/os/FreeBSD.cmake

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
# Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
32
#
43
# This program is free software; you can redistribute it and/or modify
54
# it under the terms of the GNU General Public License, version 2.0,
@@ -19,12 +18,19 @@
1918
#
2019
# You should have received a copy of the GNU General Public License
2120
# along with this program; if not, write to the Free Software
22-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2322

24-
# This file includes FreeBSD specific options and quirks, related to system checks
23+
# This file includes FreeBSD specific options and quirks,
24+
# related to system checks
2525

2626
INCLUDE(CheckCSourceRuns)
2727

28+
SET(FREEBSD 1)
29+
30+
# On FreeBSD some includes, e.g. sasl/sasl.h, is in /usr/local/include
31+
INCLUDE_DIRECTORIES(SYSTEM /usr/local/include)
32+
LIST(APPEND CMAKE_REQUIRED_INCLUDES "/usr/local/include")
33+
2834
# We require at least Clang 3.3.
2935
IF(NOT FORCE_UNSUPPORTED_COMPILER)
3036
IF(CMAKE_C_COMPILER_ID MATCHES "Clang")

cmake/os/WindowsCache.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License, version 2.0,
@@ -69,7 +69,6 @@ SET(HAVE_SYS_PARAM_H CACHE INTERNAL "")
6969
SET(HAVE_FNMATCH_H CACHE INTERNAL "")
7070
SET(HAVE_SYS_UN_H CACHE INTERNAL "")
7171
SET(HAVE_VIS_H CACHE INTERNAL "")
72-
SET(HAVE_SASL_SASL_H CACHE INTERNAL "")
7372

7473
# Libevent
7574
SET(HAVE_DEVPOLL CACHE INTERNAL "")

0 commit comments

Comments
 (0)