mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2024-11-20 03:39:17 +01:00
Remove support for OpenSSL <= 1.0.2
Removes openssl thread locking callbacks required by OpenSSL <= 1.0.2 Other SSL libraries and newer OpenSSL should be handled by libcurl in a way that is thread-safe
This commit is contained in:
parent
521eea8522
commit
f69747bb88
@ -2,7 +2,6 @@ cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)
|
||||
project (lgogdownloader LANGUAGES C CXX VERSION 3.8)
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
|
||||
set(LINK_LIBCRYPTO 0)
|
||||
|
||||
# Disable search for boost-cmake
|
||||
# Fixes building with Boost >= 1.70.0
|
||||
@ -27,19 +26,6 @@ find_package(Boost
|
||||
iostreams
|
||||
)
|
||||
find_package(CURL 7.32.0 REQUIRED)
|
||||
if(CURL_FOUND)
|
||||
execute_process(
|
||||
COMMAND ${READELF} -d ${CURL_LIBRARIES}
|
||||
COMMAND ${GREP} -q "libssl\\|libcrypto"
|
||||
RESULT_VARIABLE READELF_RESULT_VAR
|
||||
)
|
||||
if(READELF_RESULT_VAR EQUAL 0)
|
||||
add_definitions(-DSSL_THREAD_SETUP_OPENSSL=1)
|
||||
find_package(Libcrypto REQUIRED)
|
||||
set(LINK_LIBCRYPTO 1)
|
||||
endif(READELF_RESULT_VAR EQUAL 0)
|
||||
endif(CURL_FOUND)
|
||||
|
||||
find_package(Jsoncpp REQUIRED)
|
||||
find_package(Htmlcxx REQUIRED)
|
||||
find_package(Tinyxml2 REQUIRED)
|
||||
@ -154,12 +140,6 @@ if (NOT ATOMIC_BUILD_SUCCEEDED)
|
||||
endif ()
|
||||
file(REMOVE ${CMAKE_BINARY_DIR}/test_atomic.cpp)
|
||||
|
||||
if(LINK_LIBCRYPTO EQUAL 1)
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PRIVATE ${Libcrypto_LIBRARIES}
|
||||
)
|
||||
endif(LINK_LIBCRYPTO EQUAL 1)
|
||||
|
||||
if(USE_QT_GUI)
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PRIVATE Qt5::Widgets
|
||||
|
@ -11,22 +11,19 @@ It uses the same API as GOG Galaxy which doesn't have Linux support at the momen
|
||||
* [htmlcxx](http://htmlcxx.sourceforge.net/)
|
||||
* [tinyxml2](https://github.com/leethomason/tinyxml2)
|
||||
* [boost](http://www.boost.org/) (regex, date-time, system, filesystem, program-options, iostreams)
|
||||
* [libcrypto](https://www.openssl.org/) if libcurl is built with OpenSSL
|
||||
* [zlib](https://www.zlib.net/)
|
||||
* [qtwebengine](https://www.qt.io/) if built with -DUSE_QT_GUI=ON
|
||||
|
||||
## Make dependencies
|
||||
* [cmake](https://cmake.org/) >= 3.0.0
|
||||
* [help2man](https://www.gnu.org/software/help2man/help2man.html) (optional, man page generation)
|
||||
* [grep](https://www.gnu.org/software/grep/)
|
||||
* [binutils](https://www.gnu.org/software/binutils/) (readelf)
|
||||
|
||||
### Debian/Ubuntu
|
||||
|
||||
# apt install build-essential libcurl4-openssl-dev libboost-regex-dev \
|
||||
libjsoncpp-dev librhash-dev libtinyxml2-dev libhtmlcxx-dev \
|
||||
libboost-system-dev libboost-filesystem-dev libboost-program-options-dev \
|
||||
libboost-date-time-dev libboost-iostreams-dev help2man cmake libssl-dev \
|
||||
libboost-date-time-dev libboost-iostreams-dev help2man cmake \
|
||||
pkg-config zlib1g-dev qtwebengine5-dev
|
||||
|
||||
## Build and install
|
||||
|
@ -1,27 +0,0 @@
|
||||
# - Try to find libcrypto
|
||||
#
|
||||
# Once done this will define
|
||||
# Libcrypto_FOUND - System has libcrypto
|
||||
# Libcrypto_INCLUDE_DIRS - The libcrypto include directories
|
||||
# Libcrypto_LIBRARIES - The libraries needed to use libcrypto
|
||||
|
||||
find_package(PkgConfig)
|
||||
pkg_check_modules(PC_LIBCRYPTO REQUIRED libcrypto)
|
||||
|
||||
find_path(LIBCRYPTO_INCLUDE_DIR openssl/crypto.h
|
||||
HINTS ${PC_LIBCRYPTO_INCLUDEDIR}
|
||||
${PC_LIBCRYPTO_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
find_library(LIBCRYPTO_LIBRARY NAMES crypto
|
||||
HINTS ${PC_LIBCRYPTO_LIBDIR}
|
||||
${PC_LIBCRYPTO_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
mark_as_advanced(LIBCRYPTO_INCLUDE_DIR LIBCRYPTO_LIBRARY)
|
||||
|
||||
if(PC_LIBCRYPTO_FOUND)
|
||||
set(Libcrypto_FOUND ON)
|
||||
set(Libcrypto_INCLUDE_DIRS ${LIBCRYPTO_INCLUDE_DIR})
|
||||
set(Libcrypto_LIBRARIES ${LIBCRYPTO_LIBRARY})
|
||||
endif(PC_LIBCRYPTO_FOUND)
|
@ -1,64 +0,0 @@
|
||||
/* This program is free software. It comes without any warranty, to
|
||||
* the extent permitted by applicable law. You can redistribute it
|
||||
* and/or modify it under the terms of the Do What The Fuck You Want
|
||||
* To Public License, Version 2, as published by Sam Hocevar. See
|
||||
* http://www.wtfpl.net/ for more details. */
|
||||
|
||||
#ifndef SSL_THREAD_SETUP_H
|
||||
#define SSL_THREAD_SETUP_H
|
||||
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
|
||||
#if SSL_THREAD_SETUP_OPENSSL == 1
|
||||
#include <openssl/crypto.h>
|
||||
|
||||
static std::mutex* ssl_mutex_array;
|
||||
|
||||
void thread_locking_callback(int mode, int n, const char* file, int line)
|
||||
{
|
||||
// suppress -Wunused-parameter messages by casting these variables to void
|
||||
(void) file;
|
||||
(void) line;
|
||||
|
||||
if(mode & CRYPTO_LOCK)
|
||||
ssl_mutex_array[n].lock();
|
||||
else
|
||||
ssl_mutex_array[n].unlock();
|
||||
}
|
||||
|
||||
unsigned long thread_id_callback()
|
||||
{
|
||||
return (unsigned long)std::hash<std::thread::id>() (std::this_thread::get_id());
|
||||
}
|
||||
|
||||
int ssl_thread_setup()
|
||||
{
|
||||
ssl_mutex_array = new std::mutex[CRYPTO_num_locks()];
|
||||
if(!ssl_mutex_array)
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
CRYPTO_set_id_callback(thread_id_callback);
|
||||
CRYPTO_set_locking_callback(thread_locking_callback);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ssl_thread_cleanup()
|
||||
{
|
||||
if(!ssl_mutex_array)
|
||||
return 0;
|
||||
|
||||
CRYPTO_set_id_callback(NULL);
|
||||
CRYPTO_set_locking_callback(NULL);
|
||||
delete[] ssl_mutex_array;
|
||||
ssl_mutex_array = NULL;
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
#define ssl_thread_setup()
|
||||
#define ssl_thread_cleanup()
|
||||
#endif
|
||||
|
||||
#endif // SSL_THREAD_SETUP_H
|
9
main.cpp
9
main.cpp
@ -8,7 +8,6 @@
|
||||
#include "config.h"
|
||||
#include "util.h"
|
||||
#include "globalconstants.h"
|
||||
#include "ssl_thread_setup.h"
|
||||
#include "galaxyapi.h"
|
||||
#include "globals.h"
|
||||
|
||||
@ -602,7 +601,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// Init curl globally
|
||||
ssl_thread_setup();
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
|
||||
Downloader downloader;
|
||||
@ -632,7 +630,6 @@ int main(int argc, char *argv[])
|
||||
if (!bLoginOK && !bIsLoggedin)
|
||||
{
|
||||
curl_global_cleanup();
|
||||
ssl_thread_cleanup();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -696,7 +693,6 @@ int main(int argc, char *argv[])
|
||||
if (Globals::globalConfig.bSaveConfig)
|
||||
{
|
||||
curl_global_cleanup();
|
||||
ssl_thread_cleanup();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -704,7 +700,6 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
std::cerr << "Failed to create config: " << Globals::globalConfig.sConfigFilePath << std::endl;
|
||||
curl_global_cleanup();
|
||||
ssl_thread_cleanup();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -718,14 +713,12 @@ int main(int argc, char *argv[])
|
||||
Util::setFilePermissions(Globals::globalConfig.sConfigFilePath, boost::filesystem::owner_read | boost::filesystem::owner_write);
|
||||
|
||||
curl_global_cleanup();
|
||||
ssl_thread_cleanup();
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Failed to create config: " << Globals::globalConfig.sConfigFilePath << std::endl;
|
||||
curl_global_cleanup();
|
||||
ssl_thread_cleanup();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -734,7 +727,6 @@ int main(int argc, char *argv[])
|
||||
if (!bInitOK)
|
||||
{
|
||||
curl_global_cleanup();
|
||||
ssl_thread_cleanup();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -802,7 +794,6 @@ int main(int argc, char *argv[])
|
||||
downloader.checkOrphans();
|
||||
|
||||
curl_global_cleanup();
|
||||
ssl_thread_cleanup();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user