Skip to content

Commit

Permalink
cmake: fix a bug that prevents rtrlib from using libssh versions abov…
Browse files Browse the repository at this point in the history
…e 0.5.0. (#162)
  • Loading branch information
colinbs authored and waehlisch committed Apr 19, 2018
1 parent a67cc59 commit b37a6c6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
25 changes: 8 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,18 @@ set(RTRLIB_SRC rtrlib/rtr_mgr.c rtrlib/lib/utils.c rtrlib/lib/alloc_utils.c rtrl
rtrlib/spki/hashtable/ht-spkitable.c rtrlib/spki/hashtable/tommyds-1.8/tommy.c)
set(RTRLIB_LINK ${RT_LIB} ${CMAKE_THREAD_LIBS_INIT})

find_package(LibSSH 0.6.0 QUIET)
find_package(LibSSH 0.5.0 QUIET)
if(LIBSSH_FOUND AND NOT NOSSH)
set(LIBSSH_060 1)
message(STATUS "libssh found, building librtr with SSH 0.6.0 support")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D LIBSSH_VERSION_MAJOR=${LibSSH_VERSION_MAJOR} -D LIBSSH_VERSION_MINOR=${LibSSH_VERSION_MINOR}")
set(RTRLIB_HAVE_LIBSSH 1)
include_directories(${LIBSSH_INCLUDE_DIRS})
set(RTRLIB_SRC ${RTRLIB_SRC} rtrlib/transport/ssh/ssh_transport.c)
set(RTRLIB_LINK ${RTRLIB_LINK} ${LIBSSH_LIBRARIES})
message(STATUS "libssh found, building librtr with SSH ${LibSSH_VERSION} support")
else()
find_package(LibSSH 0.5.0)
if(LIBSSH_FOUND AND NOT NOSSH)
set(LIBSSH_050 1)
message(STATUS "libssh found, building librtr with SSH 0.5.0 support")
endif(LIBSSH_FOUND AND NOT NOSSH)
message(WARNING "libssh >=0.5.0 not found, building librtr without SSH support")
endif(LIBSSH_FOUND AND NOT NOSSH)

if(LIBSSH_050 OR LIBSSH_060)
set(RTRLIB_HAVE_LIBSSH 1)
include_directories(${LIBSSH_INCLUDE_DIRS})
set(RTRLIB_SRC ${RTRLIB_SRC} rtrlib/transport/ssh/ssh_transport.c)
set(RTRLIB_LINK ${RTRLIB_LINK} ${LIBSSH_LIBRARIES})
else()
message(WARNING "libssh not found, building librtr without SSH support")
endif(LIBSSH_050 OR LIBSSH_060)

#doxygen target
find_package(Doxygen)
if(DOXYGEN_FOUND)
Expand Down
4 changes: 2 additions & 2 deletions rtrlib/transport/ssh/ssh_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ int tr_ssh_open(void *socket)
goto error;
}

#ifdef LIBSSH_060
#if LIBSSH_VERSION_MAJOR > 0 || LIBSSH_VERSION_MINOR > 5
const int rtval = ssh_userauth_publickey_auto(ssh_socket->session, NULL, NULL);
#else // else use libSSH version 0.5.0
#else /* else use libSSH version 0.5.0 */
const int rtval = ssh_userauth_autopubkey(ssh_socket->session, NULL);
#endif
if(rtval != SSH_AUTH_SUCCESS) {
Expand Down

0 comments on commit b37a6c6

Please sign in to comment.