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:
Thomas Göttgens
2026-07-30 11:13:11 +00:00
committed by GitHub
co-authored by GitHub
parent 21e3a583bd
commit fc67590317
3 changed files with 23 additions and 7 deletions
+11 -7
View File
@@ -1607,15 +1607,19 @@ void NodeDB::resetNodes(bool keepFavorites)
numMeshNodes = 1;
if (keepFavorites) {
LOG_INFO("Clearing node database - preserving favorites");
for (size_t i = 0; i < meshNodes->size(); i++) {
meshtastic_NodeInfoLite &node = meshNodes->at(i);
if (i > 0 && !nodeInfoLiteIsFavorite(&node)) {
eraseNodeSatellites(node.num);
node = meshtastic_NodeInfoLite();
} else {
// Compact favorites into contiguous low slots: zeroing in place leaves one above
// numMeshNodes, invisible to every `i < numMeshNodes` scan yet still serialized to flash.
for (size_t i = 1; i < meshNodes->size(); i++) {
const meshtastic_NodeInfoLite &node = meshNodes->at(i);
if (nodeInfoLiteIsFavorite(&node)) {
if (numMeshNodes != i)
meshNodes->at(numMeshNodes) = node;
numMeshNodes += 1;
} else if (node.num) {
eraseNodeSatellites(node.num);
}
};
}
std::fill(nodeDatabase.nodes.begin() + numMeshNodes, nodeDatabase.nodes.end(), meshtastic_NodeInfoLite());
} else {
LOG_INFO("Clearing node database - removing favorites");
for (size_t i = 1; i < meshNodes->size(); i++) {
+6
View File
@@ -767,6 +767,12 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
LOG_DEBUG("Send config: bluetooth");
fromRadioScratch.config.which_payload_variant = meshtastic_Config_bluetooth_tag;
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;
case meshtastic_Config_security_tag:
LOG_DEBUG("Send config: security");
+6
View File
@@ -6,6 +6,12 @@
#include "RadioInterface.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::create(PacketServer *_server)