[gnome-system-tools] Bug 395056 - Prevent changing UID of logged users and root, show a notice



commit 47f51819808cdada015c480f81bc5664a9cae4e5
Author: Milan Bouchet-Valat <nalimilan club fr>
Date:   Thu Aug 20 17:56:37 2009 +0200

    Bug 395056 - Prevent changing UID of logged users and root, show a notice
    
    Changing the UID while users are connected is authorized, but likely to create problems. Disable it, but explain why. Also, root's UID should not be editable. And don't show the notice if permissions aren't set.

 interfaces/users.ui       |   51 ++++++++++++++++++++++++++++++++++++++++++++-
 src/users/user-settings.c |   19 +++++++++++++++-
 2 files changed, 68 insertions(+), 2 deletions(-)
---
diff --git a/interfaces/users.ui b/interfaces/users.ui
index 24b22b7..db2e0e3 100644
--- a/interfaces/users.ui
+++ b/interfaces/users.ui
@@ -1114,7 +1114,7 @@
                 <child>
                   <object class="GtkTable" id="table53">
                     <property name="visible">True</property>
-                    <property name="n_rows">5</property>
+                    <property name="n_rows">6</property>
                     <property name="n_columns">3</property>
                     <property name="column_spacing">12</property>
                     <property name="row_spacing">6</property>
@@ -1264,6 +1264,55 @@
                         <property name="y_options"></property>
                       </packing>
                     </child>
+                    <child>
+                      <object class="GtkLabel" id="label1">
+                        <property name="visible">True</property>
+                        <property name="xalign">0</property>
+                      </object>
+                      <packing>
+                        <property name="top_attach">5</property>
+                        <property name="bottom_attach">6</property>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options"></property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkHBox" id="user_settings_uid_disabled">
+                        <property name="visible">True</property>
+                        <property name="spacing">6</property>
+                        <child>
+                          <object class="GtkImage" id="image1">
+                            <property name="visible">True</property>
+                            <property name="xalign">1</property>
+                            <property name="stock">gtk-info</property>
+                            <property name="icon-size">2</property>
+                          </object>
+                          <packing>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkLabel" id="label2">
+                            <property name="visible">True</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes">User must log out before you can change his ID.</property>
+                            <attributes>
+                              <attribute name="style" value="italic"/>
+                            </attributes>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">3</property>
+                        <property name="top_attach">5</property>
+                        <property name="bottom_attach">6</property>
+                      </packing>
+                    </child>
                   </object>
                   <packing>
                     <property name="expand">False</property>
diff --git a/src/users/user-settings.c b/src/users/user-settings.c
index ba03eaf..41f6d02 100644
--- a/src/users/user-settings.c
+++ b/src/users/user-settings.c
@@ -373,7 +373,7 @@ user_settings_dialog_new (OobsUser *user)
 {
 	OobsUsersConfig *config;
 	OobsGroup *no_passwd_login_group;
-	GtkWidget *dialog, *widget;
+	GtkWidget *dialog, *widget, *notice;
 	const gchar *login = NULL;
 	gchar *title;
 	gint uid;
@@ -408,7 +408,24 @@ user_settings_dialog_new (OobsUser *user)
 		set_entry_text (GTK_BIN (widget)->child, oobs_user_get_shell (user));
 
 		widget = gst_dialog_get_widget (tool->main_dialog, "user_settings_uid");
+		notice = gst_dialog_get_widget (tool->main_dialog, "user_settings_uid_disabled");
 		gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), oobs_user_get_uid (user));
+		/* Show a notice if the user is logged in,
+		 * except if we don't have the required permissions to edit UID anyway */
+		if (is_user_root (user)) {
+			gst_dialog_try_set_sensitive (tool->main_dialog,widget, FALSE);
+			gtk_widget_hide (notice);
+		}
+		else if (oobs_user_get_active (user) &&
+			 gst_dialog_is_authenticated (tool->main_dialog)) {
+			gst_dialog_try_set_sensitive (tool->main_dialog,widget, FALSE);
+			gtk_widget_show (notice);
+		}
+		else {
+			gst_dialog_try_set_sensitive (tool->main_dialog, widget, TRUE);
+			gtk_widget_hide (notice);
+		}
+
 		setup_profiles_visibility (tool, FALSE);
 	}
 



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