- 時間撮記:
- 2015-3-26 下午08:49:26 (10 年 以前)
- 檔案:
-
- 修改 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r54976 r54978 3379 3379 if (RT_SUCCESS(rc)) 3380 3380 { 3381 unsigned cDisksConfigured = 0; 3381 3382 memcpy(pbKey, aPassword.c_str(), cbKey); 3382 3383 … … 3387 3388 /* Add the key to the map */ 3388 3389 m_mapSecretKeys.insert(std::make_pair(aId, pKey)); 3389 hrc = i_configureEncryptionForDisk(aId );3390 hrc = i_configureEncryptionForDisk(aId, &cDisksConfigured); 3390 3391 if (SUCCEEDED(hrc)) 3391 3392 { 3392 if ( m_mapSecretKeys.size() == m_cDisksEncrypted 3393 pKey->m_cDisks = cDisksConfigured; 3394 m_cDisksPwProvided += cDisksConfigured; 3395 3396 if ( m_cDisksPwProvided == m_cDisksEncrypted 3393 3397 && mMachineState == MachineState_Paused) 3394 3398 { … … 3445 3449 if (RT_SUCCESS(rc)) 3446 3450 { 3451 unsigned cDisksConfigured = 0; 3447 3452 memcpy(pbKey, aPasswords[i].c_str(), cbKey); 3448 3453 … … 3453 3458 /* Add the key to the map */ 3454 3459 m_mapSecretKeys.insert(std::make_pair(aIds[i], pKey)); 3455 hrc = i_configureEncryptionForDisk(aIds[i] );3460 hrc = i_configureEncryptionForDisk(aIds[i], &cDisksConfigured); 3456 3461 if (FAILED(hrc)) 3457 3462 m_mapSecretKeys.erase(aIds[i]); 3463 else 3464 pKey->m_cDisks = cDisksConfigured; 3458 3465 } 3459 3466 else … … 3467 3474 */ 3468 3475 for (unsigned ii = 0; ii < i; ii++) 3476 { 3477 i_clearDiskEncryptionKeysOnAllAttachmentsWithKeyId(aIds[ii]); 3469 3478 removeDiskEncryptionPassword(aIds[ii]); 3479 } 3470 3480 3471 3481 break; … … 3474 3484 3475 3485 if ( SUCCEEDED(hrc) 3476 && m_ mapSecretKeys.size()== m_cDisksEncrypted3486 && m_cDisksPwProvided == m_cDisksEncrypted 3477 3487 && mMachineState == MachineState_Paused) 3478 3488 { … … 3508 3518 return setError(VBOX_E_OBJECT_IN_USE, tr("The password is still in use by the VM")); 3509 3519 3520 m_cDisksPwProvided -= pKey->m_cDisks; 3510 3521 m_mapSecretKeys.erase(it); 3511 3522 delete pKey; … … 3534 3545 delete it->second; 3535 3546 m_mapSecretKeys.clear(); 3547 m_cDisksPwProvided = 0; 3536 3548 3537 3549 return S_OK; … … 4850 4862 * 4851 4863 * @returns COM status code. 4852 * @param strId The ID of the password. 4864 * @param strId The ID of the password. 4865 * @param pcDisksConfigured Where to store the number of disks configured for the given ID. 4853 4866 */ 4854 HRESULT Console::i_configureEncryptionForDisk(const com::Utf8Str &strId) 4855 { 4867 HRESULT Console::i_configureEncryptionForDisk(const com::Utf8Str &strId, unsigned *pcDisksConfigured) 4868 { 4869 unsigned cDisksConfigured = 0; 4856 4870 HRESULT hrc = S_OK; 4857 4871 SafeIfaceArray<IMediumAttachment> sfaAttachments; … … 4959 4973 rc = pIMedium->pfnSetSecKeyIf(pIMedium, mpIfSecKey, mpIfSecKeyHlp); 4960 4974 if (rc == VERR_VD_PASSWORD_INCORRECT) 4961 return setError(VBOX_E_PASSWORD_INCORRECT, tr("The provided password for ID \"%s\" is not correct for at least one disk using this ID"), 4962 strId.c_str()); 4975 { 4976 hrc = setError(VBOX_E_PASSWORD_INCORRECT, tr("The provided password for ID \"%s\" is not correct for at least one disk using this ID"), 4977 strId.c_str()); 4978 break; 4979 } 4963 4980 else if (RT_FAILURE(rc)) 4964 return setError(E_FAIL, tr("Failed to set the encryption key (%Rrc)"), rc); 4981 { 4982 hrc = setError(E_FAIL, tr("Failed to set the encryption key (%Rrc)"), rc); 4983 break; 4984 } 4985 4986 if (RT_SUCCESS(rc)) 4987 cDisksConfigured++; 4965 4988 } 4966 4989 } … … 4969 4992 } 4970 4993 } 4994 } 4995 4996 if ( SUCCEEDED(hrc) 4997 && pcDisksConfigured) 4998 *pcDisksConfigured = cDisksConfigured; 4999 else if (FAILED(hrc)) 5000 { 5001 /* Clear disk encryption setup on successfully configured attachments. */ 5002 i_clearDiskEncryptionKeysOnAllAttachmentsWithKeyId(strId); 4971 5003 } 4972 5004 … … 5045 5077 /* Add the key to the map */ 5046 5078 m_mapSecretKeys.insert(std::make_pair(Utf8Str(pszUuid), pKey)); 5047 hrc = i_configureEncryptionForDisk(Utf8Str(pszUuid) );5079 hrc = i_configureEncryptionForDisk(Utf8Str(pszUuid), NULL); 5048 5080 if (FAILED(hrc)) 5049 5081 { … … 5112 5144 5113 5145 AssertMsg(!pKey->m_cRefs, ("No one should access the stored key at this point anymore!\n")); 5146 m_cDisksPwProvided -= pKey->m_cDisks; 5114 5147 delete pKey; 5115 5148 m_mapSecretKeys.erase(it++); … … 6507 6540 else if ( aReason == Reason_HostSuspend 6508 6541 || aReason == Reason_HostBatteryLow) 6542 { 6543 alock.acquire(); 6509 6544 i_removeSecretKeysOnSuspend(); 6545 } 6510 6546 6511 6547 LogFlowThisFunc(("hrc=%Rhrc\n", hrc));
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器