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