]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Rework] Finally remove gmime dependency from Rspamd
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 22 Dec 2016 23:58:51 +0000 (23:58 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 22 Dec 2016 23:58:51 +0000 (23:58 +0000)
CMakeLists.txt
config.h.in
src/controller.c
src/libmime/mime_expressions.c
src/libserver/protocol.c
src/libserver/task.h
src/libutil/util.c
src/rspamd_proxy.c
src/worker.c
utils/content_type_bench.c
utils/mime_tool.c

index 306f2a33f65c60d3d1411e19b721e499705e906e..aedb977d523266b3acd254f6e2f0018183592784 100644 (file)
@@ -51,7 +51,6 @@ OPTION(ENABLE_SQLITE       "Find and link with sqlite3 library [default: OFF]"
 OPTION(ENABLE_HIREDIS      "Find and link with external redis library [default: ON]"  ON)
 OPTION(ENABLE_URL_INCLUDE  "Enable urls in ucl includes (requires libcurl or libfetch) [default: OFF]" OFF)
 OPTION(NO_SHARED           "Build internal libs static [default: ON]"          ON)
-OPTION(FORCE_GMIME24       "Link with gmime2.4 [default: OFF]"                  OFF)
 OPTION(INSTALL_EXAMPLES    "Install examples [default: OFF]"                    OFF)
 OPTION(INSTALL_WEBUI       "Install web interface [default: ON]"                ON)
 OPTION(WANT_SYSTEMD_UNITS  "Install systemd unit files on Linux [default: OFF]" OFF)
@@ -662,22 +661,6 @@ IF(ENABLE_JEMALLOC MATCHES "ON")
                ROOT ${JEMALLOC_ROOT_DIR} MODULES jemalloc)
        SET(WITH_JEMALLOC "1")
 ENDIF()
-ProcessPackage(GMIME LIBRARY gmime-2.6 gmime-2.4 gmime-2.2 gmime-2
-       INCLUDE gmime/gmime.h
-       INCLUDE_SUFFIXES include/gmime include/gmime-2.0 include/gmime-2.4 include/gmime-2.6
-       ROOT ${GMIME_ROOT_DIR} MODULES gmime-2.6 gmime-2.4 gmime-2.0)
-IF(GMIME_ROOT_DIR)
-       LIST(APPEND RSPAMD_REQUIRED_LIBRARIES "-lz")
-ENDIF()
-ProcessPackage(GIO LIBRARY gio-2.0 INCLUDE glib.h
-       INCLUDE_SUFFIXES include/glib include/glib-2.0
-       ROOT ${GLIB_ROOT_DIR} MODULES gio-no-export-2.0>=2.28 gio-2.0>=2.28)
-ProcessPackage(GOBJECT LIBRARY gobject-2.0 INCLUDE glib.h
-       INCLUDE_SUFFIXES include/glib include/glib-2.0
-       ROOT ${GLIB_ROOT_DIR} MODULES gobject-no-export-2.0>=2.28 gobject-2.0>=2.28)
-ProcessPackage(GMODULE2 LIBRARY gmodule-2.0 INCLUDE glib.h
-       INCLUDE_SUFFIXES include/glib include/glib-2.0
-       ROOT ${GLIB_ROOT_DIR} MODULES gmodule-no-export-2.0>=2.28 gmodule-2.0>=2.28)
 ProcessPackage(GLIB2 LIBRARY glib-2.0 INCLUDE glib.h
        INCLUDE_SUFFIXES include/glib include/glib-2.0
        ROOT ${GLIB_ROOT_DIR} MODULES glib-2.0>=2.28)
@@ -746,10 +729,6 @@ ENDIF ()
 #Check for openssl (required for dkim)
 SET(HAVE_OPENSSL 1)
 
-IF(GMIME2_VERSION VERSION_GREATER "2.4.0" OR NOT GMIME2_VERSION)
-       SET(GMIME24 1)
-ENDIF()
-
 IF(ENABLE_HIREDIS MATCHES "ON")
        ADD_SUBDIRECTORY(contrib/hiredis)
        SET(WITH_HIREDIS 1)
index a8cbd95fab642d0248acbfaa16bb45a65cf06778..3d1c5f9472d7bfa73762fc1880c966a88f905cda 100644 (file)
@@ -9,7 +9,6 @@
 #cmakedefine GLIB_HASH_COMPAT           1
 #cmakedefine GLIB_RE_COMPAT             1
 #cmakedefine GLIB_UNISCRIPT_COMPAT              1
-#cmakedefine GMIME24             1
 #cmakedefine HAVE_AIO_H          1
 #cmakedefine HAVE_ARPA_INET_H    1
 #cmakedefine HAVE_ASM_PAUSE      1
index 4380f880edf7e920bff8411df988e22c7b13813b..16bbaff1040bcd6ea745b3503b61087a1ab2cfa2 100644 (file)
@@ -3198,7 +3198,6 @@ start_controller_worker (struct rspamd_worker *worker)
        event_base_loop (ctx->ev_base, 0);
        rspamd_worker_block_signals ();
 
-       g_mime_shutdown ();
        rspamd_stat_close ();
        rspamd_http_router_free (ctx->http);
        rspamd_log_close (worker->srv->logger);
index f404cc70c1d422a72b486e55ec59e56a1e90e9dd..d848f797dea263530ae1249b7cf11379c4bb8811 100644 (file)
@@ -1750,9 +1750,6 @@ rspamd_content_type_check (struct rspamd_task *task,
                        }
                }
 
