Re: [system-tools] Allowing password-less connexions



Will somebody answer ? ;-)

Wiating for comments, I made a second version so that:
- I use Glade 2 and provide a clean patch for the GUI
- I only use GConf to enable/disable the password-less feature (not for
the name of the group, which is hard-coded)

Cheers
Index: interfaces/users.glade
===================================================================
--- interfaces/users.glade	(révision 4234)
+++ interfaces/users.glade	(copie de travail)
@@ -1213,7 +1213,7 @@
 	      <child>
 		<widget class="GtkTable" id="table50">
 		  <property name="visible">True</property>
-		  <property name="n_rows">7</property>
+		  <property name="n_rows">8</property>
 		  <property name="n_columns">4</property>
 		  <property name="homogeneous">False</property>
 		  <property name="row_spacing">6</property>
@@ -1459,34 +1459,6 @@
 		  </child>
 
 		  <child>
-		    <widget class="GtkLabel" id="label237">
-		      <property name="visible">True</property>
-		      <property name="label" translatable="yes"></property>
-		      <property name="use_underline">False</property>
-		      <property name="use_markup">False</property>
-		      <property name="justify">GTK_JUSTIFY_LEFT</property>
-		      <property name="wrap">False</property>
-		      <property name="selectable">False</property>
-		      <property name="xalign">0</property>
-		      <property name="yalign">0.5</property>
-		      <property name="xpad">0</property>
-		      <property name="ypad">0</property>
-		      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
-		      <property name="width_chars">-1</property>
-		      <property name="single_line_mode">False</property>
-		      <property name="angle">0</property>
-		    </widget>
-		    <packing>
-		      <property name="left_attach">0</property>
-		      <property name="right_attach">1</property>
-		      <property name="top_attach">1</property>
-		      <property name="bottom_attach">7</property>
-		      <property name="x_options">fill</property>
-		      <property name="y_options"></property>
-		    </packing>
-		  </child>
-
-		  <child>
 		    <widget class="GtkLabel" id="label238">
 		      <property name="visible">True</property>
 		      <property name="label" translatable="yes"></property>
@@ -1608,6 +1580,57 @@
 		      <property name="y_options"></property>
 		    </packing>
 		  </child>
+
+		  <child>
+		    <widget class="GtkCheckButton" id="user_passwd_passwdless">
+		      <property name="visible">True</property>
+		      <property name="can_focus">True</property>
+		      <property name="label" translatable="yes">Don't ask for password at _login</property>
+		      <property name="use_underline">True</property>
+		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
+		      <property name="active">False</property>
+		      <property name="sensitive">False</property>
+		      <property name="inconsistent">False</property>
+		      <property name="draw_indicator">True</property>
+		    </widget>
+		    <packing>
+		      <property name="left_attach">1</property>
+		      <property name="right_attach">4</property>
+		      <property name="top_attach">7</property>
+		      <property name="bottom_attach">8</property>
+		      <property name="x_options">fill</property>
+		      <property name="y_options"></property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkLabel" id="label237">
+		      <property name="visible">True</property>
+		      <property name="label" translatable="yes"></property>
+		      <property name="use_underline">False</property>
+		      <property name="use_markup">False</property>
+		      <property name="justify">GTK_JUSTIFY_LEFT</property>
+		      <property name="wrap">False</property>
+		      <property name="selectable">False</property>
+		      <property name="xalign">0</property>
+		      <property name="yalign">0.5</property>
+		      <property name="xpad">0</property>
+		      <property name="ypad">0</property>
+		      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+		      <property name="width_chars">-1</property>
+		      <property name="single_line_mode">False</property>
+		      <property name="angle">0</property>
+		    </widget>
+		    <packing>
+		      <property name="left_attach">0</property>
+		      <property name="right_attach">1</property>
+		      <property name="top_attach">1</property>
+		      <property name="bottom_attach">8</property>
+		      <property name="x_options">fill</property>
+		      <property name="y_options"></property>
+		    </packing>
+		  </child>
 		</widget>
 		<packing>
 		  <property name="padding">0</property>
Index: src/users/privileges-table.c
===================================================================
--- src/users/privileges-table.c	(révision 4234)
+++ src/users/privileges-table.c	(copie de travail)
@@ -219,29 +219,6 @@
 	}
 }
 
