[evolution] Bug 678347 - Put spamd pid/socket files in $XDG_RUNTIME_DIR



commit 782d59da7b614ba04fe89411dde8b482fd3d6204
Author: Matthew Barnes <mbarnes redhat com>
Date:   Tue Jun 19 23:20:30 2012 -0400

    Bug 678347 - Put spamd pid/socket files in $XDG_RUNTIME_DIR

 modules/spamassassin/evolution-spamassassin.c |   40 +++++++++++++++++++++++-
 1 files changed, 38 insertions(+), 2 deletions(-)
---
diff --git a/modules/spamassassin/evolution-spamassassin.c b/modules/spamassassin/evolution-spamassassin.c
index 0a6330e..3166220 100644
--- a/modules/spamassassin/evolution-spamassassin.c
+++ b/modules/spamassassin/evolution-spamassassin.c
@@ -17,8 +17,10 @@
  */
 
 #include <config.h>
+#include <errno.h>
 #include <sys/types.h>
 #include <sys/wait.h>
+#include <glib/gstdio.h>
 #include <glib/gi18n-lib.h>
 
 #include <camel/camel.h>
@@ -575,17 +577,51 @@ static gboolean
 spam_assassin_start_our_own_daemon (ESpamAssassin *extension)
 {
 	const gchar *argv[8];
+	const gchar *user_runtime_dir;
 	gchar *pid_file;
 	gchar *socket_path;
 	gboolean started = FALSE;
 	gint exit_code;
 	gint ii = 0;
+	gint fd;
 	GError *error = NULL;
 
 	g_mutex_lock (extension->socket_path_mutex);
 
-	pid_file = e_mktemp ("spamd-pid-file-XXXXXX");
-	socket_path = e_mktemp ("spamd-socket-path-XXXXXX");
+	/* Don't put the PID files in Evolution's tmp directory
+	 * (as defined in e-mktemp.c) because that gets cleaned
+	 * every few hours, and these files need to persist. */
+	user_runtime_dir = g_get_user_runtime_dir ();
+
+	pid_file = g_build_filename (
+		user_runtime_dir, "spamd-pid-file-XXXXXX", NULL);
+
+	socket_path = g_build_filename (
+		user_runtime_dir, "spamd-socket-path-XXXXXX", NULL);
+
+	/* The template filename is modified in place. */
+	fd = g_mkstemp (pid_file);
+	if (fd >= 0) {
+		close (fd);
+		g_unlink (pid_file);
+	} else {
+		g_warning (
+			"Failed to create spamd-pid-file: %s",
+			g_strerror (errno));
+		goto exit;
+	}
+
+	/* The template filename is modified in place. */
+	fd = g_mkstemp (socket_path);
+	if (fd >= 0) {
+		close (fd);
+		g_unlink (socket_path);
+	} else {
+		g_warning (
+			"Failed to create spamd-socket-path: %s",
+			g_strerror (errno));
+		goto exit;
+	}
 
 	argv[ii++] = extension->spamd_binary;
 	argv[ii++] = "--socketpath";



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