From b1e3b77ff2bef3a04df7bffd36e1aa128b2accd6 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Mon, 16 Jul 2007 17:20:55 +0000 Subject: [PATCH] Module config options for next uid and gid --- ldap-useradmin/CHANGELOG | 2 ++ ldap-useradmin/config.info | 2 ++ ldap-useradmin/edit_group.cgi | 9 ++++++++- ldap-useradmin/edit_user.cgi | 11 +++++++++-- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/ldap-useradmin/CHANGELOG b/ldap-useradmin/CHANGELOG index eda9bb3cc..59c1d654d 100644 --- a/ldap-useradmin/CHANGELOG +++ b/ldap-useradmin/CHANGELOG @@ -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. diff --git a/ldap-useradmin/config.info b/ldap-useradmin/config.info index bff12a911..7f300e67b 100644 --- a/ldap-useradmin/config.info +++ b/ldap-useradmin/config.info @@ -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 diff --git a/ldap-useradmin/edit_group.cgi b/ldap-useradmin/edit_group.cgi index 8936b9894..5de5d0bb2 100755 --- a/ldap-useradmin/edit_group.cgi +++ b/ldap-useradmin/edit_group.cgi @@ -48,7 +48,14 @@ print " $text{'gedit_group'}\n"; print "\n"; print "$text{'gedit_gid'}\n"; -if ($in{'new'}) { +if ($in{'new'} && $config{'next_gid'}) { + # Next GID comes from module config + print "\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); diff --git a/ldap-useradmin/edit_user.cgi b/ldap-useradmin/edit_user.cgi index 9380f38f0..d229f92e5 100755 --- a/ldap-useradmin/edit_user.cgi +++ b/ldap-useradmin/edit_user.cgi @@ -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 "$text{'uid'}\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 " \n"; } else {