src/rpc/virnetlibsshsession.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
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@gmail.com>
---
src/rpc/virnetlibsshsession.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c
index 309e8a9340..9dc7976828 100644
--- a/src/rpc/virnetlibsshsession.c
+++ b/src/rpc/virnetlibsshsession.c
@@ -214,7 +214,11 @@ virLibsshServerKeyAsString(virNetLibsshSessionPtr sess)
size_t keyhashlen;
char *str;
- if (ssh_get_publickey(sess->session, &key) != SSH_OK) {
+#if LIBSSH_VERSION_INT <= 0x0705 /* 0.7.5 */
+# define ssh_get_server_publickey ssh_get_publickey
+#endif
+
+ 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
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On Wed, 2018-05-09 at 07:42 -0300, Julio Faracco wrote: [...] > +#if LIBSSH_VERSION_INT <= 0x0705 /* 0.7.5 */ > +# define ssh_get_server_publickey ssh_get_publickey > +#endif > + > + if (ssh_get_server_publickey(sess->session, &key) != SSH_OK) { > virReportError(VIR_ERR_LIBSSH, "%s", > _("failed to get the key of the current " > "session")); This won't work. Looking at libssh.h on Fedora 28 (libssh-devel 0.7.5-7.fc28): #define LIBSSH_VERSION_MAJOR 0 #define LIBSSH_VERSION_MINOR 7 #define LIBSSH_VERSION_MICRO 5 LIBSSH_API int ssh_get_publickey(ssh_session session, ssh_key *key); but on Debian sid (libssh-gcrypt-dev 0.8.0~20170825.94fa1e38-1): #define LIBSSH_VERSION_MAJOR 0 #define LIBSSH_VERSION_MINOR 7 #define LIBSSH_VERSION_MICRO 0 LIBSSH_API int ssh_get_server_publickey(ssh_session session, ssh_key *key); SSH_DEPRECATED LIBSSH_API int ssh_get_publickey(ssh_session session, ssh_key *key); Unsurprisingly, even after applying your patch libvirt fails to build on the latter. Not sure what's going on with the version number in the header disagreeing with the one in the package manager, but it clearly shows checking for the version number is not the way to go. I think you should add a configure-time check for the availability of the ssh_get_server_publickey() function instead, and then change your code to #ifndef HAVE_SSH_GET_SERVER_PUBLICKEY # define ssh_get_server_publickey ssh_get_publickey #endif While at it, please move it towards the top of the file rather than in the middle of the function body, please :) -- Andrea Bolognani / Red Hat / Virtualization -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
© 2016 - 2025 Red Hat, Inc.