[gnome-system-tools] Check that GID is free before creating/editing groups
- From: Milan Bouchet-Valat <milanbv src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-system-tools] Check that GID is free before creating/editing groups
- Date: Thu, 10 Dec 2009 12:14:01 +0000 (UTC)
commit d5876c24a73f9a85ee9f2d14ba920cb7b203e2db
Author: Milan Bouchet-Valat <nalimilan club fr>
Date: Thu Dec 10 13:08:33 2009 +0100
Check that GID is free before creating/editing groups
Before that, you could create a group with an existing GID, which led the members of the new group to be added to the existing one, which could be dangerous with the root group.
src/users/group-settings.c | 27 +++++++++++++++++++++++++--
1 files changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/src/users/group-settings.c b/src/users/group-settings.c
index 335d1df..b01666e 100644
--- a/src/users/group-settings.c
+++ b/src/users/group-settings.c
@@ -234,16 +234,39 @@ static void
check_gid (gchar **primary_text, gchar **secondary_text, gpointer data)
{
OobsGroup *group = OOBS_GROUP (data);
+ OobsGroupsConfig *config;
+ OobsGroup *gid_group;
GtkWidget *widget;
- gint gid;
+ gid_t gid;
+ gboolean new;
widget = gst_dialog_get_widget (tool->main_dialog, "group_settings_gid");
- gid = gtk_spin_button_get_value (GTK_SPIN_BUTTON (widget));
+ /* we know the value is positive because the range is limited */
+ gid = (unsigned) gtk_spin_button_get_value (GTK_SPIN_BUTTON (widget));
+ new = group_settings_dialog_group_is_new();
+
+ /* don't warn if nothing has changed */
+ if (!new && gid == oobs_group_get_gid (group))
+ return;
+
+ config = OOBS_GROUPS_CONFIG (GST_USERS_TOOL (tool)->groups_config);
+ gid_group = oobs_groups_config_get_from_gid (config, gid);
if (oobs_group_is_root (group) && gid != 0) {
*primary_text = g_strdup (_("Group ID of the Administrator account should not be modified"));
*secondary_text = g_strdup (_("This would leave the system unusable."));
}
+ else if (gid_group) { /* check that GID is free */
+ *primary_text = g_strdup_printf (_("Group ID %d is already used by group \"%s\""),
+ gid, oobs_group_get_name (gid_group));
+ if (new)
+ *secondary_text = g_strdup (_("Please choose a different numeric identifier for the new group."));
+ else
+ *secondary_text = g_strdup_printf (_("Please choose a different numeric identifier for new group \"%s\"."),
+ oobs_group_get_name (group));
+
+ g_object_unref (gid_group);
+ }
}
gint
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]