Skip to content

Commit

Permalink
Add RemoveFabric to AccessControl (#16685)
Browse files Browse the repository at this point in the history
Use the "public" API to delete entries for a fabric.

Tested (on Linux using chip-all-clusters-app and chip-tool) by
commissioning on three fabrics, with 3, 2, and 2 distinct ACLs,
then removing the second (middle) fabric, and verifying that
the remaining 5 ACLs are preserved, even after restart.

Part of issue #13876 (fabric removal and factory reset)
  • Loading branch information
mlepage-google authored and pull[bot] committed Jan 26, 2024
1 parent db160db commit 9c0b6f1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/access/AccessControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,22 @@ CHIP_ERROR AccessControl::Finish()
return retval;
}

CHIP_ERROR AccessControl::RemoveFabric(FabricIndex fabricIndex)
{
ChipLogProgress(DataManagement, "AccessControl: removing fabric %u", fabricIndex);

CHIP_ERROR err;
do
{
err = DeleteEntry(0, &fabricIndex);
} while (err == CHIP_NO_ERROR);

// Sentinel error is OK, just means there was no such entry.
ReturnErrorCodeIf(err != CHIP_ERROR_SENTINEL, err);

return CHIP_NO_ERROR;
}

CHIP_ERROR AccessControl::Check(const SubjectDescriptor & subjectDescriptor, const RequestPath & requestPath,
Privilege requestPrivilege)
{
Expand Down
2 changes: 2 additions & 0 deletions src/access/AccessControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,8 @@ class AccessControl
return mDelegate->DeleteEntry(index, fabricIndex);
}

CHIP_ERROR RemoveFabric(FabricIndex fabricIndex);

/**
* Iterates over entries in the access control list.
*
Expand Down
1 change: 1 addition & 0 deletions src/app/server/Server.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ class Server
{
groupDataProvider->RemoveFabric(fabricIndex);
}
Access::GetAccessControl().RemoveFabric(fabricIndex);
};
void OnFabricRetrievedFromStorage(FabricInfo * fabricInfo) override { (void) fabricInfo; }

Expand Down

0 comments on commit 9c0b6f1

Please sign in to comment.