dovecot: fix compilation and build it without libsodium

parent 7e71f1fb
......@@ -96,6 +96,7 @@ CONFIGURE_ARGS += \
--with-notify=dnotify \
--without-lzma \
--without-lz4 \
--without-sodium \
$(if $(CONFIG_DOVECOT_LDAP),--with-ldap=yes,--with-ldap=no) \
$(if $(CONFIG_DOVECOT_MYSQL),--with-mysql=yes,--with-mysql=no) \
$(if $(CONFIG_DOVECOT_PGSQL),--with-pgsql=yes,--with-pgsql=no) \
......
--- a/configure.ac
+++ b/configure.ac
@@ -488,9 +488,9 @@ have_ioloop=no
if test "$ioloop" = "best" || test "$ioloop" = "epoll"; then
AC_CACHE_CHECK([whether we can use epoll],i_cv_epoll_works,[
diff -u --recursive dovecot-2.3.1-vanilla/m4/fd_passing.m4 dovecot-2.3.1/m4/fd_passing.m4
--- dovecot-2.3.1-vanilla/m4/fd_passing.m4 2018-06-08 20:02:15.849850956 -0400
+++ dovecot-2.3.1/m4/fd_passing.m4 2018-06-08 20:04:28.947016370 -0400
@@ -8,7 +8,7 @@
CFLAGS="$CFLAGS -DBUGGY_CMSG_MACROS"
fi
- AC_TRY_RUN([
+ AC_TRY_LINK([
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
@@ -16,7 +16,7 @@
#include <unistd.h>
#include <fcntl.h>
#include "fdpass.h"
-
+ ], [
static
int nopen(void)
{
diff -u --recursive dovecot-2.3.1-vanilla/m4/glibc.m4 dovecot-2.3.1/m4/glibc.m4
--- dovecot-2.3.1-vanilla/m4/glibc.m4 2018-06-08 20:02:15.850850957 -0400
+++ dovecot-2.3.1/m4/glibc.m4 2018-06-08 20:04:00.780981363 -0400
@@ -17,7 +17,7 @@
dnl * Old glibcs have broken posix_fallocate(). Make sure not to use it.
dnl * It may also be broken in AIX.
AC_CACHE_CHECK([whether posix_fallocate() works],i_cv_posix_fallocate_works,[
- AC_TRY_RUN([
+ AC_TRY_LINK([
#include <sys/epoll.h>
-
#define _XOPEN_SOURCE 600
#include <stdio.h>
#include <stdlib.h>
@@ -26,6 +26,7 @@
#if defined(__GLIBC__) && (__GLIBC__ < 2 || __GLIBC_MINOR__ < 7)
possibly broken posix_fallocate
#endif
+ ], [
int main()
{
return epoll_create(5) < 1;
@@ -594,7 +594,7 @@ fi
dnl * Old glibcs have broken posix_fallocate(). Make sure not to use it.
dnl * It may also be broken in AIX.
AC_CACHE_CHECK([whether posix_fallocate() works],i_cv_posix_fallocate_works,[
- AC_TRY_RUN([
+ AC_TRY_LINK([
#define _XOPEN_SOURCE 600
#include <stdio.h>
#include <stdlib.h>
@@ -603,6 +603,7 @@ AC_CACHE_CHECK([whether posix_fallocate(
#if defined(__GLIBC__) && (__GLIBC__ < 2 || __GLIBC_MINOR__ < 7)
possibly broken posix_fallocate
#endif
+ ], [
int main() {
int fd = creat("conftest.temp", 0600);
int ret;
int main() {
int fd = creat("conftest.temp", 0600);
int ret;
diff -u --recursive dovecot-2.3.1-vanilla/m4/ioloop.m4 dovecot-2.3.1/m4/ioloop.m4
--- dovecot-2.3.1-vanilla/m4/ioloop.m4 2018-06-08 20:02:15.850850957 -0400
+++ dovecot-2.3.1/m4/ioloop.m4 2018-06-08 20:03:31.666945181 -0400
@@ -4,9 +4,9 @@
if test "$ioloop" = "best" || test "$ioloop" = "epoll"; then
AC_CACHE_CHECK([whether we can use epoll],i_cv_epoll_works,[
- AC_TRY_RUN([
+ AC_TRY_LINK([
#include <sys/epoll.h>
-
+ ], [
int main()
{
return epoll_create(5) < 1;
diff -u --recursive dovecot-2.3.1-vanilla/m4/mmap_write.m4 dovecot-2.3.1/m4/mmap_write.m4
--- dovecot-2.3.1-vanilla/m4/mmap_write.m4 2018-06-08 20:02:15.850850957 -0400
+++ dovecot-2.3.1/m4/mmap_write.m4 2018-06-08 20:03:27.369939841 -0400
@@ -1,7 +1,7 @@
dnl * If mmap() plays nicely with write()
AC_DEFUN([DOVECOT_MMAP_WRITE], [
AC_CACHE_CHECK([whether shared mmaps get updated by write()s],i_cv_mmap_plays_with_write,[
- AC_TRY_RUN([
+ AC_TRY_LINK([
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -9,6 +9,7 @@
#include <fcntl.h>
#include <sys/mman.h>
#include <string.h>
+ ], [
int main() {
/* return 0 if we're signed */
int f = open("conftest.mmap", O_RDWR|O_CREAT|O_TRUNC, 0600);
diff -u --recursive dovecot-2.3.1-vanilla/m4/want_gssapi.m4 dovecot-2.3.1/m4/want_gssapi.m4
--- dovecot-2.3.1-vanilla/m4/want_gssapi.m4 2018-06-08 20:02:15.850850957 -0400
+++ dovecot-2.3.1/m4/want_gssapi.m4 2018-06-08 20:04:13.204996804 -0400
@@ -54,7 +54,7 @@
# does the kerberos library support SPNEGO?
AC_CACHE_CHECK([whether GSSAPI supports SPNEGO],i_cv_gssapi_spnego,[
- AC_TRY_RUN([
+ AC_TRY_LINK([
#ifdef HAVE_GSSAPI_H
# include <gssapi.h>
#else
@@ -62,6 +62,7 @@
#endif
#include <krb5.h>
#include <string.h>
+ ], [
int main(void) {
OM_uint32 minor_status;
gss_OID_set mech_set;
Index: dovecot-2.2.33.2/src/lib/byteorder.h
===================================================================
--- dovecot-2.2.33.2.orig/src/lib/byteorder.h
+++ dovecot-2.2.33.2/src/lib/byteorder.h
@@ -23,6 +23,11 @@
#ifndef BYTEORDER_H
#define BYTEORDER_H
+#undef bswap_8
+#undef bswap_16
+#undef bswap_32
+#undef bswap_64
+
/*
* These prototypes exist to catch bugs in the code generating macros below.
*/
pigeonhole: Fix managesieve-login needs libdovecot-login
When trying to use managesieve my MUA complained sieve wasn't supported.
On investigation dovecot logs the following could be seen:
Aug 16 00:28:44 managesieve-login: Fatal: master:
service(managesieve-login): child 1430 returned error 127
Aug 16 00:31:32 managesieve-login: Error: Error loading shared
library libdovecot-login.so.0: No such file or directory
(needed by /usr/lib/dovecot/managesieve-login)
Aug 16 00:31:32 managesieve-login: Error: Error loading
shared library libdovecot.so.0: No such file or directory
(needed by /usr/lib/dovecot/managesieve-login)
Aug 16 00:31:32 managesieve-login: Error: Error relocating
/usr/lib/dovecot/managesieve-login: net_ip2addr: symbol not found
The issue (verified with readelf on non-working build and build with my fix)
is that there is no RPATH information in the pigeonhole binaries (like
managesieve-login).
The dovecot-config that is 'installed' in the staging dir
assumes that plugins will be built on the same host as the installed files.
The 'installed' dovecot-config (partial) looks like:
LIBDOVECOT='-L/usr/lib/dovecot -ldovecot'
LIBDOVECOT_LOGIN='-ldovecot-login -L/home/user/Build/openwrt/openwrt-ath79/staging_dir/target-mips_24kc_musl/usr/lib -lssl -lcrypto'
LIBDOVECOT_SQL=-ldovecot-sql
LIBDOVECOT_COMPRESS=-ldovecot-compression
LIBDOVECOT_LDA=-ldovecot-lda
LIBDOVECOT_STORAGE='-ldovecot-storage '
LIBDOVECOT_DSYNC=-ldovecot-dsync
LIBDOVECOT_LIBFTS=-ldovecot-fts
This patch modifed dovecot-config that gets installed on the assumption
that users of libdovecot will also be cross-compiled (a safe bet).
Index: dovecot-2.3.2.1/Makefile.am
===================================================================
--- dovecot-2.3.2.1.orig/Makefile.am
+++ dovecot-2.3.2.1/Makefile.am
@@ -73,7 +73,7 @@ install-exec-hook:
grep -v '^LIBDOVECOT_.*_INCLUDE' dovecot-config | \
grep -v '^LIBDOVECOT.*_DEPS' | sed \
-e "s|^\(DOVECOT_INSTALLED\)=.*$$|\1=yes|" \
- -e "s|^\(LIBDOVECOT\)=.*$$|\1='-L$(pkglibdir) -ldovecot'|" \
+ -e "s|^\(LIBDOVECOT\)=.*$$|\1='-L$(STAGING_DIR)$(pkglibdir) -ldovecot'|" \
-e "s|^\(LIBDOVECOT_LOGIN\)=.*$$|\1='-ldovecot-login $(SSL_LIBS)'|" \
-e "s|^\(LIBDOVECOT_SQL\)=.*$$|\1=-ldovecot-sql|" \
-e "s|^\(LIBDOVECOT_COMPRESS\)=.*$$|\1=-ldovecot-compression|" \
@@ -81,7 +81,8 @@ install-exec-hook:
-e "s|^\(LIBDOVECOT_LDA\)=.*$$|\1=-ldovecot-lda|" \
-e "s|^\(LIBDOVECOT_LIBFTS\)=.*$$|\1=-ldovecot-fts|" \
-e "s|^\(LIBDOVECOT_STORAGE\)=.*$$|\1='-ldovecot-storage $(LINKED_STORAGE_LDADD)'|" \
- -e "s|^\(LIBDOVECOT_INCLUDE\)=.*$$|\1=-I$(pkgincludedir)|" \
+ -e "s|^\(LIBDOVECOT_INCLUDE\)=.*$$|\1=-I$(STAGING_DIR)$(pkgincludedir)|" \
+ -e "s|^\(DOVECOT_BINARY_LDFLAGS=\".*\)\"$$|\1 -Wl,-rpath -Wl,$(pkglibdir)\"|" \
> $(DESTDIR)$(pkglibdir)/dovecot-config
uninstall-hook:
diff --git a/src/lib-dcrypt/dcrypt-openssl.c b/src/lib-dcrypt/dcrypt-openssl.c
index c2dbd30..201ab40 100644
--- a/src/lib-dcrypt/dcrypt-openssl.c
+++ b/src/lib-dcrypt/dcrypt-openssl.c
@@ -20,6 +20,7 @@
#include <openssl/engine.h>
#include <openssl/hmac.h>
#include <openssl/objects.h>
+#include <openssl/bn.h>
#include "dcrypt.h"
#include "dcrypt-private.h"
diff --git a/src/lib-ssl-iostream/iostream-openssl-context.c b/src/lib-ssl-iostream/iostream-openssl-context.c
index e3c902e..ad6a9c1 100644
--- a/src/lib-ssl-iostream/iostream-openssl-context.c
+++ b/src/lib-ssl-iostream/iostream-openssl-context.c
@@ -6,6 +6,9 @@
#include "dovecot-openssl-common.h"
#include <openssl/crypto.h>
+#include <openssl/rsa.h>
+#include <openssl/dh.h>
+#include <openssl/bn.h>
#include <openssl/x509.h>
#include <openssl/pem.h>
#include <openssl/ssl.h>
--- a/src/lib-dcrypt/dcrypt-openssl.c
+++ b/src/lib-dcrypt/dcrypt-openssl.c
@@ -17,10 +17,12 @@
#include <openssl/bio.h>
#include <openssl/pem.h>
#include <openssl/x509.h>
-#include <openssl/engine.h>
#include <openssl/hmac.h>
#include <openssl/objects.h>
#include <openssl/bn.h>
+#ifndef OPENSSL_NO_ENGINE
+#include <openssl/engine.h>
+#endif
#include "dcrypt.h"
#include "dcrypt-private.h"
@@ -179,11 +181,13 @@ static bool dcrypt_openssl_error(const char **error_r)
static bool dcrypt_openssl_initialize(const struct dcrypt_settings *set,
const char **error_r)
{
+#ifndef OPENSSL_NO_ENGINE
if (set->crypto_device != NULL && set->crypto_device[0] != '\0') {
if (dovecot_openssl_common_global_set_engine(
set->crypto_device, error_r) <= 0)
return FALSE;
}
+#endif
return TRUE;
}
--- a/src/lib-ssl-iostream/dovecot-openssl-common.c
+++ b/src/lib-ssl-iostream/dovecot-openssl-common.c
@@ -5,11 +5,14 @@
#include "dovecot-openssl-common.h"
#include <openssl/ssl.h>
-#include <openssl/engine.h>
#include <openssl/rand.h>
+#ifndef OPENSSL_NO_ENGINE
+#include <openssl/engine.h>
-static int openssl_init_refcount = 0;
static ENGINE *dovecot_openssl_engine;
+#endif
+
+static int openssl_init_refcount = 0;
#ifdef HAVE_SSL_NEW_MEM_FUNCS
static void *dovecot_openssl_malloc(size_t size, const char *u0 ATTR_UNUSED, int u1 ATTR_UNUSED)
@@ -75,17 +78,21 @@ bool dovecot_openssl_common_global_unref(void)
if (--openssl_init_refcount > 0)
return TRUE;
+#ifndef OPENSSL_NO_ENGINE
if (dovecot_openssl_engine != NULL) {
ENGINE_finish(dovecot_openssl_engine);
dovecot_openssl_engine = NULL;
}
+#endif
/* OBJ_cleanup() is called automatically by EVP_cleanup() in
newer versions. Doesn't hurt to call it anyway. */
OBJ_cleanup();
#ifdef HAVE_SSL_COMP_FREE_COMPRESSION_METHODS
SSL_COMP_free_compression_methods();
#endif
+#ifndef OPENSSL_NO_ENGINE
ENGINE_cleanup();
+#endif
EVP_cleanup();
CRYPTO_cleanup_all_ex_data();
#ifdef HAVE_OPENSSL_AUTO_THREAD_DEINIT
@@ -107,6 +114,7 @@ bool dovecot_openssl_common_global_unref(void)
int dovecot_openssl_common_global_set_engine(const char *engine,
const char **error_r)
{
+#ifndef OPENSSL_NO_ENGINE
if (dovecot_openssl_engine != NULL)
return 1;
@@ -128,5 +136,6 @@ int dovecot_openssl_common_global_set_engine(const char *engine,
dovecot_openssl_engine = NULL;
return -1;
}
+#endif
return 1;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment