Skip to content
Closed
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
2 changes: 1 addition & 1 deletion win/packaging/CPackWixConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ add_component(Backup
DESCRIPTION "Installs backup utilities(mariabackup and mbstream)")

#Miscellaneous hidden components, part of server / or client programs
foreach(comp connect-engine connect-engine-jdbc ClientPlugins aws-key-management rocksdb-engine)
foreach(comp connect-engine connect-engine-jdbc ClientPlugins aws-key-management rocksdb-engine plugin-hashicorp-key-management)
add_component(${comp} GROUP MySQLServer HIDDEN)
endforeach()

Expand Down