Repository: incubator-sentry
Updated Branches:
  refs/heads/master 25f88cb88 -> fba126789


SENTRY-1052: Sentry shell should use kerberos requestor and give better error 
messages for kerberos failures


Project: http://git-wip-us.apache.org/repos/asf/incubator-sentry/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-sentry/commit/fba12678
Tree: http://git-wip-us.apache.org/repos/asf/incubator-sentry/tree/fba12678
Diff: http://git-wip-us.apache.org/repos/asf/incubator-sentry/diff/fba12678

Branch: refs/heads/master
Commit: fba126789702ced8944b2ebe68a53972e0c7d8fb
Parents: 25f88cb
Author: Gregory Chanan <[email protected]>
Authored: Thu Feb 4 16:23:50 2016 -0800
Committer: Gregory Chanan <[email protected]>
Committed: Fri Feb 5 00:29:05 2016 -0800

----------------------------------------------------------------------
 .../provider/db/generic/tools/SentryShellSolr.java  | 15 ++++++++++-----
 .../sentry/provider/db/tools/SentryShellHive.java   | 16 +++++++++++-----
 2 files changed, 21 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/fba12678/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/generic/tools/SentryShellSolr.java
----------------------------------------------------------------------
diff --git 
a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/generic/tools/SentryShellSolr.java
 
b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/generic/tools/SentryShellSolr.java
index b0d97cd..3e21faf 100644
--- 
a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/generic/tools/SentryShellSolr.java
+++ 
b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/generic/tools/SentryShellSolr.java
@@ -21,6 +21,7 @@ package org.apache.sentry.provider.db.generic.tools;
 import org.apache.commons.lang.StringUtils;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.security.UserGroupInformation;
 import 
org.apache.sentry.provider.db.generic.service.thrift.SentryGenericServiceClient;
 import 
org.apache.sentry.provider.db.generic.service.thrift.SentryGenericServiceClientFactory;
 import org.apache.sentry.provider.db.generic.tools.command.*;
@@ -42,12 +43,13 @@ public class SentryShellSolr extends SentryShellCommon {
   @Override
   public void run() throws Exception {
     Command command = null;
-    String requestorName = System.getProperty("user.name", "");
     String component = "SOLR";
     Configuration conf = getSentryConf();
 
     String service = conf.get(SOLR_SERVICE_NAME, "service1");
     SentryGenericServiceClient client = 
SentryGenericServiceClientFactory.create(conf);
+    UserGroupInformation ugi = UserGroupInformation.getLoginUser();
+    String requestorName = ugi.getShortUserName();
 
     if (isCreateRole) {
       command = new CreateRoleCmd(roleName, component);
@@ -90,13 +92,16 @@ public class SentryShellSolr extends SentryShellCommon {
   public static void main(String[] args) throws Exception {
     SentryShellSolr sentryShell = new SentryShellSolr();
     try {
-      if (sentryShell.executeShell(args)) {
-        System.out.println("The operation completed successfully.");
-      }
+      sentryShell.executeShell(args);
     } catch (Exception e) {
       LOGGER.error(e.getMessage(), e);
+      Throwable current =  e;
+      // find the first printable message;
+      while (current != null && current.getMessage() == null) {
+        current = current.getCause();
+      }
       System.out.println("The operation failed." +
-          e.getMessage() == null ? "" : "  Message: " + e.getMessage());
+          (current.getMessage() == null ? "" : "  Message: " + 
current.getMessage()));
       System.exit(1);
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/fba12678/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/tools/SentryShellHive.java
----------------------------------------------------------------------
diff --git 
a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/tools/SentryShellHive.java
 
b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/tools/SentryShellHive.java
index 80c8442..dc7f829 100644
--- 
a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/tools/SentryShellHive.java
+++ 
b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/tools/SentryShellHive.java
@@ -21,6 +21,7 @@ package org.apache.sentry.provider.db.tools;
 import org.apache.commons.lang.StringUtils;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.sentry.provider.db.service.thrift.SentryPolicyServiceClient;
 import org.apache.sentry.provider.db.tools.command.hive.*;
 import org.apache.sentry.service.thrift.SentryServiceClientFactory;
@@ -39,8 +40,9 @@ public class SentryShellHive extends SentryShellCommon {
 
   public void run() throws Exception {
     Command command = null;
-    String requestorName = System.getProperty("user.name", "");
     SentryPolicyServiceClient client = 
SentryServiceClientFactory.create(getSentryConf());
+    UserGroupInformation ugi = UserGroupInformation.getLoginUser();
+    String requestorName = ugi.getShortUserName();
 
     if (isCreateRole) {
       command = new CreateRoleCmd(roleName);
@@ -80,12 +82,16 @@ public class SentryShellHive extends SentryShellCommon {
   public static void main(String[] args) throws Exception {
     SentryShellHive sentryShell = new SentryShellHive();
     try {
-      if (sentryShell.executeShell(args)) {
-        System.out.println("The operation is compeleted successfully.");
-      }
+      sentryShell.executeShell(args);
     } catch (Exception e) {
       LOGGER.error(e.getMessage(), e);
-      System.out.println("The operation is failed, please refer to log file 
for the root cause.");
+      Throwable current =  e;
+      // find the first printable message;
+      while (current != null && current.getMessage() == null) {
+        current = current.getCause();
+      }
+       System.out.println("The operation failed." +
+          (current.getMessage() == null ? "" : "  Message: " + 
current.getMessage()));
     }
   }
 

Reply via email to