diff mbox series

[2/4] configure: Avoid using libssh deprecated API

Message ID 20190814121527.17876-3-philmd@redhat.com (mailing list archive)
State New, archived
Headers show
Series configure: Fix libssh on Ubuntu 18.04 | expand

Commit Message

Philippe Mathieu-Daudé Aug. 14, 2019, 12:15 p.m. UTC
The libssh packaged by a distribution can predate version 0.8,
but still provides the newer API introduced after version 0.7.

Using the deprecated API leads to build failure, as on Ubuntu 18.04:

    CC      block/ssh.o
  block/ssh.c: In function 'check_host_key_hash':
  block/ssh.c:444:5: error: 'ssh_get_publickey' is deprecated [-Werror=deprecated-declarations]
       r = ssh_get_publickey(s->session, &pubkey);
       ^
  In file included from block/ssh.c:27:0:
  /usr/include/libssh/libssh.h:489:31: note: declared here
   SSH_DEPRECATED LIBSSH_API int ssh_get_publickey(ssh_session session, ssh_key *key);
                                 ^~~~~~~~~~~~~~~~~
  rules.mak:69: recipe for target 'block/ssh.o' failed
  make: *** [block/ssh.o] Error 1

Fix by using the newer API if available.

Suggested-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 block/ssh.c | 2 +-
 configure   | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

Comments

