From: Rocco Rutte Date: Fri, 28 Apr 2006 08:35:02 +0000 (+0000) Subject: pdmef+fix+sslinterface. Triggered by a warning when compiling X-Git-Tag: mutt-1-5-12-rel~99 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=41b5cab5a498606a015fcdb52eb3d19147007cef;p=mutt pdmef+fix+sslinterface. Triggered by a warning when compiling with POP and GNUTLS, I noticed the SSL interfaces for OpenSSL and GNUTLS internally are different which doesn't make sense. --- diff --git a/buffy.c b/buffy.c index 0404b3db..f359529a 100644 --- a/buffy.c +++ b/buffy.c @@ -309,6 +309,7 @@ int mutt_buffy_check (int force) #ifdef USE_IMAP if (tmp->magic != M_IMAP) + { #endif #ifdef USE_POP if (mx_is_pop (tmp->path)) @@ -327,6 +328,9 @@ int mutt_buffy_check (int force) #endif continue; } +#ifdef USE_IMAP + } +#endif /* check to see if the folder is the currently selected folder * before polling */ diff --git a/configure.in b/configure.in index 7c07a858..b49bdb48 100644 --- a/configure.in +++ b/configure.in @@ -587,6 +587,7 @@ AC_ARG_WITH(ssl, AC_HELP_STRING([--with-ssl[=PFX]], [Compile in SSL support for AC_CHECK_FUNCS(RAND_status RAND_egd) AC_DEFINE(USE_SSL,1,[ Define if you want support for SSL. ]) + AC_DEFINE(USE_SSL_OPENSSL,1,[ Define if you want support for SSL via OpenSSL. ]) LIBS="$saved_LIBS" MUTTLIBS="$MUTTLIBS -lssl -lcrypto" MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS mutt_ssl.o" @@ -597,7 +598,7 @@ AC_ARG_WITH(ssl, AC_HELP_STRING([--with-ssl[=PFX]], [Compile in SSL support for AC_ARG_WITH([gnutls], AC_HELP_STRING([--with-gnutls[=PFX]], [Enable SSL support using gnutls]), [gnutls_prefix="$withval"], [gnutls_prefix="no"]) -if test "$gnutls_prefix" != "no" +if test "$gnutls_prefix" != "no" -a x"$need_ssl" != xyes then if test "$need_socket" != "yes" then @@ -607,7 +608,9 @@ then [dnl GNUTLS found CPPFLAGS="$CPPFLAGS $LIBGNUTLS_CFLAGS" MUTTLIBS="$MUTTLIBS $LIBGNUTLS_LIBS" - AC_DEFINE(USE_GNUTLS, 1, [Define if you want support for SSL via the gnutls library.]) + + AC_DEFINE(USE_SSL,1,[ Define if you want support for SSL. ]) + AC_DEFINE(USE_SSL_GNUTLS,1,[ Define if you want support for SSL via GNUTLS. ]) MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS mutt_ssl_gnutls.o" need_ssl=yes], diff --git a/globals.h b/globals.h index a7b7da1f..cf1bafde 100644 --- a/globals.h +++ b/globals.h @@ -115,17 +115,17 @@ WHERE char *Signature; WHERE char *SimpleSearch; WHERE char *Spoolfile; WHERE char *SpamSep; -#if defined(USE_SSL) || defined(USE_GNUTLS) +#if defined(USE_SSL) WHERE char *SslCertFile INITVAL (NULL); #endif -#ifdef USE_SSL +#ifdef USE_SSL_OPENSSL WHERE char *SslClientCert INITVAL (NULL); WHERE LIST *SslSessionCerts INITVAL (NULL); #endif #if defined(USE_SSL) WHERE char *SslEntropyFile INITVAL (NULL); #endif -#ifdef USE_GNUTLS +#ifdef USE_SSL_GNUTLS WHERE short SslDHPrimeBits; WHERE char *SslCACertFile INITVAL (NULL); #endif diff --git a/imap/imap.c b/imap/imap.c index 1ab9a08f..f707f3d4 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -32,7 +32,7 @@ #include "browser.h" #include "message.h" #include "imap_private.h" -#if defined(USE_SSL) || defined(USE_GNUTLS) +#if defined(USE_SSL) # include "mutt_ssl.h" #endif #include "buffy.h" @@ -409,7 +409,7 @@ int imap_open_connection (IMAP_DATA* idata) if (ascii_strncasecmp ("* OK [CAPABILITY", idata->buf, 16) && imap_check_capabilities (idata)) goto bail; -#if defined(USE_SSL) || defined(USE_GNUTLS) +#if defined(USE_SSL) /* Attempt STARTTLS if available and desired. */ if (!idata->conn->ssf && (option(OPTSSLFORCETLS) || mutt_bit_isset (idata->capabilities, STARTTLS))) @@ -426,11 +426,7 @@ int imap_open_connection (IMAP_DATA* idata) goto bail; if (rc != -2) { -#ifdef USE_SSL if (mutt_ssl_starttls (idata->conn)) -#elif USE_GNUTLS - if (mutt_gnutls_starttls (idata->conn)) -#endif { mutt_error (_("Could not negotiate TLS connection")); mutt_sleep (1); @@ -469,9 +465,11 @@ int imap_open_connection (IMAP_DATA* idata) return 0; +#if defined(USE_SSL) err_close_conn: mutt_socket_close (idata->conn); idata->state = IMAP_DISCONNECTED; +#endif bail: FREE (&idata->capstr); return -1; diff --git a/init.c b/init.c index da3d82e0..bd23c344 100644 --- a/init.c +++ b/init.c @@ -31,7 +31,7 @@ #include "mutt_crypt.h" #include "mutt_idna.h" -#if defined(USE_SSL) || defined(USE_GNUTLS) +#if defined(USE_SSL) #include "mutt_ssl.h" #endif diff --git a/init.h b/init.h index bf419600..ee09d743 100644 --- a/init.h +++ b/init.h @@ -92,12 +92,15 @@ struct option_t # ifndef USE_POP # define USE_POP # endif +# ifndef USE_SSL_OPENSSL +# define USE_SSL_OPENSSL +# endif +# ifndef USE_SSL_GNUTLS +# define USE_SSL_GNUTLS +# endif # ifndef USE_SSL # define USE_SSL # endif -# ifndef USE_GNUTLS -# define USE_GNUTLS -# endif # ifndef USE_SOCKET # define USE_SOCKET # endif @@ -1914,15 +1917,15 @@ struct option_t MuttVars[] = { ** (S/MIME only) */ -#if defined(USE_SSL) || defined(USE_GNUTLS) -#ifdef USE_SSL +#if defined(USE_SSL) +#ifdef USE_SSL_OPENSSL { "ssl_client_cert", DT_PATH, R_NONE, UL &SslClientCert, 0 }, /* ** .pp ** The file containing a client certificate and its associated private ** key. */ -#endif /* USE_SSL */ +#endif /* USE_SSL_OPENSSL */ { "ssl_force_tls", DT_BOOL, R_NONE, OPTSSLFORCETLS, 0 }, /* ** .pp @@ -1954,7 +1957,7 @@ struct option_t MuttVars[] = { ** .pp ** Example: set certificate_file=~/.mutt/certificates */ -# if defined _MAKEDOC || !defined(USE_GNUTLS) +# if defined _MAKEDOC || !defined(USE_SSL_GNUTLS) { "ssl_usesystemcerts", DT_BOOL, R_NONE, OPTSSLSYSTEMCERTS, 1 }, /* ** .pp @@ -1974,7 +1977,7 @@ struct option_t MuttVars[] = { ** This variables specifies whether to attempt to use SSLv2 in the ** SSL authentication process. */ -# endif /* defined _MAKEDOC || !defined(USE_GNUTLS) */ +# endif /* defined _MAKEDOC || !defined(USE_SSL_GNUTLS) */ { "ssl_use_sslv3", DT_BOOL, R_NONE, OPTSSLV3, 1 }, /* ** .pp @@ -1987,7 +1990,7 @@ struct option_t MuttVars[] = { ** This variables specifies whether to attempt to use TLSv1 in the ** SSL authentication process. */ -# ifdef USE_GNUTLS +# ifdef USE_SSL_GNUTLS { "ssl_min_dh_prime_bits", DT_NUM, R_NONE, UL &SslDHPrimeBits, 0 }, /* ** .pp @@ -2004,8 +2007,8 @@ struct option_t MuttVars[] = { ** .pp ** Example: set ssl_ca_certificates_file=/etc/ssl/certs/ca-certificates.crt */ -# endif /* USE_GNUTLS */ -#endif /* defined(USE_SSL) || defined(USE_GNUTLS) */ +# endif /* USE_SSL_GNUTLS */ +#endif /* defined(USE_SSL) */ { "pipe_split", DT_BOOL, R_NONE, OPTPIPESPLIT, 0 }, /* diff --git a/main.c b/main.c index 33dddf84..0d9d113d 100644 --- a/main.c +++ b/main.c @@ -264,16 +264,16 @@ static void show_version (void) #endif -#ifdef USE_SSL - "+USE_SSL " +#ifdef USE_SSL_OPENSSL + "+USE_SSL_OPENSSL " #else - "-USE_SSL " + "-USE_SSL_OPENSSL " #endif -#ifdef USE_GNUTLS - "+USE_GNUTLS " +#ifdef USE_SSL_GNUTLS + "+USE_SSL_GNUTLS " #else - "-USE_GNUTLS " + "-USE_SSL_GNUTLS " #endif #ifdef USE_SASL diff --git a/mutt.h b/mutt.h index 0af519d9..105d3687 100644 --- a/mutt.h +++ b/mutt.h @@ -248,7 +248,7 @@ enum /* options for socket code */ M_NEW_SOCKET, -#ifdef USE_SSL +#ifdef USE_SSL_OPENSSL M_NEW_SSL_SOCKET, #endif @@ -289,7 +289,7 @@ enum OPT_QUIT, OPT_REPLYTO, OPT_RECALL, -#if defined(USE_SSL) || defined(USE_GNUTLS) +#if defined(USE_SSL) OPT_SSLSTARTTLS, #endif OPT_SUBJECT, @@ -376,15 +376,15 @@ enum OPTIMAPPEEK, OPTIMAPSERVERNOISE, #endif -#if defined(USE_SSL) || defined(USE_GNUTLS) -# ifndef USE_GNUTLS +#if defined(USE_SSL) +# ifndef USE_SSL_GNUTLS OPTSSLSYSTEMCERTS, OPTSSLV2, -# endif /* USE_GNUTLS */ +# endif /* USE_SSL_GNUTLS */ OPTSSLV3, OPTTLSV1, OPTSSLFORCETLS, -#endif /* defined(USE_SSL) || defined(USE_GNUTLS) */ +#endif /* defined(USE_SSL) */ OPTIMPLICITAUTOVIEW, OPTINCLUDEONLYFIRST, OPTKEEPFLAGGED, diff --git a/mutt_socket.c b/mutt_socket.c index 08edee34..ff64ee8b 100644 --- a/mutt_socket.c +++ b/mutt_socket.c @@ -26,7 +26,7 @@ #include "globals.h" #include "mutt_socket.h" #include "mutt_tunnel.h" -#if defined(USE_SSL) || defined(USE_GNUTLS) +#if defined(USE_SSL) # include "mutt_ssl.h" #endif @@ -275,10 +275,8 @@ CONNECTION* mutt_conn_find (const CONNECTION* start, const ACCOUNT* account) mutt_tunnel_socket_setup (conn); else if (account->flags & M_ACCT_SSL) { -#ifdef USE_SSL - ssl_socket_setup (conn); -#elif USE_GNUTLS - if (mutt_gnutls_socket_setup (conn) < 0) +#if defined(USE_SSL) + if (mutt_ssl_socket_setup (conn) < 0) { mutt_socket_free (conn); return NULL; diff --git a/mutt_ssl.c b/mutt_ssl.c index 35fae093..2a388f9d 100644 --- a/mutt_ssl.c +++ b/mutt_ssl.c @@ -229,7 +229,7 @@ static int ssl_socket_open_err (CONNECTION *conn) } -int ssl_socket_setup (CONNECTION * conn) +int mutt_ssl_socket_setup (CONNECTION * conn) { if (ssl_init() < 0) { diff --git a/mutt_ssl.h b/mutt_ssl.h index ee98f633..d579ab48 100644 --- a/mutt_ssl.h +++ b/mutt_ssl.h @@ -21,14 +21,9 @@ #include "mutt_socket.h" -#ifdef USE_SSL +#if defined(USE_SSL) int mutt_ssl_starttls (CONNECTION* conn); - -extern int ssl_socket_setup (CONNECTION *conn); +int mutt_ssl_socket_setup (CONNECTION *conn); #endif -#ifdef USE_GNUTLS -int mutt_gnutls_starttls (CONNECTION* conn); -extern int mutt_gnutls_socket_setup (CONNECTION *conn); -#endif #endif /* _MUTT_SSL_H_ */ diff --git a/mutt_ssl_gnutls.c b/mutt_ssl_gnutls.c index 1dfa8b68..1f1bca23 100644 --- a/mutt_ssl_gnutls.c +++ b/mutt_ssl_gnutls.c @@ -72,7 +72,7 @@ static int tls_init (void) return 0; } -int mutt_gnutls_socket_setup (CONNECTION* conn) +int mutt_ssl_socket_setup (CONNECTION* conn) { if (tls_init() < 0) return -1; @@ -144,7 +144,7 @@ static int tls_socket_open (CONNECTION* conn) return 0; } -int mutt_gnutls_starttls (CONNECTION* conn) +int mutt_ssl_starttls (CONNECTION* conn) { if (tls_init() < 0) return -1; @@ -441,7 +441,7 @@ static int tls_check_stored_hostname (const gnutls_datum *cert, strcmp(linestr + pmatch[2].rm_so, buf) == 0) { regfree(&preg); - safe_free((void**)&linestr); + FREE(&linestr); fclose(fp); return 1; } diff --git a/pop_lib.c b/pop_lib.c index b976bf67..c3f1e3c2 100644 --- a/pop_lib.c +++ b/pop_lib.c @@ -24,7 +24,7 @@ #include "mx.h" #include "url.h" #include "pop.h" -#ifdef USE_SSL +#if defined(USE_SSL) # include "mutt_ssl.h" #endif @@ -274,7 +274,7 @@ int pop_open_connection (POP_DATA *pop_data) return -2; } -#if defined(USE_SSL) || defined(USE_GNUTLS) +#if defined(USE_SSL) /* Attempt STLS if available and desired. */ if (!pop_data->conn->ssf && (pop_data->cmd_stls || option(OPTSSLFORCETLS))) { @@ -301,11 +301,7 @@ int pop_open_connection (POP_DATA *pop_data) mutt_error ("%s", pop_data->err_msg); mutt_sleep (2); } -#ifdef USE_SSL else if (mutt_ssl_starttls (pop_data->conn)) -#elif USE_GNUTLS - else if (mutt_gnutls_starttls (pop_data->conn)) -#endif { mutt_error (_("Could not negotiate TLS connection")); mutt_sleep (2);