Commit 066d8362 authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

Fix unix_gid search; still a terrible way to do this, but at least

it won't barf when it finds an allocated group it was not expecting
to be.
parent e257816e
#!/usr/bin/perl -wT
#
# Copyright (c) 2005-2011 University of Utah and the Flux Group.
# Copyright (c) 2005-2013 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -273,7 +273,10 @@ sub Create($$$$$$)
#
# Get me an unused unix id. Nice query, eh? Basically, find
# unused numbers by looking at existing numbers plus one, and
# check to see if that number is taken.
# check to see if that number is taken. The point is to look
# for holes since the space is only 16 bits, but this is really
# ineffecient! Not really a problem with smallish number of groups
# but terrible for 1000s!
#
$query_result =
DBQueryWarn("select g.unix_gid + 1 as start from groups as g ".
......@@ -286,16 +289,22 @@ sub Create($$$$$$)
return undef
if (! $query_result);
my $unused;
if (! $query_result->numrows) {
print "*** WARNING: Could not find an unused unix_gid!\n";
return undef;
$unused = $min_gid;
}
else {
($unused) = $query_result->fetchrow_array();
}
my ($unused) = $query_result->fetchrow_array();
if (getgrgid($unused)) {
# Keep going.
$min_gid++;
if ($min_gid >= 50000) {
print "*** WARNING: Could not find an unused unix_gid!\n";
return undef;
}
}
else {
# Break out of loop.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment