gnome-keyring r1058 - in trunk: . common daemon library library/tests reference reference/tmpl ui



Author: nnielsen
Date: Thu Feb 14 17:22:27 2008
New Revision: 1058
URL: http://svn.gnome.org/viewvc/gnome-keyring?rev=1058&view=rev

Log:
	* common/gkr-buffer.c:
	* common/gkr-buffer.h:
	* common/gkr-daemon-util.c:
	* common/gkr-daemon-util.h:
	* daemon/gkr-daemon.c:
	* daemon/gkr-daemon-ops.c:
	* library/gnome-keyring.c:
	* library/gnome-keyring.h:
	* library/gnome-keyring-opcodes.h:
	* library/gnome-keyring-proto.c:
	* library/gnome-keyring-proto.h:
	* library/tests/unit-test-other.c:
	* reference/gnome-keyring-sections.txt:
	* reference/tmpl/gnome-keyring-daemon.sgml: (added)
	* reference/tmpl/gnome-keyring-misc.sgml:
	* ui/gkr-ask-daemon.c:
	* ui/gkr-ask-daemon.h:
	* ui/gkr-ask-request.c:
	* ui/gkr-ask-tool.c: Add API to sync up environment between session manager
	and the daemon. 

Added:
   trunk/reference/tmpl/gnome-keyring-daemon.sgml
Modified:
   trunk/ChangeLog
   trunk/common/gkr-buffer.c
   trunk/common/gkr-buffer.h
   trunk/common/gkr-daemon-util.c
   trunk/common/gkr-daemon-util.h
   trunk/daemon/gkr-daemon-ops.c
   trunk/daemon/gkr-daemon.c
   trunk/library/gnome-keyring-opcodes.h
   trunk/library/gnome-keyring-proto.c
   trunk/library/gnome-keyring-proto.h
   trunk/library/gnome-keyring.c
   trunk/library/gnome-keyring.h
   trunk/library/tests/unit-test-other.c
   trunk/reference/gnome-keyring-sections.txt
   trunk/reference/tmpl/gnome-keyring-misc.sgml
   trunk/ui/gkr-ask-daemon.c
   trunk/ui/gkr-ask-daemon.h
   trunk/ui/gkr-ask-request.c
   trunk/ui/gkr-ask-tool.c

Modified: trunk/common/gkr-buffer.c
==============================================================================
--- trunk/common/gkr-buffer.c	(original)
+++ trunk/common/gkr-buffer.c	Thu Feb 14 17:22:27 2008
@@ -444,3 +444,70 @@
 	
 	return 1;
 }
+
+int
+gkr_buffer_add_stringv (GkrBuffer *buffer, const char** strv)
+{
+	const char **v;
+	uint32_t n = 0;
+	
+	if (!strv)
+		return 0;
+	
+	/* Add the number of strings coming */
+	for (v = strv; *v; ++v)
+		++n;
+	if (!gkr_buffer_add_uint32 (buffer, n))
+		return 0;
+	
+	/* Add the individual strings */
+	for (v = strv; *v; ++v) {
+		if (!gkr_buffer_add_string (buffer, *v))
+			return 0;
+	}
+	
+	return 1;
+}
+
+int
+gkr_buffer_get_stringv (GkrBuffer *buffer, size_t offset, size_t *next_offset,
+		                char ***strv_ret, GkrBufferAllocator allocator)
+{
+	uint32_t n, i, j;
+	size_t len;
+	
+	if (!allocator)
+		allocator = buffer->allocator;
+	
+	/* First the number of environment variable lines */
+	if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &n))
+		return 0;
+	
+	/* Then that number of strings */
+	len = (n + 1) * sizeof (char*);
+	*strv_ret = (char**)(allocator) (NULL, len);
+	if (!*strv_ret)
+		return 0;
+	
+	/* All null strings */
+	memset (*strv_ret, 0, len);
+	
+	for (i = 0; i < n; ++i) {
+		if (!gkr_buffer_get_string (buffer, offset, &offset, 
+		                            &((*strv_ret)[i]), allocator)) {
+			
+			/* Free all the strings on failure */
+			for (j = 0; j < i; ++j) {
+				if ((*strv_ret)[j])
+					(allocator) ((*strv_ret)[j], 0);
+			}
+			
+			return 0;
+		}
+	}
+	
+	if (next_offset != NULL)
+		*next_offset = offset;
+	
+	return 1;
+}

