From 1650f051c15f62c12ada20a041927428e00773af Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 27 Mar 2013 11:53:05 +0000 Subject: [PATCH] Fix CentOS 5 build. --- CMakeLists.txt | 16 +++++++++++++++- config.h.in | 4 ++++ src/dkim.c | 25 +++++++++++++++++++++++++ src/main.c | 4 ++++ src/plugins/regexp.c | 4 ++++ 5 files changed, 52 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ea4e2ea1..c27884fd4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -538,6 +538,20 @@ INCLUDE_DIRECTORIES(${GLIB2_INCLUDE_DIRS}) LINK_DIRECTORIES(${GLIB2_LIBRARY_DIRS}) +FIND_LIBRARY(LIBZ_LIBRARY NAMES z PATH_SUFFIXES lib64 lib + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw + /opt/local + /opt/csw + /opt + DOC "Path where the libz library can be found") +IF(NOT LIBZ_LIBRARY) + MESSAGE(FATAL_ERROR "libz is required for libgmime") +ENDIF(NOT LIBZ_LIBRARY) # Check for libevent FIND_LIBRARY(LIBEVENT_LIBRARY NAMES event PATH_SUFFIXES lib64 lib @@ -955,8 +969,8 @@ AddModules(MODULES_LIST WORKERS_LIST) ################################ SUBDIRS SECTION ########################### +ADD_SUBDIRECTORY(contrib/lgpl) IF(GLIB_COMPAT) - ADD_SUBDIRECTORY(contrib/lgpl) INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/contrib/lgpl") ENDIF(GLIB_COMPAT) diff --git a/config.h.in b/config.h.in index 91c1277ee..0ecb53059 100644 --- a/config.h.in +++ b/config.h.in @@ -426,6 +426,10 @@ #include "gchecksum.h" #endif +#if (GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION < 14) +typedef off_t goffset; +#endif + #ifndef BUILD_STATIC #include #endif diff --git a/src/dkim.c b/src/dkim.c index b0bc19541..feb11893d 100644 --- a/src/dkim.c +++ b/src/dkim.c @@ -79,7 +79,15 @@ rspamd_dkim_parse_signature (rspamd_dkim_context_t* ctx, const gchar *param, gsi { ctx->b = memory_pool_alloc (ctx->pool, len + 1); rspamd_strlcpy (ctx->b, param, len + 1); +#if ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION < 20)) + gchar *tmp; + gsize tmp_len = len; + tmp = g_base64_decode (ctx->b, &tmp_len); + rspamd_strlcpy (ctx->b, tmp, len + 1); + g_free (tmp); +#else g_base64_decode_inplace (ctx->b, &len); +#endif ctx->blen = len; return TRUE; } @@ -322,7 +330,15 @@ rspamd_dkim_parse_bodyhash (rspamd_dkim_context_t* ctx, const gchar *param, gsiz { ctx->bh = memory_pool_alloc (ctx->pool, len + 1); rspamd_strlcpy (ctx->bh, param, len + 1); +#if ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION < 20)) + gchar *tmp; + gsize tmp_len = len; + tmp = g_base64_decode (ctx->bh, &tmp_len); + rspamd_strlcpy (ctx->bh, tmp, len + 1); + g_free (tmp); +#else g_base64_decode_inplace (ctx->bh, &len); +#endif ctx->bhlen = len; return TRUE; } @@ -627,7 +643,16 @@ rspamd_dkim_make_key (const gchar *keydata, guint keylen, GError **err) rspamd_strlcpy (key->keydata, keydata, keylen + 1); key->keylen = keylen + 1; key->decoded_len = keylen + 1; +#if ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION < 20)) + gchar *tmp; + gsize tmp_len = keylen; + tmp = g_base64_decode (key->keydata, &tmp_len); + rspamd_strlcpy (key->keydata, tmp, keylen + 1); + g_free (tmp); + key->decoded_len = tmp_len; +#else g_base64_decode_inplace (key->keydata, &key->decoded_len); +#endif #ifdef HAVE_OPENSSL key->key_bio = BIO_new_mem_buf (key->keydata, key->decoded_len); if (key->key_bio == NULL) { diff --git a/src/main.c b/src/main.c index e50b223aa..ed72e48bc 100644 --- a/src/main.c +++ b/src/main.c @@ -467,10 +467,14 @@ fork_worker (struct rspamd_main *rspamd, struct worker_conf *cf) close_log (rspamd->logger); open_log (rspamd->logger); #if ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION <= 30)) +# if (GLIB_MINOR_VERSION > 20) /* Ugly hack for old glib */ if (!g_thread_get_initialized ()) { g_thread_init (NULL); } +# else + g_thread_init (NULL); +# endif #endif msg_info ("starting %s process %P", cf->worker->name, getpid ()); cf->worker->worker_start_func (cur); diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c index 9dce07772..272805548 100644 --- a/src/plugins/regexp.c +++ b/src/plugins/regexp.c @@ -1309,9 +1309,13 @@ process_regexp_item (struct worker_task *task, void *user_data) if (!item->lua_function && regexp_module_ctx->max_threads > 1) { if (regexp_module_ctx->workers == NULL) { #if ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION <= 30)) +# if GLIB_MINOR_VERSION > 20 if (! g_thread_get_initialized ()) { g_thread_init (NULL); } +# else + g_thread_init (NULL); +# endif workers_mtx = g_mutex_new (); #else workers_mtx = memory_pool_alloc (regexp_module_ctx->regexp_pool, sizeof (GMutex)); -- 2.39.5