Skip to contentSkip to conversation

mesh: Allow to finish key refresh when no AppKeys are stored

PATCH Applied Inga Stotland 2 participants 2 messages Feb 5, 2020 – Feb 7, 2020 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mesh: Allow to finish key refresh when no AppKeys are stored

This handles a case when a Key Refresh procedure is in place with no application keys stored in the keyring. When KR procedure is finalized, the check for the presence of AppKeys storage directory does not return failure if the directory does not exist.

Also, remove duplicate include.

---
 mesh/keyring.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
mesh/keyring.c +5 -2
index 41cb2e980..4a6f9f27d 100644
@@ -24,10 +24,10 @@
 #define _GNU_SOURCE
 #include <fcntl.h>
 #include <dirent.h>
+#include <errno.h>
 #include <limits.h>
 #include <stdio.h>
 #include <unistd.h>
-#include <dirent.h>
 
 #include <sys/stat.h>
 
@@ -166,7 +166,10 @@ bool keyring_finalize_app_keys(struct mesh_node *node, uint16_t net_idx)
 	snprintf(key_dir, PATH_MAX, "%s%s", node_path, app_key_dir);
 	dir = opendir(key_dir);
 	if (!dir) {
-		l_error("Failed to App Key storage directory: %s", key_dir);
+		if (errno == ENOENT)
+			return true;
+
+		l_error("Failed to open AppKey storage directory: %s", key_dir);
 		return false;
 	}
 
Signature · 1 line
2.21.1
Applied
#1 lore raw

Applied

Quoted 38 lines · Inga Stotland

This handles a case when a Key Refresh procedure is in place with no application keys stored in the keyring. When KR procedure is finalized, the check for the presence of AppKeys storage directory does not return failure if the directory does not exist.

Also, remove duplicate include.

---
 mesh/keyring.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
mesh/keyring.c +5 -2
index 41cb2e980..4a6f9f27d 100644
@@ -24,10 +24,10 @@
 #define _GNU_SOURCE
 #include <fcntl.h>
 #include <dirent.h>
+#include <errno.h>
 #include <limits.h>
 #include <stdio.h>
 #include <unistd.h>
-#include <dirent.h>
 
 #include <sys/stat.h>
 
@@ -166,7 +166,10 @@ bool keyring_finalize_app_keys(struct mesh_node *node, uint16_t net_idx)
 	snprintf(key_dir, PATH_MAX, "%s%s", node_path, app_key_dir);
 	dir = opendir(key_dir);
 	if (!dir) {
-		l_error("Failed to App Key storage directory: %s", key_dir);
+		if (errno == ENOENT)
+			return true;
+
+		l_error("Failed to open AppKey storage directory: %s", key_dir);
 		return false;
 	}