summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilan Bouchet-Valat <nalimilan@club.fr>2010-03-14 15:41:44 +0100
committerMilan Bouchet-Valat <nalimilan@club.fr>2010-03-14 16:13:08 +0100
commit475e95c7c18181b82a51ca67fb0caecc5d8083e6 (patch)
tree77dc5edc4ad271f656e5e118a96874d0860cf179
parent2465d52331c70736db1c5fadbc98efae75f7d0ae (diff)
Check for changes before applying group changes
A simple check before running an external command to modify groups makes the whole process of committing GroupsConfig much quicker.
-rw-r--r--Users/Groups.pm29
1 files changed, 18 insertions, 11 deletions
diff --git a/Users/Groups.pm b/Users/Groups.pm
index aba40f3..da492ad 100644
--- a/Users/Groups.pm
+++ b/Users/Groups.pm
@@ -176,23 +176,30 @@ sub change_group
if ($Utils::Backend::tool{"system"} eq "FreeBSD")
{
- $users_arr = $$new_group[$USERS];
- $str = join (",", sort @$users_arr);
+ if (($$old_group[$GID] != $$new_group[$GID]) || ($$old_group[$LOGIN] ne $$new_group[$LOGIN])
+ || !Utils::Util::struct_eq ($$new_group[$USERS], $$old_group[$USERS]))
+ {
+ $users_arr = $$new_group[$USERS];
+ $str = join (",", sort @$users_arr);
- @command = ($cmd_pw, "groupmod", "-n", $$old_group[$LOGIN],
- "-g", $$new_group[$GID],
- "-l", $$new_group[$LOGIN],
- "-M", $str);
+ @command = ($cmd_pw, "groupmod", "-n", $$old_group[$LOGIN],
+ "-g", $$new_group[$GID],
+ "-l", $$new_group[$LOGIN],
+ "-M", $str);
- &Utils::File::run (@command);
+ &Utils::File::run (@command);
+ }
}
else
{
- @command = ($cmd_groupmod, "-g", $$new_group[$GID],
- "-n", $$new_group[$LOGIN],
- $$old_group[$LOGIN]);
+ if (($$old_group[$GID] != $$new_group[$GID]) || ($$old_group[$LOGIN] ne $$new_group[$LOGIN]))
+ {
+ @command = ($cmd_groupmod, "-g", $$new_group[$GID],
+ "-n", $$new_group[$LOGIN],
+ $$old_group[$LOGIN]);
- &Utils::File::run (@command);
+ &Utils::File::run (@command);
+ }
# Let's see if the users that compose the group have changed.
if (!Utils::Util::struct_eq ($$new_group[$USERS], $$old_group[$USERS]))