[PATCH] Use "new" gnutls types

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] Use "new" gnutls types

Samba - samba-technical mailing list
Hi,

the attached patch uses the "new" GnuTLS types which have been introduced in
2004 (version 1.0.20). I think it is safe to use them with GnuTLS 3.x now :)

This removed a bunch of deprecation warnings ...


Review and push appreciated.


Thanks,


        Andreas

--
Andreas Schneider                   GPG-ID: CC014E3D
Samba Team                             [hidden email]
www.samba.org

s4-tls.patch.txt (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Use "new" gnutls types

Samba - samba-technical mailing list
On Tue, May 09, 2017 at 01:24:15PM +0200, Andreas Schneider via samba-technical wrote:
> Hi,
>
> the attached patch uses the "new" GnuTLS types which have been introduced in
> 2004 (version 1.0.20). I think it is safe to use them with GnuTLS 3.x now :)
>
> This removed a bunch of deprecation warnings ...
>
>
> Review and push appreciated.

LGTM - pushed !

>
>
> Andreas
>
> --
> Andreas Schneider                   GPG-ID: CC014E3D
> Samba Team                             [hidden email]
> www.samba.org

> From c77486d8ee4f2243a5c39a8628ec2887d823ba1c Mon Sep 17 00:00:00 2001
> From: Andreas Schneider <[hidden email]>
> Date: Tue, 9 May 2017 13:17:13 +0200
> Subject: [PATCH] s4:tls: Do not use deprecated GnuTLS types
>
> Those have been deprecated with GnuTLS 1.0.20 in 2004. I think it is
> safe to use them now ;)
>
> Signed-off-by: Andreas Schneider <[hidden email]>
> ---
>  source4/lib/tls/tls.c         | 14 +++++++-------
>  source4/lib/tls/tls_tstream.c | 16 +++++++++-------
>  2 files changed, 16 insertions(+), 14 deletions(-)
>
> diff --git a/source4/lib/tls/tls.c b/source4/lib/tls/tls.c
> index ad8bbd444a4..ac4df221999 100644
> --- a/source4/lib/tls/tls.c
> +++ b/source4/lib/tls/tls.c
> @@ -39,8 +39,8 @@ typedef gnutls_datum gnutls_datum_t;
>  
>  /* hold persistent tls data */
>  struct tls_params {
> - gnutls_certificate_credentials x509_cred;
> - gnutls_dh_params dh_params;
> + gnutls_certificate_credentials_t x509_cred;
> + gnutls_dh_params_t dh_params;
>   bool tls_enabled;
>   const char *tls_priority;
>  };
> @@ -52,14 +52,14 @@ struct tls_context {
>   struct tevent_fd *fde;
>   bool tls_enabled;
>  #if ENABLE_GNUTLS
> - gnutls_session session;
> + gnutls_session_t session;
>   bool done_handshake;
>   bool have_first_byte;
>   uint8_t first_byte;
>   bool tls_detect;
>   const char *plain_chars;
>   bool output_pending;
> - gnutls_certificate_credentials xcred;
> + gnutls_certificate_credentials_t xcred;
>   bool interrupted;
>  #endif
>  };
> @@ -111,7 +111,7 @@ static NTSTATUS tls_socket_init(struct socket_context *sock)
>  /*
>    callback for reading from a socket
>  */
> -static ssize_t tls_pull(gnutls_transport_ptr ptr, void *buf, size_t size)
> +static ssize_t tls_pull(gnutls_transport_ptr_t ptr, void *buf, size_t size)
>  {
>   struct tls_context *tls = talloc_get_type(ptr, struct tls_context);
>   NTSTATUS status;
> @@ -150,7 +150,7 @@ static ssize_t tls_pull(gnutls_transport_ptr ptr, void *buf, size_t size)
>  /*
>    callback for writing to a socket
>  */
> -static ssize_t tls_push(gnutls_transport_ptr ptr, const void *buf, size_t size)
> +static ssize_t tls_push(gnutls_transport_ptr_t ptr, const void *buf, size_t size)
>  {
>   struct tls_context *tls = talloc_get_type(ptr, struct tls_context);
>   NTSTATUS status;
> @@ -545,7 +545,7 @@ struct socket_context *tls_init_server(struct tls_params *params,
>   params->x509_cred));
>   gnutls_certificate_server_set_request(tls->session, GNUTLS_CERT_REQUEST);
>   gnutls_dh_set_prime_bits(tls->session, DH_BITS);
> - gnutls_transport_set_ptr(tls->session, (gnutls_transport_ptr)tls);
> + gnutls_transport_set_ptr(tls->session, (gnutls_transport_ptr_t)tls);
>   gnutls_transport_set_pull_function(tls->session, (gnutls_pull_func)tls_pull);
>   gnutls_transport_set_push_function(tls->session, (gnutls_push_func)tls_push);
>  #if GNUTLS_VERSION_MAJOR < 3
> diff --git a/source4/lib/tls/tls_tstream.c b/source4/lib/tls/tls_tstream.c
> index 28fe3328b12..94689718d63 100644
> --- a/source4/lib/tls/tls_tstream.c
> +++ b/source4/lib/tls/tls_tstream.c
> @@ -85,7 +85,7 @@ struct tstream_tls {
>   int error;
>  
>  #if ENABLE_GNUTLS
> - gnutls_session tls_session;
> + gnutls_session_t tls_session;
>  #endif /* ENABLE_GNUTLS */
>  
>   enum tls_verify_peer_state verify_peer;
> @@ -190,7 +190,7 @@ static void tstream_tls_push_trigger_write(struct tevent_context *ev,
>     struct tevent_immediate *im,
>     void *private_data);
>  
> -static ssize_t tstream_tls_push_function(gnutls_transport_ptr ptr,
> +static ssize_t tstream_tls_push_function(gnutls_transport_ptr_t ptr,
>   const void *buf, size_t size)
>  {
>   struct tstream_context *stream =
> @@ -329,7 +329,7 @@ static void tstream_tls_push_done(struct tevent_req *subreq)
>  
>  static void tstream_tls_pull_done(struct tevent_req *subreq);
>  
> -static ssize_t tstream_tls_pull_function(gnutls_transport_ptr ptr,
> +static ssize_t tstream_tls_pull_function(gnutls_transport_ptr_t ptr,
>   void *buf, size_t size)
>  {
>   struct tstream_context *stream =
> @@ -911,8 +911,8 @@ static const struct tstream_context_ops tstream_tls_ops = {
>  
>  struct tstream_tls_params {
>  #if ENABLE_GNUTLS
> - gnutls_certificate_credentials x509_cred;
> - gnutls_dh_params dh_params;
> + gnutls_certificate_credentials_t x509_cred;
> + gnutls_dh_params_t dh_params;
>   const char *tls_priority;
>  #endif /* ENABLE_GNUTLS */
>   bool tls_enabled;
> @@ -1115,7 +1115,8 @@ struct tevent_req *_tstream_tls_connect_send(TALLOC_CTX *mem_ctx,
>   return tevent_req_post(req, ev);
>   }
>  
> - gnutls_transport_set_ptr(tlss->tls_session, (gnutls_transport_ptr)state->tls_stream);
> + gnutls_transport_set_ptr(tlss->tls_session,
> + (gnutls_transport_ptr_t)state->tls_stream);
>   gnutls_transport_set_pull_function(tlss->tls_session,
>     (gnutls_pull_func)tstream_tls_pull_function);
>   gnutls_transport_set_push_function(tlss->tls_session,
> @@ -1390,7 +1391,8 @@ struct tevent_req *_tstream_tls_accept_send(TALLOC_CTX *mem_ctx,
>        GNUTLS_CERT_REQUEST);
>   gnutls_dh_set_prime_bits(tlss->tls_session, DH_BITS);
>  
> - gnutls_transport_set_ptr(tlss->tls_session, (gnutls_transport_ptr)state->tls_stream);
> + gnutls_transport_set_ptr(tlss->tls_session,
> + (gnutls_transport_ptr_t)state->tls_stream);
>   gnutls_transport_set_pull_function(tlss->tls_session,
>     (gnutls_pull_func)tstream_tls_pull_function);
>   gnutls_transport_set_push_function(tlss->tls_session,
> --
> 2.12.2
>