Changeset 91457 in vbox for trunk/src/VBox/Main
- Timestamp:
- Sep 29, 2021 2:08:32 PM (3 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/idl/VirtualBox.xidl
r91416 r91457 6016 6016 </enum> 6017 6017 6018 <enum 6019 name="UefiVariableAttributes" 6020 uuid="cda505ec-b444-4aef-b55c-b687717bdac5" 6021 > 6022 <desc> 6023 Possible variable attributes. More than one flag may be set. 6024 <see><link to="IUefiVariableStore"/></see> 6025 </desc> 6026 6027 <const name="None" value="0"> 6028 <desc>No attributes set.</desc> 6029 </const> 6030 <const name="NonVolatile" value="0x01"> 6031 <desc>Variable is stored in non volatile storage.</desc> 6032 </const> 6033 <const name="BootServiceAccess" value="0x02"> 6034 <desc>Variable can be accessed from the boot services.</desc> 6035 </const> 6036 <const name="RuntimeAccess" value="0x04"> 6037 <desc>Variable can be accessed from the runtime.</desc> 6038 </const> 6039 <const name="HwErrorRecord" value="0x08"> 6040 <desc>Variable contains a hardware error record.</desc> 6041 </const> 6042 <const name="AuthWriteAccess" value="0x100"> 6043 <desc>Writing to this variable requires an authenticated source.</desc> 6044 </const> 6045 <const name="AuthTimeBasedWriteAccess" value="0x200"> 6046 <desc>Variable was written with a time based authentication.</desc> 6047 </const> 6048 <const name="AuthAppendWrite" value="0x400"> 6049 <desc>The variable can be appended only.</desc> 6050 </const> 6051 </enum> 6052 6018 6053 <interface 6019 6054 name="IUefiVariableStore" extends="$unknown" 6020 uuid=" f39d5888-9009-4e77-94b5-9cdcfc1859c3"6055 uuid="d134c6b6-4479-430d-bb73-68a452ba3e67" 6021 6056 wsmap="managed" 6022 6057 reservedMethods="10" reservedAttributes="5" … … 6028 6063 </desc> 6029 6064 6065 <attribute name="secureBootEnabled" type="boolean"> 6066 <desc>Flag whether secure boot is currently enabled for the VM.</desc> 6067 </attribute> 6068 6030 6069 <method name="addVariable"> 6031 6070 <desc>Adds a new variable to the non volatile storage area.</desc> … … 6036 6075 <desc>UUID of the variable owner.</desc> 6037 6076 </param> 6077 <param name="attributes" type="UefiVariableAttributes" safearray="yes" dir="in"> 6078 <desc>Attributes of the variable.</desc> 6079 </param> 6038 6080 <param name="data" type="octet" dir="in" safearray="yes"> 6039 6081 <desc>The variable data.</desc> … … 6056 6098 <desc>Name of the variable.</desc> 6057 6099 </param> 6058 <param name="owner" type="uuid" mod="string" dir="in">6059 <desc>UUID of the variable owner.</desc>6060 </param>6061 6100 <param name="data" type="octet" dir="in" safearray="yes"> 6062 6101 <desc>The new variable data.</desc> … … 6072 6111 <desc>UUID of the variable owner returned on success.</desc> 6073 6112 </param> 6113 <param name="attributes" type="UefiVariableAttributes" safearray="yes" dir="out"> 6114 <desc>Attributes of the variable.</desc> 6115 </param> 6074 6116 <param name="data" type="octet" dir="out" safearray="yes"> 6075 6117 <desc>The variable data returned on success.</desc> … … 6087 6129 <desc>UUID of the variable owners returned on success.</desc> 6088 6130 </param> 6131 </method> 6132 6133 <method name="enrollOraclePlatformKey"> 6134 <desc> 6135 Enroll the default platform key from Oracle for enabling Secure Boot. 6136 </desc> 6089 6137 </method> 6090 6138 -
trunk/src/VBox/Main/include/UefiVariableStoreImpl.h
r91396 r91457 49 49 50 50 // Wrapped NVRAM store properties 51 HRESULT getSecureBootEnabled(BOOL *pfEnabled); 52 HRESULT setSecureBootEnabled(BOOL fEnabled); 51 53 52 54 // Wrapped NVRAM store members 53 HRESULT addVariable(const com::Utf8Str &aName, const com::Guid &aOwnerUuid, const std::vector<BYTE> &aData); 55 HRESULT addVariable(const com::Utf8Str &aName, const com::Guid &aOwnerUuid, const std::vector<UefiVariableAttributes_T> &aAttributes, 56 const std::vector<BYTE> &aData); 54 57 HRESULT deleteVariable(const com::Utf8Str &aName, const com::Guid &aOwnerUuid); 55 HRESULT changeVariable(const com::Utf8Str &aName, const com::Guid &aOwnerUuid, const std::vector<BYTE> &aData); 56 HRESULT queryVariableByName(const com::Utf8Str &aName, com::Guid &aOwnerUuid, std::vector<BYTE> &aData); 58 HRESULT changeVariable(const com::Utf8Str &aName, const std::vector<BYTE> &aData); 59 HRESULT queryVariableByName(const com::Utf8Str &aName, com::Guid &aOwnerUuid, std::vector<UefiVariableAttributes_T> &aAttributes, 60 std::vector<BYTE> &aData); 57 61 HRESULT queryVariables(std::vector<com::Utf8Str> &aNames, std::vector<com::Guid> &aOwnerUuids); 62 HRESULT enrollOraclePlatformKey(void); 58 63 HRESULT enrollPlatformKey(const std::vector<BYTE> &aData, const com::Guid &aOwnerUuid); 59 64 HRESULT addKek(const std::vector<BYTE> &aData, const com::Guid &aOwnerUuid, SignatureType_T enmSignatureType); … … 63 68 64 69 int i_uefiVarStoreSetVarAttr(const char *pszVar, uint32_t fAttr); 70 int i_uefiVarStoreQueryVarAttr(const char *pszVar, uint32_t *pfAttr); 71 int i_uefiVarStoreQueryVarSz(const char *pszVar, uint64_t *pcbVar); 72 int i_uefiVarStoreQueryVarOwnerUuid(const char *pszVar, PRTUUID pUuid); 73 uint32_t i_uefiVarAttrToMask(const std::vector<UefiVariableAttributes_T> &aAttributes); 74 void i_uefiAttrMaskToVec(uint32_t fAttr, std::vector<UefiVariableAttributes_T> &aAttributes); 65 75 66 76 HRESULT i_uefiVarStoreAddVar(PCEFI_GUID pGuid, const char *pszVar, uint32_t fAttr, PRTVFSFILE phVfsFile); 77 HRESULT i_uefiVarStoreSetVar(PCEFI_GUID pGuid, const char *pszVar, uint32_t fAttr, const void *pvData, size_t cbData); 78 HRESULT i_uefiVarStoreQueryVar(const char *pszVar, void *pvData, size_t cbData); 67 79 HRESULT i_uefiSigDbAddSig(RTEFISIGDB hEfiSigDb, const void *pvData, size_t cbData, const com::Guid &aOwnerUuid, SignatureType_T enmSignatureType); 68 80 HRESULT i_uefiVarStoreAddSignatureToDbVec(PCEFI_GUID pGuid, const char *pszDb, const std::vector<BYTE> &aData, -
trunk/src/VBox/Main/src-all/NvramStoreImpl.cpp
r91434 r91457 386 386 387 387 /* We need a write lock because of the lazy initialization. */ 388 AutoReadLock mlock(m->pParent COMMA_LOCKVAL_SRC_POS); 388 389 AutoWriteLock wlock(this COMMA_LOCKVAL_SRC_POS); 390 391 if (m->pParent->i_getFirmwareType() == FirmwareType_BIOS) 392 return setError(VBOX_E_NOT_SUPPORTED, tr("The selected firmware type doesn't support a UEFI variable store")); 389 393 390 394 /* Load the NVRAM file first if it isn't already. */ -
trunk/src/VBox/Main/src-server/UefiVariableStoreImpl.cpp
r91409 r91457 141 141 142 142 143 HRESULT UefiVariableStore::addVariable(const com::Utf8Str &aName, const com::Guid &aOwnerUuid, const std::vector<BYTE> &aData) 144 { 145 RT_NOREF(aName, aOwnerUuid, aData); 146 return E_NOTIMPL; 143 HRESULT UefiVariableStore::getSecureBootEnabled(BOOL *pfEnabled) 144 { 145 /* the machine needs to be mutable */ 146 AutoMutableStateDependency adep(m->pMachine); 147 if (FAILED(adep.rc())) return adep.rc(); 148 149 AutoReadLock rlock(this COMMA_LOCKVAL_SRC_POS); 150 151 HRESULT hrc = S_OK; 152 uint64_t cbVar = 0; 153 int vrc = i_uefiVarStoreQueryVarSz("PK", &cbVar); 154 if (RT_SUCCESS(vrc)) 155 { 156 *pfEnabled = TRUE; 157 158 /* Check the SecureBootEnable variable for the override. */ 159 vrc = i_uefiVarStoreQueryVarSz("SecureBootEnable", &cbVar); 160 if (RT_SUCCESS(vrc)) 161 { 162 if (cbVar == sizeof(uint8_t)) 163 { 164 uint8_t bVar = 0; 165 hrc = i_uefiVarStoreQueryVar("SecureBootEnable", &bVar, sizeof(bVar)); 166 if (SUCCEEDED(hrc)) 167 *pfEnabled = bVar == 0x0 ? FALSE : TRUE; 168 } 169 else 170 hrc = setError(E_FAIL, tr("The 'SecureBootEnable' variable size is bogus (expected 1, got %llu)"), cbVar); 171 } 172 else if (vrc != VERR_FILE_NOT_FOUND) 173 hrc = setError(E_FAIL, tr("Failed to query the 'SecureBootEnable' variable size: %Rrc"), vrc); 174 } 175 else if (vrc == VERR_FILE_NOT_FOUND) /* No platform key means no secure boot. */ 176 *pfEnabled = FALSE; 177 else 178 hrc = setError(E_FAIL, tr("Failed to query the platform key variable size: %Rrc"), vrc); 179 180 return hrc; 181 } 182 183 184 HRESULT UefiVariableStore::setSecureBootEnabled(BOOL fEnabled) 185 { 186 /* the machine needs to be mutable */ 187 AutoMutableStateDependency adep(m->pMachine); 188 if (FAILED(adep.rc())) return adep.rc(); 189 190 AutoWriteLock wlock(this COMMA_LOCKVAL_SRC_POS); 191 192 EFI_GUID GuidSecureBootEnable = EFI_SECURE_BOOT_ENABLE_DISABLE_GUID; 193 uint64_t cbVar = 0; 194 int vrc = i_uefiVarStoreQueryVarSz("PK", &cbVar); 195 if (RT_SUCCESS(vrc)) 196 { 197 uint8_t bVar = fEnabled ? 0x1 : 0x0; 198 return i_uefiVarStoreSetVar(&GuidSecureBootEnable, "SecureBootEnable", 199 EFI_VAR_HEADER_ATTR_NON_VOLATILE 200 | EFI_VAR_HEADER_ATTR_BOOTSERVICE_ACCESS 201 | EFI_VAR_HEADER_ATTR_RUNTIME_ACCESS, 202 &bVar, sizeof(bVar)); 203 } 204 else if (vrc == VERR_FILE_NOT_FOUND) /* No platform key means no secure boot support. */ 205 return setError(VBOX_E_OBJECT_NOT_FOUND, tr("Secure boot is not available because the platform key (PK) is not enrolled")); 206 207 return setError(E_FAIL, tr("Failed to query the platform key variable size: %Rrc"), vrc); 208 } 209 210 211 HRESULT UefiVariableStore::addVariable(const com::Utf8Str &aName, const com::Guid &aOwnerUuid, 212 const std::vector<UefiVariableAttributes_T> &aAttributes, 213 const std::vector<BYTE> &aData) 214 { 215 /* the machine needs to be mutable */ 216 AutoMutableStateDependency adep(m->pMachine); 217 if (FAILED(adep.rc())) return adep.rc(); 218 219 AutoWriteLock wlock(this COMMA_LOCKVAL_SRC_POS); 220 221 uint32_t fAttr = i_uefiVarAttrToMask(aAttributes); 222 EFI_GUID OwnerGuid; 223 RTEfiGuidFromUuid(&OwnerGuid, aOwnerUuid.raw()); 224 return i_uefiVarStoreSetVar(&OwnerGuid, aName.c_str(), fAttr, &aData.front(), aData.size()); 147 225 } 148 226 … … 155 233 156 234 157 HRESULT UefiVariableStore::changeVariable(const com::Utf8Str &aName, const com::Guid &aOwnerUuid, conststd::vector<BYTE> &aData)158 { 159 RT_NOREF(aName, a OwnerUuid, aData);235 HRESULT UefiVariableStore::changeVariable(const com::Utf8Str &aName, const std::vector<BYTE> &aData) 236 { 237 RT_NOREF(aName, aData); 160 238 return E_NOTIMPL; 161 239 } 162 240 163 241 164 HRESULT UefiVariableStore::queryVariableByName(const com::Utf8Str &aName, com::Guid &aOwnerUuid, std::vector<BYTE> &aData) 165 { 166 RT_NOREF(aName, aOwnerUuid, aData); 167 return E_NOTIMPL; 168 } 169 170 171 HRESULT UefiVariableStore::queryVariables(std::vector<com::Utf8Str> &aNames, std::vector<com::Guid> &aOwnerUuids) 172 { 173 RT_NOREF(aNames, aOwnerUuids); 242 HRESULT UefiVariableStore::queryVariableByName(const com::Utf8Str &aName, com::Guid &aOwnerUuid, 243 std::vector<UefiVariableAttributes_T> &aAttributes, 244 std::vector<BYTE> &aData) 245 { 246 RT_NOREF(aName, aOwnerUuid, aAttributes, aData); 247 248 HRESULT hrc = S_OK; 249 uint32_t fAttr; 250 int vrc = i_uefiVarStoreQueryVarAttr(aName.c_str(), &fAttr); 251 if (RT_SUCCESS(vrc)) 252 { 253 RTUUID OwnerUuid; 254 vrc = i_uefiVarStoreQueryVarOwnerUuid(aName.c_str(), &OwnerUuid); 255 if (RT_SUCCESS(vrc)) 256 { 257 uint64_t cbVar = 0; 258 vrc = i_uefiVarStoreQueryVarSz(aName.c_str(), &cbVar); 259 if (RT_SUCCESS(vrc)) 260 { 261 aData.resize(cbVar); 262 hrc = i_uefiVarStoreQueryVar(aName.c_str(), &aData.front(), aData.size()); 263 if (SUCCEEDED(hrc)) 264 { 265 aOwnerUuid = com::Guid(OwnerUuid); 266 i_uefiAttrMaskToVec(fAttr, aAttributes); 267 } 268 } 269 else 270 hrc = setError(VBOX_E_IPRT_ERROR, tr("Failed to query the size of variable '%s': %Rrc"), aName.c_str(), vrc); 271 } 272 else 273 hrc = setError(VBOX_E_IPRT_ERROR, tr("Failed to query the owner UUID of variable '%s': %Rrc"), aName.c_str(), vrc); 274 } 275 else 276 hrc = setError(VBOX_E_IPRT_ERROR, tr("Failed to query the attributes of variable '%s': %Rrc"), aName.c_str(), vrc); 277 278 return hrc; 279 } 280 281 282 HRESULT UefiVariableStore::queryVariables(std::vector<com::Utf8Str> &aNames, 283 std::vector<com::Guid> &aOwnerUuids) 284 { 285 /* the machine needs to be mutable */ 286 AutoMutableStateDependency adep(m->pMachine); 287 if (FAILED(adep.rc())) return adep.rc(); 288 289 AutoReadLock rlock(this COMMA_LOCKVAL_SRC_POS); 290 291 RTVFSDIR hVfsDir = NIL_RTVFSDIR; 292 int vrc = RTVfsDirOpen(m->hVfsUefiVarStore, "by-name", 0 /*fFlags*/, &hVfsDir); 293 if (RT_SUCCESS(vrc)) 294 { 295 RTDIRENTRYEX DirEntry; 296 297 vrc = RTVfsDirReadEx(hVfsDir, &DirEntry, NULL, RTFSOBJATTRADD_NOTHING); 298 for (;;) 299 { 300 RTUUID OwnerUuid; 301 vrc = i_uefiVarStoreQueryVarOwnerUuid(DirEntry.szName, &OwnerUuid); 302 if (RT_FAILURE(vrc)) 303 break; 304 305 aNames.push_back(Utf8Str(DirEntry.szName)); 306 aOwnerUuids.push_back(com::Guid(OwnerUuid)); 307 308 vrc = RTVfsDirReadEx(hVfsDir, &DirEntry, NULL, RTFSOBJATTRADD_NOTHING); 309 if (RT_FAILURE(vrc)) 310 break; 311 } 312 313 if (vrc == VERR_NO_MORE_FILES) 314 vrc = VINF_SUCCESS; 315 316 RTVfsDirRelease(hVfsDir); 317 } 318 319 if (RT_FAILURE(vrc)) 320 return setError(VBOX_E_IPRT_ERROR, tr("Failed to query the variables: %Rrc"), vrc); 321 322 return S_OK; 323 } 324 325 326 HRESULT UefiVariableStore::enrollOraclePlatformKey(void) 327 { 174 328 return E_NOTIMPL; 175 329 } … … 285 439 286 440 return vrc; 441 } 442 443 444 /** 445 * Queries the attributes for the given EFI variable store variable. 446 * 447 * @returns IPRT status code. 448 * @param pszVar The variable to query the attributes for. 449 * @param pfAttr Where to store the attributes on success. 450 */ 451 int UefiVariableStore::i_uefiVarStoreQueryVarAttr(const char *pszVar, uint32_t *pfAttr) 452 { 453 char szVarPath[_1K]; 454 ssize_t cch = RTStrPrintf2(szVarPath, sizeof(szVarPath), "/raw/%s/attr", pszVar); 455 Assert(cch > 0); RT_NOREF(cch); 456 457 RTVFSFILE hVfsFileAttr = NIL_RTVFSFILE; 458 int vrc = RTVfsFileOpen(m->hVfsUefiVarStore, szVarPath, 459 RTFILE_O_READ | RTFILE_O_DENY_NONE | RTFILE_O_OPEN, 460 &hVfsFileAttr); 461 if (RT_SUCCESS(vrc)) 462 { 463 uint32_t fAttrLe = 0; 464 vrc = RTVfsFileRead(hVfsFileAttr, &fAttrLe, sizeof(fAttrLe), NULL /*pcbRead*/); 465 RTVfsFileRelease(hVfsFileAttr); 466 if (RT_SUCCESS(vrc)) 467 *pfAttr = RT_LE2H_U32(fAttrLe); 468 } 469 470 return vrc; 471 } 472 473 474 /** 475 * Queries the data size for the given variable. 476 * 477 * @returns IPRT status code. 478 * @param pszVar The variable to query the size for. 479 * @param pcbVar Where to store the size of the variable data on success. 480 */ 481 int UefiVariableStore::i_uefiVarStoreQueryVarSz(const char *pszVar, uint64_t *pcbVar) 482 { 483 char szVarPath[_1K]; 484 ssize_t cch = RTStrPrintf2(szVarPath, sizeof(szVarPath), "/by-name/%s", pszVar); 485 Assert(cch > 0); RT_NOREF(cch); 486 487 RTVFSFILE hVfsFile = NIL_RTVFSFILE; 488 int vrc = RTVfsFileOpen(m->hVfsUefiVarStore, szVarPath, 489 RTFILE_O_READ | RTFILE_O_DENY_NONE | RTFILE_O_OPEN, 490 &hVfsFile); 491 if (RT_SUCCESS(vrc)) 492 { 493 vrc = RTVfsFileQuerySize(hVfsFile, pcbVar); 494 RTVfsFileRelease(hVfsFile); 495 } 496 else if (vrc == VERR_PATH_NOT_FOUND) 497 vrc = VERR_FILE_NOT_FOUND; 498 499 return vrc; 500 } 501 502 503 /** 504 * Returns the owner UUID of the given variable. 505 * 506 * @returns IPRT status code. 507 * @param pszVar The variable to query the owner UUID for. 508 * @param pUuid Where to store the owner UUID on success. 509 */ 510 int UefiVariableStore::i_uefiVarStoreQueryVarOwnerUuid(const char *pszVar, PRTUUID pUuid) 511 { 512 char szVarPath[_1K]; 513 ssize_t cch = RTStrPrintf2(szVarPath, sizeof(szVarPath), "/raw/%s/uuid", pszVar); 514 Assert(cch > 0); RT_NOREF(cch); 515 516 RTVFSFILE hVfsFileAttr = NIL_RTVFSFILE; 517 int vrc = RTVfsFileOpen(m->hVfsUefiVarStore, szVarPath, 518 RTFILE_O_READ | RTFILE_O_DENY_NONE | RTFILE_O_OPEN, 519 &hVfsFileAttr); 520 if (RT_SUCCESS(vrc)) 521 { 522 EFI_GUID OwnerGuid; 523 vrc = RTVfsFileRead(hVfsFileAttr, &OwnerGuid, sizeof(OwnerGuid), NULL /*pcbRead*/); 524 RTVfsFileRelease(hVfsFileAttr); 525 if (RT_SUCCESS(vrc)) 526 RTEfiGuidToUuid(pUuid, &OwnerGuid); 527 } 528 529 return vrc; 530 } 531 532 533 /** 534 * Converts the given vector of variables attributes to a bitmask used internally. 535 * 536 * @returns Mask of UEFI variable attributes. 537 * @param vectAttributes Vector of variable atttributes. 538 */ 539 uint32_t UefiVariableStore::i_uefiVarAttrToMask(const std::vector<UefiVariableAttributes_T> &vecAttributes) 540 { 541 uint32_t fAttr = 0; 542 543 for (size_t i = 0; i < vecAttributes.size(); i++) 544 fAttr |= (ULONG)vecAttributes[i]; 545 546 return fAttr; 547 } 548 549 550 /** 551 * Converts the given aatribute mask to the attribute vector used externally. 552 * 553 * @returns nothing. 554 * @param fAttr The attribute mask. 555 * @param aAttributes The vector to store the attibutes in. 556 */ 557 void UefiVariableStore::i_uefiAttrMaskToVec(uint32_t fAttr, std::vector<UefiVariableAttributes_T> &aAttributes) 558 { 559 if (fAttr & EFI_VAR_HEADER_ATTR_NON_VOLATILE) 560 aAttributes.push_back(UefiVariableAttributes_NonVolatile); 561 if (fAttr & EFI_VAR_HEADER_ATTR_BOOTSERVICE_ACCESS) 562 aAttributes.push_back(UefiVariableAttributes_BootServiceAccess); 563 if (fAttr & EFI_VAR_HEADER_ATTR_RUNTIME_ACCESS) 564 aAttributes.push_back(UefiVariableAttributes_RuntimeAccess); 565 if (fAttr & EFI_VAR_HEADER_ATTR_HW_ERROR_RECORD) 566 aAttributes.push_back(UefiVariableAttributes_HwErrorRecord); 567 if (fAttr & EFI_AUTH_VAR_HEADER_ATTR_AUTH_WRITE_ACCESS) 568 aAttributes.push_back(UefiVariableAttributes_AuthWriteAccess); 569 if (fAttr & EFI_AUTH_VAR_HEADER_ATTR_TIME_BASED_AUTH_WRITE_ACCESS) 570 aAttributes.push_back(UefiVariableAttributes_AuthTimeBasedWriteAccess); 571 if (fAttr & EFI_AUTH_VAR_HEADER_ATTR_APPEND_WRITE) 572 aAttributes.push_back(UefiVariableAttributes_AuthAppendWrite); 287 573 } 288 574 … … 354 640 355 641 642 HRESULT UefiVariableStore::i_uefiVarStoreSetVar(PCEFI_GUID pGuid, const char *pszVar, uint32_t fAttr, const void *pvData, size_t cbData) 643 { 644 RTVFSFILE hVfsFileVar = NIL_RTVFSFILE; 645 646 HRESULT hrc = i_uefiVarStoreAddVar(pGuid, pszVar, fAttr, &hVfsFileVar); 647 if (SUCCEEDED(hrc)) 648 { 649 int vrc = RTVfsFileWrite(hVfsFileVar, pvData, cbData, NULL /*pcbWritten*/); 650 if (RT_FAILURE(vrc)) 651 hrc = setError(E_FAIL, tr("Setting the variable '%s' failed: %Rrc"), pszVar, vrc); 652 653 RTVfsFileRelease(hVfsFileVar); 654 } 655 656 return hrc; 657 } 658 659 660 HRESULT UefiVariableStore::i_uefiVarStoreQueryVar(const char *pszVar, void *pvData, size_t cbData) 661 { 662 HRESULT hrc = S_OK; 663 664 char szVarPath[_1K]; 665 ssize_t cch = RTStrPrintf2(szVarPath, sizeof(szVarPath), "/by-name/%s", pszVar); 666 Assert(cch > 0); RT_NOREF(cch); 667 668 RTVFSFILE hVfsFile = NIL_RTVFSFILE; 669 int vrc = RTVfsFileOpen(m->hVfsUefiVarStore, szVarPath, 670 RTFILE_O_READ | RTFILE_O_DENY_NONE | RTFILE_O_OPEN, 671 &hVfsFile); 672 if (RT_SUCCESS(vrc)) 673 { 674 vrc = RTVfsFileRead(hVfsFile, pvData, cbData, NULL /*pcbRead*/); 675 if (RT_FAILURE(vrc)) 676 hrc = setError(E_FAIL, tr("Failed to read data of variable '%s': %Rrc"), pszVar, vrc); 677 678 RTVfsFileRelease(hVfsFile); 679 } 680 else 681 hrc = setError(E_FAIL, tr("Failed to open variable '%s' for reading: %Rrc"), pszVar, vrc); 682 683 return hrc; 684 } 685 356 686 HRESULT UefiVariableStore::i_uefiSigDbAddSig(RTEFISIGDB hEfiSigDb, const void *pvData, size_t cbData, 357 687 const com::Guid &aOwnerUuid, SignatureType_T enmSignatureType) … … 385 715 386 716 HRESULT hrc = i_uefiVarStoreAddVar(pGuid, pszDb, 387 EFI_VAR_HEADER_ATTR_NON_VOLATILE388 | EFI_VAR_HEADER_ATTR_BOOTSERVICE_ACCESS389 | EFI_VAR_HEADER_ATTR_RUNTIME_ACCESS390 | EFI_AUTH_VAR_HEADER_ATTR_TIME_BASED_AUTH_WRITE_ACCESS,391 &hVfsFileSigDb);717 EFI_VAR_HEADER_ATTR_NON_VOLATILE 718 | EFI_VAR_HEADER_ATTR_BOOTSERVICE_ACCESS 719 | EFI_VAR_HEADER_ATTR_RUNTIME_ACCESS 720 | EFI_AUTH_VAR_HEADER_ATTR_TIME_BASED_AUTH_WRITE_ACCESS, 721 &hVfsFileSigDb); 392 722 if (SUCCEEDED(hrc)) 393 723 {
Note:
See TracChangeset
for help on using the changeset viewer.