diff -Nru mutt-1.4.gnutls/PATCHES mutt-1.4.gnutlsdlopen/PATCHES --- mutt-1.4.gnutls/PATCHES Sun Jun 9 22:44:46 2002 +++ mutt-1.4.gnutlsdlopen/PATCHES Sun Jun 9 22:50:20 2002 @@ -1,0 +1 @@ +patch-1.4.admcd.gnutlsdlopen.53d diff -Nru mutt-1.4.gnutls/imap/imap.c mutt-1.4.gnutlsdlopen/imap/imap.c --- mutt-1.4.gnutls/imap/imap.c Sun Jun 9 22:44:46 2002 +++ mutt-1.4.gnutlsdlopen/imap/imap.c Sun Jun 9 22:50:20 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.4.gnutls/mutt_ssl_gnutls_dlopen.c mutt-1.4.gnutlsdlopen/mutt_ssl_gnutls_dlopen.c --- mutt-1.4.gnutls/mutt_ssl_gnutls_dlopen.c Thu Jan 1 01:00:00 1970 +++ mutt-1.4.gnutlsdlopen/mutt_ssl_gnutls_dlopen.c Sun Jun 9 22:50:20 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