-static gboolean
-find_group_in_profile (OobsGroup      *group,
-		       GstUserProfile *profile)
-{
-	gchar **groups;
-	const gchar *name;
-
-	if (!profile->groups)
-		return FALSE;
-
-	groups = profile->groups;
-	name = oobs_group_get_name (group);
-
-	while (*groups) {
-		if (strcmp (*groups, name) == 0)
-			return TRUE;
-
-		groups++;
-	}
-
-	return FALSE;
-}
-
 void
 privileges_table_set_from_profile (GstUserProfile *profile)
 {
@@ -262,7 +239,7 @@
 				    -1);
 
 		gtk_list_store_set (GTK_LIST_STORE (child_model), &iter,
-				    COL_MEMBER, find_group_in_profile (group, profile),
+				    COL_MEMBER, gst_user_profiles_find_group (group, profile),
 				    -1);
 
 		valid = gtk_tree_model_iter_next (child_model, &iter);
Index: src/users/user-profiles.c
===================================================================
--- src/users/user-profiles.c	(révision 4234)
+++ src/users/user-profiles.c	(copie de travail)
@@ -202,3 +202,26 @@
 
 	return priv->default_profile;
 }
+
+gboolean
+gst_user_profiles_find_group (OobsGroup      *group,
+		              GstUserProfile *profile)
+{
+	gchar **groups;
+	const gchar *name;
+
+	if (!profile->groups)
+		return FALSE;
+
+	groups = profile->groups;
+	name = oobs_group_get_name (group);
+
+	while (*groups) {
+		if (strcmp (*groups, name) == 0)
+			return TRUE;
+
+		groups++;
+	}
+
+	return FALSE;
+}
Index: src/users/user-profiles.h
===================================================================
--- src/users/user-profiles.h	(révision 4234)
+++ src/users/user-profiles.h	(copie de travail)
@@ -68,6 +68,8 @@
 						const gchar     *profile);
 GstUserProfile*  gst_user_profiles_get_current (GstUserProfiles *profiles);
 GstUserProfile*  gst_user_profiles_get_default_profile (GstUserProfiles *profiles);
+gboolean         gst_user_profiles_find_group (OobsGroup        *group,
+		                                       GstUserProfile   *profile);
 
 
 G_END_DECLS
Index: src/users/user-settings.c
===================================================================
--- src/users/user-settings.c	(révision 4234)
+++ src/users/user-settings.c	(copie de travail)
@@ -312,6 +312,7 @@
 user_settings_dialog_new (OobsUser *user)
 {
 	OobsUsersConfig *config;
+	OobsGroup passwdless_group;
 	GtkWidget *dialog, *widget;
 	const gchar *login = NULL;
 	gchar *title;
@@ -389,6 +390,15 @@
 	widget = gst_dialog_get_widget (tool->main_dialog, "user_passwd_manual");
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
 
+	/* set password-less login */
+	if (gstconf_get_bool (users, "enable_passwordless")) {
+		widget = gst_dialog_get_widget (tool->main_dialog, "user_passwd_passwdless");
+		gtk_widget_set_sensitive (widget, TRUE);
+		passwdless_group = oobs_group_new (PASSWDLESS_GROUP);
+		if (gst_profile_find_group (passwdless_group, user)
+			gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(widget), TRUE);
+	}
+
 	if (!login)
 		table_set_default_profile (GST_USERS_TOOL (tool));
 
@@ -638,6 +648,7 @@
 {
 	GtkWidget *widget;
 	OobsGroup *group;
+	OobsGroup *passwdless_group;
 	OobsUser *user;
 	const gchar *str;
 	gboolean password_changed;
@@ -690,6 +701,15 @@
 		oobs_user_set_password (user, gtk_entry_get_text (GTK_ENTRY (widget)));
 	}
 
+	/* allowed to login without password? */
+	widget = gst_dialog_get_widget (tool->main_dialog, "user_passwd_passwdless");
+	passwdless_group = oobs_group_new (PASSWDLESS_GROUP);
+	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)))
+		oobs_group_add_user (passwdless_group, user);
+	else
+		oobs_group_remove_user (passwdless_group, user);
+	}
+
 	group = get_main_group (oobs_user_get_login_name (user));
 	oobs_user_set_main_group (user, group);
 	g_object_unref (group);
Index: src/users/user-settings.h
===================================================================
--- src/users/user-settings.h	(révision 4234)
+++ src/users/user-settings.h	(copie de travail)
@@ -24,6 +24,8 @@
 #ifndef __USER_SETTINGS_H
 #define __USER_SETTINGS_H
 
+#define PASSWDLESS_GROUP "passwordless"
+
 gboolean        user_delete                      (GtkTreeModel *model,
 						  GtkTreePath *path);
 GtkWidget *     user_settings_dialog_new         (OobsUser *user);


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