Modified: trunk/common/gkr-buffer.h
==============================================================================
--- trunk/common/gkr-buffer.h	(original)
+++ trunk/common/gkr-buffer.h	Thu Feb 14 17:22:27 2008
@@ -151,7 +151,16 @@
                                                  size_t *next_offset, 
                                                  char **str_ret, 
                                                  GkrBufferAllocator allocator);
-                                                 
+
+int             gkr_buffer_add_stringv          (GkrBuffer *buffer, 
+                                                 const char** strv);
+
+int             gkr_buffer_get_stringv          (GkrBuffer *buffer,
+                                                 size_t offset,
+                                                 size_t *next_offset,
+		                                         char ***strv_ret, 
+		                                         GkrBufferAllocator allocator);
+
 int		gkr_buffer_add_uint64		(GkrBuffer *buffer,
 						 uint64_t val);
 

Modified: trunk/common/gkr-daemon-util.c
==============================================================================
--- trunk/common/gkr-daemon-util.c	(original)
+++ trunk/common/gkr-daemon-util.c	Thu Feb 14 17:22:27 2008
@@ -33,7 +33,7 @@
 #include <unistd.h>
 
 static gchar* master_directory = NULL;
-static gchar* published_environ = NULL;
+static GArray* published_environ = NULL;
 
 /* Forward declaration, see gnu libc code lower down in this file */
 static char* do_mkdtemp (char *template);
@@ -89,29 +89,42 @@
 static void
 uninit_environment (gpointer data)
 {
-	g_free (published_environ);
+	guint i;
+	
+	if (published_environ) {
+		for (i = 0; i < published_environ->len; ++i)
+			g_free (g_array_index (published_environ, gchar*, i));
+		g_array_free (published_environ, TRUE);
+	}
+	
 	published_environ = NULL;
 }
 
+static void 
+init_environment ()
+{
+	if (published_environ)
+		return;
+	published_environ = g_array_new (TRUE, TRUE, sizeof (gchar*)); 
+	gkr_cleanup_register (uninit_environment, NULL);
+}
+
 void
 gkr_daemon_util_push_environment (const gchar *name, const gchar *value)
 {
 	gchar *env;
-	
-	if (!published_environ)
-		gkr_cleanup_register (uninit_environment, NULL);
+
+	init_environment ();
 		
-	env = g_strdup_printf ("%s%s=%s\n", 
-	                       published_environ ? published_environ : "",
-	                       name, value);
-	g_free (published_environ);
-	published_environ = env;
+	env = g_strdup_printf ("%s=%s", name, value);
+	g_array_append_val (published_environ, env);
 }
 
-const gchar*
+const gchar**
 gkr_daemon_util_get_environment (void)
 {
-	return published_environ ? published_environ : "";
+	init_environment ();
+	return (const gchar**)published_environ->data;
 }
 
 /* Copyright (C) 1999, 2001-2002 Free Software Foundation, Inc.

Modified: trunk/common/gkr-daemon-util.h
==============================================================================
--- trunk/common/gkr-daemon-util.h	(original)
+++ trunk/common/gkr-daemon-util.h	Thu Feb 14 17:22:27 2008
@@ -30,6 +30,6 @@
 
 void            gkr_daemon_util_push_environment        (const gchar *name, const gchar *value);
 
-const gchar*    gkr_daemon_util_get_environment         (void);
+const gchar**   gkr_daemon_util_get_environment         (void);
 
 #endif /*GKRMASTERDIRECTORY_H_*/

Modified: trunk/daemon/gkr-daemon-ops.c
==============================================================================
--- trunk/daemon/gkr-daemon-ops.c	(original)
+++ trunk/daemon/gkr-daemon-ops.c	Thu Feb 14 17:22:27 2008
@@ -25,6 +25,7 @@
 #include "gkr-daemon.h"
 
 #include "common/gkr-buffer.h"
+#include "common/gkr-daemon-util.h"
 #include "common/gkr-location.h"
 #include "common/gkr-secure-memory.h"
 
