Discussion:
[libvirt] [PATCH v3 0/4] rpc: fixing compilation error due to deprecated functions.
Julio Faracco
2018-11-23 19:52:32 UTC
Permalink
After 0.8.0 release, libssh deprecated some functions like:
ssh_is_server_known() and ssh_write_knownhost(). They were replaced by
ssh_session_is_known_server() and ssh_session_update_known_hosts()
respectively. This serie creates the alias to keep the compatibility and
create an auxiliar enum to help it because
ssh_session_update_known_hosts() introduced new state returns.

v1-v2: Rebasing ssh_session_is_known_server() return states.
v2-v3: Only code syntax fixes.

Julio Faracco (4):
m4: checking if ssh_session_is_known_server() exists.
rpc: replacing ssh_is_server_known() by ssh_session_is_known_server().
m4: checking if ssh_session_update_known_hosts() exists.
rpc: replacing ssh_write_knownhost() by
ssh_session_update_known_hosts().

m4/virt-libssh.m4 | 12 ++++++++++++
src/rpc/virnetlibsshsession.c | 18 +++++++++++++++++-
2 files changed, 29 insertions(+), 1 deletion(-)
--
2.19.1
Julio Faracco
2018-11-23 19:52:33 UTC
Permalink
This commit adds some checks inside libssh m4 checking to verify if
ssh_session_is_known_server function is available. This new function
scope replaces the old ssh_is_server_known() from libssh 0.8.0 and
below versions.

Another auxiliar enumerator was added to keep the compatibility with the
old standard used by ssh_is_server_known() function.

Signed-off-by: Julio Faracco <***@gmail.com>
---
m4/virt-libssh.m4 | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/m4/virt-libssh.m4 b/m4/virt-libssh.m4
index 01c3b75c72..52bd4d3639 100644
--- a/m4/virt-libssh.m4
+++ b/m4/virt-libssh.m4
@@ -33,6 +33,14 @@ AC_DEFUN([LIBVIRT_CHECK_LIBSSH],[
[],
[AC_DEFINE_UNQUOTED([ssh_get_server_publickey], [ssh_get_publickey],
[ssh_get_publickey is deprecated and replaced by ssh_get_server_publickey.])])
+ AC_CHECK_FUNC([ssh_session_is_known_server],
+ [],
+ [AC_DEFINE_UNQUOTED([ssh_session_is_known_server], [ssh_is_server_known],
+ [ssh_is_server_known is deprecated and replaced by ssh_session_is_known_server.])])
+ AC_CHECK_TYPES([enum ssh_known_hosts_e],
+ [AC_DEFINE([HAVE_SSH_KNOWN_HOSTS_E], [1],
+ [Defined if enum ssh_known_hosts_e exists in libssh.h])],
+ [], [[#include <libssh/libssh.h>]])
CFLAGS="$old_CFLAGS"
LIBS="$old_LIBS"
fi
--
2.19.1
Julio Faracco
2018-11-23 19:52:35 UTC
Permalink
This commit adds some checks inside libssh m4 checking to verify if
ssh_session_update_known_hosts function is available. This new function
scope replaces the old ssh_write_knownhost() from libssh 0.8.0 and
below versions.

Signed-off-by: Julio Faracco <***@gmail.com>
---
m4/virt-libssh.m4 | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/m4/virt-libssh.m4 b/m4/virt-libssh.m4
index 52bd4d3639..f6d307f8d1 100644
--- a/m4/virt-libssh.m4
+++ b/m4/virt-libssh.m4
@@ -41,6 +41,10 @@ AC_DEFUN([LIBVIRT_CHECK_LIBSSH],[
[AC_DEFINE([HAVE_SSH_KNOWN_HOSTS_E], [1],
[Defined if enum ssh_known_hosts_e exists in libssh.h])],
[], [[#include <libssh/libssh.h>]])
+ AC_CHECK_FUNC([ssh_session_update_known_hosts],
+ [],
+ [AC_DEFINE_UNQUOTED([ssh_session_update_known_hosts], [ssh_write_knownhost],
+ [ssh_write_knownhost is deprecated and replaced by ssh_session_update_known_hosts.])])
CFLAGS="$old_CFLAGS"
LIBS="$old_LIBS"
fi
--
2.19.1
Julio Faracco
2018-11-23 19:52:34 UTC
Permalink
After version 0.8.0, libssh deprecated the function scope
ssh_is_server_known() and moved to ssh_session_is_known_server().
So, libvirt is failing to compile using this new function name.

Signed-off-by: Julio Faracco <***@gmail.com>
---
src/rpc/virnetlibsshsession.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)

diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c
index 7c5f158f4d..eb6d6843a2 100644
--- a/src/rpc/virnetlibsshsession.c
+++ b/src/rpc/virnetlibsshsession.c
@@ -80,6 +80,22 @@ struct _virNetLibsshAuthMethod {
int tries;
};

+#ifndef HAVE_SSH_KNOWN_HOSTS_E
+/* This is an auxiliar enum to help libssh migration to version 0.8.0
+ * or higher. This enum associates the enumerator ssh_server_known_e
+ * with new ssh_known_hosts_e enum. In other words, it can be removed
+ * in the future. ERROR was moved from -1 to -2 and NOT_FOUND from 4
+ * to -1. */
+enum _vir_ssh_known_hosts_e {
+ SSH_KNOWN_HOSTS_ERROR = SSH_SERVER_ERROR,
+ SSH_KNOWN_HOSTS_UNKNOWN = SSH_SERVER_NOT_KNOWN,
+ SSH_KNOWN_HOSTS_OK,
+ SSH_KNOWN_HOSTS_CHANGED,
+ SSH_KNOWN_HOSTS_OTHER,
+ SSH_KNOWN_HOSTS_NOT_FOUND,
+};
+#endif
+
struct _virNetLibsshSession {
virObjectLockable parent;
virNetLibsshSessionState state;
--
2.19.1
Julio Faracco
2018-11-23 19:52:36 UTC
Permalink
After version 0.8.0, libssh deprecated the function scope
ssh_write_knownhost() and moved to ssh_session_update_known_hosts().
So, libvirt is failing to compile using this new function name.

Signed-off-by: Julio Faracco <***@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 eb6d6843a2..5a7ca04dec 100644
--- a/src/rpc/virnetlibsshsession.c
+++ b/src/rpc/virnetlibsshsession.c
@@ -397,7 +397,7 @@ virNetLibsshCheckHostKey(virNetLibsshSessionPtr sess)

/* write the host key file, if specified */
if (sess->knownHostsFile) {
- if (ssh_write_knownhost(sess->session) < 0) {
+ if (ssh_session_update_known_hosts(sess->session) < 0) {
errmsg = ssh_get_error(sess->session);
virReportError(VIR_ERR_LIBSSH,
_("failed to write known_host file '%s': %s"),
--
2.19.1
Loading...