accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [2/2] accumulo git commit: ACCUMULO-3690 Have tracer log in as the trace user too.
Date Fri, 20 Mar 2015 17:08:05 GMT
ACCUMULO-3690 Have tracer log in as the trace user too.


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/4ca31438
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/4ca31438
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/4ca31438

Branch: refs/heads/master
Commit: 4ca314384e464264c1c19ba38ea83cb332f00c3c
Parents: e82d683
Author: Josh Elser <elserj@apache.org>
Authored: Fri Mar 20 13:05:54 2015 -0400
Committer: Josh Elser <elserj@apache.org>
Committed: Fri Mar 20 13:05:54 2015 -0400

----------------------------------------------------------------------
 .../org/apache/accumulo/tracer/TraceServer.java | 31 +++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/4ca31438/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceServer.java
----------------------------------------------------------------------
diff --git a/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceServer.java b/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceServer.java
index b37404d..7f41067 100644
--- a/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceServer.java
+++ b/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceServer.java
@@ -18,6 +18,7 @@ package org.apache.accumulo.tracer;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
 
+import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.net.ServerSocket;
 import java.nio.channels.ServerSocketChannel;
@@ -58,6 +59,7 @@ import org.apache.accumulo.tracer.thrift.RemoteSpan;
 import org.apache.accumulo.tracer.thrift.SpanReceiver.Iface;
 import org.apache.accumulo.tracer.thrift.SpanReceiver.Processor;
 import org.apache.hadoop.io.Text;
+import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.htrace.Span;
 import org.apache.thrift.TByteArrayOutputStream;
 import org.apache.thrift.TException;
@@ -296,8 +298,35 @@ public class TraceServer implements Watcher {
     zoo.exists(path, this);
   }
 
+  private static void loginTracer(AccumuloConfiguration acuConf) {
+    Map<String,String> loginMap = acuConf.getAllPropertiesWithPrefix(Property.TRACE_TOKEN_PROPERTY_PREFIX);
+    String keyTab = loginMap.get(Property.TRACE_TOKEN_PROPERTY_PREFIX.getKey() + "keytab");
+    if (keyTab == null || keyTab.length() == 0) {
+      keyTab = acuConf.getPath(Property.GENERAL_KERBEROS_KEYTAB);
+    }
+    if (keyTab == null || keyTab.length() == 0)
+      return;
+
+    String principalConfig = acuConf.get(Property.TRACE_USER);
+    if (principalConfig == null || principalConfig.length() == 0)
+      return;
+
+    log.info("Attempting to login as {} with {}", principalConfig, keyTab);
+    if (SecurityUtil.login(principalConfig, keyTab)) {
+      try {
+        // This spawns a thread to periodically renew the logged in (trace) user
+        UserGroupInformation.getLoginUser();
+        return;
+      } catch (IOException io) {
+        log.error("Error starting up renewal thread. This shouldn't be happening.", io);
+      }
+    }
+
+    throw new RuntimeException("Failed to perform Kerberos login for " + principalConfig
+ " using  " + keyTab);
+  }
+
   public static void main(String[] args) throws Exception {
-    SecurityUtil.serverLogin(SiteConfiguration.getInstance());
+    loginTracer(SiteConfiguration.getInstance());
     ServerOpts opts = new ServerOpts();
     final String app = "tracer";
     opts.parseArgs(app, args);


Mime
View raw message