Skip to content

Commit 9809143

Browse files
author
Mate Szalay-Beko
committed
ZOOKEEPER-2122: add SSL support for C-client
1 parent 874aaf1 commit 9809143

29 files changed

Lines changed: 1545 additions & 228 deletions

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,17 @@ zookeeper-client/zookeeper-client-c/install-sh
8989
zookeeper-client/zookeeper-client-c/ltmain.sh
9090
zookeeper-client/zookeeper-client-c/missing
9191
zookeeper-server/src/test/resources/
92+
zookeeper-client/zookeeper-client-c/.deps/
93+
zookeeper-client/zookeeper-client-c/.libs/
94+
zookeeper-client/zookeeper-client-c/Makefile
95+
zookeeper-client/zookeeper-client-c/cli_mt
96+
zookeeper-client/zookeeper-client-c/cli_st
97+
zookeeper-client/zookeeper-client-c/config.h
98+
zookeeper-client/zookeeper-client-c/config.status
99+
zookeeper-client/zookeeper-client-c/libtool
100+
zookeeper-client/zookeeper-client-c/load_gen
101+
zookeeper-client/zookeeper-client-c/stamp-h1
102+
zookeeper-client/zookeeper-client-c/build
92103

93104
# Python
94105
*.py[cod]

build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1778,7 +1778,7 @@ xmlns:cs="antlib:com.puppycrawl.tools.checkstyle.ant">
17781778
<exclude name="zookeeper-client/zookeeper-client-c/include/winstdint.h"/>
17791779
<exclude name="zookeeper-client/zookeeper-client-c/src/hashtable/"/>
17801780
<exclude name="zookeeper-client/zookeeper-client-c/test-driver"/>
1781-
<exclude name="zookeeper-client/zookeeper-client-c/tests/quorum.cfg"/>
1781+
<exclude name="zookeeper-client/zookeeper-client-c/tests/zoo.cfg"/>
17821782
<exclude name="zookeeper-contrib/zookeeper-contrib-loggraph/src/main/resources/webapp/org/apache/zookeeper/graph/resources/date.format.js"/>
17831783
<exclude name="zookeeper-contrib/zookeeper-contrib-loggraph/src/main/resources/webapp/org/apache/zookeeper/graph/resources/g.bar.js"/>
17841784
<exclude name="zookeeper-contrib/zookeeper-contrib-loggraph/src/main/resources/webapp/org/apache/zookeeper/graph/resources/g.dot.js"/>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@
808808
<exclude>src/hashtable/*</exclude>
809809
<exclude>include/winconfig.h</exclude>
810810
<exclude>tests/wrappers.opt</exclude>
811-
<exclude>tests/quorum.cfg</exclude>
811+
<exclude>tests/zoo.cfg</exclude>
812812
<exclude>tests/wrappers-mt.opt</exclude>
813813
<exclude>**/c-doc.Doxyfile</exclude>
814814
</excludes>

zookeeper-client/zookeeper-client-c/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,19 @@ target_link_libraries(zookeeper PUBLIC
182182
$<$<PLATFORM_ID:Linux>:rt> # clock_gettime
183183
$<$<PLATFORM_ID:Windows>:ws2_32>) # Winsock 2.0
184184

185+
option(WITH_OPENSSL "openssl directory" OFF)
186+
if(WITH_OPENSSL)
187+
target_compile_definitions(zookeeper PUBLIC HAVE_OPENSSL_H)
188+
include_directories(${WITH_OPENSSL}/include)
189+
link_directories(${WITH_OPENSSL}/lib)
190+
if(WIN32)
191+
target_link_libraries(zookeeper PUBLIC ssleay32 libeay32)
192+
else()
193+
target_link_libraries(zookeeper PUBLIC ssl crypto)
194+
endif()
195+
196+
endif()
197+
185198
if(WANT_SYNCAPI AND NOT WIN32)
186199
find_package(Threads REQUIRED)
187200
target_link_libraries(zookeeper PUBLIC Threads::Threads)
@@ -224,6 +237,7 @@ if(WANT_SYNCAPI)
224237
endif()
225238

