Add a read-only password for repeaters and sensors
ro.password grants the read-only role at login. These logins are never saved, cannot evict saved ACL entries, and on a sensor get no location. Sensors also honor guest.password now (blank disables guest login).
This commit is contained in:
1 parent
f74879e829
commit
50b7dd7301
8 files changed
+113
-24
No files matched your search
@@ -61,7 +61,7 @@ void ClientACL::save(FILESYSTEM* fs, bool (*filter)(ClientInfo*)) {
|
||||
|
||||
for (int i = 0; i < num_clients; i++) {
|
||||
auto c = &clients[i];
|
||||
if (c->permissions == 0 || (filter && !filter(c))) continue; // skip deleted entries, or by filter function
|
||||
if (c->permissions == 0 || (c->permissions & PERM_ACL_TRANSIENT) || (filter && !filter(c))) continue; // skip deleted/transient entries, or by filter function
|
||||
|
||||
bool success = (file.write(c->id.pub_key, 32) == 32);
|
||||
success = success && (file.write((uint8_t *) &c->permissions, 1) == 1);
|
||||
@@ -94,11 +94,13 @@ ClientInfo* ClientACL::getClient(const uint8_t* pubkey, int key_len) {
|
||||
return NULL; // not found
|
||||
}
|
||||
|
||||
ClientInfo* ClientACL::putClient(const mesh::Identity& id, uint8_t init_perms) {
|
||||
ClientInfo* ClientACL::putClient(const mesh::Identity& id, uint8_t init_perms, bool shared_pw) {
|
||||
uint32_t min_time = 0xFFFFFFFF;
|
||||
ClientInfo* oldest = NULL;
|
||||
for (int i = 0; i < num_clients; i++) {
|
||||
if (id.matches(clients[i].id)) return &clients[i]; // already known
|
||||
bool unsaved = clients[i].permissions == 0 || (clients[i].permissions & PERM_ACL_TRANSIENT);
|
||||
if (shared_pw && !unsaved) continue; // shared password logins can only evict other unsaved entries
|
||||
if (!clients[i].isAdmin() && clients[i].last_activity < min_time) {
|
||||
oldest = &clients[i];
|
||||
min_time = oldest->last_activity;
|
||||
@@ -109,7 +111,7 @@ ClientInfo* ClientACL::putClient(const mesh::Identity& id, uint8_t init_perms) {
|
||||
if (num_clients < MAX_CLIENTS) {
|
||||
c = &clients[num_clients++];
|
||||
} else {
|
||||
if (oldest == NULL) return NULL; // every entry is an admin, so don't evict
|
||||
if (oldest == NULL) return NULL; // every entry is an admin (or saved), so don't evict
|
||||
c = oldest; // evict least active contact
|
||||
}
|
||||
memset(c, 0, sizeof(*c));
|
||||
|
||||
Reference in new issue
Block a user