]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/UserIdentification/UserIdentifyManagerDxe/UserIdentifyManager.c
Update UID drivers to align with latest UEFI spec 2.3.1.
[mirror_edk2.git] / SecurityPkg / UserIdentification / UserIdentifyManagerDxe / UserIdentifyManager.c
index e846b71f035903562258638bc6dcbd8279c451b5..00826f75896b701d2d59cd63d711f2a43ebb53df 100644 (file)
@@ -1016,6 +1016,8 @@ ExpandUserProfile (
   @param[in]  ByType              If TRUE, Provider is credential class guid.\r
                                   If FALSE, Provider is provider guid.\r
   @param[in]  User                Points to user profile.\r
+  @param[in]  Delete              If TRUE, delete User from the provider; If FALSE, add  \r
+                                  User info from the provider.\r
 \r
   @retval EFI_SUCCESS      Add or delete record successfully.\r
   @retval Others           Fail to add or delete record.\r
@@ -1025,17 +1027,17 @@ EFI_STATUS
 ModifyProviderCredential (\r
   IN  EFI_GUID                                  *Provider,\r
   IN  BOOLEAN                                   ByType,\r
-  IN  USER_PROFILE_ENTRY                        *User\r
+  IN  USER_PROFILE_ENTRY                        *User,\r
+  IN  BOOLEAN                                   Delete\r
   )\r
 {\r
   UINTN                         Index;\r
-  EFI_USER_CREDENTIAL_PROTOCOL  *UserCredential;\r
+  EFI_USER_CREDENTIAL2_PROTOCOL *UserCredential;\r
   \r
   if (Provider == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  \r
   //\r
   // Find the specified credential provider.\r
   //\r
@@ -1045,7 +1047,11 @@ ModifyProviderCredential (
     //\r
     UserCredential = mProviderDb->Provider[Index];\r
     if (CompareGuid (&UserCredential->Identifier, Provider)) {\r
-      return UserCredential->Enroll (UserCredential, User);\r
+      if (Delete) {\r
+        return UserCredential->Delete (UserCredential, User);\r
+      } else {\r
+        return UserCredential->Enroll (UserCredential, User);\r
+      }\r
     }\r
   }\r
 \r
@@ -1059,9 +1065,11 @@ ModifyProviderCredential (
   Found the providers information in PolicyInfo, and then add or delete the user's credential\r
   record in the providers.\r
 \r
-  @param  User                    Points to user profile.\r
-  @param  PolicyInfo              Point to identification policy to be modified.\r
-  @param  InfoLen                 The length of PolicyInfo.\r
+  @param[in]  User                Points to user profile.\r
+  @param[in]  PolicyInfo          Point to identification policy to be modified.\r
+  @param[in]  InfoLen             The length of PolicyInfo.\r
+  @param[in]  Delete              If TRUE, delete User from the provider; If FALSE, add  \r
+                                  User info from the provider.\r
 \r
   @retval EFI_SUCCESS      Modify PolicyInfo successfully.\r
   @retval Others           Fail to modify PolicyInfo.\r
@@ -1071,7 +1079,8 @@ EFI_STATUS
 ModifyCredentialInfo (\r
   IN  USER_PROFILE_ENTRY                        *User,\r
   IN  UINT8                                     *PolicyInfo,\r
-  IN  UINTN                                     InfoLen\r
+  IN  UINTN                                     InfoLen,\r
+  IN  BOOLEAN                                   Delete\r
   )\r
 {\r
   EFI_STATUS                    Status;\r
@@ -1089,14 +1098,14 @@ ModifyCredentialInfo (
     Identity = (EFI_USER_INFO_IDENTITY_POLICY *) (PolicyInfo + TotalLen);\r
     switch (Identity->Type) {\r
     case EFI_USER_INFO_IDENTITY_CREDENTIAL_TYPE:\r
-      Status = ModifyProviderCredential ((EFI_GUID *) (Identity + 1), TRUE, User);\r
+      Status = ModifyProviderCredential ((EFI_GUID *) (Identity + 1), TRUE, User, Delete);\r
       if (EFI_ERROR (Status)) {\r
         return Status;\r
       }\r
       break;\r
 \r
     case EFI_USER_INFO_IDENTITY_CREDENTIAL_PROVIDER:\r
-      Status = ModifyProviderCredential ((EFI_GUID *) (Identity + 1), FALSE, User);\r
+      Status = ModifyProviderCredential ((EFI_GUID *) (Identity + 1), FALSE, User, Delete);\r
       if (EFI_ERROR (Status)) {\r
         return Status;\r
       }\r
@@ -1372,7 +1381,7 @@ ModifyUserIpInfo (
         //\r
         // The credential is NOT found in the old identity policy; add it.\r
         //\r
-        Status = ModifyCredentialInfo (User, (UINT8 *) Identity, Identity->Length);\r
+        Status = ModifyCredentialInfo (User, (UINT8 *) Identity, Identity->Length, FALSE);\r
         if (EFI_ERROR (Status)) {\r
           break;\r
         }\r
@@ -1399,7 +1408,7 @@ ModifyUserIpInfo (
             break;\r
           }\r
 \r
-          ModifyCredentialInfo (User, (UINT8 *) Identity, Identity->Length);\r
+          ModifyCredentialInfo (User, (UINT8 *) Identity, Identity->Length, TRUE);\r
           CredentialCount--;\r
         }\r
       }\r
@@ -1426,7 +1435,7 @@ ModifyUserIpInfo (
         //\r
         // The credential is found in the old identity policy, so delete the old credential first.\r
         //\r
-        Status = ModifyCredentialInfo (User, (UINT8 *) Identity, Identity->Length);\r
+        Status = ModifyCredentialInfo (User, (UINT8 *) Identity, Identity->Length, TRUE);\r
         if (EFI_ERROR (Status)) {\r
           //\r
           // Failed to delete old credential.\r
@@ -1438,7 +1447,7 @@ ModifyUserIpInfo (
         //\r
         // Add the new credential.\r
         //\r
-        Status = ModifyCredentialInfo (User, (UINT8 *) Identity, Identity->Length);\r
+        Status = ModifyCredentialInfo (User, (UINT8 *) Identity, Identity->Length, FALSE);\r
         if (EFI_ERROR (Status)) {\r
           //\r
           // Failed to enroll the user by new identification policy.\r
@@ -1462,7 +1471,7 @@ ModifyUserIpInfo (
         //\r
         // The credential is NOT found in the new identity policy. Delete the old credential.\r
         //\r
-        ModifyCredentialInfo (User, (UINT8 *) Identity, Identity->Length);\r
+        ModifyCredentialInfo (User, (UINT8 *) Identity, Identity->Length, TRUE);\r
       }\r
     }\r
     TotalLen += Identity->Length;\r
@@ -1526,7 +1535,8 @@ AddUserInfo (
     Status = ModifyCredentialInfo (\r
               User,\r
               (UINT8 *) ((EFI_USER_INFO *) Info + 1),\r
-              InfoSize - sizeof (EFI_USER_INFO)\r
+              InfoSize - sizeof (EFI_USER_INFO),\r
+              FALSE\r
               );\r
     if (EFI_ERROR (Status)) {\r
       return Status;\r
@@ -1672,7 +1682,7 @@ DelUserInfo (
   if (Info->InfoType == EFI_USER_INFO_IDENTIFIER_RECORD) {\r
     return EFI_ACCESS_DENIED;\r
   } else if (Info->InfoType == EFI_USER_INFO_IDENTITY_POLICY_RECORD) {\r
-    Status = ModifyCredentialInfo (User, (UINT8 *) (Info + 1), Info->InfoSize - sizeof (EFI_USER_INFO));\r
+    Status = ModifyCredentialInfo (User, (UINT8 *) (Info + 1), Info->InfoSize - sizeof (EFI_USER_INFO), TRUE);\r
     if (EFI_ERROR (Status)) {\r
       return Status;\r
     }\r
@@ -2331,7 +2341,7 @@ IdentifyByProviderId (
   EFI_HII_HANDLE                HiiHandle;\r
   EFI_GUID                      FormSetId;\r
   EFI_FORM_ID                   FormId;\r
-  EFI_USER_CREDENTIAL_PROTOCOL  *UserCredential;\r
+  EFI_USER_CREDENTIAL2_PROTOCOL *UserCredential;\r
 \r
   if (Provider == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -2523,7 +2533,7 @@ AddProviderSelection (
   EFI_STRING_ID                 ProvID;\r
   CHAR16                        *ProvStr;\r
   UINTN                         Index;\r
-  EFI_USER_CREDENTIAL_PROTOCOL  *UserCredential;\r
+  EFI_USER_CREDENTIAL2_PROTOCOL *UserCredential;\r
 \r
   for (Index = 0; Index < mProviderDb->Count; Index++) {\r
     UserCredential = mProviderDb->Provider[Index];\r
@@ -3152,7 +3162,7 @@ InitProviderInfo (
   HandleBuf   = NULL;\r
   Status = gBS->LocateHandleBuffer (\r
                   ByProtocol,\r
-                  &gEfiUserCredentialProtocolGuid,\r
+                  &gEfiUserCredential2ProtocolGuid,\r
                   NULL,\r
                   &HandleCount,\r
                   &HandleBuf\r
@@ -3166,8 +3176,8 @@ InitProviderInfo (
   //\r
   mProviderDb = AllocateZeroPool (\r
                   sizeof (CREDENTIAL_PROVIDER_INFO) - \r
-                  sizeof (EFI_USER_CREDENTIAL_PROTOCOL *) + \r
-                  HandleCount * sizeof (EFI_USER_CREDENTIAL_PROTOCOL *)\r
+                  sizeof (EFI_USER_CREDENTIAL2_PROTOCOL *) + \r
+                  HandleCount * sizeof (EFI_USER_CREDENTIAL2_PROTOCOL *)\r
                   );\r
   if (mProviderDb == NULL) {\r
     FreePool (HandleBuf);\r
@@ -3178,7 +3188,7 @@ InitProviderInfo (
   for (Index = 0; Index < HandleCount; Index++) {\r
     Status = gBS->HandleProtocol (\r
                     HandleBuf[Index],\r
-                    &gEfiUserCredentialProtocolGuid,\r
+                    &gEfiUserCredential2ProtocolGuid,\r
                     (VOID **) &mProviderDb->Provider[Index]\r
                     );\r
     if (EFI_ERROR (Status)) {\r
@@ -3513,7 +3523,7 @@ IdentifyUser (
   EFI_CREDENTIAL_LOGON_FLAGS    AutoLogon;\r
   EFI_USER_INFO                 *IdentifyInfo;\r
   EFI_USER_INFO_IDENTITY_POLICY *Identity;\r
-  EFI_USER_CREDENTIAL_PROTOCOL  *UserCredential;\r
+  EFI_USER_CREDENTIAL2_PROTOCOL *UserCredential;\r
   USER_PROFILE_ENTRY            *UserEntry;\r
 \r
   //\r
@@ -4114,7 +4124,7 @@ UserProfileSetInfo (
   credential and add it.\r
 \r
   @param[in] This          Points to this instance of the EFI_USER_MANAGER_PROTOCOL.\r
-  @param[in] Changed       Handle on which is installed an instance of the EFI_USER_CREDENTIAL_PROTOCOL \r
+  @param[in] Changed       Handle on which is installed an instance of the EFI_USER_CREDENTIAL2_PROTOCOL \r
                            where the user has changed.\r
 \r
   @retval EFI_SUCCESS      The User Identity Manager has handled the notification.\r
@@ -4130,7 +4140,7 @@ UserProfileNotify (
   )\r
 {\r
   EFI_STATUS                    Status;\r
-  EFI_USER_CREDENTIAL_PROTOCOL  *Provider;\r
+  EFI_USER_CREDENTIAL2_PROTOCOL *Provider;\r
   EFI_USER_INFO_IDENTIFIER      UserId;\r
   EFI_USER_INFO_HANDLE          UserInfo;\r
   EFI_USER_INFO_HANDLE          UserInfo2;\r
@@ -4144,7 +4154,7 @@ UserProfileNotify (
   \r
   Status = gBS->HandleProtocol (\r
                   Changed,\r
-                  &gEfiUserCredentialProtocolGuid,\r
+                  &gEfiUserCredential2ProtocolGuid,\r
                   (VOID **) &Provider\r
                   );\r
   if (EFI_ERROR (Status)) {\r