From 782d59da7b614ba04fe89411dde8b482fd3d6204 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 19 Jun 2012 23:20:30 -0400 Subject: Bug 678347 - Put spamd pid/socket files in $XDG_RUNTIME_DIR --- modules/spamassassin/evolution-spamassassin.c | 40 +++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'modules/spamassassin') 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 +#include #include #include +#include #include #include @@ -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"; -- cgit v1.2.3