From 6685b3d2c05a4a1d4a10146cdd6aba6a50a57793 Mon Sep 17 00:00:00 2001 From: Tomoya Fujita Date: Sat, 1 Mar 2025 10:24:16 -0800 Subject: [PATCH 1/2] use rmw_enclave_options_xxx APIs instead. Signed-off-by: Tomoya Fujita --- rmw_microxrcedds_c/src/rmw_init.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/rmw_microxrcedds_c/src/rmw_init.c b/rmw_microxrcedds_c/src/rmw_init.c index 39454f8b..955cda9c 100644 --- a/rmw_microxrcedds_c/src/rmw_init.c +++ b/rmw_microxrcedds_c/src/rmw_init.c @@ -52,7 +52,7 @@ rmw_init_options_init( init_options->instance_id = 0; init_options->implementation_identifier = eprosima_microxrcedds_identifier; init_options->allocator = allocator; - init_options->enclave = "/"; + init_options->enclave = NULL; init_options->domain_id = 0; init_options->security_options = rmw_get_default_security_options(); @@ -133,9 +133,21 @@ rmw_init_options_copy( return RMW_RET_INVALID_ARGUMENT; } memcpy(dst, src, sizeof(rmw_init_options_t)); - + rmw_ret_t ret; + const rcutils_allocator_t * allocator = &src->allocator; + RCUTILS_CHECK_ALLOCATOR(allocator, return RMW_RET_INVALID_ARGUMENT); + if (src->enclave != NULL) { + // Expecting this does not happen, + // because rmw_microxrcedds does not support SROS 2 security feature. + ret = rmw_enclave_options_copy(src->enclave, allocator, &dst.enclave); + if (RMW_RET_OK != ret) { + return ret; + } + } rmw_uxrce_mempool_item_t * memory_node = get_memory(&init_options_memory); if (!memory_node) { + rmw_enclave_options_fini(dst.enclave, allocator); + // Error already assigned below RMW_UROS_TRACE_MESSAGE("Not available memory node") return RMW_RET_ERROR; } @@ -154,7 +166,8 @@ rmw_init_options_fini( rmw_init_options_t * init_options) { RMW_CHECK_ARGUMENT_FOR_NULL(init_options, RMW_RET_INVALID_ARGUMENT); - RCUTILS_CHECK_ALLOCATOR(&(init_options->allocator), return RMW_RET_INVALID_ARGUMENT); + rcutils_allocator_t * allocator = &init_options->allocator; + RCUTILS_CHECK_ALLOCATOR(allocator, return RMW_RET_INVALID_ARGUMENT); RMW_CHECK_TYPE_IDENTIFIERS_MATCH( init_options->implementation_identifier, RMW_RET_INCORRECT_RMW_IMPLEMENTATION); @@ -175,6 +188,15 @@ rmw_init_options_fini( return RMW_RET_ERROR; } + rmw_ret_t ret; + if (init_options->enclave != NULL) { + // Expecting this does not happen, + // because rmw_microxrcedds does not support SROS 2 security feature. + ret = rmw_enclave_options_fini(init_options->enclave, allocator); + if (ret != RMW_RET_OK) { + return ret; + } + } *init_options = rmw_get_zero_initialized_init_options(); From 0486cfaa2840fc17a6d232ad88e9d5b8ecc88946 Mon Sep 17 00:00:00 2001 From: Tomoya Fujita Date: Mon, 3 Mar 2025 10:39:36 -0800 Subject: [PATCH 2/2] address review comments. Signed-off-by: Tomoya Fujita --- rmw_microxrcedds_c/src/rmw_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rmw_microxrcedds_c/src/rmw_init.c b/rmw_microxrcedds_c/src/rmw_init.c index 955cda9c..8d5fd90c 100644 --- a/rmw_microxrcedds_c/src/rmw_init.c +++ b/rmw_microxrcedds_c/src/rmw_init.c @@ -139,14 +139,14 @@ rmw_init_options_copy( if (src->enclave != NULL) { // Expecting this does not happen, // because rmw_microxrcedds does not support SROS 2 security feature. - ret = rmw_enclave_options_copy(src->enclave, allocator, &dst.enclave); + ret = rmw_enclave_options_copy(src->enclave, allocator, &dst->enclave); if (RMW_RET_OK != ret) { return ret; } } rmw_uxrce_mempool_item_t * memory_node = get_memory(&init_options_memory); if (!memory_node) { - rmw_enclave_options_fini(dst.enclave, allocator); + rmw_enclave_options_fini(dst->enclave, allocator); // Error already assigned below RMW_UROS_TRACE_MESSAGE("Not available memory node") return RMW_RET_ERROR;