Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clearing up Door Lock users and credentials #37900

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/app/clusters/door-lock-server/door-lock-server.cpp
Original file line number Diff line number Diff line change
@@ -2173,6 +2173,16 @@ bool DoorLockServer::clearFabricFromUsers(chip::EndpointId endpointId, chip::Fab
user.lastModifiedBy = kUndefinedFabricIndex;
}

if (user.createdBy == kUndefinedFabricIndex && user.lastModifiedBy == kUndefinedFabricIndex)
Copy link
Contributor

@bzbarsky-apple bzbarsky-apple Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per spec, users/credentials should not be removed on fabric removal.

If they should be removed on factory reset (which is different from fabric removal), then that should happen in whatever code handles factory reset.

Of course if you think the spec here should change please bring that up in the relevant TT. But the door lock TT was very explicit about not removing users/credentials on fabric removal.

{
user.userName = ""_span;
user.userUniqueId = 0;
user.userStatus = UserStatusEnum::kAvailable;
user.userType = UserTypeEnum::kUnrestrictedUser;
user.credentialRule = CredentialRuleEnum::kSingle;
user.credentials = {};
}

if (!emberAfPluginDoorLockSetUser(endpointId, userIndex, user.createdBy, user.lastModifiedBy, user.userName,
user.userUniqueId, user.userStatus, user.userType, user.credentialRule,
user.credentials.data(), user.credentials.size()))
@@ -3309,6 +3319,12 @@ bool DoorLockServer::clearFabricFromCredentials(chip::EndpointId endpointId, Cre
credential.lastModifiedBy = kUndefinedFabricIndex;
}

if (credential.createdBy == kUndefinedFabricIndex && credential.lastModifiedBy == kUndefinedFabricIndex)
{
credential.status = DlCredentialStatus::kAvailable;
credential.credentialData = {};
}

if (!emberAfPluginDoorLockSetCredential(endpointId, credentialIndex, credential.createdBy, credential.lastModifiedBy,
credential.status, credential.credentialType, credential.credentialData))
{