Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions plugin/hashicorp_key_management/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
INCLUDE(FindCURL)
FIND_PACKAGE(CURL)
IF(NOT CURL_FOUND)
# Can't build plugin
RETURN()
ENDIF()

INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR})

set(CPACK_RPM_hashicorp-key-management_PACKAGE_SUMMARY "Hashicorp Key Management plugin for MariaDB" PARENT_SCOPE)
set(CPACK_RPM_hashicorp-key-management_PACKAGE_DESCRIPTION "This encryption plugin uses Hashicorp Vault for storing encryption
keys for MariaDB Data-at-Rest encryption." PARENT_SCOPE)

MYSQL_ADD_PLUGIN(HASHICORP_KEY_MANAGEMENT
hashicorp_key_management_plugin.cc
LINK_LIBRARIES ${CURL_LIBRARIES}
LINK_LIBRARIES CURL::libcurl
CONFIG hashicorp_key_management.cnf
COMPONENT hashicorp-key-management
MODULE_ONLY)
Expand Down
65 changes: 0 additions & 65 deletions plugin/hashicorp_key_management/hashicorp_key_management_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@
#include <unordered_map>
#include <mutex>

#if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)
#define HASHICORP_HAVE_EXCEPTIONS 1
#else
#define HASHICORP_HAVE_EXCEPTIONS 0
#endif

#define HASHICORP_DEBUG_LOGGING 0

#define PLUGIN_ERROR_HEADER "hashicorp: "
Expand Down Expand Up @@ -209,23 +203,13 @@ unsigned int
if (key_version == ENCRYPTION_KEY_VERSION_INVALID)
{
clock_t timestamp;
#if HASHICORP_HAVE_EXCEPTIONS
try
{
VER_INFO &ver_info = latest_version_cache.at(key_id);
version = ver_info.key_version;
timestamp = ver_info.timestamp;
}
catch (const std::out_of_range &e)
#else
VER_MAP::const_iterator ver_iter = latest_version_cache.find(key_id);
if (ver_iter != latest_version_cache.end())
{
version = ver_iter->second.key_version;
timestamp = ver_iter->second.timestamp;
}
else
#endif
{
mtx.unlock();
return ENCRYPTION_KEY_VERSION_INVALID;
Expand All @@ -246,21 +230,13 @@ unsigned int
}
}
KEY_INFO info;
#if HASHICORP_HAVE_EXCEPTIONS
try
{
info = key_info_cache.at(KEY_ID_AND_VERSION(key_id, version));
}
catch (const std::out_of_range &e)
#else
KEY_MAP::const_iterator key_iter =
key_info_cache.find(KEY_ID_AND_VERSION(key_id, version));
if (key_iter != key_info_cache.end())
{
info = key_iter->second;
}
else
#endif
{
mtx.unlock();
return ENCRYPTION_KEY_VERSION_INVALID;
Expand Down Expand Up @@ -305,20 +281,12 @@ unsigned int HCData::cache_get_version (unsigned int key_id)
{
unsigned int version;
mtx.lock();
#if HASHICORP_HAVE_EXCEPTIONS
try
{
version = latest_version_cache.at(key_id).key_version;
}
catch (const std::out_of_range &e)
#else
VER_MAP::const_iterator ver_iter = latest_version_cache.find(key_id);
if (ver_iter != latest_version_cache.end())
{
version = ver_iter->second.key_version;
}
else
#endif
{
version = ENCRYPTION_KEY_VERSION_INVALID;
}
Expand All @@ -331,23 +299,13 @@ unsigned int HCData::cache_check_version (unsigned int key_id)
unsigned int version;
clock_t timestamp;
mtx.lock();
#if HASHICORP_HAVE_EXCEPTIONS
try
{
VER_INFO &ver_info = latest_version_cache.at(key_id);
version = ver_info.key_version;
timestamp = ver_info.timestamp;
}
catch (const std::out_of_range &e)
#else
VER_MAP::const_iterator ver_iter = latest_version_cache.find(key_id);
if (ver_iter != latest_version_cache.end())
{
version = ver_iter->second.key_version;
timestamp = ver_iter->second.timestamp;
}
else
#endif
{
mtx.unlock();
#if HASHICORP_DEBUG_LOGGING
Expand Down Expand Up @@ -978,29 +936,6 @@ struct st_mariadb_encryption hashicorp_key_management_plugin= {
0, 0, 0, 0, 0
};

#ifdef _MSC_VER

static int setenv (const char *name, const char *value, int overwrite)
{
if (!overwrite)
{
size_t len= 0;
int rc= getenv_s(&len, NULL, 0, name);
if (rc)
{
return rc;
}
if (len)
{
errno = EINVAL;
return EINVAL;
}
}
return _putenv_s(name, value);
}

#endif

#define MAX_URL_SIZE 32768

int HCData::init ()
Expand Down
38 changes: 14 additions & 24 deletions storage/connect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -360,31 +360,21 @@ ENDIF(CONNECT_WITH_MONGO)
OPTION(CONNECT_WITH_REST "Compile CONNECT storage engine with REST support" ON)

IF(CONNECT_WITH_REST)
# MESSAGE(STATUS "=====> REST support is ON")
SET(CONNECT_SOURCES ${CONNECT_SOURCES} tabrest.cpp tabrest.h)
add_definitions(-DREST_SUPPORT)
# FIND_PACKAGE(cpprestsdk QUIET)
# IF (cpprestsdk_FOUND)
# IF(UNIX)
## INCLUDE_DIRECTORIES(${CPPRESTSDK_INCLUDE_DIR})
## If needed edit next line to set the path to libcpprest.so
# SET(REST_LIBRARY -lcpprest)
# MESSAGE (STATUS ${REST_LIBRARY})
# ELSE(NOT UNIX)
## Next line sets debug compile mode matching cpprest_2_10d.dll
## when it was binary installed (can be change later in Visual Studio)
## Comment it out if not needed depending on your cpprestsdk installation.
# SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
# ENDIF(UNIX)
## IF(REST_LIBRARY) why this? how about Windows
# SET(CONNECT_SOURCES ${CONNECT_SOURCES} restget.cpp)
# add_definitions(-DREST_SOURCE)
## ENDIF()
## ELSE(NOT cpprestsdk_FOUND)
# MESSAGE(STATUS "=====> cpprestsdk package not found")
# ENDIF (cpprestsdk_FOUND)
SET(REST_LIBRARY)
FIND_PACKAGE(CURL)
IF (CURL_FOUND)
SET_PACKAGE_PROPERTIES(Curl PROPERTIES TYPE REQUIRED
PURPOSE "Required for the CONNECT_WITH_REST feature")
SET(REST_LIBRARY CURL::libcurl)
MESSAGE (STATUS ${REST_LIBRARY})
SET(CONNECT_SOURCES ${CONNECT_SOURCES} tabrest.cpp tabrest.h)
add_definitions(-DREST_SUPPORT)
ADD_FEATURE_INFO(CONNECT_REST "ON" "Support for REST API in the CONNECT storage engine")
ELSE()
MESSAGE_ONCE(CONNECT_NO_CURL "libcurl-dev header not found.")
ADD_FEATURE_INFO(CONNECT_REST "OFF" "Support for REST API in the CONNECT storage engine")
ENDIF()
ENDIF(CONNECT_WITH_REST)
ADD_FEATURE_INFO(CONNECT_REST CONNECT_WITH_REST "Support for REST API in the CONNECT storage engine")

#
# XMAP
Expand Down
2 changes: 1 addition & 1 deletion storage/connect/mysql-test/connect/t/rest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if (!`SELECT count(*) FROM INFORMATION_SCHEMA.TABLES
AND CREATE_OPTIONS LIKE "%`table_type`='JSON'%"`)
{
DROP TABLE IF EXISTS t1;
Skip Need Curl or Casablanca;
Skip Need libcurl;
}
DROP TABLE t1;
--enable_query_log
Expand Down
3 changes: 1 addition & 2 deletions storage/connect/mysql-test/connect/t/rest.test
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@ SELECT * FROM t1;
DROP TABLE t1;

#
# Clean up
# Clean up is done automatically
#
--remove_file $MYSQLD_DATADIR/test/users.json
1 change: 0 additions & 1 deletion storage/connect/plgdbsem.h
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,6 @@ typedef class VCTDEF *PVCTDEF;
typedef class PIVOTDEF *PPIVOTDEF;
typedef class DOMDEF *PDOMDEF;
typedef class DIRDEF *PDIRDEF;
typedef class RESTDEF *PRESTDEF;
typedef class OEMDEF *POEMDEF;
typedef class COLCRT *PCOLCRT;
typedef class COLDEF *PCOLDEF;
Expand Down
90 changes: 0 additions & 90 deletions storage/connect/restget.cpp

This file was deleted.

Loading