Changeset 54885 in vbox
- Timestamp:
- Mar 20, 2015 5:38:27 PM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 99100
- Location:
- trunk/src/VBox
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r54487 r54885 492 492 { "clonevdi", USAGE_CLONEMEDIUM, handleCloneMedium }, /* backward compatibility */ 493 493 { "encryptmedium", USAGE_ENCRYPTMEDIUM, handleEncryptMedium}, 494 { "checkmediumpwd", USAGE_MEDIUMENCCHKPWD, handleCheckMediumPassword}, 494 495 { "createvm", USAGE_CREATEVM, handleCreateVM }, 495 496 { "modifyvm", USAGE_MODIFYVM, handleModifyVM }, -
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h
r54487 r54885 106 106 #define USAGE_MEDIUMPROPERTY RT_BIT_64(60) 107 107 #define USAGE_ENCRYPTMEDIUM RT_BIT_64(61) 108 #define USAGE_MEDIUMENCCHKPWD RT_BIT_64(62) 108 109 #define USAGE_ALL (~(uint64_t)0) 109 110 /** @} */ … … 264 265 int handleMediumProperty(HandlerArg *a); 265 266 int handleEncryptMedium(HandlerArg *a); 267 int handleCheckMediumPassword(HandlerArg *a); 266 268 RTEXITCODE handleConvertFromRaw(int argc, char *argv[]); 267 269 HRESULT showMediumInfo(const ComPtr<IVirtualBox> &pVirtualBox, -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp
r54854 r54885 1841 1841 } 1842 1842 1843 int handleCheckMediumPassword(HandlerArg *a) 1844 { 1845 HRESULT rc; 1846 int vrc; 1847 ComPtr<IMedium> hardDisk; 1848 const char *pszFilenameOrUuid = NULL; 1849 Utf8Str strPassword; 1850 1851 if (a->argc != 2) 1852 return errorSyntax(USAGE_MEDIUMENCCHKPWD, "Invalid number of arguments: %d", a->argc); 1853 1854 pszFilenameOrUuid = a->argv[0]; 1855 1856 if (!RTStrCmp(a->argv[1], "-")) 1857 { 1858 /* Get password from console. */ 1859 vrc = getPassword("Enter password:", &strPassword); 1860 if (RT_FAILURE(vrc)) 1861 { 1862 RTMsgError("Failed to read password from standard input"); 1863 return 1; 1864 } 1865 } 1866 else 1867 { 1868 RTEXITCODE rcExit = readPasswordFile(a->argv[1], &strPassword); 1869 if (rcExit == RTEXITCODE_FAILURE) 1870 { 1871 RTMsgError("Failed to read password from file"); 1872 return rcExit; 1873 } 1874 } 1875 1876 /* Always open the medium if necessary, there is no other way. */ 1877 rc = openMedium(a, pszFilenameOrUuid, DeviceType_HardDisk, 1878 AccessMode_ReadWrite, hardDisk, 1879 false /* fForceNewUuidOnOpen */, false /* fSilent */); 1880 if (FAILED(rc)) 1881 return 1; 1882 if (hardDisk.isNull()) 1883 { 1884 RTMsgError("Invalid hard disk reference, avoiding crash"); 1885 return 1; 1886 } 1887 1888 CHECK_ERROR(hardDisk, CheckEncryptionPassword(Bstr(strPassword).raw())); 1889 if (SUCCEEDED(rc)) 1890 RTPrintf("The given password is correct\n"); 1891 return SUCCEEDED(rc) ? 0 : 1; 1892 } 1893 1843 1894 #endif /* !VBOX_ONLY_DOCS */ -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
r54725 r54885 645 645 "\n", SEP); 646 646 647 if (fCategory & USAGE_MEDIUMENCCHKPWD) 648 RTStrmPrintf(pStrm, 649 "%s checkmediumpwd %s <uuid|filename>\n" 650 " <pwd file>|-\n" 651 "\n", SEP); 652 647 653 if (fCategory & USAGE_CONVERTFROMRAW) 648 654 RTStrmPrintf(pStrm, -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r54855 r54885 13489 13489 <interface 13490 13490 name="IMedium" extends="$unknown" 13491 uuid="9 fae9ea1-c57c-4a3d-8992-cbb2b9b4b4a3"13491 uuid="9680d99b-3550-4e14-8fc4-82ad1426cbde" 13492 13492 wsmap="managed" 13493 13493 > … … 14793 14793 <param name="passwordId" type="wstring" dir="return"> 14794 14794 <desc>The ID of the password when unlocking the medium.</desc> 14795 </param> 14796 </method> 14797 14798 <method name="checkEncryptionPassword" const="yes"> 14799 <desc> 14800 Checks whether the supplied password is correct for the medium. 14801 14802 <result name="VBOX_E_NOT_SUPPORTED"> 14803 Encryption is not configured for this medium. 14804 </result> 14805 <result name="VBOX_E_PASSWORD_INCORRECT"> 14806 The given password is incorrect. 14807 </result> 14808 </desc> 14809 <param name="password" type="wstring" dir="in"> 14810 <desc>The password to check.</desc> 14795 14811 </param> 14796 14812 </method> -
trunk/src/VBox/Main/include/MediumImpl.h
r54854 r54885 280 280 ComPtr<IProgress> &aProgress); 281 281 HRESULT getEncryptionSettings(com::Utf8Str &aCipher, com::Utf8Str &aPasswordId); 282 HRESULT checkEncryptionPassword(const com::Utf8Str &aPassword); 282 283 283 284 // Private internal nmethods -
trunk/src/VBox/Main/src-server/MediumImpl.cpp
r54884 r54885 3230 3230 aCipher = CryptoSettings.pszCipherReturned; 3231 3231 RTStrFree(CryptoSettings.pszCipherReturned); 3232 3233 VDDestroy(pDisk); 3234 # else 3235 throw setError(VBOX_E_NOT_SUPPORTED, 3236 tr("Encryption is not supported because extension pack support is not built in")); 3237 # endif 3238 } 3239 catch (HRESULT aRC) { rc = aRC; } 3240 3241 return rc; 3242 } 3243 3244 HRESULT Medium::checkEncryptionPassword(const com::Utf8Str &aPassword) 3245 { 3246 HRESULT rc = S_OK; 3247 3248 try 3249 { 3250 ComObjPtr<Medium> pBase = i_getBase(); 3251 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 3252 3253 settings::StringsMap::iterator it = pBase->m->mapProperties.find("CRYPT/KeyStore"); 3254 if (it == pBase->m->mapProperties.end()) 3255 throw setError(VBOX_E_NOT_SUPPORTED, 3256 tr("The image is not configured for encryption")); 3257 3258 if (aPassword.isEmpty()) 3259 throw setError(E_INVALIDARG, 3260 tr("The given password must not be empty")); 3261 3262 # ifdef VBOX_WITH_EXTPACK 3263 static const Utf8Str strExtPackPuel("Oracle VM VirtualBox Extension Pack"); 3264 static const char *s_pszVDPlugin = "VDPluginCrypt"; 3265 ExtPackManager *pExtPackManager = m->pVirtualBox->i_getExtPackManager(); 3266 if (pExtPackManager->i_isExtPackUsable(strExtPackPuel.c_str())) 3267 { 3268 /* Load the plugin */ 3269 Utf8Str strPlugin; 3270 rc = pExtPackManager->i_getLibraryPathForExtPack(s_pszVDPlugin, &strExtPackPuel, &strPlugin); 3271 if (SUCCEEDED(rc)) 3272 { 3273 int vrc = VDPluginLoadFromFilename(strPlugin.c_str()); 3274 if (RT_FAILURE(vrc)) 3275 throw setError(VBOX_E_NOT_SUPPORTED, 3276 tr("Retrieving encryption settings of the image failed because the encryption plugin could not be loaded (%s)"), 3277 i_vdError(vrc).c_str()); 3278 } 3279 else 3280 throw setError(VBOX_E_NOT_SUPPORTED, 3281 tr("Encryption is not supported because the extension pack '%s' is missing the encryption plugin (old extension pack installed?)"), 3282 strExtPackPuel.c_str()); 3283 } 3284 else 3285 throw setError(VBOX_E_NOT_SUPPORTED, 3286 tr("Encryption is not supported because the extension pack '%s' is missing"), 3287 strExtPackPuel.c_str()); 3288 3289 PVBOXHDD pDisk = NULL; 3290 int vrc = VDCreate(m->vdDiskIfaces, i_convertDeviceType(), &pDisk); 3291 ComAssertRCThrow(vrc, E_FAIL); 3292 3293 Medium::CryptoFilterSettings CryptoSettings; 3294 3295 i_taskEncryptSettingsSetup(&CryptoSettings, NULL, it->second.c_str(), aPassword.c_str(), 3296 false /* fCreateKeyStore */); 3297 vrc = VDFilterAdd(pDisk, "CRYPT", VD_FILTER_FLAGS_READ, CryptoSettings.vdFilterIfaces); 3298 if (vrc == VERR_VD_PASSWORD_INCORRECT) 3299 throw setError(VBOX_E_PASSWORD_INCORRECT, 3300 tr("The given password is incorrect")); 3301 else if (RT_FAILURE(vrc)) 3302 throw setError(VBOX_E_INVALID_OBJECT_STATE, 3303 tr("Failed to load the encryption filter: %s"), 3304 i_vdError(vrc).c_str()); 3232 3305 3233 3306 VDDestroy(pDisk);
Note:
See TracChangeset
for help on using the changeset viewer.