kov changed libgksu/branches/libgksu2/ChangeLog, libgksu/branches/libgksu2/gksu.schemas.in, libgksu/branches/libgksu2/libgksu/ChangeLog, libgksu/branches/libgksu2/libgksu/libgksu.c

Gustavo Noronha kov at costa.debian.org
Mon Dec 12 00:32:57 UTC 2005


Mensagem de log: 
	* gksu.schemas.in:
	- remove always-ask-password for now, it will probably be
	  replaced by something else when gnome-keyring is integrated

	* libgksu.c:
	- integrated 'prompt before grab' support; also make the
	  foce-grab configuration effective


-----


Modified: libgksu/branches/libgksu2/ChangeLog
===================================================================
--- libgksu/branches/libgksu2/ChangeLog	2005-12-12 00:02:26 UTC (rev 490)
+++ libgksu/branches/libgksu2/ChangeLog	2005-12-12 00:32:56 UTC (rev 491)
@@ -1,5 +1,9 @@
 2005-12-11  Gustavo Noronha Silva  <kov at debian.org>
 
+	* gksu.schemas.in:
+	- remove always-ask-password for now, it will probably be
+	  replaced by something else when gnome-keyring is integrated
+
 	* intltoolized, modified some stuff for the package
 	  renaming to work
 

Modified: libgksu/branches/libgksu2/gksu.schemas.in
===================================================================
--- libgksu/branches/libgksu2/gksu.schemas.in	2005-12-12 00:02:26 UTC (rev 490)
+++ libgksu/branches/libgksu2/gksu.schemas.in	2005-12-12 00:32:56 UTC (rev 491)
@@ -66,23 +66,6 @@
       </schema>
 
       <schema>
-      <key>/schemas/apps/gksu/always-ask-password</key>
-      <applyto>/apps/gksu/prompt</applyto>
-      <owner>gksu</owner>
-      <type>bool</type>
-      <default>false</default>
-      <locale name="C">
-	<short>Always request a password</short>
-	<long>
-	This option will prevent gksu from trying to figure out if a
-	password is needed to run the command, or if it can be obtained
-	through	other ways, such as gnome-keyring, making it simply ask
-	for the password every time.
-	</long>
-      </locale>
-      </schema>
-
-      <schema>
       <key>/schemas/apps/gksu/display-no-pass-info</key>
       <applyto>/apps/gksu/display-no-pass-info</applyto>
       <owner>gksu</owner>
@@ -130,4 +113,4 @@
       </schema>
 
   </schemalist>  
-</gconfschemafile>
\ No newline at end of file
+</gconfschemafile>

Modified: libgksu/branches/libgksu2/libgksu/ChangeLog
===================================================================
--- libgksu/branches/libgksu2/libgksu/ChangeLog	2005-12-12 00:02:26 UTC (rev 490)
+++ libgksu/branches/libgksu2/libgksu/ChangeLog	2005-12-12 00:32:56 UTC (rev 491)
@@ -1,5 +1,9 @@
 2005-12-11  Gustavo Noronha Silva  <kov at debian.org>
 
+	* libgksu.c:
+	- integrated 'prompt before grab' support; also make the
+	  foce-grab configuration effective
+
 	* renaming files:
 	- gksu-context.{c,h} -> libgksu.{c,h}
 

Modified: libgksu/branches/libgksu2/libgksu/libgksu.c
===================================================================
--- libgksu/branches/libgksu2/libgksu/libgksu.c	2005-12-12 00:02:26 UTC (rev 490)
+++ libgksu/branches/libgksu2/libgksu/libgksu.c	2005-12-12 00:32:56 UTC (rev 491)
@@ -44,12 +44,7 @@
 #define BASE_PATH "/apps/gksu/"
 
 /* GLOBALS */
-gboolean print_pass = FALSE;
-gboolean force_grab = FALSE;
-gboolean grab = TRUE;
 gboolean message_changed = FALSE;
-gboolean prompt = FALSE;
-gboolean always_ask_pass = FALSE;
 
 GType
 gksu_error_get_type (void)