Pino Toscano Aug. 14, 2019, 12:35 p.m. UTC | #1
On Wednesday, 14 August 2019 14:15:25 CEST Philippe Mathieu-Daudé wrote:
> The libssh packaged by a distribution can predate version 0.8,
> but still provides the newer API introduced after version 0.7.
> 
> Using the deprecated API leads to build failure, as on Ubuntu 18.04:
> 
>     CC      block/ssh.o
>   block/ssh.c: In function 'check_host_key_hash':
>   block/ssh.c:444:5: error: 'ssh_get_publickey' is deprecated [-Werror=deprecated-declarations]
>        r = ssh_get_publickey(s->session, &pubkey);
>        ^
>   In file included from block/ssh.c:27:0:
>   /usr/include/libssh/libssh.h:489:31: note: declared here
>    SSH_DEPRECATED LIBSSH_API int ssh_get_publickey(ssh_session session, ssh_key *key);
>                                  ^~~~~~~~~~~~~~~~~
>   rules.mak:69: recipe for target 'block/ssh.o' failed
>   make: *** [block/ssh.o] Error 1
> 
> Fix by using the newer API if available.
> 
> Suggested-by: Andrea Bolognani <abologna@redhat.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  block/ssh.c | 2 +-
>  configure   | 7 +++++++
>  2 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/block/ssh.c b/block/ssh.c
> index 501933b855..f5fea921c6 100644
> --- a/block/ssh.c
> +++ b/block/ssh.c
> @@ -438,7 +438,7 @@ check_host_key_hash(BDRVSSHState *s, const char *hash,
>      unsigned char *server_hash;
>      size_t server_hash_len;
>  
> -#ifdef HAVE_LIBSSH_0_8
> +#ifdef HAVE_SSH_GET_SERVER_PUBLICKEY
>      r = ssh_get_server_publickey(s->session, &pubkey);
>  #else
>      r = ssh_get_publickey(s->session, &pubkey);
> diff --git a/configure b/configure
> index 1d5c07de1f..fe3fef9309 100755
> --- a/configure
> +++ b/configure
> @@ -3949,11 +3949,18 @@ fi
>  if test "$libssh" = "yes"; then
>    cat > $TMPC <<EOF
>  #include <libssh/libssh.h>
> +#ifdef HAVE_SSH_GET_SERVER_PUBLICKEY
>  int main(void) { return ssh_get_server_publickey(NULL, NULL); }
> +#else
> +int main(void) { return ssh_get_publickey(NULL, NULL); }
> +#endif
>  EOF
>    if compile_object "$libssh_cflags"; then
>      libssh_cflags="-DHAVE_LIBSSH_0_8 $libssh_cflags"
>    fi
> +  if compile_object "$libssh_cflags -DHAVE_SSH_GET_SERVER_PUBLICKEY"; then
> +    libssh_cflags="-DHAVE_SSH_GET_SERVER_PUBLICKEY $libssh_cflags"
> +  fi

Why try to compile it twice? If the check for ssh_get_server_publickey
works, then it is available...

Just add an additional HAVE_SSH_GET_SERVER_PUBLICKEY define when this
test succeeds, and change the usage of ssh_get_server_publickey based
on this.
Andrea Bolognani Aug. 14, 2019, 1:27 p.m. UTC | #2
On Wed, 2019-08-14 at 14:15 +0200, Philippe Mathieu-Daudé wrote:
> The libssh packaged by a distribution can predate version 0.8,
> but still provides the newer API introduced after version 0.7.
> 
> Using the deprecated API leads to build failure, as on Ubuntu 18.04:
> 
>     CC      block/ssh.o
>   block/ssh.c: In function 'check_host_key_hash':
>   block/ssh.c:444:5: error: 'ssh_get_publickey' is deprecated [-Werror=deprecated-declarations]
>        r = ssh_get_publickey(s->session, &pubkey);
>        ^
>   In file included from block/ssh.c:27:0:
>   /usr/include/libssh/libssh.h:489:31: note: declared here
>    SSH_DEPRECATED LIBSSH_API int ssh_get_publickey(ssh_session session, ssh_key *key);
>                                  ^~~~~~~~~~~~~~~~~
>   rules.mak:69: recipe for target 'block/ssh.o' failed
>   make: *** [block/ssh.o] Error 1
> 
> Fix by using the newer API if available.
> 
> Suggested-by: Andrea Bolognani <abologna@redhat.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  block/ssh.c | 2 +-
>  configure   | 7 +++++++
>  2 files changed, 8 insertions(+), 1 deletion(-)

Did I really suggest this? I have no recollection of doing so, or
even getting involved with libssh support in QEMU at all for that
matter.
Philippe Mathieu-Daudé Aug. 14, 2019, 2:15 p.m. UTC | #3
On 8/14/19 3:27 PM, Andrea Bolognani wrote:
> On Wed, 2019-08-14 at 14:15 +0200, Philippe Mathieu-Daudé wrote:
>> The libssh packaged by a distribution can predate version 0.8,
>> but still provides the newer API introduced after version 0.7.
>>
>> Using the deprecated API leads to build failure, as on Ubuntu 18.04:
>>
>>     CC      block/ssh.o
>>   block/ssh.c: In function 'check_host_key_hash':
>>   block/ssh.c:444:5: error: 'ssh_get_publickey' is deprecated [-Werror=deprecated-declarations]
>>        r = ssh_get_publickey(s->session, &pubkey);
>>        ^
>>   In file included from block/ssh.c:27:0:
>>   /usr/include/libssh/libssh.h:489:31: note: declared here
>>    SSH_DEPRECATED LIBSSH_API int ssh_get_publickey(ssh_session session, ssh_key *key);
>>                                  ^~~~~~~~~~~~~~~~~
>>   rules.mak:69: recipe for target 'block/ssh.o' failed
>>   make: *** [block/ssh.o] Error 1
>>
>> Fix by using the newer API if available.
>>
>> Suggested-by: Andrea Bolognani <abologna@redhat.com>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>>  block/ssh.c | 2 +-
>>  configure   | 7 +++++++
>>  2 files changed, 8 insertions(+), 1 deletion(-)
> 
> Did I really suggest this? I have no recollection of doing so, or
> even getting involved with libssh support in QEMU at all for that
> matter.

I took this suggestion from
https://www.redhat.com/archives/libvir-list/2018-May/msg00597.html
Andrea Bolognani Aug. 14, 2019, 2:51 p.m. UTC | #4
On Wed, 2019-08-14 at 16:15 +0200, Philippe Mathieu-Daudé wrote:
> On 8/14/19 3:27 PM, Andrea Bolognani wrote:
> > On Wed, 2019-08-14 at 14:15 +0200, Philippe Mathieu-Daudé wrote:
> > > The libssh packaged by a distribution can predate version 0.8,
> > > but still provides the newer API introduced after version 0.7.
> > > 
> > > Using the deprecated API leads to build failure, as on Ubuntu 18.04:
> > > 
> > >     CC      block/ssh.o
> > >   block/ssh.c: In function 'check_host_key_hash':
> > >   block/ssh.c:444:5: error: 'ssh_get_publickey' is deprecated [-Werror=deprecated-declarations]
> > >        r = ssh_get_publickey(s->session, &pubkey);
> > >        ^
> > >   In file included from block/ssh.c:27:0:
> > >   /usr/include/libssh/libssh.h:489:31: note: declared here
> > >    SSH_DEPRECATED LIBSSH_API int ssh_get_publickey(ssh_session session, ssh_key *key);
> > >                                  ^~~~~~~~~~~~~~~~~
> > >   rules.mak:69: recipe for target 'block/ssh.o' failed
> > >   make: *** [block/ssh.o] Error 1
> > > 
> > > Fix by using the newer API if available.
> > > 
> > > Suggested-by: Andrea Bolognani <abologna@redhat.com>
> > > Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> > > ---
> > >  block/ssh.c | 2 +-
> > >  configure   | 7 +++++++
> > >  2 files changed, 8 insertions(+), 1 deletion(-)
> > 
> > Did I really suggest this? I have no recollection of doing so, or
> > even getting involved with libssh support in QEMU at all for that
> > matter.
> 
> I took this suggestion from
> https://www.redhat.com/archives/libvir-list/2018-May/msg00597.html

I see :)

