diff -Nru mutt-1.5.1.gnutls/Makefile.am mutt-1.5.1.gnutlsdlopen/Makefile.am --- mutt-1.5.1.gnutls/Makefile.am Sun Jun 2 15:49:41 2002 +++ mutt-1.5.1.gnutlsdlopen/Makefile.am Sun Jun 2 15:50:21 2002 @@ -16,6 +16,7 @@ BUILT_SOURCES = keymap_defs.h patchlist.c bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@ @SMIMEAUX_TARGET@ +pkglib_LTLIBRARIES = @GNUTLSMODULE_TARGET@ mutt_SOURCES = $(BUILT_SOURCES) \ addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \ commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \ @@ -50,6 +51,7 @@ DEFS=-DPKGDATADIR=\"$(pkgdatadir)\" -DSYSCONFDIR=\"$(sysconfdir)\" \ -DBINDIR=\"$(bindir)\" -DMUTTLOCALEDIR=\"$(datadir)/locale\" \ + -DPKGLIBDIR=\"$(pkglibdir)\" \ -DHAVE_CONFIG_H=1 INCLUDES=-I. -I$(top_srcdir) $(IMAP_INCLUDES) -Iintl @@ -61,7 +63,7 @@ mutt_tunnel.c pop.c pop_auth.c pop_lib.c crypt.c smime.c pgp.c pgpinvoke.c pgpkey.c \ pgplib.c sha1.c pgpmicalg.c gnupgparse.c resize.c dotlock.c remailer.c \ browser.h mbyte.h remailer.h url.h mutt_ssl_nss.c pgppacket.c \ - mutt_ssl_gnutls.c + mutt_ssl_gnutls.c mutt_ssl_gnutls_dlopen.c EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO \ configure acconfig.h account.h \ @@ -87,8 +89,12 @@ mutt_dotlock.c: dotlock.c cp $(srcdir)/dotlock.c mutt_dotlock.c +EXTRA_LTLIBRARIES = mutt_ssl_gnutls.la +mutt_ssl_gnutls_la_SOURCES = mutt_ssl_gnutls.c +mutt_ssl_gnutls_la_LDFLAGS = -no-undefined -module -avoid-version + CLEANFILES = mutt_dotlock.c stamp-doc-rc makedoc \ - keymap_alldefs.h keymap_defs.h patchlist.c + keymap_alldefs.h keymap_defs.h patchlist.c mutt_ssl_gnutls.la ACLOCAL_AMFLAGS = -I m4 diff -Nru mutt-1.5.1.gnutls/PATCHES mutt-1.5.1.gnutlsdlopen/PATCHES --- mutt-1.5.1.gnutls/PATCHES Sun Jun 2 15:53:27 2002 +++ mutt-1.5.1.gnutlsdlopen/PATCHES Sun Jun 2 15:53:12 2002 @@ -1,0 +1 @@ +patch-1.5.1.admcd.gnutlsdlopen.52 diff -Nru mutt-1.5.1.gnutls/configure.in mutt-1.5.1.gnutlsdlopen/configure.in --- mutt-1.5.1.gnutls/configure.in Sun Jun 2 15:49:41 2002 +++ mutt-1.5.1.gnutlsdlopen/configure.in Sun Jun 2 15:52:16 2002 @@ -32,6 +32,7 @@ AC_MSG_ERROR(Compiler not ANSI compliant) fi AC_PROG_CPP +AC_PROG_LIBTOOL AC_PROG_MAKE_SET AC_PROG_INSTALL AC_PROG_RANLIB @@ -556,6 +557,16 @@ ]) AM_CONDITIONAL(USE_SSL, test x$need_ssl = xyes) +dnl GNUTLS support via module +AC_ARG_ENABLE(module, [ --enable-module Put GNUTLS support in module if using gnutls], +[ + if test x$enableval = xyes ; then + AC_CHECK_LIB(dl, dlopen,, AC_MSG_ERROR([Unable to find dlopen in dl library])) + AC_DEFINE(USE_DLOPEN,1,[ Define if you want support for GNUTLS compiled as a module. ]) + need_dlopen=yes + fi +]) + dnl SSL support via GNUTLS AC_ARG_WITH(gnutls, [ --with-gnutls Compile in SSL support for POP/IMAP via GNUTLS], [ if test "$with_gnutls" != "no" @@ -570,12 +581,26 @@ AC_DEFINE(USE_GNUTLS,1,[ Define if you want support for SSL via the GNUTLS library. ]) LIBS="$saved_LIBS" - MUTTLIBS="$MUTTLIBS $LIBGNUTLS_LIBS" - MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS mutt_ssl_gnutls.o" - CFLAGS="$CFLAGS $LIBGNUTLS_CFLAGS" + if test "$need_dlopen" != "yes"; then + MUTTLIBS="$MUTTLIBS $LIBGNUTLS_LIBS" + MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS mutt_ssl_gnutls.o" + CFLAGS="$CFLAGS $LIBGNUTLS_CFLAGS" + else + MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS mutt_ssl_gnutls_dlopen.o" + MUTTLIBS="$MUTTLIBS -ldl -rdynamic" + GNUTLSMODULE_TARGET="mutt_ssl_gnutls.la" + fi need_gnutls=yes fi ]) + +AC_SUBST(GNUTLSMODULE_TARGET) + +if test "$need_gnutls" != "yes"; then + if test "$need_dlopen" = "yes"; then + AC_MSG_ERROR([GNUTLS module building requested, without GNUTLS support]) + fi +fi dnl SSL support via NSS AC_ARG_WITH(nss, [ --with-nss[=PFX] Compile in SSL support for POP/IMAP via NSS], diff -Nru mutt-1.5.1.gnutls/imap/imap.c mutt-1.5.1.gnutlsdlopen/imap/imap.c --- mutt-1.5.1.gnutls/imap/imap.c Sun Jun 2 15:49:41 2002 +++ mutt-1.5.1.gnutlsdlopen/imap/imap.c Sun Jun 2 15:50:21 2002 @@ -385,7 +385,12 @@ goto bail; #if defined(USE_SSL) || defined(USE_GNUTLS) /* Attempt STARTTLS if available and desired. */ +#ifdef USE_DLOPEN + if (mutt_bit_isset (idata->capabilities, STARTTLS) && !idata->conn->ssf + && mutt_gnutls_starttls_prepare() == 0) +#else if (mutt_bit_isset (idata->capabilities, STARTTLS) && !idata->conn->ssf) +#endif { int rc; diff -Nru mutt-1.5.1.gnutls/mutt_ssl_gnutls_dlopen.c mutt-1.5.1.gnutlsdlopen/mutt_ssl_gnutls_dlopen.c --- mutt-1.5.1.gnutls/mutt_ssl_gnutls_dlopen.c Thu Jan 1 01:00:00 1970 +++ mutt-1.5.1.gnutlsdlopen/mutt_ssl_gnutls_dlopen.c Sun Jun 2 15:50:21 2002 @@ -0,0 +1,111 @@ +/* Copyright (C) 2001 Marco d'Itri + * Copyright (C) 2001-2002 Andrew McDonald + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + */ + +#include "mutt.h" +#include "mutt_ssl.h" +#include + +/*#define PKGLIBDIR "."*/ + +#if defined USE_DLOPEN && defined USE_GNUTLS +static int (*real_mutt_gnutls_socket_setup) (CONNECTION *conn) = NULL; +static int (*real_mutt_gnutls_starttls) (CONNECTION *conn) = NULL; + +int mutt_gnutls_socket_setup (CONNECTION * conn) +{ + /* if the gnutls module fails, we give an error every time + mutt tries to set up a socket + this gets mutt 'stuck', but is the same behaviour as if mutt + tried to use SSL when built without support for it */ + + if (!real_mutt_gnutls_socket_setup) { + void *lib; + char *error; + + lib = dlopen (PKGLIBDIR "/mutt_ssl_gnutls.so", RTLD_NOW); + if (!lib) { + mutt_error (_("Cannot load SSL module: %s"), dlerror()); + sleep (4); + return -1; + } + + real_mutt_gnutls_socket_setup = + (int (*)(CONNECTION *)) dlsym (lib, "mutt_gnutls_socket_setup"); + error = dlerror(); + if (error) { + mutt_error (_("Cannot find symbol mutt_gnutls_socket_setup: %s"), error); + sleep (4); + return -1; + } + } + + return real_mutt_gnutls_socket_setup (conn); +} + +int mutt_gnutls_starttls_prepare (void) +{ + if (!real_mutt_gnutls_starttls) { + void *lib; + char *error; + + lib = dlopen (PKGLIBDIR "/mutt_ssl_gnutls.so", RTLD_NOW); + if (!lib) { + mutt_message (_("Server supports TLS, but gnutls module won't load: proceeding unencrypted")); + mutt_sleep (0); + return -1; + } + + real_mutt_gnutls_starttls = + (int (*)(CONNECTION *)) dlsym (lib, "mutt_gnutls_starttls"); + error = dlerror(); + if (error) { + mutt_message (_("Server supports TLS, but gnutls module won't load: proceeding unencrypted")); + mutt_sleep (0); + return -1; + } + } + + return 0; +} + +int mutt_gnutls_starttls (CONNECTION* conn) +{ + if (!real_mutt_gnutls_starttls) { + void *lib; + char *error; + + lib = dlopen (PKGLIBDIR "/mutt_ssl_gnutls.so", RTLD_NOW); + if (!lib) { + mutt_error (_("Cannot load SSL module: %s"), dlerror()); + sleep (4); + return -1; + } + + real_mutt_gnutls_starttls = + (int (*)(CONNECTION *)) dlsym (lib, "mutt_gnutls_starttls"); + error = dlerror(); + if (error) { + mutt_error (_("Cannot find symbol mutt_gnutls_starttls: %s"), error); + sleep (4); + return -1; + } + } + + return real_mutt_gnutls_starttls (conn); +} +#endif diff -Nru mutt-1.5.1.gnutls/prepare mutt-1.5.1.gnutlsdlopen/prepare --- mutt-1.5.1.gnutls/prepare Wed Jun 21 16:55:23 2000 +++ mutt-1.5.1.gnutlsdlopen/prepare Sun Jun 2 15:50:21 2002 @@ -8,7 +8,8 @@ fi if aclocal -I m4 && autoheader && (cd m4 && make -f Makefile.am.in ) \ - && automake $include_deps && autoconf && ./configure $@ + && libtoolize --automake && automake $include_deps \ + && autoconf && ./configure $@ then echo echo "The mutt source code was successfully prepared."