mirror of
https://github.com/libgit2/libgit2.git
synced 2026-06-22 06:26:26 +00:00
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.
This commit is contained in:
@@ -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)
|
||||
|
||||
# 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_SHA1 "Enable SHA1. Can be set to CollisionDetection(ON)/HTTPS" ON)
|
||||
option(USE_SHA256 "Enable SHA256. Can be set to HTTPS/Builtin" ON)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# Optional external dependency: libssh2
|
||||
if(USE_SSH)
|
||||
# find libssh2
|
||||
if(USE_SSH STREQUAL ON OR USE_SSH STREQUAL "libssh2")
|
||||
find_pkglibraries(LIBSSH2 libssh2)
|
||||
|
||||
if(NOT LIBSSH2_FOUND)
|
||||
find_package(LibSSH2)
|
||||
set(LIBSSH2_INCLUDE_DIRS ${LIBSSH2_INCLUDE_DIR})
|
||||
@@ -12,30 +13,28 @@ if(USE_SSH)
|
||||
if(NOT LIBSSH2_FOUND)
|
||||
message(FATAL_ERROR "LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(LIBSSH2_FOUND)
|
||||
set(GIT_SSH 1)
|
||||
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${LIBSSH2_INCLUDE_DIRS})
|
||||
list(APPEND LIBGIT2_SYSTEM_LIBS ${LIBSSH2_LIBRARIES})
|
||||
list(APPEND LIBGIT2_PC_LIBS ${LIBSSH2_LDFLAGS})
|
||||
|
||||
check_library_exists("${LIBSSH2_LIBRARIES}" libssh2_userauth_publickey_frommemory "${LIBSSH2_LIBRARY_DIRS}" HAVE_LIBSSH2_MEMORY_CREDENTIALS)
|
||||
if(HAVE_LIBSSH2_MEMORY_CREDENTIALS)
|
||||
set(GIT_SSH_MEMORY_CREDENTIALS 1)
|
||||
set(GIT_SSH_LIBSSH2_MEMORY_CREDENTIALS 1)
|
||||
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)
|
||||
file(GLOB SSH_SRC "${EMBED_SSH_PATH}/src/*.c")
|
||||
list(SORT SSH_SRC)
|
||||
list(APPEND LIBGIT2_DEPENDENCY_OBJECTS ${SSH_SRC})
|
||||
if(WIN32 AND EMBED_SSH_PATH)
|
||||
file(GLOB SSH_SRC "${EMBED_SSH_PATH}/src/*.c")
|
||||
list(SORT 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_LIBSSH2 1)
|
||||
add_feature_info(SSH ON "using libssh2")
|
||||
else()
|
||||
add_feature_info(SSH OFF "SSH transport support")
|
||||
endif()
|
||||
|
||||
add_feature_info(SSH GIT_SSH "SSH transport support")
|
||||
|
||||
@@ -126,10 +126,10 @@ int git_libgit2_features(void)
|
||||
#ifdef GIT_HTTPS
|
||||
| GIT_FEATURE_HTTPS
|
||||
#endif
|
||||
#if defined(GIT_SSH)
|
||||
#ifdef GIT_SSH
|
||||
| GIT_FEATURE_SSH
|
||||
#endif
|
||||
#if defined(GIT_USE_NSEC)
|
||||
#ifdef GIT_USE_NSEC
|
||||
| GIT_FEATURE_NSEC
|
||||
#endif
|
||||
;
|
||||
|
||||
@@ -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 git_subtransport_definition = { git_smart_subtransport_git, 0, NULL };
|
||||
|
||||
#ifdef GIT_SSH
|
||||
static git_smart_subtransport_definition ssh_subtransport_definition = { git_smart_subtransport_ssh, 0, NULL };
|
||||
#endif
|
||||
@@ -33,11 +34,13 @@ static transport_definition transports[] = {
|
||||
{ "http://", git_transport_smart, &http_subtransport_definition },
|
||||
{ "https://", git_transport_smart, &http_subtransport_definition },
|
||||
{ "file://", git_transport_local, NULL },
|
||||
|
||||
#ifdef GIT_SSH
|
||||
{ "ssh://", git_transport_smart, &ssh_subtransport_definition },
|
||||
{ "ssh+git://", git_transport_smart, &ssh_subtransport_definition },
|
||||
{ "git+ssh://", git_transport_smart, &ssh_subtransport_definition },
|
||||
#endif
|
||||
|
||||
{ NULL, 0, 0 }
|
||||
};
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ int git_credential_ssh_key_memory_new(
|
||||
const char *privatekey,
|
||||
const char *passphrase)
|
||||
{
|
||||
#ifdef GIT_SSH_MEMORY_CREDENTIALS
|
||||
#ifdef GIT_SSH_LIBSSH2_MEMORY_CREDENTIALS
|
||||
return git_credential_ssh_key_type_new(
|
||||
cred,
|
||||
username,
|
||||
|
||||
@@ -14,7 +14,7 @@ int git_smart_subtransport_ssh(
|
||||
git_transport *owner,
|
||||
void *param)
|
||||
{
|
||||
#ifdef GIT_SSH
|
||||
#ifdef GIT_SSH_LIBSSH2
|
||||
return git_smart_subtransport_ssh_libssh2(out, owner, param);
|
||||
#else
|
||||
GIT_UNUSED(out);
|
||||
@@ -31,7 +31,7 @@ int git_transport_ssh_with_paths(
|
||||
git_remote *owner,
|
||||
void *payload)
|
||||
{
|
||||
#ifdef GIT_SSH
|
||||
#ifdef GIT_SSH_LIBSSH2
|
||||
git_strarray *paths = (git_strarray *) payload;
|
||||
git_transport *transport;
|
||||
transport_smart *smart;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "ssh_libssh2.h"
|
||||
|
||||
#ifdef GIT_SSH
|
||||
#ifdef GIT_SSH_LIBSSH2
|
||||
|
||||
#include <libssh2.h>
|
||||
|
||||
@@ -342,7 +342,7 @@ static int _git_ssh_authenticate_session(
|
||||
session, c->username, c->prompt_callback);
|
||||
break;
|
||||
}
|
||||
#ifdef GIT_SSH_MEMORY_CREDENTIALS
|
||||
#ifdef GIT_SSH_LIBSSH2_MEMORY_CREDENTIALS
|
||||
case GIT_CREDENTIAL_SSH_MEMORY: {
|
||||
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
|
||||
if (!git__prefixcmp(ptr, SSH_AUTH_PUBLICKEY)) {
|
||||
*out |= GIT_CREDENTIAL_SSH_KEY;
|
||||
*out |= GIT_CREDENTIAL_SSH_CUSTOM;
|
||||
#ifdef GIT_SSH_MEMORY_CREDENTIALS
|
||||
#ifdef GIT_SSH_LIBSSH2_MEMORY_CREDENTIALS
|
||||
*out |= GIT_CREDENTIAL_SSH_MEMORY;
|
||||
#endif
|
||||
ptr += strlen(SSH_AUTH_PUBLICKEY);
|
||||
|
||||
@@ -30,7 +30,8 @@
|
||||
#cmakedefine GIT_QSORT_MSC
|
||||
|
||||
#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_GSSAPI 1
|
||||
|
||||
@@ -675,7 +675,7 @@ void test_online_clone__ssh_auth_methods(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();
|
||||
#endif
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
#ifndef GIT_SSH
|
||||
#ifndef GIT_SSH_LIBSSH2
|
||||
clar__skip();
|
||||
#endif
|
||||
g_options.fetch_opts.callbacks.credentials = cred_foo_bar;
|
||||
|
||||
Reference in New Issue
Block a user