Commit 3fccf746 by Edward Thomson

ssh: GIT_SSH_LIBSSH2 is now distinct from GIT_SSH

We may want to support SSH but with a different provider that is not
libssh2. Add GIT_SSH to indicate that we have some inbuilt SSH support
and GIT_SSH_LIBSSH2 to indicate that support is via libssh2. This is
similar to how we support GIT_HTTPS and GIT_OPENSSL, for example.
parent 67ab8f07
...@@ -30,7 +30,7 @@ option(USE_THREADS "Use threads for parallel processing when possibl ...@@ -30,7 +30,7 @@ option(USE_THREADS "Use threads for parallel processing when possibl
option(USE_NSEC "Support nanosecond precision file mtimes and ctimes" ON) option(USE_NSEC "Support nanosecond precision file mtimes and ctimes" ON)
# Backend selection # Backend selection
option(USE_SSH "Link with libssh2 to enable SSH support" OFF) option(USE_SSH "Enable SSH support. Can be set to a specific backend" OFF)
option(USE_HTTPS "Enable HTTPS support. Can be set to a specific backend" ON) option(USE_HTTPS "Enable HTTPS support. Can be set to a specific backend" ON)
option(USE_SHA1 "Enable SHA1. Can be set to CollisionDetection(ON)/HTTPS" ON) option(USE_SHA1 "Enable SHA1. Can be set to CollisionDetection(ON)/HTTPS" ON)
option(USE_SHA256 "Enable SHA256. Can be set to HTTPS/Builtin" ON) option(USE_SHA256 "Enable SHA256. Can be set to HTTPS/Builtin" ON)
......
# Optional external dependency: libssh2 # find libssh2
if(USE_SSH) if(USE_SSH STREQUAL ON OR USE_SSH STREQUAL "libssh2")
find_pkglibraries(LIBSSH2 libssh2) find_pkglibraries(LIBSSH2 libssh2)
if(NOT LIBSSH2_FOUND) if(NOT LIBSSH2_FOUND)
find_package(LibSSH2) find_package(LibSSH2)
set(LIBSSH2_INCLUDE_DIRS ${LIBSSH2_INCLUDE_DIR}) set(LIBSSH2_INCLUDE_DIRS ${LIBSSH2_INCLUDE_DIR})
...@@ -12,30 +13,28 @@ if(USE_SSH) ...@@ -12,30 +13,28 @@ if(USE_SSH)
if(NOT LIBSSH2_FOUND) if(NOT LIBSSH2_FOUND)
message(FATAL_ERROR "LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.") message(FATAL_ERROR "LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.")
endif() endif()
endif()
if(LIBSSH2_FOUND)
set(GIT_SSH 1)
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${LIBSSH2_INCLUDE_DIRS}) list(APPEND LIBGIT2_SYSTEM_INCLUDES ${LIBSSH2_INCLUDE_DIRS})
list(APPEND LIBGIT2_SYSTEM_LIBS ${LIBSSH2_LIBRARIES}) list(APPEND LIBGIT2_SYSTEM_LIBS ${LIBSSH2_LIBRARIES})
list(APPEND LIBGIT2_PC_LIBS ${LIBSSH2_LDFLAGS}) list(APPEND LIBGIT2_PC_LIBS ${LIBSSH2_LDFLAGS})
check_library_exists("${LIBSSH2_LIBRARIES}" libssh2_userauth_publickey_frommemory "${LIBSSH2_LIBRARY_DIRS}" HAVE_LIBSSH2_MEMORY_CREDENTIALS) check_library_exists("${LIBSSH2_LIBRARIES}" libssh2_userauth_publickey_frommemory "${LIBSSH2_LIBRARY_DIRS}" HAVE_LIBSSH2_MEMORY_CREDENTIALS)
if(HAVE_LIBSSH2_MEMORY_CREDENTIALS) if(HAVE_LIBSSH2_MEMORY_CREDENTIALS)
set(GIT_SSH_MEMORY_CREDENTIALS 1) set(GIT_SSH_LIBSSH2_MEMORY_CREDENTIALS 1)
endif() endif()
else()
message(STATUS "LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.")
endif()
if(WIN32 AND EMBED_SSH_PATH) if(WIN32 AND EMBED_SSH_PATH)
file(GLOB SSH_SRC "${EMBED_SSH_PATH}/src/*.c") file(GLOB SSH_SRC "${EMBED_SSH_PATH}/src/*.c")
list(SORT SSH_SRC) list(SORT SSH_SRC)
list(APPEND LIBGIT2_DEPENDENCY_OBJECTS ${SSH_SRC}) list(APPEND LIBGIT2_DEPENDENCY_OBJECTS ${SSH_SRC})
list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${EMBED_SSH_PATH}/include")
file(WRITE "${EMBED_SSH_PATH}/src/libssh2_config.h" "#define HAVE_WINCNG\n#define LIBSSH2_WINCNG\n#include \"../win32/libssh2_config.h\"")
endif()
list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${EMBED_SSH_PATH}/include")
file(WRITE "${EMBED_SSH_PATH}/src/libssh2_config.h" "#define HAVE_WINCNG\n#define LIBSSH2_WINCNG\n#include \"../win32/libssh2_config.h\"")
set(GIT_SSH 1) set(GIT_SSH 1)
set(GIT_SSH_LIBSSH2 1)
add_feature_info(SSH ON "using libssh2")
else()
add_feature_info(SSH OFF "SSH transport support")
endif() endif()
add_feature_info(SSH GIT_SSH "SSH transport support")
...@@ -126,10 +126,10 @@ int git_libgit2_features(void) ...@@ -126,10 +126,10 @@ int git_libgit2_features(void)
#ifdef GIT_HTTPS #ifdef GIT_HTTPS
| GIT_FEATURE_HTTPS | GIT_FEATURE_HTTPS
#endif #endif
#if defined(GIT_SSH) #ifdef GIT_SSH
| GIT_FEATURE_SSH | GIT_FEATURE_SSH
#endif #endif
#if defined(GIT_USE_NSEC) #ifdef GIT_USE_NSEC
| GIT_FEATURE_NSEC | GIT_FEATURE_NSEC
#endif #endif
; ;
......
...@@ -22,6 +22,7 @@ typedef struct transport_definition { ...@@ -22,6 +22,7 @@ typedef struct transport_definition {
static git_smart_subtransport_definition http_subtransport_definition = { git_smart_subtransport_http, 1, NULL }; static git_smart_subtransport_definition http_subtransport_definition = { git_smart_subtransport_http, 1, NULL };
static git_smart_subtransport_definition git_subtransport_definition = { git_smart_subtransport_git, 0, NULL }; static git_smart_subtransport_definition git_subtransport_definition = { git_smart_subtransport_git, 0, NULL };
#ifdef GIT_SSH #ifdef GIT_SSH
static git_smart_subtransport_definition ssh_subtransport_definition = { git_smart_subtransport_ssh, 0, NULL }; static git_smart_subtransport_definition ssh_subtransport_definition = { git_smart_subtransport_ssh, 0, NULL };
#endif #endif
...@@ -33,11 +34,13 @@ static transport_definition transports[] = { ...@@ -33,11 +34,13 @@ static transport_definition transports[] = {
{ "http://", git_transport_smart, &http_subtransport_definition }, { "http://", git_transport_smart, &http_subtransport_definition },
{ "https://", git_transport_smart, &http_subtransport_definition }, { "https://", git_transport_smart, &http_subtransport_definition },
{ "file://", git_transport_local, NULL }, { "file://", git_transport_local, NULL },
#ifdef GIT_SSH #ifdef GIT_SSH
{ "ssh://", git_transport_smart, &ssh_subtransport_definition }, { "ssh://", git_transport_smart, &ssh_subtransport_definition },
{ "ssh+git://", git_transport_smart, &ssh_subtransport_definition }, { "ssh+git://", git_transport_smart, &ssh_subtransport_definition },
{ "git+ssh://", git_transport_smart, &ssh_subtransport_definition }, { "git+ssh://", git_transport_smart, &ssh_subtransport_definition },
#endif #endif
{ NULL, 0, 0 } { NULL, 0, 0 }
}; };
......
...@@ -204,7 +204,7 @@ int git_credential_ssh_key_memory_new( ...@@ -204,7 +204,7 @@ int git_credential_ssh_key_memory_new(
const char *privatekey, const char *privatekey,
const char *passphrase) const char *passphrase)
{ {
#ifdef GIT_SSH_MEMORY_CREDENTIALS #ifdef GIT_SSH_LIBSSH2_MEMORY_CREDENTIALS
return git_credential_ssh_key_type_new( return git_credential_ssh_key_type_new(
cred, cred,
username, username,
......
...@@ -14,7 +14,7 @@ int git_smart_subtransport_ssh( ...@@ -14,7 +14,7 @@ int git_smart_subtransport_ssh(
git_transport *owner, git_transport *owner,
void *param) void *param)
{ {
#ifdef GIT_SSH #ifdef GIT_SSH_LIBSSH2
return git_smart_subtransport_ssh_libssh2(out, owner, param); return git_smart_subtransport_ssh_libssh2(out, owner, param);
#else #else
GIT_UNUSED(out); GIT_UNUSED(out);
...@@ -31,7 +31,7 @@ int git_transport_ssh_with_paths( ...@@ -31,7 +31,7 @@ int git_transport_ssh_with_paths(
git_remote *owner, git_remote *owner,
void *payload) void *payload)
{ {
#ifdef GIT_SSH #ifdef GIT_SSH_LIBSSH2
git_strarray *paths = (git_strarray *) payload; git_strarray *paths = (git_strarray *) payload;
git_transport *transport; git_transport *transport;
transport_smart *smart; transport_smart *smart;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "ssh_libssh2.h" #include "ssh_libssh2.h"
#ifdef GIT_SSH #ifdef GIT_SSH_LIBSSH2
#include <libssh2.h> #include <libssh2.h>
...@@ -342,7 +342,7 @@ static int _git_ssh_authenticate_session( ...@@ -342,7 +342,7 @@ static int _git_ssh_authenticate_session(
session, c->username, c->prompt_callback); session, c->username, c->prompt_callback);
break; break;
} }
#ifdef GIT_SSH_MEMORY_CREDENTIALS #ifdef GIT_SSH_LIBSSH2_MEMORY_CREDENTIALS
case GIT_CREDENTIAL_SSH_MEMORY: { case GIT_CREDENTIAL_SSH_MEMORY: {
git_credential_ssh_key *c = (git_credential_ssh_key *)cred; git_credential_ssh_key *c = (git_credential_ssh_key *)cred;
...@@ -1020,7 +1020,7 @@ static int list_auth_methods(int *out, LIBSSH2_SESSION *session, const char *use ...@@ -1020,7 +1020,7 @@ static int list_auth_methods(int *out, LIBSSH2_SESSION *session, const char *use
if (!git__prefixcmp(ptr, SSH_AUTH_PUBLICKEY)) { if (!git__prefixcmp(ptr, SSH_AUTH_PUBLICKEY)) {
*out |= GIT_CREDENTIAL_SSH_KEY; *out |= GIT_CREDENTIAL_SSH_KEY;
*out |= GIT_CREDENTIAL_SSH_CUSTOM; *out |= GIT_CREDENTIAL_SSH_CUSTOM;
#ifdef GIT_SSH_MEMORY_CREDENTIALS #ifdef GIT_SSH_LIBSSH2_MEMORY_CREDENTIALS
*out |= GIT_CREDENTIAL_SSH_MEMORY; *out |= GIT_CREDENTIAL_SSH_MEMORY;
#endif #endif
ptr += strlen(SSH_AUTH_PUBLICKEY); ptr += strlen(SSH_AUTH_PUBLICKEY);
......
...@@ -30,7 +30,8 @@ ...@@ -30,7 +30,8 @@
#cmakedefine GIT_QSORT_MSC #cmakedefine GIT_QSORT_MSC
#cmakedefine GIT_SSH 1 #cmakedefine GIT_SSH 1
#cmakedefine GIT_SSH_MEMORY_CREDENTIALS 1 #cmakedefine GIT_SSH_LIBSSH2 1
#cmakedefine GIT_SSH_LIBSSH2_MEMORY_CREDENTIALS 1
#cmakedefine GIT_NTLM 1 #cmakedefine GIT_NTLM 1
#cmakedefine GIT_GSSAPI 1 #cmakedefine GIT_GSSAPI 1
......
...@@ -675,7 +675,7 @@ void test_online_clone__ssh_auth_methods(void) ...@@ -675,7 +675,7 @@ void test_online_clone__ssh_auth_methods(void)
*/ */
void test_online_clone__ssh_certcheck_accepts_unknown(void) void test_online_clone__ssh_certcheck_accepts_unknown(void)
{ {
#if !defined(GIT_SSH) || !defined(GIT_SSH_MEMORY_CREDENTIALS) #if !defined(GIT_SSH_LIBSSH2) || !defined(GIT_SSH_MEMORY_CREDENTIALS)
clar__skip(); clar__skip();
#endif #endif
...@@ -793,7 +793,7 @@ static int cred_foo_bar(git_credential **cred, const char *url, const char *user ...@@ -793,7 +793,7 @@ static int cred_foo_bar(git_credential **cred, const char *url, const char *user
void test_online_clone__ssh_cannot_change_username(void) void test_online_clone__ssh_cannot_change_username(void)
{ {
#ifndef GIT_SSH #ifndef GIT_SSH_LIBSSH2
clar__skip(); clar__skip();
#endif #endif
g_options.fetch_opts.callbacks.credentials = cred_foo_bar; g_options.fetch_opts.callbacks.credentials = cred_foo_bar;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment