From 0c7eda6fe0c429819013671737890ee2d9a21c1a 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 da730551..8b9e195f 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -3025,6 +3025,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 3be94710..7960d310 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