[system-tools-backends-clone] Check for changes before applying group changes
- From: Milan Bouchet-Valat <milanbv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [system-tools-backends-clone] Check for changes before applying group changes
- Date: Sun, 14 Mar 2010 15:36:57 +0000 (UTC)
commit 475e95c7c18181b82a51ca67fb0caecc5d8083e6
Author: Milan Bouchet-Valat <nalimilan club fr>
Date: Sun Mar 14 15:41:44 2010 +0100
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.
Users/Groups.pm | 29 ++++++++++++++++++-----------
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]))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]