@@ -286,22 +281,21 @@
 get_configuration_options (GksuContext *context)
 {
   GConfClient *gconf_client = context->gconf_client;
+  gboolean force_grab;
 
-  grab = !gconf_client_get_bool (gconf_client, BASE_PATH "disable-grab",
-				 NULL);
+  context->grab = !gconf_client_get_bool (gconf_client, BASE_PATH "disable-grab",
+					  NULL);
   force_grab = gconf_client_get_bool (gconf_client, BASE_PATH "force-grab",
 				      NULL);
+  if (force_grab)
+    context->grab = TRUE;
+
   context->sudo_mode = gconf_client_get_bool (gconf_client, BASE_PATH "sudo-mode",
 					      NULL);
-  prompt = gconf_client_get_bool (gconf_client, BASE_PATH "prompt",
-				  NULL);
-  always_ask_pass = gconf_client_get_bool (gconf_client,
-					   BASE_PATH "always-ask-password",
-					   NULL);
 }
 
 /**
- * gksuui_ask_password:
+ * su_ask_password:
  * @context: a #GksuContext
  * @prompt: the prompt that should be used instead of "Password: "
  * @grab: should the X keyboard and mouse inputs be grabbed
@@ -317,11 +311,12 @@
 		 gpointer data, GError **error)
 {
   GtkWidget *dialog = NULL;
+  gchar *msg;
   gchar *password = NULL, *tmp = NULL;
-
   int retvalue = 0;
+  int lock = 0;
 
-  if (grab)
+  if (context->grab)
     dialog = g_object_new (GKSUUI_TYPE_DIALOG,
 			   "type", GTK_WINDOW_POPUP,
 			   NULL);
@@ -331,31 +326,26 @@
   if (prompt)
     gksuui_dialog_set_prompt (GKSUUI_DIALOG(dialog), prompt);
 
-  if (!message_changed)
-    {
-      gchar *msg;
 
-      if (context->sudo_mode)
-	msg = g_strdup_printf (_("<b>Please enter your password\n"
-				 "to run %s as user %s</b>"),
-			       context->command,
-			       context->user);
-      else
-	msg = g_strdup_printf (_("<b>To run the program \"%s\" you need to "
-				 "enter the %s password</b>"),
-			       context->command,
-			       context->user);
+  if (context->sudo_mode)
+    msg = g_strdup_printf (_("<b>Please enter your password\n"
+			     "to run %s as user %s</b>"),
+			   context->command,
+			   context->user);
+  else
+    msg = g_strdup_printf (_("<b>To run the program \"%s\" you need to "
+			     "enter the %s password</b>"),
+			   context->command,
+			   context->user);
 
-      gksuui_dialog_set_message (GKSUUI_DIALOG(dialog), msg);
-      g_free (msg);
-    }
+  gksuui_dialog_set_message (GKSUUI_DIALOG(dialog), msg);
+  g_free (msg);
 
-  int lock = 0;
-  if (grab)
+  if (context->grab)
     lock = grab_keyboard_and_mouse (dialog);
   retvalue = gtk_dialog_run (GTK_DIALOG(dialog));
   gtk_widget_hide (dialog);
-  if (grab)
+  if (context->grab)
     ungrab_keyboard_and_mouse (lock);
 
   while (gtk_events_pending ())
@@ -465,6 +455,28 @@
 }
 
 static void
+gksu_prompt_grab (GksuContext *context)
+{
+  GtkWidget *d;
+
+  d = gtk_message_dialog_new_with_markup (NULL, 0, GTK_MESSAGE_QUESTION,
+					  GTK_BUTTONS_YES_NO,
+					  _("<b>Would you like your screen to be \"grabbed\"\n"
+					    "while you enter the password?</b>"
+					    "\n\n"
+					    "This means all applications will be paused to avoid\n"
+					    "the eavesdropping of your password by a a malicious\n"
+					    "application while you type it."));
+
+  if (gtk_dialog_run (GTK_DIALOG(d)) == GTK_RESPONSE_NO)
+    context->grab = FALSE;
+  else
+    context->grab = TRUE;
+
+  gtk_widget_destroy (d);
+}
+
+static void
 nullify_password (gchar *pass)
 {
   if (pass)
@@ -883,6 +895,12 @@
 	      gchar *password = NULL;
 	      gchar *tmp = NULL;
 
+	      gboolean prompt_grab;
+	      prompt_grab = gconf_client_get_bool (context->gconf_client, BASE_PATH "prompt",
+						   NULL);
+	      if (prompt_grab)
+		gksu_prompt_grab (context);
+
 	      tmp = ask_pass (context, buf, ask_pass_data, error);
 	      g_return_val_if_fail (tmp != NULL, -1);
 
@@ -1334,10 +1352,16 @@
       if (strncmp(buffer, "GNOME_SUDO_PASS", 15) == 0)
 	{
 	  gchar *password = NULL;
+	  gboolean prompt_grab;
 
 	  if (context->debug)
 	    fprintf (stderr, "Yeah, we're in...\n");
 
+	  prompt_grab = gconf_client_get_bool (context->gconf_client, BASE_PATH "prompt",
+						   NULL);
+	  if (prompt_grab)
+	    gksu_prompt_grab (context);
+
 	  password = ask_pass (context, _("Password: "),
 			       ask_pass_data, error);
 	  g_return_val_if_fail (password != NULL, -1);




More information about the gksu-commits mailing list