Module config options for next uid and gid

This commit is contained in:
Jamie Cameron
2007-07-16 17:20:55 +00:00
parent a6547cc304
commit b1e3b77ff2
4 changed files with 21 additions and 3 deletions

View File

@@ -47,3 +47,5 @@ In a user batch file, # is only treated as a comment at the start of a line.
For Samba users, the primary group SID is taken from the actual SID of the selected primary group, where available.
---- Changes since 1.320 ----
Limit the result size to the configured display maximum when requesting users and groups from the LDAP server.
---- Changes since 1.350 ----
Added Module Config options to specify the next UID and GID to assign to new users and groups. This avoids the need to scan all existing users to find a free UID, which can be slow on large DBs.

View File

@@ -34,6 +34,8 @@ base_uid=Lowest UID for new users,3,From Users and Groups module
base_gid=Lowest GID for new groups,3,From Users and Groups module
md5=Encryption method for passwords,1,3-LDAP MD5,1-Unix MD5,0-crypt,2-Plain text
shells=Build list of shells from,2,fixed-Builtin list,passwd-System users,shells-/etc/shells
next_uid=UID for next new user,3,Allocate automatically
next_gid=UID for next new group,3,Allocate automatically
line7=New user defaults,11
default_group=Default primary group for new users,3,From Users and Groups module

View File

@@ -48,7 +48,14 @@ print "<tr> <td valign=top><b>$text{'gedit_group'}</b></td>\n";
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'}) {
if ($in{'new'} && $config{'next_gid'}) {
# Next GID comes from module config
print "<td valign=top><input name=gid size=10 ",
"value='$config{'next_gid'}'></td>\n";
$config{'next_uid'}++;
&save_module_config();
}
elsif ($in{'new'}) {
# Find the first free GID above the base by checking all existing groups
&build_group_used(\%gused);
$newgid = &allocate_gid(\%gused);

View File

@@ -67,7 +67,7 @@ else {
@shlist = ($mconfig{'default_shell'} ? ( $mconfig{'default_shell'} ) : ( ));
%shells = map { $_, 1 } split(/,/, $config{'shells'});
push(@shlist, "/bin/sh", "/bin/csh", "/bin/false") if ($shells{'fixed'});
if ($shells{'passwd'} || $in{'new'}) {
if ($shells{'passwd'} || $in{'new'} && !$config{'next_uid'}) {
# Don't do this unless we need to, as scanning all user is slow
&build_user_used(\%used, $shells{'passwd'} ? \@shlist : undef);
}
@@ -115,7 +115,14 @@ else {
print "<td><b>$text{'uid'}</b></td>\n";
if ($in{'new'}) {
# Find the first free UID above the base
$newuid = &allocate_uid(\%used);
if ($config{'next_uid'}) {
$newuid = $config{'next_uid'};
$config{'next_uid'}++;
&save_module_config();
}
else {
$newuid = &allocate_uid(\%used);
}
print "<td><input name=uid size=10 value='$newuid'></td> </tr>\n";
}
else {