Skip to content

Commit

Permalink
Prevent infinite recurse when 2 groups are members of each other
Browse files Browse the repository at this point in the history
Tries to solve issue already reported:
theforeman#51
  • Loading branch information
c-silva committed Jun 6, 2016
1 parent 59f24a6 commit 57a9c62
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/ldap_fluff/ad_member_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def _groups_from_ldap_data(payload)
data = []
if !payload.nil?
first_level = payload[:memberof]
total_groups = _walk_group_ancestry(first_level)
total_groups, b = _walk_group_ancestry(first_level, first_level)
data = (get_groups(first_level + total_groups)).uniq
end
data
Expand All @@ -32,12 +32,15 @@ def _walk_group_ancestry(group_dns = [])
group_dns.each do |group_dn|
search = @ldap.search(:base => group_dn, :scope => Net::LDAP::SearchScope_BaseObject, :attributes => ['memberof'])
if !search.nil? && !search.first.nil?
group = search.first
set += _walk_group_ancestry(group[:memberof])
set += group[:memberof]
groups = search.first[:memberof] - known_groups
known_groups += groups
next_level, new_known_groups = _walk_group_ancestry(groups, known_groups)
set += next_level
set += groups
known_groups += next_level
end
end
set
return [set, known_groups]
end

def class_filter
Expand Down

0 comments on commit 57a9c62

Please sign in to comment.