mirror of
https://github.com/weechat/weechat.git
synced 2026-06-27 21:36:37 +02:00
core: make GnuTLS a required dependency
This commit is contained in:
@@ -82,9 +82,7 @@ else()
|
||||
check_symbol_exists(backtrace "execinfo.h" HAVE_BACKTRACE)
|
||||
endif()
|
||||
|
||||
if(GNUTLS_FOUND)
|
||||
include_directories(${GNUTLS_INCLUDE_PATH})
|
||||
endif()
|
||||
include_directories(${GNUTLS_INCLUDE_PATH})
|
||||
|
||||
include_directories(${CURL_INCLUDE_DIRS})
|
||||
|
||||
|
||||
@@ -57,14 +57,6 @@ hook_connect (struct t_weechat_plugin *plugin, const char *proxy,
|
||||
struct t_hook_connect *new_hook_connect;
|
||||
int i;
|
||||
|
||||
#ifndef HAVE_GNUTLS
|
||||
/* make C compiler happy */
|
||||
(void) gnutls_sess;
|
||||
(void) gnutls_cb;
|
||||
(void) gnutls_dhkey_size;
|
||||
(void) gnutls_priorities;
|
||||
#endif /* HAVE_GNUTLS */
|
||||
|
||||
if (!address || (port <= 0) || !callback)
|
||||
return NULL;
|
||||
|
||||
@@ -89,13 +81,11 @@ hook_connect (struct t_weechat_plugin *plugin, const char *proxy,
|
||||
new_hook_connect->sock = -1;
|
||||
new_hook_connect->ipv6 = ipv6;
|
||||
new_hook_connect->retry = retry;
|
||||
#ifdef HAVE_GNUTLS
|
||||
new_hook_connect->gnutls_sess = gnutls_sess;
|
||||
new_hook_connect->gnutls_cb = gnutls_cb;
|
||||
new_hook_connect->gnutls_dhkey_size = gnutls_dhkey_size;
|
||||
new_hook_connect->gnutls_priorities = (gnutls_priorities) ?
|
||||
strdup (gnutls_priorities) : NULL;
|
||||
#endif /* HAVE_GNUTLS */
|
||||
new_hook_connect->local_hostname = (local_hostname) ?
|
||||
strdup (local_hostname) : NULL;
|
||||
new_hook_connect->child_read = -1;
|
||||
@@ -129,7 +119,6 @@ hook_connect (struct t_weechat_plugin *plugin, const char *proxy,
|
||||
* Verifies certificates.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
int
|
||||
hook_connect_gnutls_verify_certificates (gnutls_session_t tls_session)
|
||||
{
|
||||
@@ -158,13 +147,11 @@ hook_connect_gnutls_verify_certificates (gnutls_session_t tls_session)
|
||||
|
||||
return rc;
|
||||
}
|
||||
#endif /* HAVE_GNUTLS */
|
||||
|
||||
/*
|
||||
* Sets certificates.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
int
|
||||
hook_connect_gnutls_set_certificates (gnutls_session_t tls_session,
|
||||
const gnutls_datum_t *req_ca, int nreq,
|
||||
@@ -201,7 +188,6 @@ hook_connect_gnutls_set_certificates (gnutls_session_t tls_session,
|
||||
|
||||
return rc;
|
||||
}
|
||||
#endif /* HAVE_GNUTLS */
|
||||
|
||||
/*
|
||||
* Frees data in a connect hook.
|
||||
@@ -225,13 +211,11 @@ hook_connect_free_data (struct t_hook *hook)
|
||||
free (HOOK_CONNECT(hook, address));
|
||||
HOOK_CONNECT(hook, address) = NULL;
|
||||
}
|
||||
#ifdef HAVE_GNUTLS
|
||||
if (HOOK_CONNECT(hook, gnutls_priorities))
|
||||
{
|
||||
free (HOOK_CONNECT(hook, gnutls_priorities));
|
||||
HOOK_CONNECT(hook, gnutls_priorities) = NULL;
|
||||
}
|
||||
#endif /* HAVE_GNUTLS */
|
||||
if (HOOK_CONNECT(hook, local_hostname))
|
||||
{
|
||||
free (HOOK_CONNECT(hook, local_hostname));
|
||||
@@ -336,14 +320,12 @@ hook_connect_add_to_infolist (struct t_infolist_item *item,
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (item, "retry", HOOK_CONNECT(hook, retry)))
|
||||
return 0;
|
||||
#ifdef HAVE_GNUTLS
|
||||
if (!infolist_new_var_pointer (item, "gnutls_sess", HOOK_CONNECT(hook, gnutls_sess)))
|
||||
return 0;
|
||||
if (!infolist_new_var_pointer (item, "gnutls_cb", HOOK_CONNECT(hook, gnutls_cb)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (item, "gnutls_dhkey_size", HOOK_CONNECT(hook, gnutls_dhkey_size)))
|
||||
return 0;
|
||||
#endif /* HAVE_GNUTLS */
|
||||
if (!infolist_new_var_string (item, "local_hostname", HOOK_CONNECT(hook, local_hostname)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (item, "child_read", HOOK_CONNECT(hook, child_read)))
|
||||
@@ -392,12 +374,10 @@ hook_connect_print_log (struct t_hook *hook)
|
||||
log_printf (" sock. . . . . . . . . : %d", HOOK_CONNECT(hook, sock));
|
||||
log_printf (" ipv6. . . . . . . . . : %d", HOOK_CONNECT(hook, ipv6));
|
||||
log_printf (" retry . . . . . . . . : %d", HOOK_CONNECT(hook, retry));
|
||||
#ifdef HAVE_GNUTLS
|
||||
log_printf (" gnutls_sess . . . . . : 0x%lx", HOOK_CONNECT(hook, gnutls_sess));
|
||||
log_printf (" gnutls_cb . . . . . . : 0x%lx", HOOK_CONNECT(hook, gnutls_cb));
|
||||
log_printf (" gnutls_dhkey_size . . : %d", HOOK_CONNECT(hook, gnutls_dhkey_size));
|
||||
log_printf (" gnutls_priorities . . : '%s'", HOOK_CONNECT(hook, gnutls_priorities));
|
||||
#endif /* HAVE_GNUTLS */
|
||||
log_printf (" local_hostname. . . . : '%s'", HOOK_CONNECT(hook, local_hostname));
|
||||
log_printf (" child_read. . . . . . : %d", HOOK_CONNECT(hook, child_read));
|
||||
log_printf (" child_write . . . . . : %d", HOOK_CONNECT(hook, child_write));
|
||||
|
||||
@@ -21,9 +21,7 @@
|
||||
#ifndef WEECHAT_HOOK_CONNECT_H
|
||||
#define WEECHAT_HOOK_CONNECT_H
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
#include <gnutls/gnutls.h>
|
||||
#endif
|
||||
|
||||
struct t_weechat_plugin;
|
||||
struct t_infolist_item;
|
||||
@@ -38,7 +36,6 @@ typedef int (t_hook_callback_connect)(const void *pointer, void *data,
|
||||
const char *error,
|
||||
const char *ip_address);
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
typedef int (gnutls_callback_t)(const void *pointer, void *data,
|
||||
gnutls_session_t tls_session,
|
||||
const gnutls_datum_t *req_ca, int nreq,
|
||||
@@ -50,7 +47,6 @@ typedef int (gnutls_callback_t)(const void *pointer, void *data,
|
||||
gnutls_retr_st *answer,
|
||||
#endif /* LIBGNUTLS_VERSION_NUMBER >= 0x020b00 */
|
||||
int action);
|
||||
#endif /* HAVE_GNUTLS */
|
||||
|
||||
struct t_hook_connect
|
||||
{
|
||||
@@ -61,12 +57,10 @@ struct t_hook_connect
|
||||
int ipv6; /* use IPv6 */
|
||||
int sock; /* socket (set when connected) */
|
||||
int retry; /* retry count */
|
||||
#ifdef HAVE_GNUTLS
|
||||
gnutls_session_t *gnutls_sess; /* GnuTLS session (SSL connection) */
|
||||
gnutls_callback_t *gnutls_cb; /* GnuTLS callback during handshake */
|
||||
int gnutls_dhkey_size; /* Diffie Hellman Key Exchange size */
|
||||
char *gnutls_priorities; /* GnuTLS priorities */
|
||||
#endif /* HAVE_GNUTLS */
|
||||
char *local_hostname; /* force local hostname (optional) */
|
||||
int child_read; /* to read data in pipe from child */
|
||||
int child_write; /* to write data in pipe for child */
|
||||
@@ -94,7 +88,6 @@ extern struct t_hook *hook_connect (struct t_weechat_plugin *plugin,
|
||||
t_hook_callback_connect *callback,
|
||||
const void *callback_pointer,
|
||||
void *callback_data);
|
||||
#ifdef HAVE_GNUTLS
|
||||
extern int hook_connect_gnutls_verify_certificates (gnutls_session_t tls_session);
|
||||
extern int hook_connect_gnutls_set_certificates (gnutls_session_t tls_session,
|
||||
const gnutls_datum_t *req_ca, int nreq,
|
||||
@@ -105,7 +98,6 @@ extern int hook_connect_gnutls_set_certificates (gnutls_session_t tls_session,
|
||||
#else
|
||||
gnutls_retr_st *answer);
|
||||
#endif /* LIBGNUTLS_VERSION_NUMBER >= 0x020b00 */
|
||||
#endif /* HAVE_GNUTLS */
|
||||
extern void hook_connect_free_data (struct t_hook *hook);
|
||||
extern int hook_connect_add_to_infolist (struct t_infolist_item *item,
|
||||
struct t_hook *hook);
|
||||
|
||||
@@ -34,9 +34,7 @@
|
||||
#include <curl/curl.h>
|
||||
#include <zlib.h>
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
#include <gnutls/gnutls.h>
|
||||
#endif
|
||||
|
||||
#include "weechat.h"
|
||||
#include "wee-backtrace.h"
|
||||
@@ -538,7 +536,6 @@ debug_libs_cb (const void *pointer, void *data,
|
||||
#endif /* GCRYPT_VERSION */
|
||||
|
||||
/* display gnutls version */
|
||||
#ifdef HAVE_GNUTLS
|
||||
#ifdef GNUTLS_VERSION
|
||||
gui_chat_printf (NULL, " gnutls: %s%s",
|
||||
GNUTLS_VERSION,
|
||||
@@ -547,9 +544,6 @@ debug_libs_cb (const void *pointer, void *data,
|
||||
gui_chat_printf (NULL, " gnutls: (?)%s",
|
||||
(weechat_no_gnutls) ? " (not initialized)" : "");
|
||||
#endif /* GNUTLS_VERSION */
|
||||
#else
|
||||
gui_chat_printf (NULL, " gnutls: (not available)");
|
||||
#endif /* HAVE_GNUTLS */
|
||||
|
||||
/* display curl version */
|
||||
#ifdef LIBCURL_VERSION
|
||||
|
||||
@@ -52,9 +52,7 @@
|
||||
#include <sys/uio.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
#include <gnutls/gnutls.h>
|
||||
#endif
|
||||
|
||||
#include "weechat.h"
|
||||
#include "wee-network.h"
|
||||
@@ -68,9 +66,7 @@
|
||||
|
||||
int network_init_gnutls_ok = 0;
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
gnutls_certificate_credentials_t gnutls_xcred; /* GnuTLS client credentials */
|
||||
#endif /* HAVE_GNUTLS */
|
||||
|
||||
|
||||
/*
|
||||
@@ -95,7 +91,6 @@ network_init_gcrypt ()
|
||||
void
|
||||
network_set_gnutls_ca_file ()
|
||||
{
|
||||
#ifdef HAVE_GNUTLS
|
||||
char *ca_path, *ca_path2;
|
||||
|
||||
if (weechat_no_gnutls)
|
||||
@@ -113,7 +108,6 @@ network_set_gnutls_ca_file ()
|
||||
}
|
||||
free (ca_path);
|
||||
}
|
||||
#endif /* HAVE_GNUTLS */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -123,7 +117,6 @@ network_set_gnutls_ca_file ()
|
||||
void
|
||||
network_init_gnutls ()
|
||||
{
|
||||
#ifdef HAVE_GNUTLS
|
||||
if (!weechat_no_gnutls)
|
||||
{
|
||||
gnutls_global_init ();
|
||||
@@ -142,7 +135,6 @@ network_init_gnutls ()
|
||||
&hook_connect_gnutls_set_certificates);
|
||||
#endif /* LIBGNUTLS_VERSION_NUMBER >= 0x020b00 */
|
||||
}
|
||||
#endif /* HAVE_GNUTLS */
|
||||
|
||||
network_init_gnutls_ok = 1;
|
||||
}
|
||||
@@ -156,13 +148,11 @@ network_end ()
|
||||
{
|
||||
if (network_init_gnutls_ok)
|
||||
{
|
||||
#ifdef HAVE_GNUTLS
|
||||
if (!weechat_no_gnutls)
|
||||
{
|
||||
gnutls_certificate_free_credentials (gnutls_xcred);
|
||||
gnutls_global_deinit ();
|
||||
}
|
||||
#endif /* HAVE_GNUTLS */
|
||||
network_init_gnutls_ok = 0;
|
||||
}
|
||||
}
|
||||
@@ -1278,7 +1268,6 @@ network_connect_child_timer_cb (const void *pointer, void *data,
|
||||
* finish).
|
||||
*/
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
int
|
||||
network_connect_gnutls_handshake_fd_cb (const void *pointer, void *data,
|
||||
int fd)
|
||||
@@ -1355,13 +1344,11 @@ network_connect_gnutls_handshake_fd_cb (const void *pointer, void *data,
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
#endif /* HAVE_GNUTLS */
|
||||
|
||||
/*
|
||||
* Timer callback for timeout of handshake.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
int
|
||||
network_connect_gnutls_handshake_timer_cb (const void *pointer,
|
||||
void *data,
|
||||
@@ -1390,7 +1377,6 @@ network_connect_gnutls_handshake_timer_cb (const void *pointer,
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
#endif /* HAVE_GNUTLS */
|
||||
|
||||
/*
|
||||
* Reads connection progress from child process.
|
||||
@@ -1403,9 +1389,7 @@ network_connect_child_read_cb (const void *pointer, void *data, int fd)
|
||||
char buffer[1], buf_size[6], *cb_error, *cb_ip_address, *error;
|
||||
int num_read;
|
||||
long size_msg;
|
||||
#ifdef HAVE_GNUTLS
|
||||
int rc, direction;
|
||||
#endif /* HAVE_GNUTLS */
|
||||
int sock, i;
|
||||
struct msghdr msg;
|
||||
struct cmsghdr *cmsg;
|
||||
@@ -1502,7 +1486,6 @@ network_connect_child_read_cb (const void *pointer, void *data, int fd)
|
||||
|
||||
HOOK_CONNECT(hook_connect, sock) = sock;
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
if (HOOK_CONNECT(hook_connect, gnutls_sess))
|
||||
{
|
||||
/*
|
||||
@@ -1586,7 +1569,6 @@ network_connect_child_read_cb (const void *pointer, void *data, int fd)
|
||||
}
|
||||
#endif /* LIBGNUTLS_VERSION_NUMBER < 0x02090a */
|
||||
}
|
||||
#endif /* HAVE_GNUTLS */
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1650,12 +1632,9 @@ network_connect_with_fork (struct t_hook *hook_connect)
|
||||
{
|
||||
int child_pipe[2], child_socket[2], rc, i;
|
||||
char str_error[1024];
|
||||
#ifdef HAVE_GNUTLS
|
||||
const char *pos_error;
|
||||
#endif /* HAVE_GNUTLS */
|
||||
pid_t pid;
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
/* initialize GnuTLS if SSL asked */
|
||||
if (HOOK_CONNECT(hook_connect, gnutls_sess))
|
||||
{
|
||||
@@ -1702,7 +1681,6 @@ network_connect_with_fork (struct t_hook *hook_connect)
|
||||
gnutls_transport_set_ptr (*HOOK_CONNECT(hook_connect, gnutls_sess),
|
||||
(gnutls_transport_ptr_t) ((unsigned long) HOOK_CONNECT(hook_connect, sock)));
|
||||
}
|
||||
#endif /* HAVE_GNUTLS */
|
||||
|
||||
/* create pipe for child process */
|
||||
if (pipe (child_pipe) < 0)
|
||||
|
||||
Reference in New Issue
Block a user