-#ifndef GMIME24
-               g_object_unref (part);
-#endif
                if (check_subtype) {
                        param_data = &ct->subtype;
                }
index 8b7c4b6f699512d26b2fb8d8e5dc99ebff9092af..566f7bc4b353e573d6597772c4fdaff016ef063c 100644 (file)
@@ -27,6 +27,7 @@
 #include "cryptobox.h"
 #include "contrib/zstd/zstd.h"
 #include "lua/lua_common.h"
+#include "unix-std.h"
 #include <math.h>
 
 /* Max line size */
index 7e56ded79fc7d6e2aa35225495cf78823d513a05..be94f00c2692e2fea07fb17f7e1b9f9e757939d9 100644 (file)
@@ -24,8 +24,6 @@
 #include "dns.h"
 #include "re_cache.h"
 
-#include <gmime/gmime.h>
-
 enum rspamd_command {
        CMD_CHECK,
        CMD_SYMBOLS,
index 9d87d5c9ffce1487360f24d0171efecbe9e9ba82..c33a92180f8220ec80b4aadeb40266d3a01fdb78 100644 (file)
@@ -2105,11 +2105,6 @@ rspamd_init_libs (void)
        rlim.rlim_max = rlim.rlim_cur;
        setrlimit (RLIMIT_STACK, &rlim);
 
-#ifdef GMIME_ENABLE_RFC2047_WORKAROUNDS
-       g_mime_init (GMIME_ENABLE_RFC2047_WORKAROUNDS);
-#else
-       g_mime_init (0);
-#endif
        ctx->libmagic = magic_open (MAGIC_MIME|MAGIC_NO_CHECK_COMPRESS|
                        MAGIC_NO_CHECK_ELF|MAGIC_NO_CHECK_TAR);
        ctx->local_addrs = rspamd_inet_library_init ();
@@ -2291,7 +2286,6 @@ rspamd_deinit_libs (struct rspamd_external_libs_ctx *ctx)
                }
 
                g_free (ctx->ottery_cfg);
-               g_mime_shutdown ();
 
 #ifdef HAVE_OPENSSL
                EVP_cleanup ();
index 9f81bcc992fcd435e9ab4ca4f5174f2aac39b29e..a6ca0b9727d90be10a0d92129865374a83726cf9 100644 (file)
@@ -1493,7 +1493,6 @@ start_rspamd_proxy (struct rspamd_worker *worker)
        event_base_loop (ctx->ev_base, 0);
        rspamd_worker_block_signals ();
 
-       g_mime_shutdown ();
        rspamd_log_close (worker->srv->logger);
 
        if (ctx->key) {
index df772feb5da0d02a7a980eaccd0e87b4a125d709..7b0373c9e92664be2ef361d52bc6e6ab31277fe7 100644 (file)
@@ -36,6 +36,7 @@
 #include "utlist.h"
 #include "libutil/http_private.h"
 #include "monitored.h"
+#include "unix-std.h"
 
 #include "lua/lua_common.h"
 
@@ -633,7 +634,6 @@ start_worker (struct rspamd_worker *worker)
        event_base_loop (ctx->ev_base, 0);
        rspamd_worker_block_signals ();
 
-       g_mime_shutdown ();
        rspamd_stat_close ();
        rspamd_log_close (worker->srv->logger);
 
index 634476b64c50da45d94499fc5fc2b6cf004b548d..20eebf9276140322884e3be7eb66ee55b444fb70 100644 (file)
@@ -19,7 +19,6 @@
 #include "message.h"
 #include "util.h"
 #include "content_type.h"
-#include <gmime/gmime.h>
 
 static gdouble total_time = 0;
 static gint total_parsed = 0;
@@ -44,7 +43,6 @@ rspamd_process_file (const gchar *fname, gint mode)
        GString *buf;
        struct rspamd_content_type *ct;
        gdouble t1, t2;
-       GMimeContentType *gct;
        rspamd_ftok_t t;
 
        f = g_io_channel_new_file (fname, "r", &err);
@@ -72,16 +70,9 @@ rspamd_process_file (const gchar *fname, gint mode)
                        ct = rspamd_content_type_parse (buf->str, buf->len, pool);
                        t2 = rspamd_get_virtual_ticks ();
                }
