18BOOLEAN mRedfishServiceStopped =
FALSE;
46 return EFI_INVALID_PARAMETER;
53 return EFI_UNSUPPORTED;
59 mRedfishServiceStopped =
TRUE;
65 if (EFI_ERROR (Status)) {
66 DEBUG ((DEBUG_ERROR,
"%a: fail to remove bootstrap credential: %r\n", __func__, Status));
69 DEBUG ((DEBUG_MANAGEABILITY,
"%a: bootstrap credential service stopped\n", __func__));
133 IN BOOLEAN DisableBootstrapControl,
134 IN OUT CHAR8 *BootstrapUsername, OPTIONAL
135 IN UINTN BootstrapUsernameSize,
136 IN OUT CHAR8 *BootstrapPassword, OPTIONAL
148 if (!DisableBootstrapControl && ((BootstrapUsername ==
NULL) || (BootstrapPassword ==
NULL))) {
149 return EFI_INVALID_PARAMETER;
152 if ((BootstrapUsernameSize != USERNAME_MAX_SIZE) || (BootstrapPasswordSize != PASSWORD_MAX_SIZE)) {
153 return EFI_INVALID_PARAMETER;
156 DEBUG ((DEBUG_VERBOSE,
"%a: Disable bootstrap control: 0x%x\n", __func__, DisableBootstrapControl));
164 CommandData.GroupExtensionId = REDFISH_IPMI_GROUP_EXTENSION;
165 CommandData.DisableBootstrapControl = (DisableBootstrapControl ? REDFISH_IPMI_BOOTSTRAP_CREDENTIAL_DISABLE : REDFISH_IPMI_BOOTSTRAP_CREDENTIAL_ENABLE);
167 ResponseSize =
sizeof (ResponseData);
177 IPMI_NETFN_GROUP_EXT,
178 REDFISH_IPMI_GET_BOOTSTRAP_CREDENTIALS_CMD,
179 (UINT8 *)&CommandData,
180 sizeof (CommandData),
181 (UINT8 *)&ResponseData,
185 if (EFI_ERROR (Status)) {
186 DEBUG ((DEBUG_ERROR,
"%a: IPMI transaction failure. Returning\n", __func__));
189 if (ResponseData.CompletionCode != IPMI_COMP_CODE_NORMAL) {
190 if (ResponseData.CompletionCode == REDFISH_IPMI_COMP_CODE_BOOTSTRAP_CREDENTIAL_DISABLED) {
191 DEBUG ((DEBUG_ERROR,
"%a: bootstrap credential support was disabled\n", __func__));
192 return EFI_ACCESS_DENIED;
195 DEBUG ((DEBUG_ERROR,
"%a: Completion code = 0x%x. Returning\n", __func__, ResponseData.CompletionCode));
196 return EFI_PROTOCOL_ERROR;
197 }
else if (ResponseData.GroupExtensionId != REDFISH_IPMI_GROUP_EXTENSION) {
198 DEBUG ((DEBUG_ERROR,
"%a: Group Extension Response = 0x%x. Returning\n", __func__, ResponseData.GroupExtensionId));
199 return EFI_DEVICE_ERROR;
201 if (BootstrapUsername !=
NULL) {
209 if (BootstrapPassword !=
NULL) {
210 CopyMem (BootstrapPassword, ResponseData.Password, PASSWORD_MAX_LENGTH);
214 BootstrapPassword[PASSWORD_MAX_LENGTH] =
'\0';
219 DEBUG ((DEBUG_MANAGEABILITY,
"%a: get bootstrap credential via IPMI: %r\n", __func__, Status));
241 IN OUT CHAR8 *BootstrapUsername,
242 IN UINTN BootstrapUsernameSize,
243 IN OUT CHAR8 *BootstrapPassword,
252 if ((BootstrapUsername ==
NULL) || (BootstrapPassword ==
NULL)) {
253 return EFI_INVALID_PARAMETER;
256 if ((BootstrapUsernameSize != USERNAME_MAX_SIZE) || (BootstrapPasswordSize != PASSWORD_MAX_SIZE)) {
257 return EFI_INVALID_PARAMETER;
262 CREDENTIAL_VARIABLE_NAME,
263 &gEfiRedfishVariableGuid,
267 if (EFI_ERROR (Status)) {
268 return EFI_NOT_FOUND;
274 return EFI_NOT_FOUND;
279 AsciiStrCpyS (BootstrapUsername, USERNAME_MAX_SIZE, CredentialVariable->Username);
280 AsciiStrCpyS (BootstrapPassword, PASSWORD_MAX_SIZE, CredentialVariable->Password);
282 ZeroMem (CredentialVariable->Username, USERNAME_MAX_SIZE);
283 ZeroMem (CredentialVariable->Password, PASSWORD_MAX_SIZE);
287 DEBUG ((DEBUG_MANAGEABILITY,
"%a: get bootstrap credential from variable\n", __func__));
306 IN CHAR8 *BootstrapUsername, OPTIONAL
307 IN CHAR8 *BootstrapPassword, OPTIONAL
315 if (!
DeleteVariable && ((BootstrapUsername ==
NULL) || (BootstrapUsername[0] ==
'\0'))) {
316 return EFI_INVALID_PARAMETER;
319 if (!
DeleteVariable && ((BootstrapPassword ==
NULL) || (BootstrapPassword[0] ==
'\0'))) {
320 return EFI_INVALID_PARAMETER;
327 CREDENTIAL_VARIABLE_NAME,
328 &gEfiRedfishVariableGuid,
332 if (!EFI_ERROR (Status)) {
335 CREDENTIAL_VARIABLE_NAME,
336 &gEfiRedfishVariableGuid,
337 EFI_VARIABLE_BOOTSERVICE_ACCESS,
350 ZeroMem (CredentialVariable.Username, USERNAME_MAX_SIZE);
351 ZeroMem (CredentialVariable.Password, PASSWORD_MAX_SIZE);
353 AsciiStrCpyS (CredentialVariable.Username, USERNAME_MAX_SIZE, BootstrapUsername);
354 AsciiStrCpyS (CredentialVariable.Password, PASSWORD_MAX_SIZE, BootstrapPassword);
356 Status =
gRT->SetVariable (
357 CREDENTIAL_VARIABLE_NAME,
358 &gEfiRedfishVariableGuid,
359 EFI_VARIABLE_BOOTSERVICE_ACCESS,
361 (VOID *)&CredentialVariable
364 ZeroMem (CredentialVariable.Username, USERNAME_MAX_SIZE);
365 ZeroMem (CredentialVariable.Password, PASSWORD_MAX_SIZE);
404 BOOLEAN DisableCredentialService;
406 if ((AuthMethod ==
NULL) || (UserId ==
NULL) || (Password ==
NULL)) {
407 return EFI_INVALID_PARAMETER;
412 DisableCredentialService =
PcdGetBool (PcdRedfishDisableBootstrapCredentialService);
414 if (mRedfishServiceStopped) {
415 DEBUG ((DEBUG_ERROR,
"%a: credential service is stopped due to security reason\n", __func__));
416 return EFI_ACCESS_DENIED;
422 if (*UserId ==
NULL) {
423 return EFI_OUT_OF_RESOURCES;
427 if (*Password ==
NULL) {
428 return EFI_OUT_OF_RESOURCES;
435 if (!EFI_ERROR (Status)) {
443 if (EFI_ERROR (Status)) {
444 DEBUG ((DEBUG_ERROR,
"%a: fail to get bootstrap credential: %r\n", __func__, Status));
448 if (DisableCredentialService) {
449 DEBUG ((DEBUG_MANAGEABILITY,
"%a: credential bootstrapping control disabled\n", __func__));
453 if (EFI_ERROR (Status)) {
454 DEBUG ((DEBUG_ERROR,
"%a: fail to cache bootstrap credential: %r\n", __func__, Status));
RETURN_STATUS EFIAPI AsciiStrCpyS(OUT CHAR8 *Destination, IN UINTN DestMax, IN CONST CHAR8 *Source)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE
@ ServiceStopTypeExitBootService
@ ServiceStopTypeNone
Stop Redfsih service without reason.
EDKII_REDFISH_AUTH_METHOD
@ AuthMethodHttpBasic
Basic authentication is required.
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STATUS EFIAPI IpmiSubmitCommand(IN UINT8 NetFunction, IN UINT8 Command, IN UINT8 *RequestData, IN UINT32 RequestDataSize, OUT UINT8 *ResponseData, IN OUT UINT32 *ResponseDataSize)
EFI_RUNTIME_SERVICES * gRT
#define DEBUG(Expression)
#define PcdGetBool(TokenName)
#define USERNAME_MAX_LENGTH
EFI_STATUS EFIAPI DeleteVariable(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid)
EFI_STATUS EFIAPI GetVariable2(IN CONST CHAR16 *Name, IN CONST EFI_GUID *Guid, OUT VOID **Value, OUT UINTN *Size OPTIONAL)