@@ -1511,29 +1512,21 @@
 op_set_daemon_display (GkrBuffer *packet, GkrBuffer *result,
                        GkrKeyringRequest *req)
 {
-       char *display;
-       GnomeKeyringOpCode opcode;
+	char *display;
+	GnomeKeyringOpCode opcode;
+
+	if (!gkr_proto_decode_op_string (packet, &opcode, &display))
+		return FALSE;
 
-       if (!gkr_proto_decode_op_string (packet, &opcode, &display))
-               return FALSE;
+	if (display == NULL) {
+		gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_DENIED);
+	} else {
+		g_setenv ("DISPLAY", display, FALSE);
+		gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
+	}
 
-       if ( display == NULL ) {
-               gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_DENIED);
-               goto out;
-       }
-
-       if (gkr_ask_daemon_get_display () == NULL && (g_strrstr (display, ":") != NULL)) {
-               gkr_ask_daemon_set_display (display);
-       } else {
-               gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_DENIED);
-               goto out;
-       }
-
-       gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
-
-out:
-    g_free (display);
-       return TRUE;
+	g_free (display);
+	return TRUE;
 }
 
 static gboolean
@@ -1746,6 +1739,45 @@
 	return return_val;
 }
 
+static gboolean
+op_prepare_daemon_environment (GkrBuffer *packet, GkrBuffer *result, GkrKeyringRequest *req)
+{
+	const gchar **daemonenv;
+	gchar **environment, **e;
+	gchar *x;
+
+	if (!gkr_proto_decode_prepare_environment (packet, &environment))
+		return FALSE;
+
+	/* Accept environment from outside */
+	for (e = environment; *e; ++e) {
+		x = strchr (*e, '=');
+		if (x) {
+			*(x++) = 0;
+			
+			/* We're only interested in these guys */
+			if (g_str_equal (*e, "DISPLAY")) 
+				g_setenv ("DISPLAY", x, FALSE);
+			else if (g_str_equal (*e, "DBUS_SESSION_BUS_ADDRESS"))
+				g_setenv ("DBUS_SESSION_BUS_ADDRESS", x, FALSE);
+			else if (g_str_equal (*e, "XAUTHORITY"))
+				g_setenv ("XAUTHORITY", x, FALSE);
+			else if (g_str_equal (*e, "XDG_SESSION_COOKIE"))
+				g_setenv ("XDG_SESSION_COOKIE", x, FALSE);
+		}
+	}
+	
+	g_strfreev (environment);
+
+	gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
+
+	daemonenv = gkr_daemon_util_get_environment ();
+	g_return_val_if_fail (daemonenv, FALSE);
+	
+	gkr_buffer_add_stringv (result, daemonenv);
+	return TRUE;
+}
+
 GkrDaemonOperation keyring_ops[] = {
 	op_lock_all, 			/* LOCK_ALL */
 	op_set_default_keyring, 	/* SET_DEFAULT_KEYRING */
@@ -1770,4 +1802,5 @@
 	op_change_keyring_password,     /* CHANGE_KEYRING_PASSWORD */
  	op_set_daemon_display,          /* SET_DAEMON_DISPLAY */
 	op_get_item_info,               /* GET_ITEM_INFO_PARTIAL */
+	op_prepare_daemon_environment,	/* PREPARE_DAEMON_ENVIRONMENT */
 };

Modified: trunk/daemon/gkr-daemon.c
==============================================================================
--- trunk/daemon/gkr-daemon.c	(original)
+++ trunk/daemon/gkr-daemon.c	Thu Feb 14 17:22:27 2008
@@ -405,6 +405,14 @@
 	return FALSE;
 }
 
+static void
+print_environment (pid_t pid)
+{
+	const gchar **env;
+	for (env = gkr_daemon_util_get_environment (); *env; ++env)
+		printf ("%s\n", *env);
+	printf ("GNOME_KEYRING_PID=%d\n", (gint)pid);
+}
 
 int
 main (int argc, char *argv[])
@@ -483,8 +491,7 @@
 						/* This is where we know the pid of the daemon.
 						 * The initial process will waitpid until we exit,
 						 * so there is no race */
-						printf ("%s", gkr_daemon_util_get_environment ());
-						printf ("GNOME_KEYRING_PID=%d\n", (gint)pid);
+						print_environment (pid);
 						exit (0);
 					}
 				}
@@ -508,8 +515,7 @@
 					exit (WEXITSTATUS (status));
 				
 			} else {
-				printf ("%s", gkr_daemon_util_get_environment ());
-				printf ("GNOME_KEYRING_PID=%d\n", (gint)pid);
+				print_environment (pid);
 			}
 			
 			exit (0);
