Index: daemon/ui/gkr-ask-tool.c
===================================================================
--- daemon/ui/gkr-ask-tool.c	(revision 1461)
+++ daemon/ui/gkr-ask-tool.c	(working copy)
@@ -258,18 +258,14 @@
  	return ret == GTK_RESPONSE_ACCEPT;
 }
 
-static void
-on_password_changed (GtkEditable     *editable,
-		     gpointer         user_data)
+static gdouble
+password_strength (const char *password)
 {
-	const char *password;
 	int length;
 	int i;
 	int upper, lower, digit, misc;
 	gdouble pwstrength;
 
-	password = gkr_ask_entry_get_text (GKR_ASK_ENTRY (editable));
-
 	/*
 	 * This code is based on the Master Password dialog in Firefox
 	 * (pref-masterpass.js)
@@ -321,9 +317,21 @@
 		pwstrength = 1.0;
 	}
 
-	gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (user_data), pwstrength);
+	return pwstrength;
 }
 
+static void
+on_password_changed (GtkEditable     *editable,
+		     gpointer         user_data)
+{
+	const char *password;
+
+	password = gkr_ask_entry_get_text (GKR_ASK_ENTRY (editable));
+
+	gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (user_data),
+	                               password_strength (password));
+}
+
 static gboolean
 grab_keyboard (GtkWidget *win, GdkEvent *event, gpointer data)
 {
@@ -389,6 +397,7 @@
 	const char *password, *original, *confirmation;
 	const char *env;
 	int row;
+	gdouble pwstrength;
 
 	value = g_key_file_get_value (input_data, "general", "title", NULL);
 	if (!value)
@@ -547,10 +556,28 @@
 					   confirm,
 					   1, 2, row - 1, row);
 
+		/* Fetch required password strength */
+		pwstrength = g_key_file_get_double (input_data, "general",
+		                                    "password_strength", NULL);
+
+		if (pwstrength < 0.0) {
+			pwstrength = 0.0;
+		}
+
+		if (pwstrength > 1.0) {
+			pwstrength = 1.0;
+		}
+
 		/* Strength bar: */
 		if (entry) {
 			gtk_table_resize (GTK_TABLE (ptable), ++row, 2);
 			strength_bar = gtk_progress_bar_new ();
+			gtk_progress_bar_set_text (GTK_PROGRESS_BAR (strength_bar), _("Required password strength"));
+			gtk_table_attach_defaults (GTK_TABLE (ptable), strength_bar, 1, 2, row - 1, row);
+	                gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (strength_bar), pwstrength);
+
+			gtk_table_resize (GTK_TABLE (ptable), ++row, 2);
+			strength_bar = gtk_progress_bar_new ();
 			gtk_progress_bar_set_text (GTK_PROGRESS_BAR (strength_bar), _("New password strength"));
 			g_signal_connect ((gpointer) entry, "changed", G_CALLBACK (on_password_changed), strength_bar);
 			gtk_table_attach_defaults (GTK_TABLE (ptable), strength_bar, 1, 2, row - 1, row);
@@ -619,24 +646,46 @@
 		*password_out = egg_secure_strdup (password);
 	}
 	
-	/* When it's a new password and blank, double check */
-	if (include_confirm && password && !password[0]) {
-		
-		/* Don't allow blank passwords if in paranoid mode */
-		env = g_getenv ("GNOME_KEYRING_PARANOID");
-		if (env && *env) {
-			notice_text = create_notice (_("Password cannot be blank"));
-			gtk_label_set_markup (notice, notice_text);
-			gtk_widget_show (GTK_WIDGET (notice));
-			g_free (notice_text);
-			goto retry;
-			
-		/* Double check with the user */ 
-		} else if (!confirm_blank_password (GTK_WINDOW (dialog))) {
-			goto retry;
+	/* New password, check it */
+	if (include_confirm && password) {
+		/* Password strength was set, use that */
+		if (pwstrength > 0) {
+			/* Don't allow blank passwords if strength is set */
+			if (!password[0]) {
+				notice_text = create_notice (_("Password cannot be blank"));
+				gtk_label_set_markup (notice, notice_text);
+				gtk_widget_show (GTK_WIDGET (notice));
+				g_free (notice_text);
+				goto retry;
+			}
+
+			/* Reject anything below required strength */
+			if (password_strength (password) < pwstrength) {
+				notice_text = create_notice (_("Password too weak"));
+				gtk_label_set_markup (notice, notice_text);
+				gtk_widget_show (GTK_WIDGET (notice));
+				g_free (notice_text);
+				goto retry;
+			}
 		}
+		/* When it's a new password and blank, double check */
+		else if (!password[0]) {
+			/* Don't allow blank passwords if in paranoid mode */
+			env = g_getenv ("GNOME_KEYRING_PARANOID");
+			if (env && *env) {
+				notice_text = create_notice (_("Password cannot be blank"));
+				gtk_label_set_markup (notice, notice_text);
+				gtk_widget_show (GTK_WIDGET (notice));
+				g_free (notice_text);
+				goto retry;
+				
+			/* Double check with the user */ 
+			} else if (!confirm_blank_password (GTK_WINDOW (dialog))) {
+				goto retry;
+			}
+		}
 	}
-	
+
 	if (check != NULL && response >= GKR_ASK_RESPONSE_ALLOW) {
 		g_key_file_set_boolean (output_data, "check", "check-active", 
 		                        gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)));
