You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by sp...@apache.org on 2018/06/08 18:17:15 UTC

ranger git commit: RANGER-2124: Total groups count is derived based on the groups that are updated to ranger admin instead of all the groups read from OS for unix as syn source

Repository: ranger
Updated Branches:
  refs/heads/master 80c819833 -> 06d081356


RANGER-2124: Total groups count is derived based on the groups that are updated to ranger admin instead of all the groups read from OS for unix as syn source


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

Branch: refs/heads/master
Commit: 06d0813563d118f69ba04a60396016007ac1d77e
Parents: 80c8198
Author: Sailaja Polavarapu <sp...@hortonworks.com>
Authored: Thu Jun 7 11:23:19 2018 -0700
Committer: Sailaja Polavarapu <sp...@hortonworks.com>
Committed: Thu Jun 7 11:23:19 2018 -0700

----------------------------------------------------------------------
 .../ranger/unixusersync/process/UnixUserGroupBuilder.java    | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ranger/blob/06d08135/ugsync/src/main/java/org/apache/ranger/unixusersync/process/UnixUserGroupBuilder.java
----------------------------------------------------------------------
diff --git a/ugsync/src/main/java/org/apache/ranger/unixusersync/process/UnixUserGroupBuilder.java b/ugsync/src/main/java/org/apache/ranger/unixusersync/process/UnixUserGroupBuilder.java
index f314bd8..ddab629 100644
--- a/ugsync/src/main/java/org/apache/ranger/unixusersync/process/UnixUserGroupBuilder.java
+++ b/ugsync/src/main/java/org/apache/ranger/unixusersync/process/UnixUserGroupBuilder.java
@@ -86,6 +86,8 @@ public class UnixUserGroupBuilder implements UserGroupSource {
 	private UgsyncAuditInfo ugsyncAuditInfo;
 	private UnixSyncSourceInfo unixSyncSourceInfo;
 	private boolean isStartupFlag = false;
+	Set<String> allGroups = new HashSet<>();
+
 
 	public static void main(String[] args) throws Throwable {
 		UnixUserGroupBuilder ugbuilder = new UnixUserGroupBuilder();
@@ -168,7 +170,6 @@ public class UnixUserGroupBuilder implements UserGroupSource {
 			for (Map.Entry<String, List<String>> entry : user2GroupListMap.entrySet()) {
 				String user = entry.getKey();
 				List<String> groups = entry.getValue();
-
 				try {
 					sink.addOrUpdateUser(user, groups);
 				} catch (Throwable t) {
@@ -181,7 +182,7 @@ public class UnixUserGroupBuilder implements UserGroupSource {
 		}
 		try {
 			unixSyncSourceInfo.setTotalUsersSynced(user2GroupListMap.size());
-			unixSyncSourceInfo.setTotalGroupsSynced(groupId2groupNameMap.size());
+			unixSyncSourceInfo.setTotalGroupsSynced(allGroups.size());
 			sink.postUserGroupAuditInfo(ugsyncAuditInfo);
 		} catch (Throwable t) {
 			LOG.error("sink.postUserGroupAuditInfo failed with exception: ", t);
@@ -193,6 +194,7 @@ public class UnixUserGroupBuilder implements UserGroupSource {
 	private void buildUserGroupInfo() throws Throwable {
 		user2GroupListMap = new HashMap<String,List<String>>();
 		groupId2groupNameMap = new HashMap<String, String>();
+		allGroups = new HashSet<>();
 
 		if (OS.startsWith("Mac")) {
 			buildUnixGroupList(MAC_GET_ALL_GROUPS_CMD, MAC_GET_GROUP_CMD, false);
@@ -294,6 +296,7 @@ public class UnixUserGroupBuilder implements UserGroupSource {
 							groupList.addAll(map);
 						}
 						user2GroupListMap.put(userName, groupList);
+						allGroups.addAll(groupList);
 					} else {
 						// we are ignoring the possibility that this user was present in /etc/groups.
 						LOG.warn("Group Name could not be found for group id: [" + groupId + "]. Skipping adding user [" + userName + "] with id [" + userId + "].");
@@ -368,6 +371,7 @@ public class UnixUserGroupBuilder implements UserGroupSource {
 				}
 
 				user2GroupListMap.put(entry.getKey(), allowedGroups);
+				allGroups.addAll(allowedGroups);
 			}
 			LOG.debug("End drill down group members");
 		}