-               else if (mode == MODE_GMIME) {
-                       t1 = rspamd_get_virtual_ticks ();
-                       gct = g_mime_content_type_new_from_string (buf->str);
-                       t2 = rspamd_get_virtual_ticks ();
-               }
                else {
-                       t1 = rspamd_get_virtual_ticks ();
-                       ct = rspamd_content_type_parse (buf->str, buf->len, pool);
-                       gct = g_mime_content_type_new_from_string (buf->str);
-                       t2 = rspamd_get_virtual_ticks ();
+                       rspamd_fprintf ("gmime is no longer supported\n");
+                       exit (EXIT_FAILURE);
                }
 
                total_time += t2 - t1;
@@ -109,107 +100,6 @@ rspamd_process_file (const gchar *fname, gint mode)
                                }
                        }
                }
-               else if (mode == MODE_GMIME) {
-                       if (gct) {
-                               total_valid ++;
-
-                               if (g_mime_content_type_get_media_type (gct)) {
-                                       total_type ++;
-                               }
-                               if (g_mime_content_type_get_media_subtype (gct)) {
-                                       total_subtype ++;
-                               }
-                               if (g_mime_content_type_get_parameter (gct, "charset")) {
-                                       total_charset ++;
-                               }
-                               if (g_mime_content_type_get_parameter (gct, "boundary")) {
-                                       total_boundaries ++;
-                               }
-                               if (g_mime_content_type_get_params (gct)) {
-                                       total_attrs ++;
-                               }
-
-                               g_object_unref (gct);
-                       }
-               }
-               else {
-                       if (gct && ct) {
-                               total_valid ++;
-
-                               if (g_mime_content_type_get_media_type (gct) && ct->type.len) {
-                                       t.begin = g_mime_content_type_get_media_type (gct);
-                                       t.len = strlen (t.begin);
-
-                                       if (rspamd_ftok_casecmp (&ct->type, &t) == 0) {
-                                               total_type ++;
-                                       }
-                                       else if (verbose) {
-                                               rspamd_fprintf (stderr, "type: '%*s'(rspamd) '%s'gmime\n",
-                                                               (gint)ct->type.len, ct->type.begin,
-                                                               t.begin);
-                                       }
-                               }
-                               if (g_mime_content_type_get_media_subtype (gct) && ct->subtype.len) {
-                                       t.begin = g_mime_content_type_get_media_subtype (gct);
-                                       t.len = strlen (t.begin);
-
-                                       if (rspamd_ftok_casecmp (&ct->subtype, &t) == 0) {
-                                               total_subtype ++;
-                                       }
-                                       else if (verbose) {
-                                               rspamd_fprintf (stderr, "subtype: '%*s'(rspamd) '%s'gmime\n",
-                                                               (gint)ct->subtype.len, ct->subtype.begin,
-                                                               t.begin);
-                                       }
-                               }
-                               if (g_mime_content_type_get_parameter (gct, "charset") && ct->charset.len) {
-                                       t.begin = g_mime_content_type_get_parameter (gct, "charset");
-                                       t.len = strlen (t.begin);
-
-                                       if (rspamd_ftok_casecmp (&ct->charset, &t) == 0) {
-                                               total_charset ++;
-                                       }
-                                       else if (verbose) {
-                                               rspamd_fprintf (stderr, "charset: '%*s'(rspamd) '%s'gmime\n",
-                                                               (gint)ct->charset.len, ct->charset.begin,
-                                                               t.begin);
-                                       }
-                               }
-                               else if (g_mime_content_type_get_parameter (gct, "charset")) {
-                                       if (verbose) {
-                                               rspamd_fprintf (stderr, "charset: '%s'gmime\n",
-                                                               g_mime_content_type_get_parameter (gct, "charset"));
-                                       }
-                               }
-                               if (g_mime_content_type_get_parameter (gct, "boundary") && ct->boundary.len) {
-                                       t.begin = g_mime_content_type_get_parameter (gct, "boundary");
-                                       t.len = strlen (t.begin);
-
-                                       if (rspamd_ftok_casecmp (&ct->boundary, &t) == 0) {
-                                               total_boundaries ++;
-                                       }
-                                       else if (verbose) {
-                                               rspamd_fprintf (stderr, "boundary: '%*s'(rspamd) '%s'gmime\n",
-                                                               (gint)ct->boundary.len, ct->boundary.begin,
-                                                               t.begin);
-                                       }
-                               }
-                               else if (g_mime_content_type_get_parameter (gct, "boundary")) {
-                                       if (verbose) {
-                                               rspamd_fprintf (stderr, "boundary: '%s'gmime\n",
-                                                               g_mime_content_type_get_parameter (gct, "boundary"));
-                                       }
-                               }
-                       }
-                       else if (verbose) {
-                               rspamd_fprintf (stderr, "cannot parse: %v, %d(rspamd), %d(gmime)\n",
-                                               buf, ct ? 1 : 0, gct ? 1 : 0);
-                       }
-
-                       if (gct) {
-                               g_object_unref (gct);
-                       }
-               }
        }
 
        if (err) {
@@ -227,8 +117,6 @@ main (int argc, char **argv)
 {
        gint i, start = 1, mode = MODE_NORMAL;
 
-       g_mime_init (0);
-
        if (argc > 2 && *argv[1] == '-') {
                start = 2;
 
@@ -273,7 +161,5 @@ main (int argc, char **argv)
                                total_boundaries);
        }
 
-       g_mime_shutdown ();
-
        return 0;
 }
