[gnome-system-tools] Fix handling of non-existent profile groups



commit 771b4ad2f7e6b128b013e5882ff9ae1f396c7f8f
Author: Milan Bouchet-Valat <nalimilan club fr>
Date:   Mon Mar 8 20:08:24 2010 +0100

    Fix handling of non-existent profile groups
    
    When groups are part of a user profile, but don't exist on the system, we must ignore them. Fix a leak by the way.

 src/users/user-profiles.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/src/users/user-profiles.c b/src/users/user-profiles.c
index 31c7d77..1ec01af 100644
--- a/src/users/user-profiles.c
+++ b/src/users/user-profiles.c
@@ -312,14 +312,18 @@ gst_user_profiles_get_for_user (GstUserProfiles *profiles,
 			}
 
 			group = oobs_groups_config_get_from_name (groups_config, (char *) m->data);
+
+			/* Non-existent groups are not considered as breaking match */
+			if (!group)
+				continue;
+
 			in_group = oobs_user_is_in_group (user, group);
 			if ((in_profile && !in_group) || (!in_profile && in_group)) {
 				matched_groups = FALSE;
 				break;
 			}
 
-			if (group)
-				g_object_unref (group);
+			g_object_unref (group);
 		}
 
 		/* stop at first match, since the list has been reverted on loading,
@@ -376,10 +380,17 @@ gst_user_profiles_apply (GstUserProfiles *profiles,
 		}
 
 		group = oobs_groups_config_get_from_name (groups_config, (char *) l->data);
+
+		/* Non-existent groups are simply skipped */
+		if (!group)
+			continue;
+
 		if (in_profile)
 			oobs_group_add_user (group, user);
 		else
 			oobs_group_remove_user (group, user);
+
+		g_object_unref (group);
 	}
 
 	/* default shell */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]