1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-03 16:05:42 +02:00

core: make GnuTLS a required dependency

This commit is contained in:
Sébastien Helleu
2020-04-18 11:33:22 +02:00
parent 80693dcea9
commit e130ee7358
42 changed files with 354 additions and 788 deletions
+2 -4
View File
@@ -48,10 +48,8 @@ set_target_properties(irc PROPERTIES PREFIX "")
set(LINK_LIBS)
if(GNUTLS_FOUND)
include_directories(${GNUTLS_INCLUDE_PATH})
list(APPEND LINK_LIBS ${GNUTLS_LIBRARY})
endif()
include_directories(${GNUTLS_INCLUDE_PATH})
list(APPEND LINK_LIBS ${GNUTLS_LIBRARY})
list(APPEND LINK_LIBS ${GCRYPT_LDFLAGS})
-7
View File
@@ -986,7 +986,6 @@ irc_config_server_default_change_cb (const void *pointer, void *data,
const char *
irc_config_check_gnutls_priorities (const char *priorities)
{
#ifdef HAVE_GNUTLS
gnutls_priority_t priority_cache;
const char *pos_error;
int rc;
@@ -1003,12 +1002,6 @@ irc_config_check_gnutls_priorities (const char *priorities)
if (pos_error)
return pos_error;
return priorities;
#else
/* make C compiler happy */
(void) priorities;
return NULL;
#endif /* HAVE_GNUTLS */
}
/*
+3 -5
View File
@@ -26,12 +26,10 @@
#include <arpa/inet.h>
#include <gcrypt.h>
#ifdef HAVE_GNUTLS
#include <gnutls/gnutls.h>
#if LIBGNUTLS_VERSION_NUMBER >= 0x020a01 /* 2.10.1 */
#include <gnutls/abstract.h>
#endif /* LIBGNUTLS_VERSION_NUMBER >= 0x020a01 */
#endif /* HAVE_GNUTLS */
#include "../weechat-plugin.h"
#include "irc.h"
@@ -144,7 +142,7 @@ irc_sasl_mechanism_ecdsa_nist256p_challenge (struct t_irc_server *server,
const char *sasl_username,
const char *sasl_key)
{
#if defined(HAVE_GNUTLS) && (LIBGNUTLS_VERSION_NUMBER >= 0x030015) /* 3.0.21 */
#if LIBGNUTLS_VERSION_NUMBER >= 0x030015 /* 3.0.21 */
char *data, *string, *answer_base64;
int length_data, length_username, length, ret;
char *str_privkey;
@@ -316,7 +314,7 @@ irc_sasl_mechanism_ecdsa_nist256p_challenge (struct t_irc_server *server,
return answer_base64;
#else /* no gnutls or gnutls < 3.0.21 */
#else /* GnuTLS < 3.0.21 */
/* make C compiler happy */
(void) data_base64;
@@ -329,7 +327,7 @@ irc_sasl_mechanism_ecdsa_nist256p_challenge (struct t_irc_server *server,
weechat_prefix ("error"));
return NULL;
#endif /* defined(HAVE_GNUTLS) && (LIBGNUTLS_VERSION_NUMBER >= 0x030015) */
#endif /* LIBGNUTLS_VERSION_NUMBER >= 0x030015 */
}
/*
File diff suppressed because it is too large Load Diff
-10
View File
@@ -25,9 +25,7 @@
#include <sys/time.h>
#include <regex.h>
#ifdef HAVE_GNUTLS
#include <gnutls/gnutls.h>
#endif /* HAVE_GNUTLS */
#ifndef NI_MAXHOST
#define NI_MAXHOST 256
@@ -188,11 +186,9 @@ struct t_irc_server
int is_connected; /* 1 if WeeChat is connected to server */
int ssl_connected; /* = 1 if connected with SSL */
int disconnected; /* 1 if server has been disconnected */
#ifdef HAVE_GNUTLS
gnutls_session_t gnutls_sess; /* gnutls session (only if SSL is used) */
gnutls_x509_crt_t tls_cert; /* certificate used if ssl_cert is set */
gnutls_x509_privkey_t tls_cert_key; /* key used if ssl_cert is set */
#endif /* HAVE_GNUTLS */
char *unterminated_message; /* beginning of a message in input buf */
int nicks_count; /* number of nicknames */
char **nicks_array; /* nicknames (after split) */
@@ -267,7 +263,6 @@ struct t_irc_message
/* digest algorithms for fingerprint */
#ifdef HAVE_GNUTLS
enum t_irc_fingerprint_digest_algo
{
IRC_FINGERPRINT_ALGO_SHA1 = 0,
@@ -276,13 +271,10 @@ enum t_irc_fingerprint_digest_algo
/* number of digest algorithms */
IRC_FINGERPRINT_NUM_ALGOS,
};
#endif /* HAVE_GNUTLS */
extern struct t_irc_server *irc_servers;
#ifdef HAVE_GNUTLS
extern const int gnutls_cert_type_prio[];
extern const int gnutls_prot_prio[];
#endif /* HAVE_GNUTLS */
extern struct t_irc_message *irc_recv_msgq, *irc_msgq_last_msg;
extern char *irc_server_sasl_fail_string[];
extern char *irc_server_options[][2];
@@ -355,10 +347,8 @@ extern void irc_server_msgq_add_buffer (struct t_irc_server *server,
extern void irc_server_msgq_flush ();
extern void irc_server_set_buffer_title (struct t_irc_server *server);
extern struct t_gui_buffer *irc_server_create_buffer (struct t_irc_server *server);
#ifdef HAVE_GNUTLS
int irc_server_fingerprint_search_algo_with_size (int size);
char *irc_server_fingerprint_str_sizes ();
#endif /* HAVE_GNUTLS */
extern int irc_server_connect (struct t_irc_server *server);
extern void irc_server_auto_connect (int auto_connect);
extern void irc_server_autojoin_channels (struct t_irc_server *server);
+2 -4
View File
@@ -45,10 +45,8 @@ set(LINK_LIBS)
list(APPEND LINK_LIBS ${ZLIB_LIBRARY})
if(GNUTLS_FOUND)
include_directories(${GNUTLS_INCLUDE_PATH})
list(APPEND LINK_LIBS ${GNUTLS_LIBRARY})
endif()
include_directories(${GNUTLS_INCLUDE_PATH})
list(APPEND LINK_LIBS ${GNUTLS_LIBRARY})
list(APPEND LINK_LIBS ${GCRYPT_LDFLAGS})
File diff suppressed because it is too large Load Diff
-4
View File
@@ -22,9 +22,7 @@
#include <time.h>
#ifdef HAVE_GNUTLS
#include <gnutls/gnutls.h>
#endif /* HAVE_GNUTLS */
struct t_relay_server;
@@ -92,11 +90,9 @@ struct t_relay_client
int sock; /* socket for connection */
int server_port; /* port used for connection */
int ssl; /* 1 if SSL is enabled */
#ifdef HAVE_GNUTLS
gnutls_session_t gnutls_sess; /* gnutls session (only if SSL used) */
struct t_hook *hook_timer_handshake; /* timer for doing gnutls handshake*/
int gnutls_handshake_ok; /* 1 if handshake was done and OK */
#endif /* HAVE_GNUTLS */
int websocket; /* 0=not a ws, 1=init ws, 2=ws ready */
struct t_hashtable *http_headers; /* HTTP headers for websocket */
char *address; /* string with IP address */
-23
View File
@@ -318,7 +318,6 @@ relay_config_check_network_ssl_priorities (const void *pointer, void *data,
struct t_config_option *option,
const char *value)
{
#ifdef HAVE_GNUTLS
gnutls_priority_t priority_cache;
const char *pos_error;
int rc;
@@ -347,15 +346,6 @@ relay_config_check_network_ssl_priorities (const void *pointer, void *data,
(pos_error) ? pos_error : value);
return 0;
#else
/* make C compiler happy */
(void) pointer;
(void) data;
(void) option;
(void) value;
return 1;
#endif /* HAVE_GNUTLS */
}
/*
@@ -371,13 +361,11 @@ relay_config_change_network_ssl_priorities (const void *pointer, void *data,
(void) data;
(void) option;
#ifdef HAVE_GNUTLS
if (relay_network_init_ok && relay_gnutls_priority_cache)
{
gnutls_priority_deinit (*relay_gnutls_priority_cache);
relay_network_set_priority ();
}
#endif /* HAVE_GNUTLS */
}
/*
@@ -762,17 +750,6 @@ relay_config_create_option_port_path (const void *pointer, void *data,
relay_server_get_protocol_args (option_name, &ipv4, &ipv6, &ssl,
&unix_socket, &protocol, &protocol_args);
#ifndef HAVE_GNUTLS
if (ssl)
{
weechat_printf (NULL,
_("%s%s: cannot use SSL because WeeChat was not built "
"with GnuTLS support"),
weechat_prefix ("error"), RELAY_PLUGIN_NAME);
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
}
#endif /* HAVE_GNUTLS */
if (rc != WEECHAT_CONFIG_OPTION_SET_ERROR)
{
if (protocol)
+2 -16
View File
@@ -21,9 +21,7 @@
#include <stdlib.h>
#ifdef HAVE_GNUTLS
#include <gnutls/gnutls.h>
#endif /* HAVE_GNUTLS */
#include "../weechat-plugin.h"
#include "relay.h"
@@ -34,11 +32,9 @@
int relay_network_init_ok = 0;
int relay_network_init_ssl_cert_key_ok = 0;
#ifdef HAVE_GNUTLS
gnutls_certificate_credentials_t relay_gnutls_x509_cred;
gnutls_priority_t *relay_gnutls_priority_cache = NULL;
gnutls_dh_params_t *relay_gnutls_dh_params = NULL;
#endif /* HAVE_GNUTLS */
/*
@@ -51,7 +47,6 @@ gnutls_dh_params_t *relay_gnutls_dh_params = NULL;
void
relay_network_set_ssl_cert_key (int verbose)
{
#ifdef HAVE_GNUTLS
char *certkey_path, *certkey_path2, *weechat_dir;
int ret;
@@ -99,10 +94,6 @@ relay_network_set_ssl_cert_key (int verbose)
}
free (certkey_path);
}
#else
/* make C compiler happy */
(void) verbose;
#endif /* HAVE_GNUTLS */
}
/*
@@ -112,7 +103,6 @@ relay_network_set_ssl_cert_key (int verbose)
void
relay_network_set_priority ()
{
#ifdef HAVE_GNUTLS
if (gnutls_priority_init (relay_gnutls_priority_cache,
weechat_config_string (
relay_config_network_ssl_priorities),
@@ -124,7 +114,6 @@ relay_network_set_priority ()
free (relay_gnutls_priority_cache);
relay_gnutls_priority_cache = NULL;
}
#endif /* HAVE_GNUTLS */
}
/*
@@ -134,8 +123,6 @@ relay_network_set_priority ()
void
relay_network_init ()
{
#ifdef HAVE_GNUTLS
/* credentials */
gnutls_certificate_allocate_credentials (&relay_gnutls_x509_cred);
relay_network_set_ssl_cert_key (0);
@@ -144,7 +131,7 @@ relay_network_init ()
relay_gnutls_priority_cache = malloc (sizeof (*relay_gnutls_priority_cache));
if (relay_gnutls_priority_cache)
relay_network_set_priority ();
#endif /* HAVE_GNUTLS */
relay_network_init_ok = 1;
}
@@ -157,7 +144,6 @@ relay_network_end ()
{
if (relay_network_init_ok)
{
#ifdef HAVE_GNUTLS
if (relay_gnutls_priority_cache)
{
gnutls_priority_deinit (*relay_gnutls_priority_cache);
@@ -171,7 +157,7 @@ relay_network_end ()
relay_gnutls_dh_params = NULL;
}
gnutls_certificate_free_credentials (relay_gnutls_x509_cred);
#endif /* HAVE_GNUTLS */
relay_network_init_ok = 0;
}
}
-4
View File
@@ -20,18 +20,14 @@
#ifndef WEECHAT_PLUGIN_RELAY_NETWORK_H
#define WEECHAT_PLUGIN_RELAY_NETWORK_H
#ifdef HAVE_GNUTLS
#include <gnutls/gnutls.h>
#endif /* HAVE_GNUTLS */
extern int relay_network_init_ok;
extern int relay_network_init_ssl_cert_key_ok;
#ifdef HAVE_GNUTLS
extern gnutls_certificate_credentials_t relay_gnutls_x509_cred;
extern gnutls_priority_t *relay_gnutls_priority_cache;
extern gnutls_dh_params_t *relay_gnutls_dh_params;
#endif /* HAVE_GNUTLS */
extern void relay_network_set_ssl_cert_key (int verbose);
extern void relay_network_set_priority ();
+1 -2
View File
@@ -21,9 +21,8 @@
#define WEECHAT_PLUGIN_RELAY_SERVER_H
#include <time.h>
#ifdef HAVE_GNUTLS
#define RELAY_SERVER_GNUTLS_DH_BITS 1024
#endif /* HAVE_GNUTLS */
struct t_relay_server
{