aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2012-06-20 11:20:30 +0800
committerMatthew Barnes <mbarnes@redhat.com>2012-06-20 11:26:48 +0800
commit782d59da7b614ba04fe89411dde8b482fd3d6204 (patch)
tree5ee0eb4ee39fd13fa95482655bb89acc3a7436e3 /modules
parentad2d4bd22c1931caa1c3c6997c2c9eced8096342 (diff)
downloadgsoc2013-evolution-782d59da7b614ba04fe89411dde8b482fd3d6204.tar.gz
gsoc2013-evolution-782d59da7b614ba04fe89411dde8b482fd3d6204.tar.zst
gsoc2013-evolution-782d59da7b614ba04fe89411dde8b482fd3d6204.zip
Bug 678347 - Put spamd pid/socket files in $XDG_RUNTIME_DIR
Diffstat (limited to 'modules')
-rw-r--r--modules/spamassassin/evolution-spamassassin.c40
1 files changed, 38 insertions, 2 deletions
diff --git a/modules/spamassassin/evolution-spamassassin.c b/modules/spamassassin/evolution-spamassassin.c
index 0a6330e264..3166220dea 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";