[gnome-system-tools] Enable account password (un)locking



commit 358aa0698170a252d934455fbf688a61f7fa41f5
Author: Milan Bouchet-Valat <nalimilan club fr>
Date:   Mon Mar 8 19:43:51 2010 +0100

    Enable account password (un)locking
    
    Support for this is in the backends 2.9.4. This is particularly useful for new accounts for which no password has been set, in which case accounts are disabled, so we need a visual notice and a way to enable them. Enabling accounts with an empty password requires setting a new password, which is not supported through the Advanced Settings dialog ATM.

 configure.in              |    2 +-
 interfaces/users.ui       |    7 +++--
 src/users/user-password.c |    8 ++++--
 src/users/user-settings.c |   46 +++++++++++++-------------------------------
 4 files changed, 24 insertions(+), 39 deletions(-)
---
diff --git a/configure.in b/configure.in
index 5aedd3b..22e66cd 100644
--- a/configure.in
+++ b/configure.in
@@ -28,7 +28,7 @@ AC_PROG_MAKE_SET
 dnl glib-genmarshal
 AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
 
-STB_REQUIRED=2.8
+STB_REQUIRED=2.9.4
 LIBOOBS_REQUIRED=2.29.91
 GTK_REQUIRED=2.16
 GLIB_REQUIRED=2.15.2
diff --git a/interfaces/users.ui b/interfaces/users.ui
index 87b1c6f..3066105 100644
--- a/interfaces/users.ui
+++ b/interfaces/users.ui
@@ -376,7 +376,7 @@
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
                 <property name="use_underline">True</property>
-                <signal name="clicked" handler="on_user_settings_enable_account"/>
+                <signal name="clicked" handler="on_edit_user_passwd"/>
               </object>
               <packing>
                 <property name="left_attach">2</property>
@@ -3034,6 +3034,7 @@
                         <child>
                           <object class="GtkCheckButton" id="user_settings_locked_account">
                             <property name="label" translatable="yes">Disable _account</property>
+                            <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="receives_default">False</property>
                             <property name="use_underline">True</property>
@@ -3280,9 +3281,9 @@
   <object class="GtkSizeGroup" id="user_new_notice_sizegroup">
     <property name="mode">both</property>
     <widgets>
-      <widget name="user_new_login_notice"/>
-      <widget name="user_new_login_used_notice"/>
       <widget name="user_new_login_letter_notice"/>
+      <widget name="user_new_login_used_notice"/>
+      <widget name="user_new_login_notice"/>
     </widgets>
   </object>
 </interface>
diff --git a/src/users/user-password.c b/src/users/user-password.c
index 12a2ea0..11de826 100644
--- a/src/users/user-password.c
+++ b/src/users/user-password.c
@@ -51,9 +51,6 @@ void on_user_settings_passwd_toggled      (GtkToggleButton *toggle,
 void on_passwd_entry_changed              (GtkWidget *entry,
                                            gpointer   user_data);
 
-void on_edit_user_passwd                  (GtkButton *button,
-                                           gpointer   user_data);
-
 gboolean on_user_passwd_current_focus_out (GtkWidget *entry,
                                            GdkEventFocus *event,
                                            gpointer user_data);
@@ -371,6 +368,11 @@ finish_password_change ()
 
 	/* We know we've set a non-empty password */
 	oobs_user_set_password_empty (user, FALSE);
+
+	/* Unlock account, this may not be what is wanted, but that's the only solution
+	 * since 'passwd' doesn't differentiate accounts with no passwords yet from disabled ones */
+	oobs_user_set_password_disabled (user, FALSE);
+
 	user_settings_show (user);
 
 	gst_dialog_remove_edit_dialog (tool->main_dialog, GTK_WIDGET (user_passwd_dialog));
diff --git a/src/users/user-settings.c b/src/users/user-settings.c
index aa21210..25e5e94 100644
--- a/src/users/user-settings.c
+++ b/src/users/user-settings.c
@@ -601,37 +601,6 @@ check_profile (OobsUser *user, GstUserProfile *profile)
 }
 
 /*
- * Callback for user_settings_enable_account: unlock account and commit changes.
- */
-void
-on_user_settings_enable_account  (GtkButton *enable_button,
-                                  gpointer   user_data)
-{
-	GtkWidget *disabled_image;
-	GtkWidget *disabled_label;
-	OobsUser *user;
-
-	if (!gst_tool_authenticate (tool, GST_USERS_TOOL (tool)->users_config))
-		return;
-
-	user = users_table_get_current ();
-	oobs_user_set_password_disabled (user, FALSE);
-
-	if (gst_tool_commit (tool, OOBS_OBJECT (user)) == OOBS_RESULT_OK) {
-		disabled_image = gst_dialog_get_widget (tool->main_dialog,
-		                                        "user_settings_disabled_account_image");
-		disabled_label = gst_dialog_get_widget (tool->main_dialog,
-		                                        "user_settings_disabled_account");
-
-		gtk_widget_hide (disabled_image);
-		gtk_widget_hide (disabled_label);
-		gtk_widget_hide (GTK_WIDGET (enable_button));
-	}
-
-	g_object_unref (user);
-}
-
-/*
  * Callback for user_new_name entry: on every change, fill the combo entry
  * with proposed logins. Also update validate button's sensitivity if name is empty.
  */
@@ -988,6 +957,10 @@ on_user_new (GtkButton *button, gpointer user_data)
 	oobs_user_set_encrypted_home (user, encrypt);
 	oobs_user_set_home_flags (user, OOBS_USER_CHOWN_HOME);
 
+	/* Emptying password and disabling account allows enabling it more easily if asked */
+	oobs_user_set_password_empty (user, TRUE);
+	oobs_user_set_password_disabled (user, TRUE);
+
 	/* If the user group already exists and /etc/adduser.conf USERGROUPS option is yes,
 	 * then adduser will fail, and the backends don't allow reporting that error.
 	 * So assume we want the user to be in that group. */
@@ -1263,6 +1236,10 @@ on_edit_user_advanced (GtkButton *button, gpointer user_data)
 	widget = gst_dialog_get_widget (tool->main_dialog, "user_settings_uid");
 	gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), oobs_user_get_uid (user));
 
+	widget = gst_dialog_get_widget (tool->main_dialog, "user_settings_locked_account");
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), oobs_user_get_password_disabled (user));
+
+
 	/* show a notice if the user is logged in */
 	uid_notice = gst_dialog_get_widget (tool->main_dialog, "user_settings_uid_disabled");
 
@@ -1315,6 +1292,9 @@ on_edit_user_advanced (GtkButton *button, gpointer user_data)
 	widget = gst_dialog_get_widget (tool->main_dialog, "user_settings_uid");
 	oobs_user_set_uid (user, gtk_spin_button_get_value (GTK_SPIN_BUTTON (widget)));
 
+	widget = gst_dialog_get_widget (tool->main_dialog, "user_settings_locked_account");
+	oobs_user_set_password_disabled (user, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)));
+
 	privileges_table_save (user);
 
 	/* Get main group */
@@ -1332,8 +1312,10 @@ on_edit_user_advanced (GtkButton *button, gpointer user_data)
 		oobs_user_set_main_group (user, NULL);
 
 
-	if (gst_tool_commit (tool, OOBS_OBJECT (user)) == OOBS_RESULT_OK)
+	if (gst_tool_commit (tool, OOBS_OBJECT (user)) == OOBS_RESULT_OK) {
 		gst_tool_commit (tool, GST_USERS_TOOL (tool)->groups_config);
+		user_settings_show (user);
+	}
 
 	g_object_unref (user);
 }



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