struct rspamd_stat_classifier;
struct module_s;
struct worker_s;
+struct rspamd_external_libs_ctx;
enum { VAL_UNDEF=0, VAL_TRUE, VAL_FALSE };
struct worker_s **compiled_workers; /**< list of compiled C modules */
struct rspamd_log_format *log_format; /**< parsed log format */
gchar *log_format_str; /**< raw log format string */
+
+ struct rspamd_external_libs_ctx *libs_ctx; /**< context for external libraries */
};
g_string_free (ar, FALSE);
}
-void
+struct rspamd_external_libs_ctx *
rspamd_init_libs (void)
{
struct rlimit rlim;
+ struct rspamd_external_libs_ctx *ctx;
+ ctx = g_slice_alloc0 (sizeof (*ctx));
rspamd_cryptobox_init ();
ottery_init (NULL);
#else
g_mime_init (0);
#endif
+ ctx->libmagic = magic_open (MAGIC_MIME|MAGIC_NO_CHECK_COMPRESS|
+ MAGIC_NO_CHECK_ELF|MAGIC_NO_CHECK_TAR|MAGIC_NO_CHECK_TEXT);
+ magic_compile (ctx->libmagic, NULL);
+
+ return ctx;
}
guint64
*/
void rspamd_gstring_free_soft (gpointer p);
+struct rspamd_external_libs_ctx;
/**
* Initialize rspamd libraries
*/
-void rspamd_init_libs (void);
+struct rspamd_external_libs_ctx* rspamd_init_libs (void);
/**
* Returns some statically initialized random hash seed
tmp_cfg = (struct rspamd_config *)g_malloc0 (sizeof (struct rspamd_config));
tmp_cfg->c_modules = g_hash_table_ref (rspamd_main->cfg->c_modules);
+ tmp_cfg->libs_ctx = rspamd_main->cfg->libs_ctx;
rspamd_set_logger (tmp_cfg, g_quark_try_string ("main"), rspamd_main);
rspamd_init_cfg (tmp_cfg, TRUE);
cfg_file = rspamd_mempool_strdup (tmp_cfg->cfg_pool,
init_title (argc, argv, env);
#endif
- rspamd_init_libs ();
+ rspamd_main->cfg->libs_ctx = rspamd_init_libs ();
rspamd_init_cfg (rspamd_main->cfg, TRUE);
memset (&signals, 0, sizeof (struct sigaction));
#include "libserver/events.h"
#include "libserver/roll_history.h"
#include "libserver/task.h"
+#include <magic.h>
/* Default values */
struct event_base *ev_base; /**< Event base */
};
+struct rspamd_external_libs_ctx {
+ magic_t libmagic;
+};
+
/**
* Register custom controller function