From 6ea63504fd8c71c3586abb4c0747aa1c6a39f148 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Thu, 4 Feb 2021 22:46:58 +0100 Subject: [PATCH] Don't allow meshlink_join() when the storage policy is DISABLED. It does not make sense to allow this, since we need to write host config files during a join, otherwise MeshLink's directory would be left in an invalid state. --- src/meshlink.c | 5 +++++ src/meshlink.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/meshlink.c b/src/meshlink.c index b812d273..91fefa0c 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -3022,6 +3022,11 @@ bool meshlink_join(meshlink_handle_t *mesh, const char *invitation) { return false; } + if(mesh->storage_policy == MESHLINK_STORAGE_DISABLED) { + meshlink_errno = MESHLINK_EINVAL; + return false; + } + join_state_t state = { .mesh = mesh, .sock = -1, diff --git a/src/meshlink.h b/src/meshlink.h index 0cbe84e4..fdab9b38 100644 --- a/src/meshlink.h +++ b/src/meshlink.h @@ -1106,6 +1106,7 @@ char *meshlink_invite(struct meshlink_handle *mesh, struct meshlink_submesh *sub * After a successfully accepted invitation, the name of the local node may have changed. * * This function may only be called on a mesh that has not been started yet and which is not already part of an existing mesh. + * It is not valid to call this function when the storage policy set to MESHLINK_STORAGE_DISABLED. * * This function is blocking. It can take several seconds before it returns. * There is no guarantee it will perform a successful join. -- 2.39.5