Lockdown PIN redaction, a build guard, and favorite compaction (#11285)
* Redact the pairing PIN from unauthorized lockdown clients * Fail the build when PacketAPI would bypass the lockdown gate * Compact kept favorites when resetting the node database * Make the compaction loop reference const
This commit is contained in:
co-authored by
GitHub
parent
21e3a583bd
commit
fc67590317
+11
-7
@@ -1607,15 +1607,19 @@ void NodeDB::resetNodes(bool keepFavorites)
|
|||||||
numMeshNodes = 1;
|
numMeshNodes = 1;
|
||||||
if (keepFavorites) {
|
if (keepFavorites) {
|
||||||
LOG_INFO("Clearing node database - preserving favorites");
|
LOG_INFO("Clearing node database - preserving favorites");
|
||||||
for (size_t i = 0; i < meshNodes->size(); i++) {
|
// Compact favorites into contiguous low slots: zeroing in place leaves one above
|
||||||
meshtastic_NodeInfoLite &node = meshNodes->at(i);
|
// numMeshNodes, invisible to every `i < numMeshNodes` scan yet still serialized to flash.
|
||||||
if (i > 0 && !nodeInfoLiteIsFavorite(&node)) {
|
for (size_t i = 1; i < meshNodes->size(); i++) {
|
||||||
eraseNodeSatellites(node.num);
|
const meshtastic_NodeInfoLite &node = meshNodes->at(i);
|
||||||
node = meshtastic_NodeInfoLite();
|
if (nodeInfoLiteIsFavorite(&node)) {
|
||||||
} else {
|
if (numMeshNodes != i)
|
||||||
|
meshNodes->at(numMeshNodes) = node;
|
||||||
numMeshNodes += 1;
|
numMeshNodes += 1;
|
||||||
|
} else if (node.num) {
|
||||||
|
eraseNodeSatellites(node.num);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
std::fill(nodeDatabase.nodes.begin() + numMeshNodes, nodeDatabase.nodes.end(), meshtastic_NodeInfoLite());
|
||||||
} else {
|
} else {
|
||||||
LOG_INFO("Clearing node database - removing favorites");
|
LOG_INFO("Clearing node database - removing favorites");
|
||||||
for (size_t i = 1; i < meshNodes->size(); i++) {
|
for (size_t i = 1; i < meshNodes->size(); i++) {
|
||||||
|
|||||||
@@ -767,6 +767,12 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
|
|||||||
LOG_DEBUG("Send config: bluetooth");
|
LOG_DEBUG("Send config: bluetooth");
|
||||||
fromRadioScratch.config.which_payload_variant = meshtastic_Config_bluetooth_tag;
|
fromRadioScratch.config.which_payload_variant = meshtastic_Config_bluetooth_tag;
|
||||||
fromRadioScratch.config.payload_variant.bluetooth = config.bluetooth;
|
fromRadioScratch.config.payload_variant.bluetooth = config.bluetooth;
|
||||||
|
#ifdef MESHTASTIC_PHONEAPI_ACCESS_CONTROL
|
||||||
|
if (!getAdminAuthorized()) {
|
||||||
|
// The pairing PIN is a shared secret; never expose it to an unauthenticated client.
|
||||||
|
fromRadioScratch.config.payload_variant.bluetooth.fixed_pin = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case meshtastic_Config_security_tag:
|
case meshtastic_Config_security_tag:
|
||||||
LOG_DEBUG("Send config: security");
|
LOG_DEBUG("Send config: security");
|
||||||
|
|||||||
@@ -6,6 +6,12 @@
|
|||||||
#include "RadioInterface.h"
|
#include "RadioInterface.h"
|
||||||
#include "modules/NodeInfoModule.h"
|
#include "modules/NodeInfoModule.h"
|
||||||
|
|
||||||
|
#ifdef MESHTASTIC_PHONEAPI_ACCESS_CONTROL
|
||||||
|
// receivePacket() dispatches ToRadio straight to MeshService, bypassing handleToRadioPacket and so
|
||||||
|
// the lockdown admin gate. Fail the build rather than silently ship an admin-auth bypass.
|
||||||
|
#error "USE_PACKET_API is incompatible with MESHTASTIC_PHONEAPI_ACCESS_CONTROL (PacketAPI bypasses the lockdown admin gate)"
|
||||||
|
#endif
|
||||||
|
|
||||||
PacketAPI *packetAPI = nullptr;
|
PacketAPI *packetAPI = nullptr;
|
||||||
|
|
||||||
PacketAPI *PacketAPI::create(PacketServer *_server)
|
PacketAPI *PacketAPI::create(PacketServer *_server)
|
||||||
|
|||||||
Reference in New Issue
Block a user