From ae1bc361b1ee77be826b37bc3d0b2a0d6caa34ec Mon Sep 17 00:00:00 2001 From: Mikael Arguedas Date: Mon, 13 Apr 2020 15:29:10 +0200 Subject: [PATCH] security-context -> enclave (#407) Signed-off-by: Mikael Arguedas --- rmw_connext_cpp/src/rmw_init.cpp | 14 ++--- rmw_connext_cpp/src/rmw_node_names.cpp | 8 +-- .../rmw_connext_shared_cpp/node_names.hpp | 4 +- rmw_connext_shared_cpp/src/node.cpp | 8 +-- rmw_connext_shared_cpp/src/node_names.cpp | 56 +++++++++---------- 5 files changed, 45 insertions(+), 45 deletions(-) diff --git a/rmw_connext_cpp/src/rmw_init.cpp b/rmw_connext_cpp/src/rmw_init.cpp index 9e83ca6d..0abe845b 100644 --- a/rmw_connext_cpp/src/rmw_init.cpp +++ b/rmw_connext_cpp/src/rmw_init.cpp @@ -39,7 +39,7 @@ rmw_init_options_init(rmw_init_options_t * init_options, rcutils_allocator_t all init_options->security_options = rmw_get_zero_initialized_security_options(); init_options->domain_id = RMW_DEFAULT_DOMAIN_ID; init_options->localhost_only = RMW_LOCALHOST_ONLY_DEFAULT; - init_options->security_context = NULL; + init_options->enclave = NULL; return RMW_RET_OK; } @@ -60,19 +60,19 @@ rmw_init_options_copy(const rmw_init_options_t * src, rmw_init_options_t * dst) 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; } @@ -87,7 +87,7 @@ rmw_init_options_fini(rmw_init_options_t * init_options) init_options->implementation_identifier, rti_connext_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_connext_cpp/src/rmw_node_names.cpp b/rmw_connext_cpp/src/rmw_node_names.cpp index eefef8dc..65f6c512 100644 --- a/rmw_connext_cpp/src/rmw_node_names.cpp +++ b/rmw_connext_cpp/src/rmw_node_names.cpp @@ -32,13 +32,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 get_node_names_with_security_contexts( - rti_connext_identifier, node, node_names, node_namespaces, security_contexts); + return get_node_names_with_enclaves( + rti_connext_identifier, node, node_names, node_namespaces, enclaves); } } // extern "C" diff --git a/rmw_connext_shared_cpp/include/rmw_connext_shared_cpp/node_names.hpp b/rmw_connext_shared_cpp/include/rmw_connext_shared_cpp/node_names.hpp index dc42d3c7..b7c3340b 100644 --- a/rmw_connext_shared_cpp/include/rmw_connext_shared_cpp/node_names.hpp +++ b/rmw_connext_shared_cpp/include/rmw_connext_shared_cpp/node_names.hpp @@ -30,12 +30,12 @@ get_node_names( RMW_CONNEXT_SHARED_CPP_PUBLIC rmw_ret_t -get_node_names_with_security_contexts( +get_node_names_with_enclaves( const char * implementation_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_CONNEXT_SHARED_CPP_PUBLIC rmw_ret_t diff --git a/rmw_connext_shared_cpp/src/node.cpp b/rmw_connext_shared_cpp/src/node.cpp index 604ea28e..b1295888 100644 --- a/rmw_connext_shared_cpp/src/node.cpp +++ b/rmw_connext_shared_cpp/src/node.cpp @@ -76,8 +76,8 @@ create_node( size_t length = std::snprintf( nullptr, 0, - "name=%s;namespace=%s;securitycontext=%s;", - name, namespace_, context->options.security_context) + 1; + "name=%s;namespace=%s;enclave=%s;", + name, namespace_, context->options.enclave) + 1; bool success = participant_qos.user_data.value.length(static_cast(length)); if (!success) { RMW_SET_ERROR_MSG("failed to resize participant user_data"); @@ -87,8 +87,8 @@ create_node( int written = std::snprintf( reinterpret_cast(participant_qos.user_data.value.get_contiguous_buffer()), length, - "name=%s;namespace=%s;securitycontext=%s;", - name, namespace_, context->options.security_context); + "name=%s;namespace=%s;enclave=%s;", + name, namespace_, context->options.enclave); if (written < 0 || written > static_cast(length) - 1) { RMW_SET_ERROR_MSG("failed to populate user_data buffer"); return NULL; diff --git a/rmw_connext_shared_cpp/src/node_names.cpp b/rmw_connext_shared_cpp/src/node_names.cpp index ffd364f9..cb0e1503 100644 --- a/rmw_connext_shared_cpp/src/node_names.cpp +++ b/rmw_connext_shared_cpp/src/node_names.cpp @@ -33,7 +33,7 @@ get_node_names_impl( 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("node handle is null"); @@ -77,7 +77,7 @@ get_node_names_impl( // Such names should not be returned rcutils_string_array_t tmp_names_list = rcutils_get_zero_initialized_string_array(); rcutils_string_array_t tmp_namespaces_list = rcutils_get_zero_initialized_string_array(); - rcutils_string_array_t tmp_security_contexts_list = rcutils_get_zero_initialized_string_array(); + rcutils_string_array_t tmp_enclaves_list = rcutils_get_zero_initialized_string_array(); int named_nodes_num = 1; @@ -97,8 +97,8 @@ get_node_names_impl( goto cleanup; } - if (security_contexts) { - rcutils_ret = rcutils_string_array_init(&tmp_security_contexts_list, length, &allocator); + if (enclaves) { + rcutils_ret = rcutils_string_array_init(&tmp_enclaves_list, length, &allocator); if (rcutils_ret != RCUTILS_RET_OK) { RMW_SET_ERROR_MSG(rcutils_get_error_string().str); @@ -120,11 +120,11 @@ get_node_names_impl( final_ret = rmw_convert_rcutils_ret_to_rmw_ret(rcutils_ret); goto cleanup; } - if (security_contexts) { - tmp_security_contexts_list.data[0] = rcutils_strdup( - node->context->options.security_context, allocator); + if (enclaves) { + tmp_enclaves_list.data[0] = rcutils_strdup( + node->context->options.enclave, allocator); if (!tmp_namespaces_list.data[0]) { - RMW_SET_ERROR_MSG("could not allocate memory for a security context name"); + RMW_SET_ERROR_MSG("could not allocate memory for a enclave name"); final_ret = rmw_convert_rcutils_ret_to_rmw_ret(rcutils_ret); goto cleanup; } @@ -135,7 +135,7 @@ get_node_names_impl( auto dds_ret = participant->get_discovered_participant_data(pbtd, handles[i - 1]); std::string name; std::string namespace_; - std::string security_context; + std::string enclave; if (DDS::RETCODE_OK == dds_ret) { auto data = static_cast(pbtd.user_data.value.get_contiguous_buffer()); std::vector kv(data, data + pbtd.user_data.value.length()); @@ -144,7 +144,7 @@ get_node_names_impl( auto name_found = map.find("name"); auto ns_found = map.find("namespace"); - auto security_context_found = map.find("securitycontext"); + auto enclave_found = map.find("enclave"); if (name_found != map.end()) { name = std::string(name_found->second.begin(), name_found->second.end()); @@ -154,9 +154,9 @@ get_node_names_impl( namespace_ = std::string(ns_found->second.begin(), ns_found->second.end()); } - if (security_context_found != map.end()) { - security_context = std::string( - security_context_found->second.begin(), security_context_found->second.end()); + if (enclave_found != map.end()) { + enclave = std::string( + enclave_found->second.begin(), enclave_found->second.end()); } } @@ -181,10 +181,10 @@ get_node_names_impl( goto cleanup; } - if (security_contexts) { - tmp_security_contexts_list.data[named_nodes_num] = rcutils_strdup( - security_context.c_str(), allocator); - if (!tmp_security_contexts_list.data[named_nodes_num]) { + if (enclaves) { + tmp_enclaves_list.data[named_nodes_num] = rcutils_strdup( + enclave.c_str(), allocator); + if (!tmp_enclaves_list.data[named_nodes_num]) { RMW_SET_ERROR_MSG("could not allocate memory for a node's namespace"); final_ret = rmw_convert_rcutils_ret_to_rmw_ret(rcutils_ret); goto cleanup; @@ -210,8 +210,8 @@ get_node_names_impl( goto cleanup; } - if (security_contexts) { - rcutils_ret = rcutils_string_array_init(security_contexts, named_nodes_num, &allocator); + if (enclaves) { + rcutils_ret = rcutils_string_array_init(enclaves, named_nodes_num, &allocator); if (rcutils_ret != RCUTILS_RET_OK) { RMW_SET_ERROR_MSG("could not allocate memory for node_namespaces output"); @@ -223,8 +223,8 @@ get_node_names_impl( for (auto i = 0; i < named_nodes_num; ++i) { node_names->data[i] = rcutils_strdup(tmp_names_list.data[i], allocator); node_namespaces->data[i] = rcutils_strdup(tmp_namespaces_list.data[i], allocator); - if (security_contexts) { - security_contexts->data[i] = rcutils_strdup(tmp_security_contexts_list.data[i], allocator); + if (enclaves) { + enclaves->data[i] = rcutils_strdup(tmp_enclaves_list.data[i], allocator); } } @@ -266,8 +266,8 @@ get_node_names_impl( } } - if (security_contexts) { - rcutils_ret = rcutils_string_array_fini(security_contexts); + if (enclaves) { + rcutils_ret = rcutils_string_array_fini(enclaves); if (rcutils_ret != RCUTILS_RET_OK) { RCUTILS_LOG_ERROR_NAMED( "rmw_connext_cpp", @@ -295,7 +295,7 @@ get_node_names_impl( rcutils_reset_error(); } - rcutils_ret = rcutils_string_array_fini(&tmp_security_contexts_list); + rcutils_ret = rcutils_string_array_fini(&tmp_enclaves_list); if (rcutils_ret != RCUTILS_RET_OK) { RCUTILS_LOG_ERROR_NAMED( "rmw_connext_cpp", @@ -318,16 +318,16 @@ get_node_names( } rmw_ret_t -get_node_names_with_security_contexts( +get_node_names_with_enclaves( const char * implementation_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 (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; } return get_node_names_impl( - implementation_identifier, node, node_names, node_namespaces, security_contexts); + implementation_identifier, node, node_names, node_namespaces, enclaves); }