summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Neumann <mneumann@ntecs.de>2017-01-06 12:58:18 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-01-06 12:59:22 +0000
commit553573e4bd9e69b84f266472a0e383efa6fc8f4d (patch)
tree1891dbb6238723c54a010c1bb9947dac08f42153
parente678028df3c06178be770b2bb068d5bc25fb4957 (diff)
downloadrspamd-553573e4bd9e69b84f266472a0e383efa6fc8f4d.tar.gz
rspamd-553573e4bd9e69b84f266472a0e383efa6fc8f4d.zip
Fix shm on DragonFly
Rspamd tried to call shm_open(3) with a path in the root filesystem (e.g. /rhm.3f0fd440d46fac91e1b4). But DragonFly uses regular files for shm. Obviously, this fails, because rspamd has no permissions to create files in the root (/). Lots of lines like the following were found in /var/log/rspamd/rspamd.log before this patch: rspamd_shmem_mkstemp: /usr/obj/dports/mail/rspamd/rspamd-1.4.1/src /libutil/util.c:1970: failed to create temp shmem /rhm.3f0fd440d46fac91e1b4: Permission denied Also, rspamd made the receiving of mail very slow, when used in the pre-accept rmilter setting, due to these errors. Even worse, it just didn't filter emails at all. This patch fixes the problem by creating the shm files in /tmp for DragonFly. With this patch applied, these lines are gone from the log and emails now correctly contain the X-Spamd-Result header, AND receiving mails is now much much faster. For rspamd 1.4.1, we will fix it in dports: https://github.com/DragonFlyBSD/DeltaPorts/pull/727
-rw-r--r--src/libutil/http.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libutil/http.c b/src/libutil/http.c
index 8796963f1..e4f2fa725 100644
--- a/src/libutil/http.c
+++ b/src/libutil/http.c
@@ -2371,7 +2371,13 @@ rspamd_http_message_set_body (struct rspamd_http_message *msg,
storage->shared.name = g_slice_alloc (sizeof (*storage->shared.name));
REF_INIT_RETAIN (storage->shared.name, rspamd_http_shname_dtor);
#ifdef HAVE_SANE_SHMEM
+#if defined(__DragonFly__)
+ // DragonFly uses regular files for shm. User rspamd is not allowed to create
+ // files in the root.
+ storage->shared.name->shm_name = g_strdup ("/tmp/rhm.XXXXXXXXXXXXXXXXXXXX");
+#else
storage->shared.name->shm_name = g_strdup ("/rhm.XXXXXXXXXXXXXXXXXXXX");
+#endif
storage->shared.shm_fd = rspamd_shmem_mkstemp (storage->shared.name->shm_name);
#else
/* XXX: assume that tempdir is /tmp */