Compare commits

...

18 Commits

Author SHA1 Message Date
Andreas Schneider
e949e135b6 Bump version to 0.8.1 2018-08-13 22:19:33 +02:00
Andreas Schneider
1510b63d20 cmake: Bump library version for release
(cherry picked from commit a3475c2e4b)
2018-08-13 22:19:25 +02:00
Andreas Schneider
0db4d9bd46 init: Add a library constructor and destructor for VC
If we compile with Visual Studio, we need a DllMain() for running init
and finialize which is the same as a constructor and destructor.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 4d87256ca7)
2018-08-13 22:12:22 +02:00
Andreas Schneider
1e17e084bf cmake: Only set -Werror on UNIX
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 6aa9392699)
2018-08-13 22:12:21 +02:00
Andreas Schneider
a2c14c5ec5 cmake: Improve NSIS detection on Windows
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 0656f8a43d)
2018-08-13 22:12:19 +02:00
Anderson Toshiyuki Sasaki
b99849c831 init: ignore init counter if destructor calls finalize
If the destructor calls finalize, ignore the init counter and finalize
the library anyway.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 66a3bc0332)
2018-08-13 15:27:51 +02:00
Andreas Schneider
c7d4286ca1 cmake: Fix PACKAGE and VERSION in config.h
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit dbce0e5228)
2018-08-13 13:49:30 +02:00
Andreas Schneider
434e2b7212 cmake: Fix pkg-config file
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 8ef35a005c)
2018-08-13 13:49:28 +02:00
Andreas Schneider
acf0f0fa6e cmake: Remove obsolete libssh_threads.pc.cmake
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 8425dce7b2)
2018-08-13 13:49:26 +02:00
Anderson Toshiyuki Sasaki
220e6b66e8 threads: use static error check mutex initializer if available
This changes the condition to use the static error check mutex
initializer.  If it is not available, use the default static mutex
initializer.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 0be1ae0e3b)
2018-08-13 13:49:24 +02:00
Andreas Schneider
c4d4731ddf cmake: Only install static lib if built WITH_STATIC_LIB
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 83898f3f6c)
2018-08-13 13:49:21 +02:00
Andreas Schneider
139ccaa78c include: Fix version number
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-13 11:01:27 +02:00
Andreas Schneider
c42410b560 init: Only use constructor attribute if available
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit f2b6899298)
2018-08-13 11:00:52 +02:00
Andreas Schneider
120f11812d cmake: Detect constructor and destructor attributes
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 4c058aefd9)
2018-08-13 11:00:50 +02:00
Andreas Schneider
500486d501 cmake: Fix fallthrough attribute detection
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 8c2ad7bdd3)
2018-08-13 11:00:48 +02:00
Andreas Schneider
6708debd4c cmake: Fix check for bounded attribute
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit e04a8b3abd)
2018-08-13 11:00:47 +02:00
Andreas Schneider
852a8b4875 cmake: Set the PACKAGE_VERSION correctly
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 15ab612592)
2018-08-13 11:00:45 +02:00
Andreas Schneider
9c6b4ecb48 cpack: Fix ignore files
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-10 14:24:02 +02:00
16 changed files with 136 additions and 78 deletions

View File

@@ -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

View File

@@ -10,7 +10,7 @@ set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
# SOURCE GENERATOR
set(CPACK_SOURCE_GENERATOR "TXZ")
set(CPACK_SOURCE_IGNORE_FILES "~$;[.]swp$;/[.]git/;.gitignore;build;obj*;tags;cscope.*")
set(CPACK_SOURCE_IGNORE_FILES "~$;[.]swp$;/[.]git/;.gitignore;/build*;/obj*;tags;cscope.*")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
### NSIS INSTALLER

View File

@@ -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

View File

@@ -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("
void test_constructor_attribute(void) __attribute__ ((constructor));
void test_constructor_attribute(void)
{
return;
}
int main(void) {
return 0;
}" HAVE_CONSTRUCTOR_ATTRIBUTE)
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))
enum direction_e {
UP = 0,
DOWN,
};
int main(void) {
enum direction_e key = UP;
int i = 10;
int j = 0;
int i = 2;
switch (key) {
case UP:
i = 5;
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)

View File

@@ -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)

View File

@@ -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}
)

View File

@@ -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

View File

@@ -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, \

View File

@@ -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

View File

@@ -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}")

View File

@@ -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}

View File

@@ -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}

View File

@@ -1 +1 @@
4.5.0
4.5.1

View File

View File

@@ -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}")

View File

@@ -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 */
/** @} */