Skip to content

Commit d54295d

Browse files
committed
fix gid conflicts
1 parent 78c4aaa commit d54295d

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

resources/lib/UnityLDAP.php

+14-13
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function getNextUIDNumber($UnitySQL)
120120
$max_uid = $UnitySQL->getSiteVar('MAX_UID');
121121
$new_uid = $max_uid + 1;
122122

123-
while ($this->UIDNumInUse($new_uid)) {
123+
while ($this->UIDNumInUse($new_uid) || $this->GIDNumInUse($new_uid)) {
124124
$new_uid++;
125125
}
126126

@@ -134,7 +134,7 @@ public function getNextPiGIDNumber($UnitySQL)
134134
$max_pigid = $UnitySQL->getSiteVar('MAX_PIGID');
135135
$new_pigid = $max_pigid + 1;
136136

137-
while ($this->PIGIDNumInUse($new_pigid)) {
137+
while ($this->GIDNumInUse($new_pigid)) {
138138
$new_pigid++;
139139
}
140140

@@ -169,27 +169,28 @@ private function UIDNumInUse($id)
169169
return false;
170170
}
171171

172-
private function PIGIDNumInUse($id)
172+
// FIXME libpam-ldap on unity nodes does not check specific OUs, they check the whole tree
173+
// one should conform to the other
174+
private function GIDNumInUse($id)
173175
{
176+
$groups = $this->groupOU->getChildrenArray(true);
177+
foreach ($groups as $group) {
178+
if ($group["gidnumber"][0] == $id) {
179+
return true;
180+
}
181+
}
174182
$pi_groups = $this->pi_groupOU->getChildrenArray(true);
175183
foreach ($pi_groups as $pi_group) {
176184
if ($pi_group["gidnumber"][0] == $id) {
177185
return true;
178186
}
179187
}
180-
181-
return false;
182-
}
183-
184-
private function GIDNumInUse($id)
185-
{
186-
$groups = $this->groupOU->getChildrenArray(true);
187-
foreach ($groups as $group) {
188-
if ($group["gidnumber"][0] == $id) {
188+
$org_groups = $this->org_groupOU->getChildrenArray(true);
189+
foreach ($org_groups as $org_group) {
190+
if ($org_group["gidnumber"][0] == $id) {
189191
return true;
190192
}
191193
}
192-
193194
return false;
194195
}
195196

0 commit comments

Comments
 (0)