Changeset 103532 in vbox
- Timestamp:
- Feb 22, 2024 2:05:31 PM (11 months ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/manual/en_US/man_VBoxManage-modifynvram.xml
r99513 r103532 91 91 <arg>--owner-uuid=<replaceable>uuid</replaceable></arg> 92 92 </cmdsynopsis> 93 <cmdsynopsis id="synopsis-vboxmanage-modifynvram-secureboot"> 94 <command>VBoxManage modifynvram</command> 95 <group choice="req"> 96 <arg choice="plain"><replaceable>uuid</replaceable></arg> 97 <arg choice="plain"><replaceable>vmname</replaceable></arg> 98 </group> 99 <arg choice="plain">secureboot</arg> 100 <group choice="req"> 101 <arg choice="plain">--enable</arg> 102 <arg choice="plain">--disable</arg> 103 </group> 104 </cmdsynopsis> 93 105 <cmdsynopsis id="synopsis-vboxmanage-modifynvram-listvars"> 94 106 <command>VBoxManage modifynvram</command> … … 194 206 <term><option>--owner-uuid=<replaceable>uuid</replaceable></option></term> 195 207 <listitem><para>The UUID identifying the owner of the platform key.</para> 208 </listitem> 209 </varlistentry> 210 </variablelist> 211 </refsect2> 212 213 <refsect2 id="vboxmanage-modifynvram-secureboot"> 214 <title>modifynvram secureboot</title> 215 <remark role="help-copy-synopsis"/> 216 <para> 217 Enables or disables UEFI secure boot. 218 </para> 219 <variablelist> 220 <varlistentry> 221 <term><option>--enable></option></term> 222 <listitem><para>Enables UEFI secure boot if the state of the key 223 enrolment permits.</para> 224 </listitem> 225 </varlistentry> 226 <varlistentry> 227 <term><option>--disable></option></term> 228 <listitem><para>Disables UEFI secure boot.</para> 196 229 </listitem> 197 230 </varlistentry> -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp
r101125 r103532 1414 1414 if (bstrNVRAMFile.isNotEmpty()) 1415 1415 SHOW_BSTR_STRING("BIOS NVRAM File", Info::tr("BIOS NVRAM File:"), bstrNVRAMFile); 1416 if ( firmwareType == FirmwareType_EFI || firmwareType == FirmwareType_EFI32 1417 || firmwareType == FirmwareType_EFI64 || firmwareType == FirmwareType_EFIDUAL) 1418 { 1419 ComPtr<IUefiVariableStore> uefiVarStore; 1420 CHECK_ERROR_RET(nvramStore, COMGETTER(UefiVariableStore)(uefiVarStore.asOutParam()), hrc); 1421 SHOW_BOOLEAN_PROP(uefiVarStore, SecureBootEnabled, "SecureBoot", Info::tr("UEFI Secure Boot:")); 1422 } 1416 1423 SHOW_BOOLEAN_PROP_EX(platform, RTCUseUTC, "rtcuseutc", Info::tr("RTC:"), "UTC", Info::tr("local time")); 1417 1424 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyNvram.cpp
r98988 r103532 64 64 static RTEXITCODE handleModifyNvramInitUefiVarStore(HandlerArg *a, ComPtr<INvramStore> &nvramStore) 65 65 { 66 RT_NOREF(a); 66 if (a->argc != 2) 67 return errorTooManyParameters(&a->argv[1]); 67 68 68 69 CHECK_ERROR2I_RET(nvramStore, InitUefiVariableStore(0 /*aSize*/), RTEXITCODE_FAILURE); … … 79 80 static RTEXITCODE handleModifyNvramEnrollMsSignatures(HandlerArg *a, ComPtr<INvramStore> &nvramStore) 80 81 { 81 RT_NOREF(a); 82 if (a->argc != 2) 83 return errorTooManyParameters(&a->argv[1]); 82 84 83 85 ComPtr<IUefiVariableStore> uefiVarStore; … … 252 254 static RTEXITCODE handleModifyNvramEnrollOraclePlatformKey(HandlerArg *a, ComPtr<INvramStore> &nvramStore) 253 255 { 254 RT_NOREF(a); 256 if (a->argc != 2) 257 return errorTooManyParameters(&a->argv[1]); 255 258 256 259 ComPtr<IUefiVariableStore> uefiVarStore; … … 263 266 264 267 /** 268 * Handles the 'modifynvram myvm secureboot' sub-command. 269 * @returns Exit code. 270 * @param a The handler argument package. 271 * @param nvram Reference to the NVRAM store interface. 272 */ 273 static RTEXITCODE handleModifyNvramSecureBoot(HandlerArg *a, ComPtr<INvramStore> &nvramStore) 274 { 275 static const RTGETOPTDEF s_aOptions[] = 276 { 277 /* common options */ 278 { "--enable", 'e', RTGETOPT_REQ_NOTHING }, 279 { "--disable", 'd', RTGETOPT_REQ_NOTHING } 280 }; 281 282 int enable = -1; 283 284 RTGETOPTSTATE GetState; 285 int vrc = RTGetOptInit(&GetState, a->argc - 2, &a->argv[2], s_aOptions, RT_ELEMENTS(s_aOptions), 0, 0); 286 AssertRCReturn(vrc, RTEXITCODE_FAILURE); 287 288 int c; 289 RTGETOPTUNION ValueUnion; 290 while ((c = RTGetOpt(&GetState, &ValueUnion)) != 0) 291 { 292 switch (c) 293 { 294 case 'e': // --enable 295 if (enable >= 0) 296 return errorSyntax(Nvram::tr("You can specify either --enable or --disable once.")); 297 enable = 1; 298 break; 299 300 case 'd': // --disable 301 if (enable >= 0) 302 return errorSyntax(Nvram::tr("You can specify either --enable or --disable once.")); 303 enable = 0; 304 break; 305 306 default: 307 return errorGetOpt(c, &ValueUnion); 308 } 309 } 310 311 if (enable < 0) 312 return errorSyntax(Nvram::tr("You have to specify either --enable or --disable.")); 313 314 ComPtr<IUefiVariableStore> uefiVarStore; 315 CHECK_ERROR2I_RET(nvramStore, COMGETTER(UefiVariableStore)(uefiVarStore.asOutParam()), RTEXITCODE_FAILURE); 316 317 CHECK_ERROR2I_RET(uefiVarStore, COMSETTER(SecureBootEnabled((BOOL)enable)), RTEXITCODE_FAILURE); 318 return RTEXITCODE_SUCCESS; 319 } 320 321 322 /** 265 323 * Handles the 'modifynvram myvm listvars' sub-command. 266 324 * @returns Exit code. … … 270 328 static RTEXITCODE handleModifyNvramListUefiVars(HandlerArg *a, ComPtr<INvramStore> &nvramStore) 271 329 { 272 RT_NOREF(a); 330 if (a->argc != 2) 331 return errorTooManyParameters(&a->argv[1]); 273 332 274 333 ComPtr<IUefiVariableStore> uefiVarStore; … … 362 421 } 363 422 else 364 rcExit = RTMsgErrorExitFailure(Nvram::tr("Error opening '%s': %Rrc"), pszVarDataFilename, vrc);423 rcExit = RTMsgErrorExitFailure(Nvram::tr("Error opening '%s': %Rrc"), pszVarDataFilename, vrc); 365 424 } 366 425 … … 491 550 } 492 551 else 493 rcExit = RTMsgErrorExitFailure(Nvram::tr("Error opening '%s': %Rrc"), pszVarDataFilename, vrc);552 rcExit = RTMsgErrorExitFailure(Nvram::tr("Error opening '%s': %Rrc"), pszVarDataFilename, vrc); 494 553 495 554 return rcExit; … … 548 607 hrc = handleModifyNvramEnrollOraclePlatformKey(a, nvramStore) == RTEXITCODE_SUCCESS ? S_OK : E_FAIL; 549 608 } 609 else if (!strcmp(a->argv[1], "secureboot")) 610 { 611 setCurrentSubcommand(HELP_SCOPE_MODIFYNVRAM_SECUREBOOT); 612 hrc = handleModifyNvramSecureBoot(a, nvramStore) == RTEXITCODE_SUCCESS ? S_OK : E_FAIL; 613 } 550 614 else if (!strcmp(a->argv[1], "listvars")) 551 615 { … … 569 633 } 570 634 else 571 return errorUnknownSubcommand(a->argv[ 0]);635 return errorUnknownSubcommand(a->argv[1]); 572 636 573 637 /* commit changes */ -
trunk/src/VBox/Main/include/AutoStateDep.h
r98263 r103532 73 73 mRegistered(FALSE) 74 74 { 75 Assert(aThat);76 mRC = aThat->i_addStateDependency(taDepType, &mMachineState,77 &mRegistered);75 if (RT_VALID_PTR(aThat)) 76 mRC = aThat->i_addStateDependency(taDepType, &mMachineState, 77 &mRegistered); 78 78 } 79 79 ~AutoStateDependency() 80 80 { 81 if ( SUCCEEDED(mRC))81 if (RT_VALID_PTR(mThat) && SUCCEEDED(mRC)) 82 82 mThat->i_releaseStateDependency(); 83 83 } … … 88 88 { 89 89 AssertReturnVoid(SUCCEEDED(mRC)); 90 mThat->i_releaseStateDependency(); 90 if (RT_VALID_PTR(mThat)) 91 mThat->i_releaseStateDependency(); 91 92 mRC = E_FAIL; 92 93 } … … 98 99 { 99 100 AssertReturnVoid(!SUCCEEDED(mRC)); 100 mRC = mThat->i_addStateDependency(taDepType, &mMachineState, 101 &mRegistered); 101 if (RT_VALID_PTR(mThat)) 102 mRC = mThat->i_addStateDependency(taDepType, &mMachineState, 103 &mRegistered); 104 else 105 mRC = S_OK; 102 106 } 103 107 -
trunk/src/VBox/Main/src-all/NvramStoreImpl.cpp
r99739 r103532 380 380 { 381 381 #ifndef VBOX_COM_INPROC 382 /* the machine needs to be mutable */383 AutoMutableStateDependency adep(m->pParent);384 if (FAILED(adep.hrc())) return adep.hrc();385 386 382 Utf8Str strPath; 387 383 NvramStore::getNonVolatileStorageFile(strPath); … … 418 414 { 419 415 m->pUefiVarStore.queryInterfaceTo(aUefiVarStore.asOutParam()); 420 421 /* Mark the NVRAM store as potentially modified. */ 422 m->pParent->i_setModified(Machine::IsModified_NvramStore); 416 /* The "modified" state is handled by i_retainUefiVarStore. */ 423 417 } 424 418 … … 1066 1060 HRESULT NvramStore::i_retainUefiVarStore(PRTVFS phVfs, bool fReadonly) 1067 1061 { 1068 /* the machine needs to be mutable */1069 AutoMutableStateDependency adep( m->pParent);1062 /* the machine needs to be mutable unless fReadonly is set */ 1063 AutoMutableStateDependency adep(fReadonly ? NULL : m->pParent); 1070 1064 if (FAILED(adep.hrc())) return adep.hrc(); 1071 1065 -
trunk/src/VBox/Main/src-server/UefiVariableStoreImpl.cpp
r99739 r103532 152 152 HRESULT UefiVariableStore::getSecureBootEnabled(BOOL *pfEnabled) 153 153 { 154 /* the machine needs to be mutable */155 AutoMutableStateDependency adep(m->pMachine);156 if (FAILED(adep.hrc())) return adep.hrc();157 158 154 HRESULT hrc = i_retainUefiVariableStore(true /*fReadonly*/); 159 155 if (FAILED(hrc)) return hrc; … … 324 320 std::vector<BYTE> &aData) 325 321 { 326 /* the machine needs to be mutable */327 AutoMutableStateDependency adep(m->pMachine);328 if (FAILED(adep.hrc())) return adep.hrc();329 330 322 HRESULT hrc = i_retainUefiVariableStore(true /*fReadonly*/); 331 323 if (FAILED(hrc)) return hrc; … … 370 362 std::vector<com::Guid> &aOwnerUuids) 371 363 { 372 /* the machine needs to be mutable */373 AutoMutableStateDependency adep(m->pMachine);374 if (FAILED(adep.hrc())) return adep.hrc();375 376 364 HRESULT hrc = i_retainUefiVariableStore(true /*fReadonly*/); 377 365 if (FAILED(hrc)) return hrc; … … 522 510 HRESULT UefiVariableStore::enrollDefaultMsSignatures(void) 523 511 { 512 /* the machine needs to be mutable */ 524 513 AutoMutableStateDependency adep(m->pMachine); 525 514 if (FAILED(adep.hrc())) return adep.hrc();
Note:
See TracChangeset
for help on using the changeset viewer.