@@ -519,8 +525,7 @@
 		close_stdinout ();
 
 	} else {
-		g_print ("%s", gkr_daemon_util_get_environment ());
-		g_print ("GNOME_KEYRING_PID=%d\n", (gint)getpid ());
+		print_environment (getpid ());
 	}
 
 	/* Daemon process continues here */

Modified: trunk/library/gnome-keyring-opcodes.h
==============================================================================
--- trunk/library/gnome-keyring-opcodes.h	(original)
+++ trunk/library/gnome-keyring-opcodes.h	Thu Feb 14 17:22:27 2008
@@ -47,6 +47,7 @@
 	GNOME_KEYRING_OP_CHANGE_KEYRING_PASSWORD,
 	GNOME_KEYRING_OP_SET_DAEMON_DISPLAY,
 	GNOME_KEYRING_OP_GET_ITEM_INFO_FULL,
+	GNOME_KEYRING_OP_PREPARE_ENVIRONMENT,
 
 	/* Add new ops here */
 	

Modified: trunk/library/gnome-keyring-proto.c
==============================================================================
--- trunk/library/gnome-keyring-proto.c	(original)
+++ trunk/library/gnome-keyring-proto.c	Thu Feb 14 17:22:27 2008
@@ -595,6 +595,23 @@
 	return TRUE;
 }
 
+gboolean
+gkr_proto_encode_prepare_environment (GkrBuffer *buffer, const gchar **environment)
+{
+	gsize op_start;
+	
+	if (!gkr_proto_start_operation (buffer, GNOME_KEYRING_OP_PREPARE_ENVIRONMENT,
+	                                &op_start))
+		return FALSE;
+		
+	if (!gkr_buffer_add_stringv (buffer, environment))
+		return FALSE;
+
+	if (!gkr_proto_end_operation (buffer, op_start))
+		return FALSE;
+
+	return TRUE;
+}
 
 gboolean
 gkr_proto_decode_attribute_list (GkrBuffer *buffer, gsize offset, gsize *next_offset,
@@ -1411,7 +1428,45 @@
 	return FALSE;
 }
 
+gboolean
+gkr_proto_decode_prepare_environment (GkrBuffer *buffer, gchar ***environment)
+{
+	GnomeKeyringOpCode op;
+	gsize offset;
+	
+	if (!gkr_proto_decode_packet_operation (buffer, &op))
+		return FALSE;
+	if (op != GNOME_KEYRING_OP_PREPARE_ENVIRONMENT)
+		return FALSE;
+		
+	offset = 8;
+	
+	if (!gkr_buffer_get_stringv (buffer, offset, &offset, environment, g_realloc))
+		return FALSE; 
+	
+	return TRUE;
+}
+
+gboolean 
+gkr_proto_decode_prepare_environment_reply (GkrBuffer *buffer, GnomeKeyringResult *result,
+                                            char ***environment)
+{
+	gsize offset;
+	guint32 res;
 
+	offset = 4;
+
+	if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &res))
+		return FALSE;
+	*result = res;
+
+	if (res == GNOME_KEYRING_RESULT_OK) {
+		if (!gkr_buffer_get_stringv (buffer, offset, &offset, environment, NULL))
+			return FALSE; 
+	}		
+	
+	return TRUE;
+}
 
 gboolean
 gkr_proto_decode_result_int_list_reply (GkrBuffer *buffer, GnomeKeyringResult *result,

Modified: trunk/library/gnome-keyring-proto.h
==============================================================================
--- trunk/library/gnome-keyring-proto.h	(original)
+++ trunk/library/gnome-keyring-proto.h	Thu Feb 14 17:22:27 2008
@@ -126,6 +126,8 @@
 gboolean gkr_proto_encode_set_keyring_info           (GkrBuffer                 *buffer,
                                                       const char                *keyring,
                                                       GnomeKeyringInfo          *info);
+gboolean gkr_proto_encode_prepare_environment        (GkrBuffer                 *buffer, 
+                                                      const gchar              **environment);
 
 
 /* demarshallers */
@@ -219,7 +221,10 @@
                                                       char                      **keyring,
                                                       guint32                    *item_id,
                                                       GList                     **acl);
