mirror of
https://github.com/webmin/webmin.git
synced 2026-03-20 16:50:24 +00:00
Avoid ID clashes in new allocation mode
This commit is contained in:
@@ -50,9 +50,14 @@ print "<td valign=top><input name=group size=10 value='$group'></td>\n";
|
||||
print "<td valign=top><b>$text{'gedit_gid'}</b></td>\n";
|
||||
if ($in{'new'} && $config{'next_gid'}) {
|
||||
# Next GID comes from module config
|
||||
while(1) {
|
||||
$newgid = $config{'next_gid'};
|
||||
$config{'next_gid'}++;
|
||||
last if (!&check_uid_used($ldap, &get_group_base(),
|
||||
"gidNumber", $newgid));
|
||||
}
|
||||
print "<td valign=top><input name=gid size=10 ",
|
||||
"value='$config{'next_gid'}'></td>\n";
|
||||
$config{'next_uid'}++;
|
||||
"value='$newgid'></td>\n";
|
||||
&save_module_config();
|
||||
}
|
||||
elsif ($in{'new'}) {
|
||||
|
||||
@@ -116,8 +116,12 @@ print "<td><b>$text{'uid'}</b></td>\n";
|
||||
if ($in{'new'}) {
|
||||
# Find the first free UID above the base
|
||||
if ($config{'next_uid'}) {
|
||||
$newuid = $config{'next_uid'};
|
||||
$config{'next_uid'}++;
|
||||
while(1) {
|
||||
$newuid = $config{'next_uid'};
|
||||
$config{'next_uid'}++;
|
||||
last if (!&check_uid_used($ldap, &get_user_base(),
|
||||
"uidNumber", $newuid));
|
||||
}
|
||||
&save_module_config();
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1137,5 +1137,15 @@ $string =~ s/
|
||||
return $string;
|
||||
}
|
||||
|
||||
# check_uid_used(&ldap, base, name, id)_
|
||||
# Returns 1 if a user or group can be found with the given uid or gid
|
||||
sub check_uid_used
|
||||
{
|
||||
local ($ldap, $base, $name, $id) = @_;
|
||||
local $rv = $ldap->search('base' => $base,
|
||||
'filter' => "($name=$id)");
|
||||
return $rv->count ? 1 : 0;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user