summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2018-09-11 14:50:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2018-09-11 14:50:53 +0000
commitb98ccdd866b83cdc7ded6248b905b8ca6287892d (patch)
treefe3b45bc892068ff211db2d8042d727693928564
parentReleasing progress-linux version 0.8.0-1~dschinn1. (diff)
downloadlibssh-b98ccdd866b83cdc7ded6248b905b8ca6287892d.zip
libssh-b98ccdd866b83cdc7ded6248b905b8ca6287892d.tar.xz
Merging upstream version 0.8.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
-rw-r--r--CMakeLists.txt4
-rw-r--r--ChangeLog6
-rw-r--r--ConfigureChecks.cmake64
-rw-r--r--DefineOptions.cmake6
-rw-r--r--cmake/Modules/FindNSIS.cmake9
-rw-r--r--config.h.cmake7
-rw-r--r--include/libssh/libssh.h4
-rw-r--r--include/libssh/threads.h2
-rw-r--r--libssh-config-version.cmake.in2
-rw-r--r--libssh.pc.cmake4
-rw-r--r--libssh_threads.pc.cmake6
-rw-r--r--src/ABI/current2
-rw-r--r--src/ABI/libssh-4.5.1.symbols0
-rw-r--r--src/CMakeLists.txt24
-rw-r--r--src/init.c72
15 files changed, 135 insertions, 77 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 16989ea..c53f82d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.2.0)
cmake_policy(SET CMP0048 NEW)
-project(libssh VERSION 0.8.0 LANGUAGES C)
+project(libssh VERSION 0.8.1 LANGUAGES C)
# global needed variable
set(APPLICATION_NAME ${PROJECT_NAME})
@@ -13,7 +13,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
# Increment AGE. Set REVISION to 0
# If the source code was changed, but there were no interface changes:
# Increment REVISION.
-set(LIBRARY_VERSION "4.5.0")
+set(LIBRARY_VERSION "4.5.1")
set(LIBRARY_SOVERSION "4")
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
diff --git a/ChangeLog b/ChangeLog
index 85b2ae3..e6ba89d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,12 @@
ChangeLog
==========
+version 0.8.1 (released 2018-08-13)
+ * Fixed version number in the header
+ * Fixed version number in pkg-config and cmake config
+ * Fixed library initialization
+ * Fixed attribute detection
+
version 0.8.0 (released 2018-08-10)
* Removed support for deprecated SSHv1 protocol
* Added new connector API for clients
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 07c53c7..650119c 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -7,8 +7,8 @@ include(CheckTypeSize)
include(CheckCXXSourceCompiles)
include(TestBigEndian)
-set(PACKAGE ${APPLICATION_NAME})
-set(VERSION ${APPLICATION_VERSION})
+set(PACKAGE ${PROJECT_NAME})
+set(VERSION ${PROJECT_VERSION})
set(DATADIR ${DATA_INSTALL_DIR})
set(LIBDIR ${LIB_INSTALL_DIR})
set(PLUGINDIR "${PLUGIN_INSTALL_DIR}-${LIBRARY_SOVERSION}")
@@ -267,25 +267,47 @@ int main(void) {
return 0;
}" HAVE_MSC_THREAD_LOCAL_STORAGE)
+###########################################################
+# For detecting attributes we need to treat warnings as
+# errors
+if (UNIX)
+ set(CMAKE_REQUIRED_FLAGS "-Werror")
+endif (UNIX)
+
check_c_source_compiles("
-#define FALL_THROUGH __attribute__((fallthrough))
+void test_constructor_attribute(void) __attribute__ ((constructor));
-enum direction_e {
- UP = 0,
- DOWN,
-};
+void test_constructor_attribute(void)
+{
+ return;
+}
int main(void) {
- enum direction_e key = UP;
- int i = 10;
- int j = 0;
+ return 0;
+}" HAVE_CONSTRUCTOR_ATTRIBUTE)
- switch (key) {
- case UP:
- i = 5;
+check_c_source_compiles("
+void test_destructor_attribute(void) __attribute__ ((destructor));
+
+void test_destructor_attribute(void)
+{
+ return;
+}
+
+int main(void) {
+ return 0;
+}" HAVE_DESTRUCTOR_ATTRIBUTE)
+
+check_c_source_compiles("
+#define FALL_THROUGH __attribute__((fallthrough))
+
+int main(void) {
+ int i = 2;
+
+ switch (i) {
+ case 0:
FALL_THROUGH;
- case DOWN:
- j = i * 2;
+ case 1:
break;
default:
break;
@@ -332,11 +354,17 @@ int main(void) {
return 0;
}" HAVE_COMPILER__FUNCTION__)
+# Stop treating warnings as errors
+unset(CMAKE_REQUIRED_FLAGS)
check_c_source_compiles("
-void chacha_keysetup(struct chacha_ctx *x, const u_char *k, u_int kbits)
- __attribute__((__bounded__(__minbytes__, 2, CHACHA_MINKEYLEN)));
-int main(void) { return 0; }" HAVE_GCC_BOUNDED_ATTRIBUTE)
+#define ARRAY_LEN 16
+void test_attr(const unsigned char *k)
+ __attribute__((__bounded__(__minbytes__, 2, 16)));
+
+int main(void) {
+ return 0;
+}" HAVE_GCC_BOUNDED_ATTRIBUTE)
if (WITH_DEBUG_CRYPTO)
set(DEBUG_CRYPTO 1)
diff --git a/DefineOptions.cmake b/DefineOptions.cmake
index eb60b09..3b9e427 100644
--- a/DefineOptions.cmake
+++ b/DefineOptions.cmake
@@ -29,8 +29,12 @@ if(WITH_BENCHMARKS)
set(UNIT_TESTING ON)
endif(WITH_BENCHMARKS)
+if (WITH_STATIC_LIB)
+ set(BUILD_STATIC_LIB ON)
+endif (WITH_STATIC_LIB)
+
if (UNIT_TESTING)
- set(WITH_STATIC_LIB ON)
+ set(BUILD_STATIC_LIB ON)
endif (UNIT_TESTING)
if (WITH_NACL)
diff --git a/cmake/Modules/FindNSIS.cmake b/cmake/Modules/FindNSIS.cmake
index 21f80d8..9f1ab17 100644
--- a/cmake/Modules/FindNSIS.cmake
+++ b/cmake/Modules/FindNSIS.cmake
@@ -21,17 +21,16 @@
#
if (WIN32)
- set(_NSIS_ROOT_HINTS
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\NSIS;Default]")
+ set(_x86 "(x86)")
set(_NSIS_ROOT_PATHS
- $ENV{PROGRAMFILES}/NSIS)
+ "$ENV{ProgramFiles}/NSIS"
+ "$ENV{ProgramFiles${_x86}}/NSIS"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\NSIS;Default]")
find_path(NSIS_ROOT_PATH
NAMES
Include/Library.nsh
- HINTS
- ${_NSIS_ROOT_HINTS}
PATHS
${_NSIS_ROOT_PATHS}
)
diff --git a/config.h.cmake b/config.h.cmake
index 421f527..8c469b6 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -1,8 +1,8 @@
/* Name of package */
-#cmakedefine PACKAGE "${APPLICATION_NAME}"
+#cmakedefine PACKAGE "${PROJECT_NAME}"
/* Version number of package */
-#cmakedefine VERSION "${APPLICATION_VERSION}"
+#cmakedefine VERSION "${PROJECT_VERSION}"
#cmakedefine LOCALEDIR "${LOCALE_INSTALL_DIR}"
#cmakedefine DATADIR "${DATADIR}"
@@ -193,6 +193,9 @@
#cmakedefine HAVE_FALLTHROUGH_ATTRIBUTE 1
+#cmakedefine HAVE_CONSTRUCTOR_ATTRIBUTE 1
+#cmakedefine HAVE_DESTRUCTOR_ATTRIBUTE 1
+
#cmakedefine HAVE_GCC_VOLATILE_MEMORY_PROTECTION 1
#cmakedefine HAVE_GCC_NARG_MACRO 1
diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h
index e78b8a2..42cdc6a 100644
--- a/include/libssh/libssh.h
+++ b/include/libssh/libssh.h
@@ -78,8 +78,8 @@
/* libssh version */
#define LIBSSH_VERSION_MAJOR 0
-#define LIBSSH_VERSION_MINOR 7
-#define LIBSSH_VERSION_MICRO 90
+#define LIBSSH_VERSION_MINOR 8
+#define LIBSSH_VERSION_MICRO 1
#define LIBSSH_VERSION_INT SSH_VERSION_INT(LIBSSH_VERSION_MAJOR, \
LIBSSH_VERSION_MINOR, \
diff --git a/include/libssh/threads.h b/include/libssh/threads.h
index e8ccf7b..522f91d 100644
--- a/include/libssh/threads.h
+++ b/include/libssh/threads.h
@@ -29,7 +29,7 @@
#include <pthread.h>
#define SSH_MUTEX pthread_mutex_t
-#if defined _GNU_SOURCE
+#if defined(PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP)
#define SSH_MUTEX_STATIC_INIT PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
#else
#define SSH_MUTEX_STATIC_INIT PTHREAD_MUTEX_INITIALIZER
diff --git a/libssh-config-version.cmake.in b/libssh-config-version.cmake.in
index 98f292c..4bff45e 100644
--- a/libssh-config-version.cmake.in
+++ b/libssh-config-version.cmake.in
@@ -1,4 +1,4 @@
-set(PACKAGE_VERSION @APPLICATION_VERSION@)
+set(PACKAGE_VERSION @PROJECT_VERSION@)
# Check whether the requested PACKAGE_FIND_VERSION is compatible
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
diff --git a/libssh.pc.cmake b/libssh.pc.cmake
index 3b1cb8d..48fbf7f 100644
--- a/libssh.pc.cmake
+++ b/libssh.pc.cmake
@@ -1,6 +1,6 @@
-Name: ${APPLICATION_NAME}
+Name: ${PROJECT_NAME}
Description: The SSH Library
-Version: ${APPLICATION_VERSION}
+Version: ${PROJECT_VERSION}
Libs: -L${LIB_INSTALL_DIR} -lssh
Cflags: -I${INCLUDE_INSTALL_DIR}
diff --git a/libssh_threads.pc.cmake b/libssh_threads.pc.cmake
deleted file mode 100644
index 5479c34..0000000
--- a/libssh_threads.pc.cmake
+++ /dev/null
@@ -1,6 +0,0 @@
-Name: ${APPLICATION_NAME}_threads
-Description: The SSH Library Thread Extension
-Version: ${APPLICATION_VERSION}
-Libs: -L${LIB_INSTALL_DIR} -lssh_threads
-Cflags: -I${INCLUDE_INSTALL_DIR}
-
diff --git a/src/ABI/current b/src/ABI/current
index a84947d..99523d4 100644
--- a/src/ABI/current
+++ b/src/ABI/current
@@ -1 +1 @@
-4.5.0
+4.5.1 \ No newline at end of file
diff --git a/src/ABI/libssh-4.5.1.symbols b/src/ABI/libssh-4.5.1.symbols
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/ABI/libssh-4.5.1.symbols
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e5746b1..7171b4a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -106,12 +106,12 @@ set(LIBSSH_SHARED_LIBRARY
CACHE INTERNAL "libssh shared library"
)
-if (WITH_STATIC_LIB)
+if (BUILD_STATIC_LIB)
set(LIBSSH_STATIC_LIBRARY
ssh_static
CACHE INTERNAL "libssh static library"
)
-endif (WITH_STATIC_LIB)
+endif (BUILD_STATIC_LIB)
set(libssh_SRCS
agent.c
@@ -340,7 +340,7 @@ install(
COMPONENT libraries
)
-if (WITH_STATIC_LIB)
+if (BUILD_STATIC_LIB)
add_library(${LIBSSH_STATIC_LIBRARY} STATIC ${libssh_SRCS})
if (MSVC)
@@ -370,14 +370,14 @@ if (WITH_STATIC_LIB)
)
endif (WIN32)
- install(
- TARGETS
- ${LIBSSH_STATIC_LIBRARY}
- DESTINATION
- ${LIB_INSTALL_DIR}/${OUTPUT_SUFFIX}
- COMPONENT
- libraries
- )
-endif (WITH_STATIC_LIB)
+ if (WITH_STATIC_LIB)
+ install(TARGETS
+ ${LIBSSH_STATIC_LIBRARY}
+ DESTINATION
+ ${LIB_INSTALL_DIR}/${OUTPUT_SUFFIX}
+ COMPONENT
+ libraries)
+ endif (WITH_STATIC_LIB)
+endif (BUILD_STATIC_LIB)
message(STATUS "Threads_FOUND=${Threads_FOUND}")
diff --git a/src/init.c b/src/init.c
index f942243..ea3e643 100644
--- a/src/init.c
+++ b/src/init.c
@@ -32,8 +32,17 @@
#include <winsock2.h>
#endif
+#ifdef HAVE_CONSTRUCTOR_ATTRIBUTE
#define CONSTRUCTOR_ATTRIBUTE __attribute__((constructor))
+#else
+#define CONSTRUCTOR_ATTRIBUTE
+#endif /* HAVE_CONSTRUCTOR_ATTRIBUTE */
+
+#ifdef HAVE_DESTRUCTOR_ATTRIBUTE
#define DESTRUCTOR_ATTRIBUTE __attribute__((destructor))
+#else
+#define DESTRUCTOR_ATTRIBUTE
+#endif /* HAVE_DESTRUCTOR_ATTRIBUTE */
/* Declare static mutex */
static SSH_MUTEX ssh_init_mutex = SSH_MUTEX_STATIC_INIT;
@@ -144,29 +153,29 @@ static int _ssh_finalize(unsigned destructor) {
if (!destructor) {
ssh_mutex_lock(&ssh_init_mutex);
- }
-
- if (_ssh_initialized == 1) {
- _ssh_initialized = 0;
- if (_ssh_init_ret < 0) {
+ if (_ssh_initialized > 1) {
+ _ssh_initialized--;
goto _ret;
}
- ssh_dh_finalize();
- ssh_crypto_finalize();
- ssh_socket_cleanup();
- /* It is important to finalize threading after CRYPTO because
- * it still depends on it */
- ssh_threads_finalize();
-
- }
- else {
- if (_ssh_initialized > 0) {
- _ssh_initialized--;
+ if (_ssh_initialized == 1) {
+ if (_ssh_init_ret < 0) {
+ goto _ret;
+ }
}
}
+ /* If the counter reaches zero or it is the destructor calling, finalize */
+ ssh_dh_finalize();
+ ssh_crypto_finalize();
+ ssh_socket_cleanup();
+ /* It is important to finalize threading after CRYPTO because
+ * it still depends on it */
+ ssh_threads_finalize();
+
+ _ssh_initialized = 0;
+
_ret:
if (!destructor) {
ssh_mutex_unlock(&ssh_init_mutex);
@@ -191,14 +200,6 @@ void libssh_destructor(void)
if (rc < 0) {
fprintf(stderr, "Error in libssh_destructor()\n");
}
-
- /* Detect if ssh_init() was called without matching ssh_finalize() */
- if (_ssh_initialized > 0) {
- fprintf(stderr,
- "Warning: ssh still initialized; probably ssh_init() "
- "was called more than once (init count: %d)\n",
- _ssh_initialized);
- }
}
/**
@@ -221,4 +222,27 @@ int ssh_finalize(void) {
return _ssh_finalize(0);
}
+#ifdef _WIN32
+
+#ifdef _MSC_VER
+/* Library constructor and destructor */
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+ int rc;
+
+ if (fdwReason == DLL_PROCESS_ATTACH) {
+ rc = ssh_init();
+ } else if (fdwReason == DLL_PROCESS_DETACH) {
+ rc = ssh_finalize();
+ }
+
+ if (rc != 0) {
+ return FALSE;
+ }
+ return TRUE;
+}
+#endif /* _MSC_VER */
+
+#endif /* _WIN32 */
+
/** @} */