226239
if(WANT_CPPUNIT)
240+
set (CMAKE_CXX_STANDARD 11)
227241
add_executable(zktest ${test_sources})
228242
target_include_directories(zktest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
229243

zookeeper-client/zookeeper-client-c/Makefile.am

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,28 @@
22
include $(top_srcdir)/aminclude.am
33

44
AUTOMAKE_OPTIONS = serial-tests
5+
56
if SOLARIS
67
SOLARIS_CPPFLAGS = -D_POSIX_PTHREAD_SEMANTICS
78
SOLARIS_LIB_LDFLAGS = -lnsl -lsocket
89
endif
9-
AM_CPPFLAGS = -I${srcdir}/include -I${srcdir}/tests -I${srcdir}/generated $(SOLARIS_CPPFLAGS)
10+
11+
if WANT_OPENSSL
12+
OPENSSL_CPPFLAGS = -DHAVE_OPENSSL_H -I$(OPENSSL_DIR)
13+
OPENSSL_LIB_LDFLAGS = -lssl -lcrypto
14+
endif
15+
16+
AM_CPPFLAGS = -I${srcdir}/include -I${srcdir}/tests -I${srcdir}/generated $(SOLARIS_CPPFLAGS) $(OPENSSL_CPPFLAGS)
1017
AM_CFLAGS = -Wall -Werror -Wdeclaration-after-statement
1118
AM_CXXFLAGS = -Wall $(USEIPV6)
19+
LIB_LDFLAGS = -no-undefined -version-info 2 $(SOLARIS_LIB_LDFLAGS) $(OPENSSL_LIB_LDFLAGS)
1220

1321
# Additional flags for coverage testing (if enabled)
1422
if ENABLEGCOV
1523
AM_CFLAGS += -fprofile-arcs -ftest-coverage
1624
AM_LDFLAGS = -lgcov
1725
endif
1826

19-
LIB_LDFLAGS = -no-undefined -version-info 2 $(SOLARIS_LIB_LDFLAGS)
20-
2127
pkginclude_HEADERS = include/zookeeper.h include/zookeeper_version.h include/zookeeper_log.h include/proto.h include/recordio.h generated/zookeeper.jute.h
2228
EXTRA_DIST=LICENSE
2329

@@ -107,7 +113,7 @@ TEST_SOURCES = \
107113
tests/ZooKeeperQuorumServer.h \
108114
tests/TestReadOnlyClient.cc \
109115
tests/TestLogClientEnv.cc \
110-
tests/TestServerRequireClientSASLAuth.cc \
116+
tests/TestServerRequireClientSASLAuth.cc \
111117
$(NULL)
112118

113119
if SOLARIS
@@ -121,14 +127,14 @@ check_PROGRAMS = zktest-st
121127
TESTS_ENVIRONMENT = ZKROOT=${srcdir}/../.. \
122128
CLASSPATH=$$CLASSPATH:$$CLOVER_HOME/lib/clover*.jar
123129
nodist_zktest_st_SOURCES = $(TEST_SOURCES)
124-
zktest_st_LDADD = libzkst.la libhashtable.la $(CPPUNIT_LIBS) -ldl
130+
zktest_st_LDADD = libzkst.la libhashtable.la $(CPPUNIT_LIBS) $(OPENSSL_LIB_LDFLAGS) -ldl
125131
zktest_st_CXXFLAGS = -DUSE_STATIC_LIB $(CPPUNIT_CFLAGS) $(USEIPV6) $(SOLARIS_CPPFLAGS)
126132
zktest_st_LDFLAGS = -shared $(SYMBOL_WRAPPERS) $(SOLARIS_LIB_LDFLAGS)
127133

128134
if WANT_SYNCAPI
129135
check_PROGRAMS += zktest-mt
130136
nodist_zktest_mt_SOURCES = $(TEST_SOURCES) tests/PthreadMocks.cc
131-
zktest_mt_LDADD = libzkmt.la libhashtable.la -lpthread $(CPPUNIT_LIBS) -ldl
137+
zktest_mt_LDADD = libzkmt.la libhashtable.la -lpthread $(CPPUNIT_LIBS) $(OPENSSL_LIB_LDFLAGS) -ldl
132138
zktest_mt_CXXFLAGS = -DUSE_STATIC_LIB -DTHREADED $(CPPUNIT_CFLAGS) $(USEIPV6)
133139
if SOLARIS
134140
SHELL_SYMBOL_WRAPPERS_MT = cat ${srcdir}/tests/wrappers-mt.opt

zookeeper-client/zookeeper-client-c/configure.ac

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ DX_INIT_DOXYGEN([zookeeper],[c-doc.Doxyfile],[docs])
2323

2424
# initialize automake
2525
AM_INIT_AUTOMAKE([-Wall foreign])
26+
2627
AC_CONFIG_HEADER([config.h])
2728

2829
# Checks for programs.
@@ -37,6 +38,26 @@ else
3738
CHECK_CPPUNIT(1.10.2)
3839
fi
3940

41+
AM_CONDITIONAL([WANT_OPENSSL],[test "x$with_openssl" != x])
42+
43+
44+
AC_ARG_WITH(openssl,
45+
AS_HELP_STRING([--without-openssl],
46+
[Do not use Openssl. Default: auto-detect]), [
47+
case "$with_openssl" in
48+
yes|no)
49+
: # Nothing special to do here
50+
;;
51+
*)
52+
if test ! -d "$withval" ; then
53+
AC_MSG_ERROR([--with-openssl path does not point to a directory])
54+
fi
55+
OPENSSL_DIR="$withval"
56+
AC_SUBST(OPENSSL_DIR)
57+
esac
58+
])
59+
AH_TEMPLATE(USE_OPENSSL,[Openssl support is available])
60+
4061
if test "$CALLER" = "ANT" ; then
4162
CPPUNIT_CFLAGS="$CPPUNIT_CFLAGS -DZKSERVER_CMD=\"\\\"${base_dir}/zookeeper-client/zookeeper-client-c/tests/zkServer.sh\\\"\""
4263
else
@@ -92,6 +113,9 @@ AC_MSG_CHECKING([whether to enable gcov])
92113
AS_IF([test "x${enable_gcov}" = "xyes"],AC_MSG_RESULT([yes]),AC_MSG_RESULT([no]))
93114
AM_CONDITIONAL([ENABLEGCOV],[test "x${enable_gcov}" = "xyes"])
94115

116+
117+
CXXFLAGS="$CXXFLAGS -std=c++11"
118+
95119
AC_ARG_WITH([syncapi],
96120
[AS_HELP_STRING([--with-syncapi],[build with support for SyncAPI [default=yes]])],
97121
[],[with_syncapi=yes])

0 commit comments

Comments
 (0)