You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by xu...@apache.org on 2015/08/02 04:53:48 UTC

hive git commit: HIVE-10594: Remote Spark client doesn't use Kerberos keytab to authenticate [Spark Branch] (Reviewed by Chao)

Repository: hive
Updated Branches:
  refs/heads/branch-1 6eb95bdd6 -> 182c7f411


HIVE-10594: Remote Spark client doesn't use Kerberos keytab to authenticate [Spark Branch] (Reviewed by Chao)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/182c7f41
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/182c7f41
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/182c7f41

Branch: refs/heads/branch-1
Commit: 182c7f4115653f3db9ccd7f6a9f3c1fd93b44795
Parents: 6eb95bd
Author: xzhang <xz...@xzdt>
Authored: Mon Jun 22 13:04:12 2015 -0700
Committer: xzhang <xz...@xzdt>
Committed: Sat Aug 1 19:52:06 2015 -0700

----------------------------------------------------------------------
 .../hive/spark/client/SparkClientImpl.java      | 21 +++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/182c7f41/spark-client/src/main/java/org/apache/hive/spark/client/SparkClientImpl.java
----------------------------------------------------------------------
diff --git a/spark-client/src/main/java/org/apache/hive/spark/client/SparkClientImpl.java b/spark-client/src/main/java/org/apache/hive/spark/client/SparkClientImpl.java
index 9e34a49..60baa31 100644
--- a/spark-client/src/main/java/org/apache/hive/spark/client/SparkClientImpl.java
+++ b/spark-client/src/main/java/org/apache/hive/spark/client/SparkClientImpl.java
@@ -50,7 +50,10 @@ import java.util.concurrent.Future;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
 import org.apache.hadoop.hive.shims.Utils;
+import org.apache.hadoop.security.SecurityUtil;
+import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hive.spark.client.rpc.Rpc;
 import org.apache.hive.spark.client.rpc.RpcConfiguration;
 import org.apache.hive.spark.client.rpc.RpcServer;
@@ -310,6 +313,17 @@ class SparkClientImpl implements SparkClient {
 
       List<String> argv = Lists.newArrayList();
 
+      if (hiveConf.getVar(HiveConf.ConfVars.HIVE_SERVER2_AUTHENTICATION).equalsIgnoreCase("kerberos")) {
+          argv.add("kinit");
+          String principal = SecurityUtil.getServerPrincipal(hiveConf.getVar(ConfVars.HIVE_SERVER2_KERBEROS_PRINCIPAL),
+              "0.0.0.0");
+          String keyTabFile = hiveConf.getVar(ConfVars.HIVE_SERVER2_KERBEROS_KEYTAB);
+          argv.add(principal);
+          argv.add("-k");
+          argv.add("-t");
+          argv.add(keyTabFile + ";");
+      }
+
       if (sparkHome != null) {
         argv.add(new File(sparkHome, "bin/spark-submit").getAbsolutePath());
       } else {
@@ -406,14 +420,15 @@ class SparkClientImpl implements SparkClient {
         argv.add(String.format("%s=%s", hiveSparkConfKey, value));
       }
 
-      LOG.info("Running client driver with argv: {}", Joiner.on(" ").join(argv));
+      String cmd = Joiner.on(" ").join(argv);
+      LOG.info("Running client driver with argv: {}", cmd);
+      ProcessBuilder pb = new ProcessBuilder("sh", "-c", cmd);
 
-      ProcessBuilder pb = new ProcessBuilder(argv.toArray(new String[argv.size()]));
       if (isTesting != null) {
         pb.environment().put("SPARK_TESTING", isTesting);
       }
-      final Process child = pb.start();
 
+      final Process child = pb.start();
       int childId = childIdGenerator.incrementAndGet();
       redirect("stdout-redir-" + childId, child.getInputStream());
       redirect("stderr-redir-" + childId, child.getErrorStream());