-
-
+gboolean gkr_proto_decode_prepare_environment        (GkrBuffer                  *buffer, 
+                                                      char                     ***environment);
+gboolean gkr_proto_decode_prepare_environment_reply  (GkrBuffer                  *buffer,
+                                                      GnomeKeyringResult         *res,
+                                                      char                     ***environment);
    
 #endif /* GNOME_KEYRING_PROTO_H */

Modified: trunk/library/gnome-keyring.c
==============================================================================
--- trunk/library/gnome-keyring.c	(original)
+++ trunk/library/gnome-keyring.c	Thu Feb 14 17:22:27 2008
@@ -1725,13 +1725,9 @@
 
 /**
  * gnome_keyring_daemon_set_display_sync:
- * @display: The X display string.
+ * @display: Deprecated 
  * 
- * Set the display that should be used to display GNOME Keyring dialogs
- * and prompts.
- * 
- * Return value: %GNOME_KEYRING_RESULT_OK if the operation was succcessful or 
- * an error result otherwise.
+ * Deprecated. Use gnome_keyring_daemon_prepare_environment_sync()
  **/ 
 GnomeKeyringResult
 gnome_keyring_daemon_set_display_sync (const char *display)
@@ -1765,6 +1761,59 @@
 }
 
 /**
+ * gnome_keyring_daemon_prepare_environment_sync:
+ * 
+ * Used by session managers or applications that manage the gnome-keyring-daemon
+ * process. Prepares the environment of both the daemon and the application
+ * for successful communication. 
+ * 
+ * This includes telling the daemon the DBUS addresses, X display and related 
+ * information to use for communication and display. This information is only 
+ * used by the daemon if it does not already have it. For example the X display
+ * of the daemon cannot be changed using this call.  
+ * 
+ * Return value: %GNOME_KEYRING_RESULT_OK if the operation was succcessful or 
+ * an error result otherwise. 
+ **/ 
+GnomeKeyringResult
+gnome_keyring_daemon_prepare_environment_sync (void)
+{
+	GkrBuffer send, receive;
+	GnomeKeyringResult res;
+	gchar **daemonenv, **e;
+
+	gkr_buffer_init_full (&send, 128, g_realloc);
+
+	if (!gkr_proto_encode_prepare_environment (&send, (const gchar**)environ)) {
+		gkr_buffer_uninit (&send);
+		return GNOME_KEYRING_RESULT_BAD_ARGUMENTS;
+	}
+
+	gkr_buffer_init_full (&receive, 128, g_realloc);
+	res = run_sync_operation (&send, &receive);
+	gkr_buffer_uninit (&send);
+	if (res != GNOME_KEYRING_RESULT_OK) {
+		gkr_buffer_uninit (&receive);
+		return res;
+	}
+
+	if (!gkr_proto_decode_prepare_environment_reply (&receive, &res, &daemonenv)) {
+		gkr_buffer_uninit (&receive);
+		return GNOME_KEYRING_RESULT_IO_ERROR;
+	}
+	gkr_buffer_uninit (&receive);
+	
+	if (res == GNOME_KEYRING_RESULT_OK) {
+		for (e = daemonenv; *e; ++e)
+			putenv (*e);
+	}
+	
+	g_strfreev (daemonenv);
+
+	return res;
+}
+
+/**
  * gnome_keyring_info_set_lock_on_idle:
  * @keyring_info: The keyring info.
  * @value: Whether to lock or not.

Modified: trunk/library/gnome-keyring.h
==============================================================================
--- trunk/library/gnome-keyring.h	(original)
+++ trunk/library/gnome-keyring.h	Thu Feb 14 17:22:27 2008
@@ -215,9 +215,6 @@
 GnomeKeyringResult gnome_keyring_list_item_ids_sync (const char                                   *keyring,
 						     GList                                       **ids);
 
-GnomeKeyringResult gnome_keyring_daemon_set_display_sync (const char *display);
-
-
 void              gnome_keyring_info_free             (GnomeKeyringInfo *keyring_info);
 GnomeKeyringInfo *gnome_keyring_info_copy             (GnomeKeyringInfo *keyring_info);
 void              gnome_keyring_info_set_lock_on_idle (GnomeKeyringInfo *keyring_info,
@@ -508,5 +505,13 @@
 							     const char                            *password,
 							     guint32                               *item_id);
 
+/* -----------------------------------------------------------------------------
+ * USED ONLY BY THE SESSION
+ */
+ 
+/* Deprecated */
+GnomeKeyringResult    gnome_keyring_daemon_set_display_sync         (const char *display);
+
+GnomeKeyringResult    gnome_keyring_daemon_prepare_environment_sync (void);
 
 #endif /* GNOME_KEYRING_H */

