qemu-trad: fix build with recent gnutls
cover qemu-trad: fix build with recent gnutls
Building qemu-traditional fails with current gnutls:
../libqemu_common.a(vnc.o): In function `vnc_start_tls':/home/abuild/rpmbuild/BUILD/xen-4.6.30745/non-dbg/tools/qemu-xen-traditional-dir/vnc.c:2164: undefined reference to gnutls_kx_set_priority' /home/abuild/rpmbuild/BUILD/xen-4.6.30745/non-dbg/tools/qemu-xen-traditional-dir/vnc.c:2171: undefined reference to gnutls_certificate_type_set_priority' /home/abuild/rpmbuild/BUILD/xen-4.6.30745/non-dbg/tools/qemu-xen-traditional-dir/vnc.c:2178: undefined reference to `gnutls_protocol_set_priority'
collect2: error: ld returned 1 exit status
Makefile:740: recipe for target 'qemu-dm' failed
To fix the build two upstream patches need to be backported. One fixes the compile error, the other one removes another deprecated function warning.
This series was only compile tested.
Please review and apply to qemu-trad, xen-4.2 and later is affected.
Olaf
Andre Przywara (1):
vnc-tls: Fix compilation with newer versions of GNU-TLS
Gerd Hoffmann (1):
vns/tls: don't use depricated gnutls functions
vnc.c | 71 +++++++++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 23 deletions(-)
PATCH 1/2 vns/tls: don't use depricated gnutls functions
From: Gerd Hoffmann <[email protected]>
Avoid using deprecated gnutls functions with recent gnutls versions. Fixes build failure on Fedora 16. Keep the old way for compatibility with old installations such as RHEL-5 (gnutls 1.4.x).
Based on a patch from Raghavendra D Prabhu <[email protected]>
Upstream commit f40d55081667a716312b9a8b6e13835c4074f56b
--- vnc.c | 65 +++++++++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 20 deletions(-)
vnc.c +45 -20
@@ -2135,13 +2135,52 @@ static void vnc_handshake_io(void *opaque) { (vs)->subauth == VNC_AUTH_VENCRYPT_X509VNC || \ (vs)->subauth == VNC_AUTH_VENCRYPT_X509PLAIN) +#if defined(GNUTLS_VERSION_NUMBER ) && \ +GNUTLS_VERSION_NUMBER >=0x020200 /* 2.2.0 */ +static int vnc_set_gnutls_priority (gnutls_session_t s,int x509) +{ +const char *priority = x509 ?"NORMAL" :"NORMAL:+ANON-DH" ; +int rc; -static int vnc_start_tls (struct VncState *vs) { -static const int cert_type_priority[] = {GNUTLS_CRT_X509 ,0 }; -static const int protocol_priority[]= {GNUTLS_TLS1_1 ,GNUTLS_TLS1_0 ,GNUTLS_SSL3 ,0 }; -static const int kx_anon[] = {GNUTLS_KX_ANON_DH ,0 }; -static const int kx_x509[] = {GNUTLS_KX_DHE_DSS ,GNUTLS_KX_RSA ,GNUTLS_KX_DHE_RSA ,GNUTLS_KX_SRP ,0 }; + rc =gnutls_priority_set_direct (s, priority,NULL ); +if (rc !=GNUTLS_E_SUCCESS ) { +return -1 ; + } +return 0 ; +} +#else +static int vnc_set_gnutls_priority (gnutls_session_t s,int x509) +{ +static const int cert_types[] = {GNUTLS_CRT_X509 ,0 }; +static const int protocols[] = { +GNUTLS_TLS1_1 ,GNUTLS_TLS1_0 ,GNUTLS_SSL3 ,0 + }; +static const int kx_anon[] = {GNUTLS_KX_ANON_DH ,0 }; +static const int kx_x509[] = { +GNUTLS_KX_DHE_DSS ,GNUTLS_KX_RSA , +GNUTLS_KX_DHE_RSA ,GNUTLS_KX_SRP ,0 + }; +int rc; + + rc =gnutls_kx_set_priority (s, x509 ? kx_x509 : kx_anon); +if (rc !=GNUTLS_E_SUCCESS ) { +return -1 ; + } + + rc =gnutls_certificate_type_set_priority (s, cert_types); +if (rc !=GNUTLS_E_SUCCESS ) { +return -1 ; + } + rc =gnutls_protocol_set_priority (s, protocols); +if (rc !=GNUTLS_E_SUCCESS ) { +return -1 ; + } +return 0 ; +} +#endif + +static int vnc_start_tls (struct VncState *vs) {VNC_DEBUG ("Do TLS setup\n" );if (vnc_tls_initialize () <0 ) {VNC_DEBUG ("Failed to init TLS\n" );
@@ -2161,21 +2200,7 @@ static int vnc_start_tls(struct VncState *vs) {return -1 ; } -if (gnutls_kx_set_priority (vs->tls_session,NEED_X509_AUTH (vs) ? kx_x509 : kx_anon) <0 ) { -gnutls_deinit (vs->tls_session); - vs->tls_session =NULL ; -vnc_client_error (vs); -return -1 ; - } - -if (gnutls_certificate_type_set_priority (vs->tls_session, cert_type_priority) <0 ) { -gnutls_deinit (vs->tls_session); - vs->tls_session =NULL ; -vnc_client_error (vs); -return -1 ; - } - -if (gnutls_protocol_set_priority (vs->tls_session, protocol_priority) <0 ) { +if (vnc_set_gnutls_priority (vs->tls_session, !!NEED_X509_AUTH (vs)) <0 ) {gnutls_deinit (vs->tls_session); vs->tls_session =NULL ;vnc_client_error (vs);
Re: [PATCH 1/2] vns/tls: don't use depricated gnutls functions
Quoted 6 lines · Olaf Hering
From: Gerd Hoffmann <[email protected]>
Avoid using deprecated gnutls functions with recent gnutls versions. Fixes build failure on Fedora 16. Keep the old way for compatibility with old installations such as RHEL-5 (gnutls 1.4.x).
Quoted 7 lines
Based on a patch from Raghavendra D Prabhu <[email protected]>
Upstream commit
f40d55081667a716312b9a8b6e13835c4074f56bSigned-off-by Gerd Hoffmann <[email protected]>Signed-off-by Anthony Liguori <[email protected]>Signed-off-by Olaf Hering <[email protected]>
The patch looks good. I've only compiled it on Debian and Arch since I don't see how to enable vnc tls via xl.
Signature · 1 line
Anthony PERARD
PATCH 2/2 vnc-tls: Fix compilation with newer versions of GNU-TLS
In reply to Olaf HeringFrom: Andre Przywara <[email protected]>
In my installation of GNU-TLS (v3.0.23) the type gnutls_anon_server_credentials is marked deprecated, so -Werror breaks compilation.
Simply replacing it with the newer ..._t version fixed the compilation on my machine (Slackware 14.0). I cannot tell how far back this "new" type goes, at least the header file in RHEL 5.0 (v1.4.1) seems to have it already. If someone finds a broken distribution, tell me and I insert some compat code.
Upstream commit 7d2a929feba319c18603e324b1750830d6c8b7a1
Message-id: [email protected]
--- vnc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
vnc.c +3 -3
@@ -1909,9 +1909,9 @@ static int vnc_tls_initialize(void)return 1 ; } -static gnutls_anon_server_credentials vnc_tls_initialize_anon_cred (void ) +static gnutls_anon_server_credentials_t vnc_tls_initialize_anon_cred (void ) { -gnutls_anon_server_credentials anon_cred; +gnutls_anon_server_credentials_t anon_cred;int ret;if ((ret =gnutls_anon_allocate_server_credentials (&anon_cred)) <0 ) {
@@ -2228,7 +2228,7 @@ static int vnc_start_tls(struct VncState *vs) { } }else { -gnutls_anon_server_credentials anon_cred =vnc_tls_initialize_anon_cred (); +gnutls_anon_server_credentials_t anon_cred =vnc_tls_initialize_anon_cred ();if (!anon_cred) {gnutls_deinit (vs->tls_session); vs->tls_session =NULL ;
Re: [PATCH 2/2] vnc-tls: Fix compilation with newer versions of GNU-TLS
Quoted 11 lines · Olaf Hering
From: Andre Przywara <[email protected]>
In my installation of GNU-TLS (v3.0.23) the type
gnutls_anon_server_credentialsis marked deprecated, so -Werror breaks compilation.
Simply replacing it with the newer ..._t version fixed the compilation on my machine (Slackware 14.0). I cannot tell how far back this "new" type goes, at least the header file in RHEL 5.0 (v1.4.1) seems to have it already. If someone finds a broken distribution, tell me and I insert some compat code.
Quoted 7 lines
Upstream commit
7d2a929feba319c18603e324b1750830d6c8b7a1Signed-off-by Andre Przywara <[email protected]>Message-id: [email protected]
Signed-off-by Anthony Liguori <[email protected]>Signed-off-by Olaf Hering <[email protected]>
Signature · 1 line
Anthony PERARD