kov changed libgksu/trunk/ChangeLog, libgksu/trunk/libgksu/Makefile.am, libgksu/trunk/libgksu/libgksu.c, libgksu/trunk/libgksu/libgksu.h

Gustavo Noronha kov at alioth.debian.org
Mon Dec 31 19:05:30 UTC 2007


Mensagem de log: 
accepted patch from mvo with minor aditions by me to add a new functionality: always_ask_password

-----


Modified: libgksu/trunk/ChangeLog
===================================================================
--- libgksu/trunk/ChangeLog	2007-12-31 18:46:36 UTC (rev 811)
+++ libgksu/trunk/ChangeLog	2007-12-31 19:05:28 UTC (rev 812)
@@ -6,6 +6,12 @@
 	  root); thanks to Uwe Kleine-König <ukleinek at informatik.uni-freiburg.de>
 	  for pointing out; Debian bug #449180
 
+	* libgksu/libgksu.c:
+	- accepted patch from Ubuntu by Michael Vogt to add a new
+	  property for GksuContext: always_ask_password; the patch
+	  suffered minor aditions by me to also implement the functionality
+	  to the su backend and document the limitations (Debian bug #453423)
+
 	* libgksuui/gksuui-dialog.c:
 	- accepted patch from Ubuntu by Michael Vogt that fixes
 	  the capslock notification so that it doesn't change the

Modified: libgksu/trunk/libgksu/Makefile.am
===================================================================
--- libgksu/trunk/libgksu/Makefile.am	2007-12-31 18:46:36 UTC (rev 811)
+++ libgksu/trunk/libgksu/Makefile.am	2007-12-31 19:05:28 UTC (rev 812)
@@ -9,7 +9,7 @@
 # minor -> keeps compatibility (additions to the API)
 # micro -> no change to the API/ABI
 libgksu2_la_LIBADD = ../libgksuui/libgksuui1.0.la
-libgksu2_la_LDFLAGS = -version-info 0:1:0 -Wl,-O1 -lutil ${LIBGKSU_LIBS}
+libgksu2_la_LDFLAGS = -version-info 0:2:0 -Wl,-O1 -lutil ${LIBGKSU_LIBS}
 if USE_VERSION_SCRIPT
 libgksu2_la_LDFLAGS += -Wl,--version-script=libgksu.ver
 endif

Modified: libgksu/trunk/libgksu/libgksu.c
===================================================================
--- libgksu/trunk/libgksu/libgksu.c	2007-12-31 18:46:36 UTC (rev 811)
+++ libgksu/trunk/libgksu/libgksu.c	2007-12-31 19:05:28 UTC (rev 812)
@@ -1348,6 +1348,7 @@
   context->message = NULL;
   context->alert = NULL;
   context->grab = TRUE;
+  context->always_ask_password = FALSE;
 
   context->debug = FALSE;
 
@@ -1621,6 +1622,38 @@
 }
 
 /**
+ * gksu_context_set_always_ask_password:
+ * @context: the #GksuContext you want to modify
+ * @value: TRUE or FALSE
+ *
+ * Set up if gksu should always ask for a password. Notice that this
+ * will only work when passwords are cached, as done by gnome-keyring
+ * for gksu's su mode and by sudo for gksu's sudo mode, but will have no
+ * effect if su or sudo are set up to not require the password at all.
+ */
+void
+gksu_context_set_always_ask_password (GksuContext *context, gboolean value)
+{
+  context->always_ask_password = value;
+}
+
+/**
+ * gksu_context_get_always_ask_password:
+ * @context: the #GksuContext you want to ask whether a grab will be done.
+ *
+ * Returns TRUE if gksu has been asked to always ask for a password 
+ * (even if sudo or gnome-keyring have cached it)
+ *
+ * Returns: TRUE if yes, FALSE otherwise.
+ */
+gboolean
+gksu_context_get_always_ask_password (GksuContext *context)
+{
+   return context->always_ask_password;
+}
+
+
+/**
  * gksu_context_set_launcher_context:
  * @context: the #GksuContext you want to set the sn context in
  * @sn_context: the #SnLauncherContext you want to set
@@ -1995,8 +2028,12 @@
 	      if (prompt_grab)
 		gksu_prompt_grab (context);
 
-	      /* try to get the password from the GNOME Keyring first */
-	      password = get_gnome_keyring_password (context);
+              /* try to get the password from the GNOME Keyring first, but
+	       * only if we have not been requested to always ask for the
+	       * password
+	       */
+	      if (!context->always_ask_password)
+	        password = get_gnome_keyring_password (context);
 	      if (password == NULL)
 		{
 		  password = ask_pass (context, buf, ask_pass_data, error);
@@ -2362,12 +2399,18 @@
 	fprintf (stderr, "No ask_pass set, using default!\n");
       ask_pass = su_ask_password;
     }
-
   if (pass_not_needed == NULL)
     {
       pass_not_needed = no_pass;
     }
 
+  if (context->aways_ask_password)
+    {
+       gint exit_status;
+       g_spawn_command_line_sync("/usr/bin/sudo -K", NULL, NULL, &exit_status, NULL);
+    }
+
+
   /*
      FIXME: need to set GError in a more detailed way
   */

Modified: libgksu/trunk/libgksu/libgksu.h
===================================================================
--- libgksu/trunk/libgksu/libgksu.h	2007-12-31 18:46:36 UTC (rev 811)
+++ libgksu/trunk/libgksu/libgksu.h	2007-12-31 19:05:28 UTC (rev 812)
@@ -61,6 +61,7 @@
   gchar *message;
   gchar *alert;
   gboolean grab;
+  gboolean always_ask_password;
 
   /* startup notification */
   SnLauncherContext *sn_context;
@@ -160,6 +161,12 @@
 gksu_context_get_grab (GksuContext *context);
 
 void
+gksu_context_set_always_ask_password (GksuContext *context, gboolean value);
+
+gboolean
+gksu_context_get_always_ask_password (GksuContext *context);
+
+void
 gksu_context_set_launcher_context (GksuContext *context, SnLauncherContext *sn_context);
 
 SnLauncherContext*




More information about the gksu-commits mailing list