X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=SecurityPkg%2FUserIdentification%2FUserProfileManagerDxe%2FUserProfileDelete.c;h=af5d3109dd7b8b32c33a57b73c8d4d39692c9e27;hp=fffc93beab9a7e269e9e815da4c5c7d20d029646;hb=28ce4cb3590bc3aaa91c3be75429d4e8722415e2;hpb=a0c56a8219ec268d8ac4e051035f1636545cc478 diff --git a/SecurityPkg/UserIdentification/UserProfileManagerDxe/UserProfileDelete.c b/SecurityPkg/UserIdentification/UserProfileManagerDxe/UserProfileDelete.c index fffc93beab..af5d3109dd 100644 --- a/SecurityPkg/UserIdentification/UserProfileManagerDxe/UserProfileDelete.c +++ b/SecurityPkg/UserIdentification/UserProfileManagerDxe/UserProfileDelete.c @@ -1,13 +1,13 @@ /** @file The functions to delete a user profile. - -Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at + +Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ @@ -17,12 +17,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. /** Get the username from the specified user. - @param[in] User Handle of a user profile. + @param[in] User Handle of a user profile. @retval EFI_STRING_ID The String Id of the user's username. **/ -EFI_STRING_ID +EFI_STRING_ID GetUserName ( IN EFI_USER_PROFILE_HANDLE User ) @@ -35,14 +35,14 @@ GetUserName ( UINTN NameLen; CHAR16 UserName[USER_NAME_LENGTH]; EFI_STRING_ID UserId; - + // // Allocate user information memory. // MemSize = sizeof (EFI_USER_INFO) + 63; Info = AllocateZeroPool (MemSize); ASSERT (Info != NULL); - + // // Get user name information. // @@ -116,7 +116,7 @@ GetUserName ( /** Add a username item in form. - @param[in] User Points to the user profile whose username is added. + @param[in] User Points to the user profile whose username is added. @param[in] Index The index of the user in the user name list @param[in] OpCodeHandle Points to container for dynamic created opcodes. @@ -137,7 +137,7 @@ AddUserToForm ( if (NameId == 0) { return ; } - + // // Create user name option. // @@ -173,7 +173,7 @@ AddUserToForm ( /** Delete the user specified by UserIndex in user profile database. - @param[in] UserIndex The index of user in the user name list + @param[in] UserIndex The index of user in the user name list to be deleted. **/ @@ -185,6 +185,9 @@ DeleteUser ( EFI_STATUS Status; EFI_USER_PROFILE_HANDLE User; EFI_INPUT_KEY Key; + EFI_USER_INFO_HANDLE UserInfo; + EFI_USER_INFO *Info; + UINTN InfoSize; // // Find specified user profile and delete it. @@ -194,7 +197,7 @@ DeleteUser ( if (EFI_ERROR (Status)) { goto Done; } - + while (UserIndex > 1) { Status = mUserManager->GetNext (mUserManager, &User); if (EFI_ERROR (Status)) { @@ -204,6 +207,32 @@ DeleteUser ( } if (UserIndex == 1) { + // + // Get the identification policy. + // + Status = FindInfoByType (User, EFI_USER_INFO_IDENTITY_POLICY_RECORD, &UserInfo); + if (EFI_ERROR (Status)) { + goto Done; + } + + InfoSize = 0; + Info = NULL; + Status = mUserManager->GetInfo (mUserManager, User, UserInfo, Info, &InfoSize); + if (Status == EFI_BUFFER_TOO_SMALL) { + Info = AllocateZeroPool (InfoSize); + if (Info == NULL) { + goto Done; + } + Status = mUserManager->GetInfo (mUserManager, User, UserInfo, Info, &InfoSize); + } + + // + // Delete the user on the credential providers by its identification policy. + // + ASSERT (Info != NULL); + DeleteCredentialFromProviders ((UINT8 *)(Info + 1), Info->InfoSize - sizeof (EFI_USER_INFO), User); + FreePool (Info); + Status = mUserManager->Delete (mUserManager, User); if (EFI_ERROR (Status)) { goto Done; @@ -216,7 +245,7 @@ DeleteUser ( L"Please Press Any Key to Continue ...", NULL ); - return ; + return ; } Done: