From c04668082ac544ef11cf6e07187f02aa7897284b Mon Sep 17 00:00:00 2001 From: Mikael Arguedas Date: Fri, 10 Apr 2020 00:00:10 +0200 Subject: [PATCH 1/2] security-context -> enclave Signed-off-by: Mikael Arguedas --- rmw_fastrtps_cpp/src/init_rmw_context_impl.cpp | 4 ++-- rmw_fastrtps_cpp/src/rmw_node_names.cpp | 8 ++++---- .../src/init_rmw_context_impl.cpp | 4 ++-- rmw_fastrtps_dynamic_cpp/src/rmw_node_names.cpp | 8 ++++---- .../custom_participant_info.hpp | 4 ++-- .../rmw_fastrtps_shared_cpp/participant.hpp | 2 +- .../include/rmw_fastrtps_shared_cpp/rmw_common.hpp | 4 ++-- rmw_fastrtps_shared_cpp/src/participant.cpp | 8 ++++---- rmw_fastrtps_shared_cpp/src/rmw_init.cpp | 14 +++++++------- rmw_fastrtps_shared_cpp/src/rmw_node_names.cpp | 8 ++++---- 10 files changed, 32 insertions(+), 32 deletions(-) diff --git a/rmw_fastrtps_cpp/src/init_rmw_context_impl.cpp b/rmw_fastrtps_cpp/src/init_rmw_context_impl.cpp index 8c9193433..8b3ec2fb2 100644 --- a/rmw_fastrtps_cpp/src/init_rmw_context_impl.cpp +++ b/rmw_fastrtps_cpp/src/init_rmw_context_impl.cpp @@ -63,7 +63,7 @@ init_context_impl(rmw_context_t * context) context->options.domain_id, &context->options.security_options, (context->options.localhost_only == RMW_LOCALHOST_ONLY_ENABLED) ? 1 : 0, - context->options.security_context, + context->options.enclave, common_context.get()), [&](CustomParticipantInfo * participant_info) { if (RMW_RET_OK != rmw_fastrtps_shared_cpp::destroy_participant(participant_info)) { @@ -173,7 +173,7 @@ init_context_impl(rmw_context_t * context) } common_context->graph_cache.add_participant( common_context->gid, - context->options.security_context); + context->options.enclave); graph_guard_condition.release(); publisher.release(); diff --git a/rmw_fastrtps_cpp/src/rmw_node_names.cpp b/rmw_fastrtps_cpp/src/rmw_node_names.cpp index 78833a667..2c670c246 100644 --- a/rmw_fastrtps_cpp/src/rmw_node_names.cpp +++ b/rmw_fastrtps_cpp/src/rmw_node_names.cpp @@ -41,13 +41,13 @@ rmw_get_node_names( } rmw_ret_t -rmw_get_node_names_with_security_contexts( +rmw_get_node_names_with_enclaves( const rmw_node_t * node, rcutils_string_array_t * node_names, rcutils_string_array_t * node_namespaces, - rcutils_string_array_t * security_contexts) + rcutils_string_array_t * enclaves) { - return rmw_fastrtps_shared_cpp::__rmw_get_node_names_with_security_contexts( - eprosima_fastrtps_identifier, node, node_names, node_namespaces, security_contexts); + return rmw_fastrtps_shared_cpp::__rmw_get_node_names_with_enclaves( + eprosima_fastrtps_identifier, node, node_names, node_namespaces, enclaves); } } // extern "C" diff --git a/rmw_fastrtps_dynamic_cpp/src/init_rmw_context_impl.cpp b/rmw_fastrtps_dynamic_cpp/src/init_rmw_context_impl.cpp index 5fa76772b..8d7608c4e 100644 --- a/rmw_fastrtps_dynamic_cpp/src/init_rmw_context_impl.cpp +++ b/rmw_fastrtps_dynamic_cpp/src/init_rmw_context_impl.cpp @@ -63,7 +63,7 @@ init_context_impl(rmw_context_t * context) context->options.domain_id, &context->options.security_options, (context->options.localhost_only == RMW_LOCALHOST_ONLY_ENABLED) ? 1 : 0, - context->options.security_context, + context->options.enclave, common_context.get()), [&](CustomParticipantInfo * participant_info) { if (RMW_RET_OK != rmw_fastrtps_shared_cpp::destroy_participant(participant_info)) { @@ -174,7 +174,7 @@ init_context_impl(rmw_context_t * context) } common_context->graph_cache.add_participant( common_context->gid, - context->options.security_context); + context->options.enclave); graph_guard_condition.release(); publisher.release(); diff --git a/rmw_fastrtps_dynamic_cpp/src/rmw_node_names.cpp b/rmw_fastrtps_dynamic_cpp/src/rmw_node_names.cpp index 624fdf641..715972b49 100644 --- a/rmw_fastrtps_dynamic_cpp/src/rmw_node_names.cpp +++ b/rmw_fastrtps_dynamic_cpp/src/rmw_node_names.cpp @@ -41,13 +41,13 @@ rmw_get_node_names( } rmw_ret_t -rmw_get_node_names_with_security_contexts( +rmw_get_node_names_with_enclaves( const rmw_node_t * node, rcutils_string_array_t * node_names, rcutils_string_array_t * node_namespaces, - rcutils_string_array_t * security_contexts) + rcutils_string_array_t * enclaves) { - return rmw_fastrtps_shared_cpp::__rmw_get_node_names_with_security_contexts( - eprosima_fastrtps_identifier, node, node_names, node_namespaces, security_contexts); + return rmw_fastrtps_shared_cpp::__rmw_get_node_names_with_enclaves( + eprosima_fastrtps_identifier, node, node_names, node_namespaces, enclaves); } } // extern "C" diff --git a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/custom_participant_info.hpp b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/custom_participant_info.hpp index 44c8a31ff..552081f68 100644 --- a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/custom_participant_info.hpp +++ b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/custom_participant_info.hpp @@ -78,13 +78,13 @@ class ParticipantListener : public eprosima::fastrtps::ParticipantListener if (name_found == map.end()) { return; } - auto security_context = + auto enclave = std::string(name_found->second.begin(), name_found->second.end()); context->graph_cache.add_participant( rmw_fastrtps_shared_cpp::create_rmw_gid( identifier_, info.info.m_guid), - security_context); + enclave); break; } case eprosima::fastrtps::rtps::ParticipantDiscoveryInfo::REMOVED_PARTICIPANT: diff --git a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/participant.hpp b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/participant.hpp index d44f2fb94..f10303cf8 100644 --- a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/participant.hpp +++ b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/participant.hpp @@ -32,7 +32,7 @@ create_participant( size_t domain_id, const rmw_security_options_t * security_options, bool localhost_only, - const char * security_context, + const char * enclave, rmw_dds_common::Context * common_context); RMW_FASTRTPS_SHARED_CPP_PUBLIC diff --git a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/rmw_common.hpp b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/rmw_common.hpp index 118d7a075..0f5b9dcc4 100644 --- a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/rmw_common.hpp +++ b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/rmw_common.hpp @@ -126,12 +126,12 @@ __rmw_init_event( RMW_FASTRTPS_SHARED_CPP_PUBLIC rmw_ret_t -__rmw_get_node_names_with_security_contexts( +__rmw_get_node_names_with_enclaves( const char * identifier, const rmw_node_t * node, rcutils_string_array_t * node_names, rcutils_string_array_t * node_namespaces, - rcutils_string_array_t * security_contexts); + rcutils_string_array_t * enclaves); RMW_FASTRTPS_SHARED_CPP_PUBLIC rmw_ret_t diff --git a/rmw_fastrtps_shared_cpp/src/participant.cpp b/rmw_fastrtps_shared_cpp/src/participant.cpp index 2f6cad6ae..2c750a539 100644 --- a/rmw_fastrtps_shared_cpp/src/participant.cpp +++ b/rmw_fastrtps_shared_cpp/src/participant.cpp @@ -140,7 +140,7 @@ rmw_fastrtps_shared_cpp::create_participant( size_t domain_id, const rmw_security_options_t * security_options, bool localhost_only, - const char * security_context, + const char * enclave, rmw_dds_common::Context * common_context) { if (!security_options) { @@ -167,16 +167,16 @@ rmw_fastrtps_shared_cpp::create_participant( participantAttrs.rtps.builtin.domainId = static_cast(domain_id); - size_t length = snprintf(nullptr, 0, "securitycontext=%s;", security_context) + 1; + size_t length = snprintf(nullptr, 0, "securitycontext=%s;", enclave) + 1; participantAttrs.rtps.userData.resize(length); int written = snprintf( reinterpret_cast(participantAttrs.rtps.userData.data()), - length, "securitycontext=%s;", security_context); + length, "securitycontext=%s;", enclave); if (written < 0 || written > static_cast(length) - 1) { RMW_SET_ERROR_MSG("failed to populate user_data buffer"); return nullptr; } - participantAttrs.rtps.setName(security_context); + participantAttrs.rtps.setName(enclave); bool leave_middleware_default_qos = false; const char * env_value; diff --git a/rmw_fastrtps_shared_cpp/src/rmw_init.cpp b/rmw_fastrtps_shared_cpp/src/rmw_init.cpp index 9bd8c5666..84597c3b8 100644 --- a/rmw_fastrtps_shared_cpp/src/rmw_init.cpp +++ b/rmw_fastrtps_shared_cpp/src/rmw_init.cpp @@ -39,7 +39,7 @@ rmw_init_options_init( init_options->implementation_identifier = identifier; init_options->allocator = allocator; init_options->impl = nullptr; - init_options->security_context = NULL; + init_options->enclave = NULL; init_options->domain_id = RMW_DEFAULT_DOMAIN_ID; init_options->security_options = rmw_get_default_security_options(); init_options->localhost_only = RMW_LOCALHOST_ONLY_DEFAULT; @@ -64,19 +64,19 @@ rmw_init_options_copy( const rcutils_allocator_t * allocator = &src->allocator; rmw_ret_t ret = RMW_RET_OK; - allocator->deallocate(dst->security_context, allocator->state); + allocator->deallocate(dst->enclave, allocator->state); *dst = *src; - dst->security_context = NULL; + dst->enclave = NULL; dst->security_options = rmw_get_zero_initialized_security_options(); - dst->security_context = rcutils_strdup(src->security_context, *allocator); - if (src->security_context && !dst->security_context) { + dst->enclave = rcutils_strdup(src->enclave, *allocator); + if (src->enclave && !dst->enclave) { ret = RMW_RET_BAD_ALLOC; goto fail; } return rmw_security_options_copy(&src->security_options, allocator, &dst->security_options); fail: - allocator->deallocate(dst->security_context, allocator->state); + allocator->deallocate(dst->enclave, allocator->state); return ret; } @@ -91,7 +91,7 @@ rmw_init_options_fini(const char * identifier, rmw_init_options_t * init_options init_options->implementation_identifier, identifier, return RMW_RET_INCORRECT_RMW_IMPLEMENTATION); - allocator.deallocate(init_options->security_context, allocator.state); + allocator.deallocate(init_options->enclave, allocator.state); rmw_security_options_fini(&init_options->security_options, &allocator); *init_options = rmw_get_zero_initialized_init_options(); return RMW_RET_OK; diff --git a/rmw_fastrtps_shared_cpp/src/rmw_node_names.cpp b/rmw_fastrtps_shared_cpp/src/rmw_node_names.cpp index d8dd03b48..5b4324dc2 100644 --- a/rmw_fastrtps_shared_cpp/src/rmw_node_names.cpp +++ b/rmw_fastrtps_shared_cpp/src/rmw_node_names.cpp @@ -69,12 +69,12 @@ __rmw_get_node_names( } rmw_ret_t -__rmw_get_node_names_with_security_contexts( +__rmw_get_node_names_with_enclaves( const char * identifier, const rmw_node_t * node, rcutils_string_array_t * node_names, rcutils_string_array_t * node_namespaces, - rcutils_string_array_t * security_contexts) + rcutils_string_array_t * enclaves) { if (!node) { RMW_SET_ERROR_MSG("null node handle"); @@ -86,7 +86,7 @@ __rmw_get_node_names_with_security_contexts( if (rmw_check_zero_rmw_string_array(node_namespaces) != RMW_RET_OK) { return RMW_RET_ERROR; } - if (rmw_check_zero_rmw_string_array(security_contexts) != RMW_RET_OK) { + if (rmw_check_zero_rmw_string_array(enclaves) != RMW_RET_OK) { return RMW_RET_ERROR; } if (node->implementation_identifier != identifier) { @@ -99,7 +99,7 @@ __rmw_get_node_names_with_security_contexts( return common_context->graph_cache.get_node_names( node_names, node_namespaces, - security_contexts, + enclaves, &allocator); } } // namespace rmw_fastrtps_shared_cpp From a29fbb9894cbe55f9416edf0ecea6ccef4b56ae9 Mon Sep 17 00:00:00 2001 From: Mikael Arguedas Date: Fri, 10 Apr 2020 00:06:34 +0200 Subject: [PATCH 2/2] securitycontext -> enclave Signed-off-by: Mikael Arguedas --- .../rmw_fastrtps_shared_cpp/custom_participant_info.hpp | 2 +- rmw_fastrtps_shared_cpp/src/participant.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/custom_participant_info.hpp b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/custom_participant_info.hpp index 552081f68..c20969d79 100644 --- a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/custom_participant_info.hpp +++ b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/custom_participant_info.hpp @@ -73,7 +73,7 @@ class ParticipantListener : public eprosima::fastrtps::ParticipantListener case eprosima::fastrtps::rtps::ParticipantDiscoveryInfo::DISCOVERED_PARTICIPANT: { auto map = rmw::impl::cpp::parse_key_value(info.info.m_userData); - auto name_found = map.find("securitycontext"); + auto name_found = map.find("enclave"); if (name_found == map.end()) { return; diff --git a/rmw_fastrtps_shared_cpp/src/participant.cpp b/rmw_fastrtps_shared_cpp/src/participant.cpp index 2c750a539..779c5c190 100644 --- a/rmw_fastrtps_shared_cpp/src/participant.cpp +++ b/rmw_fastrtps_shared_cpp/src/participant.cpp @@ -167,11 +167,11 @@ rmw_fastrtps_shared_cpp::create_participant( participantAttrs.rtps.builtin.domainId = static_cast(domain_id); - size_t length = snprintf(nullptr, 0, "securitycontext=%s;", enclave) + 1; + size_t length = snprintf(nullptr, 0, "enclave=%s;", enclave) + 1; participantAttrs.rtps.userData.resize(length); int written = snprintf( reinterpret_cast(participantAttrs.rtps.userData.data()), - length, "securitycontext=%s;", enclave); + length, "enclave=%s;", enclave); if (written < 0 || written > static_cast(length) - 1) { RMW_SET_ERROR_MSG("failed to populate user_data buffer"); return nullptr;