index 6b3fbccda739ddbceb5237ccd51a1d3504750cfd..cdbd4c04e19288ceb6a51c6bcb21f9f8f4111b0e 100644 (file)
@@ -22,7 +22,6 @@
 #include "task.h"
 #include "mime_parser.h"
 #include "unix-std.h"
-#include <gmime/gmime.h>
 
 #define MODE_NORMAL 0
 #define MODE_GMIME 1
@@ -75,6 +74,7 @@ rspamd_show_message (struct rspamd_mime_part *part)
                                part, part->parent_part);
 }
 
+#if 0
 static void
 mime_foreach_callback (GMimeObject * parent,
        GMimeObject * part,
@@ -114,7 +114,7 @@ mime_foreach_callback (GMimeObject * parent,
                                g_mime_content_type_get_media_subtype (type));
        }
 }
-
+#endif
 static void
 rspamd_process_file (struct rspamd_config *cfg, const gchar *fname, gint mode)
 {
@@ -123,10 +123,12 @@ rspamd_process_file (struct rspamd_config *cfg, const gchar *fname, gint mode)
        gpointer map;
        struct stat st;
        GError *err = NULL;
+#if 0
        GMimeMessage *message;
        GMimeParser *parser;
        GMimeStream *stream;
        GByteArray tmp;
+#endif
        struct rspamd_mime_part *part;
        guint i;
        gdouble ts1, ts2;
@@ -163,6 +165,7 @@ rspamd_process_file (struct rspamd_config *cfg, const gchar *fname, gint mode)
                        g_error_free (err);
                }
        }
+#if 0
        else if (mode == MODE_GMIME) {
                tmp.data = map;
                tmp.len = st.st_size;
@@ -171,7 +174,7 @@ rspamd_process_file (struct rspamd_config *cfg, const gchar *fname, gint mode)
                parser = g_mime_parser_new_with_stream (stream);
                message = g_mime_parser_construct_message (parser);
        }
-
+#endif
        ts2 = rspamd_get_ticks ();
        total_time += ts2 - ts1;
 
@@ -190,16 +193,19 @@ rspamd_process_file (struct rspamd_config *cfg, const gchar *fname, gint mode)
                        }
                }
        }
+#if 0
        else if (mode == MODE_GMIME) {
                g_mime_message_foreach (message, mime_foreach_callback, NULL);
        }
+#endif
 
        rspamd_task_free (task);
        munmap (map, st.st_size);
-
+#if 0
        if (mode == MODE_GMIME) {
                g_object_unref (message);
        }
+#endif
 }
 
 int
@@ -237,7 +243,6 @@ main (int argc, char **argv)
 
        rspamd_log_close (logger);
        REF_RELEASE (cfg);
-       g_mime_shutdown ();
 
        return 0;
 }