This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new 9eb6c2fa603 [fix](jni) pass krb5 conf to jni (#47679)
9eb6c2fa603 is described below

commit 9eb6c2fa6039c4d2595486800b3db51985244efa
Author: Mingyu Chen (Rayner) <morning...@163.com>
AuthorDate: Mon Feb 10 22:27:11 2025 +0800

    [fix](jni) pass krb5 conf to jni (#47679)
    
    ### What problem does this PR solve?
    
    Related PR: #47299
    
    Problem Summary:
    
    This pick part of #47299, only related to `jni-util.cpp`.
    To pass the krb5.conf config to Jni env
---
 be/src/util/jni-util.cpp | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/be/src/util/jni-util.cpp b/be/src/util/jni-util.cpp
index 01409fb3ea5..df79ee15339 100644
--- a/be/src/util/jni-util.cpp
+++ b/be/src/util/jni-util.cpp
@@ -32,6 +32,7 @@
 #include <string>
 #include <vector>
 
+#include "common/config.h"
 #include "gutil/strings/substitute.h"
 #include "util/doris_metrics.h"
 #include "util/jni_native_method.h"
@@ -90,6 +91,10 @@ const std::string GetDorisJNIClasspathOption() {
     }
 }
 
+const std::string GetKerb5ConfPath() {
+    return "-Djava.security.krb5.conf=" + config::kerberos_krb5_conf_path;
+}
+
 [[maybe_unused]] void SetEnvIfNecessary() {
     const auto* doris_home = getenv("DORIS_HOME");
     DCHECK(doris_home) << "Environment variable DORIS_HOME is not set.";
@@ -103,10 +108,11 @@ const std::string GetDorisJNIClasspathOption() {
     // LIBHDFS_OPTS
     const std::string java_opts = getenv("JAVA_OPTS") ? getenv("JAVA_OPTS") : 
"";
     std::string libhdfs_opts =
-            fmt::format("{} -Djava.library.path={}/lib/hadoop_hdfs/native:{}", 
java_opts,
+            fmt::format("{} -Djava.library.path={}/lib/hadoop_hdfs/native:{} 
", java_opts,
                         getenv("DORIS_HOME"), getenv("DORIS_HOME") + 
std::string("/lib"));
+    libhdfs_opts += fmt::format("{} ", GetKerb5ConfPath());
 
-    setenv("LIBHDFS_OPTS", libhdfs_opts.c_str(), 0);
+    setenv("LIBHDFS_OPTS", libhdfs_opts.c_str(), 1);
 }
 
 // Only used on non-x86 platform
@@ -136,6 +142,7 @@ const std::string GetDorisJNIClasspathOption() {
                                                
std::istream_iterator<std::string>());
             options.push_back(GetDorisJNIClasspathOption());
         }
+        options.push_back(GetKerb5ConfPath());
         std::unique_ptr<JavaVMOption[]> jvm_options(new 
JavaVMOption[options.size()]);
         for (int i = 0; i < options.size(); ++i) {
             jvm_options[i] = {const_cast<char*>(options[i].c_str()), nullptr};


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to