diff options
Diffstat (limited to 'lib/AdminPanel')
-rw-r--r-- | lib/AdminPanel/Module/Users.pm | 25 | ||||
-rw-r--r-- | lib/AdminPanel/Shared/Users.pm | 20 |
2 files changed, 27 insertions, 18 deletions
diff --git a/lib/AdminPanel/Module/Users.pm b/lib/AdminPanel/Module/Users.pm index cf709426..a238b7a0 100644 --- a/lib/AdminPanel/Module/Users.pm +++ b/lib/AdminPanel/Module/Users.pm @@ -571,7 +571,7 @@ sub _addGroupDialog { $hbox = $factory->createHBox($align); my $gidManually = $factory->createCheckBox($hbox, $self->loc->N("Specify group ID manually"), 0); $factory->createHSpacing($hbox, 2); - my $GID = $factory->createIntField($hbox, $self->loc->N("GID"), 1, 65000, 500); + my $GID = $factory->createIntField($hbox, $self->loc->N("GID"), 1, 65000, $self->sh_users->min_GID); $GID->setEnabled($gidManually->value()); $gidManually->setNotify(1); @@ -608,12 +608,15 @@ sub _addGroupDialog { $continue = 0; } - my $gid = 0; + my $gid = -1; if ($continue && $gidManually->value()) { - if (($gid = $GID->value()) < 500) { + if (($gid = $GID->value()) < $self->sh_users->min_GID) { $errorString = ""; - my $gidchoice = $self->sh_gui->ask_YesOrNo({ title => $self->loc->N(" Group Gid is < 500"), - text => $self->loc->N("Creating a group with a GID less than 500 is not recommended.\n Are you sure you want to do this?\n\n")}); + my $gidchoice = $self->sh_gui->ask_YesOrNo({ title => $self->loc->N(" Group Gid is < %n", $self->sh_users->min_GID), + text => $self->loc->N("Creating a group with a GID less than %d is not recommended.\n Are you sure you want to do this?\n\n", + $self->sh_users->min_GID + ) + }); $continue = $gidchoice; } else { if ($self->sh_users->groupIDExists($gid)) { @@ -632,11 +635,12 @@ sub _addGroupDialog { } else { Sys::Syslog::syslog('info|local1', $self->loc->N("Adding group: %s ", $groupname)); - $self->sh_users->addGroup({ + my $groupParams = { groupname => $groupname, - gid => $gid, is_system => $is_system, - }); + }; + $groupParams->{gid} = $gid if $gid != -1; + $self->sh_users->addGroup($groupParams); $self->_refresh(); last; } @@ -1185,9 +1189,6 @@ sub _refreshGroups { my $strfilt = $self->get_widget('filter')->value(); my $filtergroups = $self->get_widget('filter_system')->isChecked(); - my $groups; - defined $self->sh_users->ctx and $groups = $self->sh_users->ctx->GroupsEnumerateFull; - $self->dialog->startMultipleChanges(); #for some reasons QT send an event using table->selectItem() # WA remove notification immediate @@ -1196,7 +1197,7 @@ sub _refreshGroups { my $groupInfo = $self->sh_users->getGroupsInfo({ groupname_filter => $strfilt, - filter_system => $filtergroups, + filter_system => $filtergroups, }); my $itemColl = new yui::YItemCollection; diff --git a/lib/AdminPanel/Shared/Users.pm b/lib/AdminPanel/Shared/Users.pm index bfce0e7b..1c5b6a4f 100644 --- a/lib/AdminPanel/Shared/Users.pm +++ b/lib/AdminPanel/Shared/Users.pm @@ -149,7 +149,7 @@ sub _USERInitialize { return undef; } -## min UID was 500 now is 1000, let's change in a single point +## min (custom) UID was 500 now is 1000, let's change in a single point has 'min_UID' => ( default => 1000, is => 'ro', @@ -157,6 +157,14 @@ has 'min_UID' => ( init_arg => undef, ); +## min (custom) GID was 500 now should be 1000 as for users +has 'min_GID' => ( + default => 1000, + is => 'ro', + isa => 'Int', + init_arg => undef, +); + #============================================================= =head2 BUILD @@ -729,10 +737,10 @@ sub getGroupsInfo { my $groups = $self->ctx->GroupsEnumerateFull; my @GroupReal; - LOOP: foreach my $g (@$groups) { - next LOOP if $filtergroups && $g->Gid($self->USER_GetValue) <= 499 || $g->Gid($self->USER_GetValue) == 65534; - - if ($filtergroups && $g->Gid($self->USER_GetValue) > 499 && $g->Gid($self->USER_GetValue) < 1000) { + LOOP: foreach my $g (@{$groups}) { + my $gid = $g->Gid($self->USER_GetValue); + next LOOP if $filtergroups && $gid <= 499 || $gid == 65534; + if ($filtergroups && $gid > 499 && $gid < $self->min_GID) { my $groupname = $g->GroupName($self->USER_GetValue); my $l = $self->ctx->LookupUserByName($groupname); if (!defined($l)) { @@ -811,7 +819,7 @@ sub getUsersInfo { $users = $self->ctx->UsersEnumerateFull; my @UserReal; - LOOP: foreach my $l (@$users) { + LOOP: foreach my $l (@{$users}) { next LOOP if $filterusers && $l->Uid($self->USER_GetValue) <= 499 || $l->Uid($self->USER_GetValue) == 65534; next LOOP if $filterusers && $l->Uid($self->USER_GetValue) > 499 && $l->Uid($self->USER_GetValue) < $self->min_UID && ($l->HomeDir($self->USER_GetValue) =~ /^\/($|var\/|run\/)/ || $l->LoginShell($self->USER_GetValue) =~ /(nologin|false)$/); |