Repository: kudu
Updated Branches:
  refs/heads/master 7177fc359 -> 334ecafd0


Add compile time checks for kerberos, libvmem

This change adds compile time checks for the kerberos and vmem
libraries. These changes will help other projects (e.g. Impala) to
include Kudu code in their own repositories.

Change-Id: I0322e44784c026b6d6f1d3088bed03e95e94eb45
Reviewed-on: http://gerrit.cloudera.org:8080/10870
Tested-by: Kudu Jenkins
Reviewed-by: Sailesh Mukil <sail...@cloudera.com>
Reviewed-by: Todd Lipcon <t...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/334ecafd
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/334ecafd
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/334ecafd

Branch: refs/heads/master
Commit: 334ecafd014d9ece739ebd03d3b8ccb32032bb26
Parents: 7177fc3
Author: Lars Volker <l...@cloudera.com>
Authored: Mon Jul 2 09:55:10 2018 -0700
Committer: Todd Lipcon <t...@apache.org>
Committed: Fri Jul 6 17:04:53 2018 +0000

----------------------------------------------------------------------
 CMakeLists.txt                   |  5 +++++
 src/kudu/cfile/cfile-test.cc     |  6 +++---
 src/kudu/security/CMakeLists.txt |  9 +++++++++
 src/kudu/security/init.cc        |  6 +++---
 src/kudu/util/CMakeLists.txt     | 11 ++++++++---
 src/kudu/util/cache-test.cc      |  4 ++--
 src/kudu/util/cache.cc           |  2 +-
 7 files changed, 31 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/334ecafd/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a180a72..1458bc8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1153,6 +1153,11 @@ ADD_THIRDPARTY_LIB(pmemobj
   DEPS ${PMEMOBJ_DEPS})
 endif()
 
+if (EXISTS ${VMEM_SHARED_LIB})
+  set(HAVE_LIB_VMEM 1)
+  add_definitions(-DHAVE_LIB_VMEM=1)
+endif()
+
 ## curl
 find_package(CURL REQUIRED)
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/334ecafd/src/kudu/cfile/cfile-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/cfile/cfile-test.cc b/src/kudu/cfile/cfile-test.cc
index 526dde5..3213495 100644
--- a/src/kudu/cfile/cfile-test.cc
+++ b/src/kudu/cfile/cfile-test.cc
@@ -395,7 +395,7 @@ class TestCFileBothCacheTypes : public TestCFile,
                                 public 
