Bug 1406457 - libssh driver segfaults when connecting from the root account
Summary: libssh driver segfaults when connecting from the root account
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libvirt
Version: unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Peter Krempa
QA Contact:
URL:
Whiteboard:
: 1414278 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-12-20 15:19 UTC by Peter Krempa
Modified: 2017-01-18 09:17 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-01-11 12:40:39 UTC
Embargoed:


Attachments (Terms of Use)

Description Peter Krempa 2016-12-20 15:19:32 UTC
Description of problem:
segfault as we try to set NULL known_hosts file path for the root user as libvirt was not able to figure out the path:

Thread 1 (Thread 0x7ffff7fd9780 (LWP 27811)):
#0  0x00007ffff695759a in strlen () from /lib64/libc.so.6
#1  0x00007ffff69572be in strdup () from /lib64/libc.so.6
#2  0x00007ffff5468c29 in ?? () from /usr/lib64/libssh.so.4
#3  0x00007ffff5469d86 in ssh_options_set () from /usr/lib64/libssh.so.4
#4  0x00007ffff73da633 in virNetLibsshSessionSetHostKeyVerification () from /usr/lib64/libvirt.so.0
#5  0x00007ffff73e0b1d in ?? () from /usr/lib64/libvirt.so.0

Version-Release number of selected component (if applicable):
2.5.0

How reproducible:
100%

Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 Peter Krempa 2017-01-11 12:40:39 UTC
Following commits fix the issue and improve a few parts of the code that deals with libssh connections:

commit 1a5de3fe2e72992cfb614fea2acb0335459ebdea
Author: Pino Toscano <ptoscano>
Date:   Tue Jan 10 19:43:20 2017 +0100

    remote: do not check for an existing config dir
    
    When composing the path to the default known_hosts file (for the libssh
    and libssh2 drivers), do not check whether the configuration directory
    (determined by virGetUserConfigDirectory()) exists: both the drivers can
    handle non-existing files, and are able to create them (and their
    directories) in that case.
    
    This adds a small behaviour change: before, the key for an unknown host,
    and manually accepted, was saved only if the configuration directory
    existed -- a bit incoherent behaviour though.

commit 45c4a70c70978d3b5d6a02b27bcdf501da8185e4
Author: Pino Toscano <ptoscano>
Date:   Tue Jan 10 19:43:19 2017 +0100

    remote: fix logic for known_hosts and keyfile checks
    
    If any of them is specified for the libssh and libssh2 drivers, there is
    no need to depend on checks based on other paths: in particular, a
    specified path for known_hosts was ignored if the local config directory
    could not be determined, and the path for keyfile was ignored if the
    home could not be determined.
    
    Instead, lazily determine and use these two paths only in case they are
    needed.

commit 408a1ce5f87d3a901693927bb108e714f25873fc
Author: Pino Toscano <ptoscano>
Date:   Tue Jan 10 19:43:18 2017 +0100

    rpc: libssh: allow a NULL known_hosts file
    
    Make sure that virNetLibsshSessionSetHostKeyVerification accepts a NULL
    value for the path to the known_hosts file:
    - call ssh_options_set(SSH_OPTIONS_KNOWNHOSTS) anyway, using /dev/null,
      otherwise libssh will use its default path
    - do not call ssh_write_knownhost when no known hosts file was set
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1406457

Comment 2 Peter Krempa 2017-01-18 09:17:35 UTC
*** Bug 1414278 has been marked as a duplicate of this bug. ***


Note You need to log in before you can comment on or make changes to this bug.