[libvirt] [PATCH] rpc: fixing compilation error due to deprecated ssh_get_publickey().

John Ferlan jferlan at redhat.com
Fri May 4 16:53:14 UTC 2018



On 05/01/2018 12:21 PM, Julio Faracco wrote:
> After 0.7.5 release, libssh deprecated ssh_get_publickey() method to
> introduce ssh_get_server_publickey(). This commit check the current
> version of libssh and use the proper method during the compilation.
> See the error:
> 
> make[3]: Entering directory '/home/julio/Desktop/virt/libvirt/src'
>   CC       rpc/libvirt_net_rpc_la-virnetlibsshsession.lo
> rpc/virnetlibsshsession.c:217:9: error: 'ssh_get_publickey' is deprecated [-Werror,-Wdeprecated-declarations]
>     if (ssh_get_publickey(sess->session, &key) != SSH_OK) {
>         ^
> /usr/include/libssh/libssh.h:489:1: note: 'ssh_get_publickey' has been explicitly marked deprecated here
> SSH_DEPRECATED LIBSSH_API int ssh_get_publickey(ssh_session session, ssh_key *key);
> ^
> /usr/include/libssh/libssh.h:99:40: note: expanded from macro 'SSH_DEPRECATED'
>                                        ^
> 1 error generated.
> Makefile:8604: recipe for target 'rpc/libvirt_net_rpc_la-virnetlibsshsession.lo' failed
> 
> Signed-off-by: Julio Faracco <jcfaracco at gmail.com>
> ---
>  src/rpc/virnetlibsshsession.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c
> index 309e8a9340..96c5bc0882 100644
> --- a/src/rpc/virnetlibsshsession.c
> +++ b/src/rpc/virnetlibsshsession.c
> @@ -214,7 +214,11 @@ virLibsshServerKeyAsString(virNetLibsshSessionPtr sess)
>      size_t keyhashlen;
>      char *str;
>  
> +#if LIBSSH_VERSION_INT > 0x0705 /* 0.7.5 */
> +    if (ssh_get_server_publickey(sess->session, &key) != SSH_OK) {
> +#else
>      if (ssh_get_publickey(sess->session, &key) != SSH_OK) {
> +#endif

Usually this involves changes to some m4/* file that would do the
version check and existence of some API and set a WITH_xxx or HAVE_xxx
type conditional which would then be used.

I typically try to avoid m4/* files and build stuff, so not my area of
expertise, but m4/virt-libssh.m4 is perhaps where you should start.
Perhaps usage of AC_CHECK_FUNCS

Look up HAVE_GNUTLS_CIPHER_ENCRYPT and how m4/virt-gnutls.m4 will check
for gnutls_cipher_encrypt for at least one example that comes to my mind.

John

>          virReportError(VIR_ERR_LIBSSH, "%s",
>                         _("failed to get the key of the current "
>                           "session"));
> 




More information about the libvir-list mailing list