Return-Path: X-Original-To: apmail-argus-commits-archive@minotaur.apache.org Delivered-To: apmail-argus-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 25914171C0 for ; Fri, 31 Oct 2014 02:12:22 +0000 (UTC) Received: (qmail 2162 invoked by uid 500); 31 Oct 2014 02:12:22 -0000 Delivered-To: apmail-argus-commits-archive@argus.apache.org Received: (qmail 2150 invoked by uid 500); 31 Oct 2014 02:12:21 -0000 Mailing-List: contact commits-help@argus.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@argus.incubator.apache.org Delivered-To: mailing list commits@argus.incubator.apache.org Received: (qmail 2141 invoked by uid 99); 31 Oct 2014 02:12:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 31 Oct 2014 02:12:21 +0000 X-ASF-Spam-Status: No, hits=-2000.6 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 31 Oct 2014 02:12:20 +0000 Received: (qmail 99695 invoked by uid 99); 31 Oct 2014 02:09:30 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 31 Oct 2014 02:09:30 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id BE495A05963; Fri, 31 Oct 2014 02:09:29 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: madhan@apache.org To: commits@argus.incubator.apache.org Message-Id: <5ec19843cbc044eaa5f73995e05febe7@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: ARGUS-138: Fixed the bug that caused code to let some of the users with userid below MIN_UNIX_USER_ID_TO_SYNC Date: Fri, 31 Oct 2014 02:09:29 +0000 (UTC) X-Virus-Checked: Checked by ClamAV on apache.org Repository: incubator-argus Updated Branches: refs/heads/master 38c359470 -> fa2ff5ae7 ARGUS-138: Fixed the bug that caused code to let some of the users with userid below MIN_UNIX_USER_ID_TO_SYNC Signed-off-by: Madhan Neethiraj Project: http://git-wip-us.apache.org/repos/asf/incubator-argus/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-argus/commit/fa2ff5ae Tree: http://git-wip-us.apache.org/repos/asf/incubator-argus/tree/fa2ff5ae Diff: http://git-wip-us.apache.org/repos/asf/incubator-argus/diff/fa2ff5ae Branch: refs/heads/master Commit: fa2ff5ae72077b5b6f764a6386c15c661570d6b8 Parents: 38c3594 Author: Alok Lal Authored: Wed Oct 29 10:38:17 2014 -0700 Committer: Madhan Neethiraj Committed: Thu Oct 30 19:07:39 2014 -0700 ---------------------------------------------------------------------- .../process/UnixUserGroupBuilder.java | 41 ++++++++------------ 1 file changed, 17 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/fa2ff5ae/ugsync/src/main/java/com/xasecure/unixusersync/process/UnixUserGroupBuilder.java ---------------------------------------------------------------------- diff --git a/ugsync/src/main/java/com/xasecure/unixusersync/process/UnixUserGroupBuilder.java b/ugsync/src/main/java/com/xasecure/unixusersync/process/UnixUserGroupBuilder.java index b457e7a..8d4af61 100644 --- a/ugsync/src/main/java/com/xasecure/unixusersync/process/UnixUserGroupBuilder.java +++ b/ugsync/src/main/java/com/xasecure/unixusersync/process/UnixUserGroupBuilder.java @@ -42,8 +42,8 @@ public class UnixUserGroupBuilder implements UserGroupSource { private UserGroupSyncConfig config = UserGroupSyncConfig.getInstance() ; private Map> user2GroupListMap = new HashMap>(); + private Map> internalUser2GroupListMap = new HashMap>(); private Map groupId2groupNameMap = new HashMap() ; - private List userList = new ArrayList() ; private int minimumUserId = 0 ; private long passwordFileModiiedAt = 0 ; @@ -98,7 +98,6 @@ public class UnixUserGroupBuilder implements UserGroupSource { private void buildUserGroupInfo() throws Throwable { user2GroupListMap = new HashMap>(); groupId2groupNameMap = new HashMap() ; - userList = new ArrayList() ; buildUnixGroupList(); buildUnixUserList(); @@ -107,8 +106,8 @@ public class UnixUserGroupBuilder implements UserGroupSource { } } - public void print() { - for(String user : userList) { + private void print() { + for(String user : user2GroupListMap.keySet()) { LOG.debug("USER:" + user) ; List groups = user2GroupListMap.get(user) ; if (groups != null) { @@ -119,14 +118,6 @@ public class UnixUserGroupBuilder implements UserGroupSource { } } - private List getUserList() { - return userList ; - } - - private List getGroupListForUser(String aUserName) { - return user2GroupListMap.get(aUserName) ; - } - private void buildUnixUserList() throws Throwable { File f = new File(UNIX_USER_PASSWORD_FILE) ; @@ -168,22 +159,24 @@ public class UnixUserGroupBuilder implements UserGroupSource { } if (numUserId >= minimumUserId ) { - userList.add(userName) ; String groupName = groupId2groupNameMap.get(groupId) ; if (groupName != null) { - List groupList = user2GroupListMap.get(userName) ; - if (groupList == null) { - groupList = new ArrayList() ; - user2GroupListMap.put(userName, groupList) ; - } - if (! groupList.contains(groupName)) { - groupList.add(groupName) ; + List groupList = new ArrayList(); + groupList.add(groupName); + // do we already know about this use's membership to other groups? If so add those, too + if (internalUser2GroupListMap.containsKey(userName)) { + groupList.addAll(internalUser2GroupListMap.get(userName)); } + user2GroupListMap.put(userName, groupList); } else { - LOG.warn("Group Name could not be found for group id: [" + groupId + "]") ; + // 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 + "].") ; } } + else { + LOG.debug("Skipping user [" + userName + "] since its userid [" + userId + "] is less than minuserid limit [" + minimumUserId + "]."); + } } reader.close() ; @@ -234,13 +227,13 @@ public class UnixUserGroupBuilder implements UserGroupSource { } groupId2groupNameMap.put(groupId,groupName) ; - + // also build an internal map of users to their group list which is consulted by user list creator if (groupMembers != null && ! groupMembers.trim().isEmpty()) { for(String user : groupMembers.split(",")) { - List groupList = user2GroupListMap.get(user) ; + List groupList = internalUser2GroupListMap.get(user) ; if (groupList == null) { groupList = new ArrayList() ; - user2GroupListMap.put(user, groupList) ; + internalUser2GroupListMap.put(user, groupList) ; } if (! groupList.contains(groupName)) { groupList.add(groupName) ;