summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2014-06-30 10:03:36 +0200
committerVicent Marti <tanoku@gmail.com>2014-08-05 02:06:14 +0200
commitaa1b62ba14e37d41da444b1ad608c8dd9448a417 (patch)
tree5e7769bcc2f18b5bcdb2154fd89bcc5383b41e50
parent1d430056f4817f48b0cf212a3aa27f8e26a7a7c2 (diff)
downloadlibgit2-aa1b62ba14e37d41da444b1ad608c8dd9448a417.tar.gz
ssh: create the right callback signature based on build options
When linking against libssh2, create the transport.h such that it contains its definition for custom crypto and keyboard-interactive callbacks. If we don't link against libssh2, create an equivalent signature which has void pointers instead of pointers to libssh2 structures. This would be one way to fix #2438.
-rw-r--r--CMakeLists.txt11
-rw-r--r--include/git2/transport.h.in (renamed from include/git2/transport.h)19
2 files changed, 20 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6f1a97ed..45881d6a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -408,6 +408,17 @@ IF (SONAME)
ENDIF()
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libgit2.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libgit2.pc @ONLY)
+IF (LIBSSH2_FOUND)
+ SET(INCLUDE_LIBSSH2 "#include <libssh2.h>")
+ SET(GIT_SSH_PK_FUNC "typedef LIBSSH2_USERAUTH_PUBLICKEY_SIGN_FUNC((*git_cred_sign_callback));")
+ SET(GIT_SSH_KI_FUNC "typedef LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC((*git_cred_ssh_interactive_callback));")
+ELSE ()
+ SET(GIT_SSH_PK_FUNC "typedef int (*git_cred_sign_callback)(void *, unsigned char **, size_t *, const unsigned char *, size_t, void **);")
+ SET(GIT_SSH_KI_FUNC "typedef int (*git_cred_ssh_interactive_callback)(const char *, int, const char *, int, int, const void *, void *, void **);")
+ENDIF ()
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/include/git2/transport.h.in ${CMAKE_CURRENT_SOURCE_DIR}/include/git2/transport.h @ONLY)
+
+
IF (MSVC_IDE)
# Precompiled headers
SET_TARGET_PROPERTIES(git2 PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h")
diff --git a/include/git2/transport.h b/include/git2/transport.h.in
index af7812b5..73f0a99a 100644
--- a/include/git2/transport.h
+++ b/include/git2/transport.h.in
@@ -11,9 +11,7 @@
#include "net.h"
#include "types.h"
-#ifdef GIT_SSH
-#include <libssh2.h>
-#endif
+@INCLUDE_LIBSSH2@
/**
* @file git2/transport.h
@@ -61,13 +59,14 @@ typedef struct {
char *password;
} git_cred_userpass_plaintext;
-#ifdef GIT_SSH
-typedef LIBSSH2_USERAUTH_PUBLICKEY_SIGN_FUNC((*git_cred_sign_callback));
-typedef LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC((*git_cred_ssh_interactive_callback));
-#else
-typedef int (*git_cred_sign_callback)(void *, ...);
-typedef int (*git_cred_ssh_interactive_callback)(void *, ...);
-#endif
+/*
+ * This defines the callbacks for custom public key signatures and
+ * keyboard-interactive authentication. It is replaced at build-time
+ * with either the libssh2 signature or a dummy signature that's close
+ * enough but with void pointers instead of libssh2 structures.
+ */
+@GIT_SSH_PK_FUNC@
+@GIT_SSH_KI_FUNC@
/**
* A ssh key from disk