I feel like adding a Suggested-by because of something that was
posted on an unrelated project's mailing list is stretching the
definition of the tag a bit, so if you end up having to respin I
think it would be reasonable to drop it, but honestly it's not a
big deal either way: I was just curious.
Philippe Mathieu-Daudé Aug. 14, 2019, 3:14 p.m. UTC | #5
On 8/14/19 4:51 PM, Andrea Bolognani wrote:
> On Wed, 2019-08-14 at 16:15 +0200, Philippe Mathieu-Daudé wrote:
>> On 8/14/19 3:27 PM, Andrea Bolognani wrote:
>>> On Wed, 2019-08-14 at 14:15 +0200, Philippe Mathieu-Daudé wrote:
>>>> The libssh packaged by a distribution can predate version 0.8,
>>>> but still provides the newer API introduced after version 0.7.
>>>>
>>>> Using the deprecated API leads to build failure, as on Ubuntu 18.04:
>>>>
>>>>     CC      block/ssh.o
>>>>   block/ssh.c: In function 'check_host_key_hash':
>>>>   block/ssh.c:444:5: error: 'ssh_get_publickey' is deprecated [-Werror=deprecated-declarations]
>>>>        r = ssh_get_publickey(s->session, &pubkey);
>>>>        ^
>>>>   In file included from block/ssh.c:27:0:
>>>>   /usr/include/libssh/libssh.h:489:31: note: declared here
>>>>    SSH_DEPRECATED LIBSSH_API int ssh_get_publickey(ssh_session session, ssh_key *key);
>>>>                                  ^~~~~~~~~~~~~~~~~
>>>>   rules.mak:69: recipe for target 'block/ssh.o' failed
>>>>   make: *** [block/ssh.o] Error 1
>>>>
>>>> Fix by using the newer API if available.
>>>>
>>>> Suggested-by: Andrea Bolognani <abologna@redhat.com>
>>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>>> ---
>>>>  block/ssh.c | 2 +-
>>>>  configure   | 7 +++++++
>>>>  2 files changed, 8 insertions(+), 1 deletion(-)
>>>
>>> Did I really suggest this? I have no recollection of doing so, or
>>> even getting involved with libssh support in QEMU at all for that
>>> matter.
>>
>> I took this suggestion from
>> https://www.redhat.com/archives/libvir-list/2018-May/msg00597.html
> 
> I see :)
> 
> I feel like adding a Suggested-by because of something that was
> posted on an unrelated project's mailing list is stretching the
> definition of the tag a bit, so if you end up having to respin I
> think it would be reasonable to drop it, but honestly it's not a
> big deal either way: I was just curious.

