Try this diff.

Untested but if my theory as to why it's breaking is correct, it
should work.

Only the dlopen()'d libdriver_mysql.so modules are linked with
-lpthread. This isn't enough on OpenBSD, the programs calling them
also need linking that way.

LD_PRELOAD didn't work because Dovecot cleans the environment that
it passes to child processes (specifically, whichever of lda, auth,
dict, *-login etc. actually call dlopen to load the mysql module).

Diff is done this way for expediency, to go upstream it would at
least want the patch moving to configure.ac and checking the OS.

Index: Makefile
===================================================================
RCS file: /cvs/ports/mail/dovecot/Makefile,v
retrieving revision 1.227
diff -u -p -r1.227 Makefile
--- Makefile    25 Oct 2014 22:06:40 -0000      1.227
+++ Makefile    27 Oct 2014 11:54:42 -0000
@@ -9,6 +9,7 @@ COMMENT-postgresql= PostgreSQL authentic
 
 V_MAJOR=       2.2
 V_DOVECOT=     2.2.15
+REVISION-server=0
 
 DISTNAME=      dovecot-${V_DOVECOT}
 PKGNAME=       dovecot-${V_DOVECOT}
@@ -35,7 +36,7 @@ MAINTAINER=   Brad Smith <b...@comstyle.co
 # LGPLv2.1 and MIT
 PERMIT_PACKAGE_CDROM=  Yes
 
-WANTLIB-server=        bz2 c crypto lz4 lzma sqlite3 ssl z 
${MODLIBICONV_WANTLIB}
+WANTLIB-server=        bz2 c crypto lz4 lzma pthread sqlite3 ssl z 
${MODLIBICONV_WANTLIB}
 WANTLIB-ldap=  crypto lber-2.4 ldap-2.4 sasl2 ssl
 WANTLIB-mysql= crypto m lib/mysql/mysqlclient pthread ssl stdc++ z
 WANTLIB-postgresql= crypto pq>=4 ssl
Index: patches/patch-configure
===================================================================
RCS file: patches/patch-configure
diff -N patches/patch-configure
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-configure     27 Oct 2014 11:54:42 -0000
@@ -0,0 +1,12 @@
+$OpenBSD$
+--- configure.orig     Mon Oct 27 11:49:14 2014
++++ configure  Mon Oct 27 11:49:23 2014
+@@ -25263,7 +25263,7 @@ _ACEOF
+ 
+ 
+ CFLAGS="$CFLAGS $EXTRA_CFLAGS"
+-NOPLUGIN_LDFLAGS="-no-undefined"
++NOPLUGIN_LDFLAGS="-no-undefined -lpthread"
+ if test "$with_gnu_ld" = yes; then
+   NOPLUGIN_LDFLAGS="$NOPLUGIN_LDFLAGS -Wl,--as-needed"
+ fi

Reply via email to