Modified: trunk/library/tests/unit-test-other.c
==============================================================================
--- trunk/library/tests/unit-test-other.c	(original)
+++ trunk/library/tests/unit-test-other.c	Thu Feb 14 17:22:27 2008
@@ -46,9 +46,16 @@
 {
 	GnomeKeyringResult res;
 	
-	/* Shouldn't work */
-	res = gnome_keyring_daemon_set_display_sync ("WOOF");
-	CuAssertIntEquals(cu, GNOME_KEYRING_RESULT_DENIED, res);	
+	res = gnome_keyring_daemon_set_display_sync (":0.0");
+	CuAssertIntEquals(cu, GNOME_KEYRING_RESULT_OK, res);	
+}
+
+void unit_test_setup_environment (CuTest* cu)
+{
+	GnomeKeyringResult res;
+
+	res = gnome_keyring_daemon_prepare_environment_sync ();
+	CuAssertIntEquals(cu, GNOME_KEYRING_RESULT_OK, res);
 }
 
 void unit_test_result_string (CuTest* cu)

Modified: trunk/reference/gnome-keyring-sections.txt
==============================================================================
--- trunk/reference/gnome-keyring-sections.txt	(original)
+++ trunk/reference/gnome-keyring-sections.txt	Thu Feb 14 17:22:27 2008
@@ -152,7 +152,11 @@
 gnome_keyring_is_available
 gnome_keyring_cancel_request
 gnome_keyring_string_list_free
+</SECTION>
+<SECTION>
+<FILE>gnome-keyring-daemon</FILE>
 gnome_keyring_daemon_set_display_sync
+gnome_keyring_daemon_prepare_environment_sync
 </SECTION>
 <SECTION>
 <FILE>gnome-keyring-memory</FILE>

Added: trunk/reference/tmpl/gnome-keyring-daemon.sgml
==============================================================================
--- (empty file)
+++ trunk/reference/tmpl/gnome-keyring-daemon.sgml	Thu Feb 14 17:22:27 2008
@@ -0,0 +1,36 @@
+<!-- ##### SECTION Title ##### -->
+Daemon Management Functions
+
+<!-- ##### SECTION Short_Description ##### -->
+Functions used by session managers to manage the Gnome Keyring Daemon.
+
+<!-- ##### SECTION Long_Description ##### -->
+<para>
+These functions are not used by most applications using Gnome Keyring.
+</para>
+
+<!-- ##### SECTION See_Also ##### -->
+<para>
+
+</para>
+
+<!-- ##### SECTION Stability_Level ##### -->
+
+
+<!-- ##### FUNCTION gnome_keyring_daemon_set_display_sync ##### -->
+<para>
+
+</para>
+
+ display: 
+ Returns: 
+
+
+<!-- ##### FUNCTION gnome_keyring_daemon_prepare_environment_sync ##### -->
+<para>
+
+</para>
+
+ Returns: 
+
+

Modified: trunk/reference/tmpl/gnome-keyring-misc.sgml
==============================================================================
--- trunk/reference/tmpl/gnome-keyring-misc.sgml	(original)
+++ trunk/reference/tmpl/gnome-keyring-misc.sgml	Thu Feb 14 17:22:27 2008
@@ -41,12 +41,3 @@
 @strings: 
 
 
-<!-- ##### FUNCTION gnome_keyring_daemon_set_display_sync ##### -->
-<para>
-
-</para>
-
- display: 
- Returns: 
-
-

Modified: trunk/ui/gkr-ask-daemon.c
==============================================================================
--- trunk/ui/gkr-ask-daemon.c	(original)
+++ trunk/ui/gkr-ask-daemon.c	Thu Feb 14 17:22:27 2008
@@ -35,7 +35,6 @@
 
 static GkrAsyncWait *wait_condition = NULL;
 static GkrAskRequest *current_ask = NULL;
-static gchar *the_display = NULL;
 
 static GkrAskHook ask_daemon_hook = NULL;
 static gpointer ask_daemon_hook_data = NULL;
@@ -48,9 +47,6 @@
 	if (current_ask)
 		gkr_ask_request_cancel (current_ask);
 	
-	g_free (the_display);
-	the_display = NULL;
-	
 	g_assert (wait_condition);
 	gkr_async_wait_free (wait_condition);
 	wait_condition = NULL;
@@ -61,18 +57,12 @@
 static void
 ask_daemon_init (void)
 {
-	const gchar* display;
-
 	if (ask_daemon_inited)
 		return;
 	ask_daemon_inited = TRUE;
 	
 	wait_condition = gkr_async_wait_new ();
 	
-	display = g_getenv ("DISPLAY");
-	if (display && display[0])
-		the_display = g_strdup (display);
-		
 	gkr_cleanup_register (ask_daemon_cleanup, NULL);
 }
 
@@ -122,21 +112,6 @@
 	g_assert (gkr_ask_request_is_complete (ask));
 }
 
-void 
-gkr_ask_daemon_set_display (const gchar* display)
-{
-	ask_daemon_init ();
-	
-	g_free (the_display);
-	the_display = g_strdup (display);
-}
-
-const gchar*
-gkr_ask_daemon_get_display (void)
-{
-	return the_display;
-}
-
 void
 gkr_ask_daemon_set_hook (GkrAskHook hook, gpointer data)
 {

Modified: trunk/ui/gkr-ask-daemon.h
==============================================================================
--- trunk/ui/gkr-ask-daemon.h	(original)
+++ trunk/ui/gkr-ask-daemon.h	Thu Feb 14 17:22:27 2008
@@ -30,10 +30,6 @@
 
 void           gkr_ask_daemon_process     (GkrAskRequest* ask);
 
-void           gkr_ask_daemon_set_display (const gchar* display);
-
-const gchar*   gkr_ask_daemon_get_display (void);
-
 typedef void (*GkrAskHook) (GkrAskRequest* ask, gpointer data);
 
 void           gkr_ask_daemon_set_hook    (GkrAskHook hook, gpointer data);

Modified: trunk/ui/gkr-ask-request.c
==============================================================================
--- trunk/ui/gkr-ask-request.c	(original)
+++ trunk/ui/gkr-ask-request.c	Thu Feb 14 17:22:27 2008
@@ -539,7 +539,6 @@
 launch_ask_helper (GkrAskRequest *ask)
 {
 	GkrAskRequestPrivate *pv = GKR_ASK_REQUEST_GET_PRIVATE (ask);
-	const gchar* display;
 	char **envp;
 	int i, n;
 	GError *error = NULL;
@@ -558,11 +557,6 @@
 	envp = g_new (char*, n + 2);
 	for (i = 0; i < n; i++)
 		envp[i] = g_strdup (environ[i]);
-	
-	/* And add in the stuff we need */
-	display = gkr_ask_daemon_get_display ();
-	if (display && display[0])
-		envp[i++] = g_strdup_printf ("DISPLAY=%s", display);
 	envp[i++] = NULL;
 
 	gkr_buffer_resize (&pv->buffer, 0);

Modified: trunk/ui/gkr-ask-tool.c
==============================================================================
--- trunk/ui/gkr-ask-tool.c	(original)
+++ trunk/ui/gkr-ask-tool.c	Thu Feb 14 17:22:27 2008
@@ -38,11 +38,14 @@
 #include <errno.h>
 #include <sys/mman.h>
 #include <unistd.h>
+#include <syslog.h>
 
 static GKeyFile *input_data = NULL;
 static GKeyFile *output_data = NULL;
 static gboolean grabbed = FALSE;
 
+#define LOG_ERRORS 1
+
 /* -----------------------------------------------------------------------------
  * MEMORY
  */
@@ -120,6 +123,13 @@
 	         msg1 ? msg1 : "", 
 	         msg1 && msg2 ? ": " : "",
 	         msg2 ? msg2 : "");
+#if LOG_ERRORS
+	syslog (LOG_AUTH | LOG_ERR, "%s: %s%s%s\n", 
+	         g_get_prgname (),
+	         msg1 ? msg1 : "", 
+	         msg1 && msg2 ? ": " : "",
+	         msg2 ? msg2 : "");
+#endif
 	exit (1);
 }
 



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