Understood, sorry.
Andrea Bolognani Aug. 15, 2019, 8:52 a.m. UTC | #6
On Wed, 2019-08-14 at 17:14 +0200, Philippe Mathieu-Daudé wrote:
> On 8/14/19 4:51 PM, Andrea Bolognani wrote:
> > On Wed, 2019-08-14 at 16:15 +0200, Philippe Mathieu-Daudé wrote:
> > > On 8/14/19 3:27 PM, Andrea Bolognani wrote:
> > > > On Wed, 2019-08-14 at 14:15 +0200, Philippe Mathieu-Daudé wrote:
> > > > > Suggested-by: Andrea Bolognani <abologna@redhat.com>
> > > > > Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> > > > > ---
> > > > >  block/ssh.c | 2 +-
> > > > >  configure   | 7 +++++++
> > > > >  2 files changed, 8 insertions(+), 1 deletion(-)
> > > > 
> > > > Did I really suggest this? I have no recollection of doing so, or
> > > > even getting involved with libssh support in QEMU at all for that
> > > > matter.
> > > 
> > > I took this suggestion from
> > > https://www.redhat.com/archives/libvir-list/2018-May/msg00597.html
> > 
> > I see :)
> > 
> > I feel like adding a Suggested-by because of something that was
> > posted on an unrelated project's mailing list is stretching the
> > definition of the tag a bit, so if you end up having to respin I
> > think it would be reasonable to drop it, but honestly it's not a
> > big deal either way: I was just curious.
> 
> Understood, sorry.

Nothing to apologize for! :)
diff mbox series

Patch

diff --git a/block/ssh.c b/block/ssh.c
index 501933b855..f5fea921c6 100644
--- a/block/ssh.c
+++ b/block/ssh.c
@@ -438,7 +438,7 @@  check_host_key_hash(BDRVSSHState *s, const char *hash,
     unsigned char *server_hash;
     size_t server_hash_len;
 
-#ifdef HAVE_LIBSSH_0_8
+#ifdef HAVE_SSH_GET_SERVER_PUBLICKEY
     r = ssh_get_server_publickey(s->session, &pubkey);
 #else
     r = ssh_get_publickey(s->session, &pubkey);
diff --git a/configure b/configure
index 1d5c07de1f..fe3fef9309 100755
--- a/configure
+++ b/configure
@@ -3949,11 +3949,18 @@  fi
 if test "$libssh" = "yes"; then
   cat > $TMPC <<EOF
 #include <libssh/libssh.h>
+#ifdef HAVE_SSH_GET_SERVER_PUBLICKEY
 int main(void) { return ssh_get_server_publickey(NULL, NULL); }
+#else
+int main(void) { return ssh_get_publickey(NULL, NULL); }
+#endif
 EOF
   if compile_object "$libssh_cflags"; then
     libssh_cflags="-DHAVE_LIBSSH_0_8 $libssh_cflags"
   fi
+  if compile_object "$libssh_cflags -DHAVE_SSH_GET_SERVER_PUBLICKEY"; then
+    libssh_cflags="-DHAVE_SSH_GET_SERVER_PUBLICKEY $libssh_cflags"
+  fi
 fi
 
 ##########################################