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

After 0.7.5 release, libssh deprecated ssh_get_publickey() method to introduce ssh_get_server_publickey(). This commit check if ssh_get_server_publickey() is available to use. If it is not, it creates an alias to ssh_get_publickey() during the configuration. 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 Julio Faracco (2): m4: checking if ssh_get_server_publickey() exists. rpc: replacing ssh_get_publickey() by ssh_get_server_publickey(). m4/virt-libssh.m4 | 13 +++++++++++++ src/rpc/virnetlibsshsession.c | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) -- 2.17.0

This commit adds some checks inside libssh m4 checking to verify if ssh_get_server_publickey is available. This new function scope replaces the old ssh_get_publickey() from libssh 0.7.5 and below. Assuming that some distros are not showing the right version of libssh. This is a simple way to check which function is available. Signed-off-by: Julio Faracco <jcfaracco@gmail.com> --- m4/virt-libssh.m4 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/m4/virt-libssh.m4 b/m4/virt-libssh.m4 index 7e39277e10..01c3b75c72 100644 --- a/m4/virt-libssh.m4 +++ b/m4/virt-libssh.m4 @@ -23,6 +23,19 @@ AC_DEFUN([LIBVIRT_ARG_LIBSSH],[ AC_DEFUN([LIBVIRT_CHECK_LIBSSH],[ LIBVIRT_CHECK_PKG([LIBSSH], [libssh], [0.7]) + + if test "$with_libssh" = "yes" ; then + old_CFLAGS="$CFLAGS" + old_LIBS="$LIBS" + CFLAGS="$CFLAGS $LIBSSH_CFLAGS" + LIBS="$LIBS $LIBSSH_LIBS" + AC_CHECK_FUNC([ssh_get_server_publickey], + [], + [AC_DEFINE_UNQUOTED([ssh_get_server_publickey], [ssh_get_publickey], + [ssh_get_publickey is deprecated and replaced by ssh_get_server_publickey.])]) + CFLAGS="$old_CFLAGS" + LIBS="$old_LIBS" + fi ]) AC_DEFUN([LIBVIRT_RESULT_LIBSSH],[ -- 2.17.0

After version 0.7.5, libssh deprecated the function scope ssh_get_publickey() and moved to ssh_get_server_publickey(). So, Libvirt is failing to compile using this new function name. Signed-off-by: Julio Faracco <jcfaracco@gmail.com> --- src/rpc/virnetlibsshsession.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c index 309e8a9340..6d78d2569e 100644 --- a/src/rpc/virnetlibsshsession.c +++ b/src/rpc/virnetlibsshsession.c @@ -214,7 +214,7 @@ virLibsshServerKeyAsString(virNetLibsshSessionPtr sess) size_t keyhashlen; char *str; - if (ssh_get_publickey(sess->session, &key) != SSH_OK) { + if (ssh_get_server_publickey(sess->session, &key) != SSH_OK) { virReportError(VIR_ERR_LIBSSH, "%s", _("failed to get the key of the current " "session")); -- 2.17.0

On Thu, 2018-05-10 at 17:38 -0300, Julio Faracco wrote:
After 0.7.5 release, libssh deprecated ssh_get_publickey() method to introduce ssh_get_server_publickey(). This commit check if ssh_get_server_publickey() is available to use. If it is not, it creates an alias to ssh_get_publickey() during the configuration. 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
Julio Faracco (2): m4: checking if ssh_get_server_publickey() exists. rpc: replacing ssh_get_publickey() by ssh_get_server_publickey().
m4/virt-libssh.m4 | 13 +++++++++++++ src/rpc/virnetlibsshsession.c | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-)
Interesting approach in patch 1/2. Not the way I would have done it, but it works and stays out of the way, so nothing to complain about really :) For the series Reviewed-by: Andrea Bolognani <abologna@redhat.com> and pushed. -- Andrea Bolognani / Red Hat / Virtualization
participants (2)
-
Andrea Bolognani
-
Julio Faracco