Re: [libvirt] [PATCH] rpc: fixing compilation error due to deprecated ssh_get_publickey().
On 05/06/2018 03:15 PM, Julio Faracco wrote: > Well, > > Do we have a winner? :-) > > -- > Julio Cesar Faracco > sigh, top posting is not favored in technical groups. In any case, I kind of like Eric's suggestion and I just figured you'd end up coding it and posting it. John > 2018-05-04 18:23 GMT-03:00 Eric Blake: >> On 05/04/2018 04:01 PM, Julio Faracco wrote: >>> >>> IMHO: >>> - The first approach is simple to remove in the future. >> >> >> No, both approaches are equally easy to trim down in the future (true, the >> second approach leaves a temporary variable that could possibly be deleted, >> but it's not a prerequisite to remove the temporary variable when trimming >> the ifdefs). >> >>> - The second one is easy to read and understand. >> >> >> Furthermore, the second one does not have unbalanced { vs. }, which makes it >> better for some editors. >> > +#if LIBSSH_VERSION_INT > 0x0705 /* 0.7.5 */ > +if (ssh_get_server_publickey(sess->session, ) != SSH_OK) { > +#else > if (ssh_get_publickey(sess->session, ) != SSH_OK) { > +#endif > virReportError(VIR_ERR_LIBSSH, "%s", > _("failed to get the key of the current " >"session")); How about making it easier to read and harder to mess up: #if LIBSSH_VERSION_INT > 0x0705 /* 0.7.5 */ rc = ssh_get_server_publickey(sess->session, ); #else rc = ssh_get_publickey(sess->session, ); #endif if (rc != SSH_OK) { ... } >> >> >> Furthermore, top-posting on technical lists is harder to read. >> >> If you want a third approach, there is: >> >> #if LIBSSH_VERSION_INT <= 0x0705 /* 0.7.5 */ >> # define ssh_get_server_publickey ssh_get_publickey >> #endif >> >> if (ssh_get_server_publickey(sess->session, ) != SSH_OK) { >> virReportError(... >> >> -- >> Eric Blake, Principal Software Engineer >> Red Hat, Inc. +1-919-301-3266 >> Virtualization: qemu.org | libvirt.org > > -- > libvir-list mailing list > libvir-list@redhat.com > https://www.redhat.com/mailman/listinfo/libvir-list > -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] rpc: fixing compilation error due to deprecated ssh_get_publickey().
Well, Do we have a winner? :-) -- Julio Cesar Faracco 2018-05-04 18:23 GMT-03:00 Eric Blake: > On 05/04/2018 04:01 PM, Julio Faracco wrote: >> >> IMHO: >> - The first approach is simple to remove in the future. > > > No, both approaches are equally easy to trim down in the future (true, the > second approach leaves a temporary variable that could possibly be deleted, > but it's not a prerequisite to remove the temporary variable when trimming > the ifdefs). > >> - The second one is easy to read and understand. > > > Furthermore, the second one does not have unbalanced { vs. }, which makes it > better for some editors. > +#if LIBSSH_VERSION_INT > 0x0705 /* 0.7.5 */ +if (ssh_get_server_publickey(sess->session, ) != SSH_OK) { +#else if (ssh_get_publickey(sess->session, ) != SSH_OK) { +#endif virReportError(VIR_ERR_LIBSSH, "%s", _("failed to get the key of the current " "session")); >>> >>> >>> How about making it easier to read and harder to mess up: >>> >>> #if LIBSSH_VERSION_INT > 0x0705 /* 0.7.5 */ >>> rc = ssh_get_server_publickey(sess->session, ); >>> #else >>> rc = ssh_get_publickey(sess->session, ); >>> #endif >>> >>> if (rc != SSH_OK) { >>> ... >>> } > > > Furthermore, top-posting on technical lists is harder to read. > > If you want a third approach, there is: > > #if LIBSSH_VERSION_INT <= 0x0705 /* 0.7.5 */ > # define ssh_get_server_publickey ssh_get_publickey > #endif > > if (ssh_get_server_publickey(sess->session, ) != SSH_OK) { > virReportError(... > > -- > Eric Blake, Principal Software Engineer > Red Hat, Inc. +1-919-301-3266 > Virtualization: qemu.org | libvirt.org -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] rpc: fixing compilation error due to deprecated ssh_get_publickey().
On 05/04/2018 04:01 PM, Julio Faracco wrote: IMHO: - The first approach is simple to remove in the future. No, both approaches are equally easy to trim down in the future (true, the second approach leaves a temporary variable that could possibly be deleted, but it's not a prerequisite to remove the temporary variable when trimming the ifdefs). - The second one is easy to read and understand. Furthermore, the second one does not have unbalanced { vs. }, which makes it better for some editors. +#if LIBSSH_VERSION_INT > 0x0705 /* 0.7.5 */ +if (ssh_get_server_publickey(sess->session, ) != SSH_OK) { +#else if (ssh_get_publickey(sess->session, ) != SSH_OK) { +#endif virReportError(VIR_ERR_LIBSSH, "%s", _("failed to get the key of the current " "session")); How about making it easier to read and harder to mess up: #if LIBSSH_VERSION_INT > 0x0705 /* 0.7.5 */ rc = ssh_get_server_publickey(sess->session, ); #else rc = ssh_get_publickey(sess->session, ); #endif if (rc != SSH_OK) { ... } Furthermore, top-posting on technical lists is harder to read. If you want a third approach, there is: #if LIBSSH_VERSION_INT <= 0x0705 /* 0.7.5 */ # define ssh_get_server_publickey ssh_get_publickey #endif if (ssh_get_server_publickey(sess->session, ) != SSH_OK) { virReportError(... -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] rpc: fixing compilation error due to deprecated ssh_get_publickey().
IMHO: - The first approach is simple to remove in the future. - The second one is easy to read and understand. -- Julio Cesar Faracco 2018-05-04 16:10 GMT-03:00 Jiri Denemark: > On Tue, May 01, 2018 at 13:21:15 -0300, 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, ) != 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 >> --- >> 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, ) != SSH_OK) { >> +#else >> if (ssh_get_publickey(sess->session, ) != SSH_OK) { >> +#endif >> virReportError(VIR_ERR_LIBSSH, "%s", >> _("failed to get the key of the current " >> "session")); > > How about making it easier to read and harder to mess up: > > #if LIBSSH_VERSION_INT > 0x0705 /* 0.7.5 */ > rc = ssh_get_server_publickey(sess->session, ); > #else > rc = ssh_get_publickey(sess->session, ); > #endif > > if (rc != SSH_OK) { > ... > } > > Jirka -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] rpc: fixing compilation error due to deprecated ssh_get_publickey().
On Tue, May 01, 2018 at 13:21:15 -0300, 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, ) != 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> --- > 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, ) != SSH_OK) { > +#else > if (ssh_get_publickey(sess->session, ) != SSH_OK) { > +#endif > virReportError(VIR_ERR_LIBSSH, "%s", > _("failed to get the key of the current " > "session")); How about making it easier to read and harder to mess up: #if LIBSSH_VERSION_INT > 0x0705 /* 0.7.5 */ rc = ssh_get_server_publickey(sess->session, ); #else rc = ssh_get_publickey(sess->session, ); #endif if (rc != SSH_OK) { ... } Jirka -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] rpc: fixing compilation error due to deprecated ssh_get_publickey().
On Fri, May 04, 2018 at 12:53:14PM -0400, John Ferlan wrote: > > > 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, ) != 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> > --- > > 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, ) != SSH_OK) { > > +#else > > if (ssh_get_publickey(sess->session, ) != 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. That all depends on whether we care about handling the possibility of distros backporting the function to older versions of libssh. This kind of backporting happens alot for some projects, like QEMU, but not for others. IMHO this check against LIBSSH_VERSION_INT is fine. Regards, Daniel -- |: https://berrange.com -o-https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o-https://fstop138.berrange.com :| |: https://entangle-photo.org-o-https://www.instagram.com/dberrange :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] rpc: fixing compilation error due to deprecated ssh_get_publickey().
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, ) != 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> --- > 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, ) != SSH_OK) { > +#else > if (ssh_get_publickey(sess->session, ) != 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")); > -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] 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 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, ) != 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--- 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, ) != SSH_OK) { +#else if (ssh_get_publickey(sess->session, ) != SSH_OK) { +#endif 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