You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by rm...@apache.org on 2017/02/06 05:32:55 UTC

ranger git commit: RANGER-1338:Ranger Plugin failed to download policy when JaasConfig alone is used to set the UGI instead of Principal/Keytab -Add warning for simple cluster

Repository: ranger
Updated Branches:
  refs/heads/master 223a14974 -> d55fad423


RANGER-1338:Ranger Plugin failed to download policy when JaasConfig alone is used to set the UGI instead of Principal/Keytab -Add warning for simple cluster


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

Branch: refs/heads/master
Commit: d55fad42315022931e210176fb339650181339be
Parents: 223a149
Author: rmani <rm...@hortonworks.com>
Authored: Fri Feb 3 21:35:47 2017 -0800
Committer: rmani <rm...@hortonworks.com>
Committed: Sun Feb 5 21:32:34 2017 -0800

----------------------------------------------------------------------
 .../apache/ranger/audit/provider/MiscUtil.java  | 22 +++++++++++---------
 1 file changed, 12 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ranger/blob/d55fad42/agents-audit/src/main/java/org/apache/ranger/audit/provider/MiscUtil.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/org/apache/ranger/audit/provider/MiscUtil.java b/agents-audit/src/main/java/org/apache/ranger/audit/provider/MiscUtil.java
index bb85e5e..1485c0f 100644
--- a/agents-audit/src/main/java/org/apache/ranger/audit/provider/MiscUtil.java
+++ b/agents-audit/src/main/java/org/apache/ranger/audit/provider/MiscUtil.java
@@ -644,7 +644,7 @@ public class MiscUtil {
 		}
 		try {
 			AppConfigurationEntry entries[] = Configuration.getConfiguration().getAppConfigurationEntry(jaasConfigAppName);
-			if(!ArrayUtils.isEmpty(entries)){
+			if(!ArrayUtils.isEmpty(entries)) {
 				for (AppConfigurationEntry entry : entries) {
 					if (entry.getOptions().get("keyTab") != null) {
 						keytabFile = (String) entry.getOptions().get("keyTab");
@@ -656,17 +656,19 @@ public class MiscUtil {
 						break;
 					}
 				}
-			}
-			if (!StringUtils.isEmpty(principal) && !StringUtils.isEmpty(keytabFile)) {
-				// This will login and set the UGI
-				UserGroupInformation.loginUserFromKeytab(principal, keytabFile);
-				ugi = UserGroupInformation.getLoginUser();
+				if (!StringUtils.isEmpty(principal) && !StringUtils.isEmpty(keytabFile)) {
+					// This will login and set the UGI
+					UserGroupInformation.loginUserFromKeytab(principal, keytabFile);
+					ugi = UserGroupInformation.getLoginUser();
+				} else {
+					String error_mesage = "Unable to get the principal/keytab from jaasConfigAppName: " + jaasConfigAppName;
+					logger.error(error_mesage);
+					throw new Exception(error_mesage);
+				}
+				logger.info("MiscUtil.setUGIFromJAASConfig() UGI: " + ugi + " principal: " + principal + " keytab: " + keytabFile);
 			} else {
-				String error_mesage = "Unable to get the principal/keytab from jaasConfigAppName: " + jaasConfigAppName;
-				logger.error(error_mesage);
-				throw new Exception(error_mesage);
+				logger.warn("JAASConfig file not found! Ranger Plugin will not working in a Secure Cluster...");
 			}
-			logger.info("MiscUtil.setUGIFromJAASConfig() UGI: " + ugi + " principal: " + principal + " keytab: " + keytabFile);
 		} catch ( Exception e) {
 			logger.error("Unable to set UGI for Principal: " + principal + " keytab: " + keytabFile );
 			throw e;