::testing::WithParamInterface<CacheType> {
  public:
   void SetUp() OVERRIDE {
-#if defined(__linux__)
+#if defined(HAVE_LIB_VMEM)
     // The NVM cache can run using any directory as its path -- it doesn't have
     // a lot of practical use outside of an actual NVM device, but for testing
     // purposes, we'll point it at our test dir, unless otherwise specified.
@@ -408,7 +408,7 @@ class TestCFileBothCacheTypes : public TestCFile,
       case DRAM_CACHE:
         FLAGS_block_cache_type = "DRAM";
         break;
-#if defined(__linux__)
+#if defined(HAVE_LIB_VMEM)
       case NVM_CACHE:
         FLAGS_block_cache_type = "NVM";
         break;
@@ -1029,7 +1029,7 @@ TEST_P(TestCFileBothCacheTypes, TestCacheKeysAreStable) {
   }
 }
 
-#if defined(__linux__)
+#if defined(HAVE_LIB_VMEM)
 // Inject failures in nvm allocation and ensure that we can still read a file.
 TEST_P(TestCFileBothCacheTypes, TestNvmAllocationFailure) {
   if (GetParam() != NVM_CACHE) return;

http://git-wip-us.apache.org/repos/asf/kudu/blob/334ecafd/src/kudu/security/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/kudu/security/CMakeLists.txt b/src/kudu/security/CMakeLists.txt
index 3af155d..b79486e 100644
--- a/src/kudu/security/CMakeLists.txt
+++ b/src/kudu/security/CMakeLists.txt
@@ -49,6 +49,15 @@ ADD_EXPORTABLE_LIBRARY(token_proto
 # security
 ##############################
 
+# Check for krb5_get_init_creds_opt_set_out_ccache, which is not available in 
versions
+# of MIT Kerberos older than krb5-1.6, and is also not present in Heimdal 
kerberos.
+include(CheckLibraryExists)
+check_library_exists("krb5" krb5_get_init_creds_opt_set_out_ccache
+  ${KERBEROS_LIBRARY} HAVE_KRB5_GET_INIT_CREDS_OPT_SET_OUT_CCACHE)
+if(HAVE_KRB5_GET_INIT_CREDS_OPT_SET_OUT_CCACHE)
+  add_definitions(-DHAVE_KRB5_GET_INIT_CREDS_OPT_SET_OUT_CCACHE=1)
+endif()
+
 # Fall back to using the ported functionality if we're using an older version 
of OpenSSL.
 if (${OPENSSL_VERSION} VERSION_LESS "1.0.2")
   set(PORTED_X509_CHECK_HOST_CC "x509_check_host.cc")

http://git-wip-us.apache.org/repos/asf/kudu/blob/334ecafd/src/kudu/security/init.cc
----------------------------------------------------------------------
diff --git a/src/kudu/security/init.cc b/src/kudu/security/init.cc
index 2b50fb2..ee754eb 100644
--- a/src/kudu/security/init.cc
+++ b/src/kudu/security/init.cc
@@ -270,7 +270,7 @@ Status KinitContext::DoRenewal() {
                                                             nullptr /* TKT 
service name */,
                                                             opts_),
                                  "Reacquire error: unable to login from 
keytab");
-#ifdef __APPLE__
+#if !defined(HAVE_KRB5_GET_INIT_CREDS_OPT_SET_OUT_CCACHE)
       // Heimdal krb5 doesn't have the 
'krb5_get_init_creds_opt_set_out_ccache' option,
       // so use this alternate route.
       KRB5_RETURN_NOT_OK_PREPEND(krb5_cc_initialize(g_krb5_ctx, ccache_, 
principal_),
@@ -303,7 +303,7 @@ Status KinitContext::Kinit(const string& keytab_path, const 
string& principal) {
   KRB5_RETURN_NOT_OK_PREPEND(krb5_get_init_creds_opt_alloc(g_krb5_ctx, &opts_),
                              "unable to allocate get_init_creds_opt struct");
 
-#ifndef __APPLE__
+#if defined(HAVE_KRB5_GET_INIT_CREDS_OPT_SET_OUT_CCACHE)
   
KRB5_RETURN_NOT_OK_PREPEND(krb5_get_init_creds_opt_set_out_ccache(g_krb5_ctx, 
opts_, ccache_),
                              "unable to set init_creds options");
 #endif
@@ -318,7 +318,7 @@ Status KinitContext::Kinit(const string& keytab_path, const 
string& principal) {
 
   ticket_end_timestamp_ = creds.times.endtime;
 
-#ifdef __APPLE__
+#if !defined(HAVE_KRB5_GET_INIT_CREDS_OPT_SET_OUT_CCACHE)
   // Heimdal krb5 doesn't have the 'krb5_get_init_creds_opt_set_out_ccache' 
option,
   // so use this alternate route.
   KRB5_RETURN_NOT_OK_PREPEND(krb5_cc_initialize(g_krb5_ctx, ccache_, 
principal_),

http://git-wip-us.apache.org/repos/asf/kudu/blob/334ecafd/src/kudu/util/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/kudu/util/CMakeLists.txt b/src/kudu/util/CMakeLists.txt
index 743e1af..94dd2fa 100644
--- a/src/kudu/util/CMakeLists.txt
+++ b/src/kudu/util/CMakeLists.txt
@@ -209,7 +209,7 @@ set(UTIL_SRCS
 # optimized regardless of the default optimization options.
 set_source_files_properties(memory/overwrite.cc PROPERTIES COMPILE_FLAGS "-O3")
 
-if(NOT APPLE)
+if(HAVE_LIB_VMEM)
   set(UTIL_SRCS
     ${UTIL_SRCS}
     nvm_cache.cc)
@@ -233,7 +233,12 @@ if(NOT APPLE)
     ${UTIL_LIBS}
     breakpad_client
     dl
-    rt
+    rt)
+endif()
+
+if(HAVE_LIB_VMEM)
+  set(UTIL_LIBS
+    ${UTIL_LIBS}
     vmem)
 endif()
 
@@ -280,7 +285,7 @@ target_link_libraries(kudu_test_util
   gmock
   kudu_util)
 
-if(NOT APPLE)
+if(HAVE_LIB_VMEM)
   target_link_libraries(kudu_test_util
     vmem)
 endif()

http://git-wip-us.apache.org/repos/asf/kudu/blob/334ecafd/src/kudu/util/cache-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/cache-test.cc b/src/kudu/util/cache-test.cc
index a72a871..3fd1d5f 100644
--- a/src/kudu/util/cache-test.cc
+++ b/src/kudu/util/cache-test.cc
@@ -65,12 +65,12 @@ class CacheTest : public KuduTest,
 
   virtual void SetUp() OVERRIDE {
 
-#if defined(__linux__)
+#if defined(HAVE_LIB_VMEM)
     if (google::GetCommandLineFlagInfoOrDie("nvm_cache_path").is_default) {
       FLAGS_nvm_cache_path = GetTestPath("nvm-cache");
       ASSERT_OK(Env::Default()->CreateDir(FLAGS_nvm_cache_path));
     }
-#endif // defined(__linux__)
+#endif // defined(HAVE_LIB_VMEM)
 
     // Disable approximate tracking of cache memory since we make specific
     // assertions on the MemTracker in this test.

http://git-wip-us.apache.org/repos/asf/kudu/blob/334ecafd/src/kudu/util/cache.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/cache.cc b/src/kudu/util/cache.cc
index c0bbba3..00f2e52 100644
--- a/src/kudu/util/cache.cc
+++ b/src/kudu/util/cache.cc
@@ -560,7 +560,7 @@ Cache* NewLRUCache(CacheType type, size_t capacity, const 
string& id) {
   switch (type) {
     case DRAM_CACHE:
       return new ShardedLRUCache(capacity, id);
-#if !defined(__APPLE__)
+#if defined(HAVE_LIB_VMEM)
     case NVM_CACHE:
       return NewLRUNvmCache(capacity, id);
 #endif

Reply via email to