From 00835385016a50aa17455d076a549a4310332867 Mon Sep 17 00:00:00 2001 From: Alex Kozyrev Date: Mon, 12 Aug 2019 14:30:45 -0400 Subject: [PATCH] Properly handle Barbican IPv6 address in MTCE barbican.conf stores Barbican IPv6 address enclosed by square brackets: bind_host=[abde::2] MTCE fails to connect to Barbican with such an IP address. Need to strip square brackets during barbican.conf file read in MTCE. Change-Id: I28ae627cd4998a5975d39b3edc466180e11aedf6 Closes-Bug: 1839870 Signed-off-by: Alex Kozyrev --- mtce-common/src/daemon/daemon_config.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mtce-common/src/daemon/daemon_config.cpp b/mtce-common/src/daemon/daemon_config.cpp index f3c4b540..88fc6a64 100644 --- a/mtce-common/src/daemon/daemon_config.cpp +++ b/mtce-common/src/daemon/daemon_config.cpp @@ -280,6 +280,13 @@ int barbican_config_handler ( void * user, else if (MATCH("DEFAULT", "bind_host")) // bind_host=192.168.204.2 { config_ptr->barbican_api_host = strdup(value); + // strip square brackets in case IPv6 format: bind_host=[abde::2] + if (config_ptr->barbican_api_host[0] == '[') + { + memmove(config_ptr->barbican_api_host, config_ptr->barbican_api_host+1, + strlen(config_ptr->barbican_api_host)); + config_ptr->barbican_api_host[strlen(config_ptr->barbican_api_host)-1] = '\0'; + } ilog("Barbican Host : %s\n", config_ptr->barbican_api_host ); } return (PASS);