Changeset 54725 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Mar 11, 2015 8:39:08 PM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 98893
- Location:
- trunk/src/VBox/Frontends/VBoxManage
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp
r54591 r54725 52 52 } 53 53 54 static int getPassword(const char *pszPrompt, Utf8Str *pPassword) 55 { 56 char aszPwdInput[_1K] = { 0 }; 57 58 int vrc = RTStrmPutStr(g_pStdOut, pszPrompt); 59 if (RT_SUCCESS(vrc)) 60 { 61 bool fEchoOld = false; 62 vrc = RTStrmInputGetEchoChars(g_pStdIn, &fEchoOld); 63 if (RT_SUCCESS(vrc)) 64 { 65 vrc = RTStrmInputSetEchoChars(g_pStdIn, false); 66 if (RT_SUCCESS(vrc)) 67 { 68 vrc = RTStrmGetLine(g_pStdIn, &aszPwdInput[0], sizeof(aszPwdInput)); 69 if (RT_SUCCESS(vrc)) 70 *pPassword = aszPwdInput; 71 72 int vrc2 = RTStrmInputSetEchoChars(g_pStdIn, fEchoOld); 73 AssertRC(vrc2); 74 } 75 } 76 RTStrmPutStr(g_pStdOut, "\n"); 77 } 78 79 return vrc; 80 } 54 81 55 82 static int parseMediumVariant(const char *psz, MediumVariant_T *pMediumVariant) … … 1657 1684 const char *pszFilenameOrUuid = NULL; 1658 1685 const char *pszNewPasswordId = NULL; 1686 Utf8Str strPasswordNew; 1687 Utf8Str strPasswordOld; 1659 1688 1660 1689 int c; … … 1718 1747 return errorSyntax(USAGE_ENCRYPTMEDIUM, "A new password must always have a valid identifier set at the same time"); 1719 1748 1749 if (pszPasswordNew) 1750 { 1751 if (!RTStrCmp(pszPasswordNew, "-")) 1752 { 1753 /* Get password from console. */ 1754 vrc = getPassword("Enter new password:", &strPasswordNew); 1755 if (RT_FAILURE(vrc)) 1756 { 1757 RTMsgError("Failed to read new password from standard input"); 1758 return 1; 1759 } 1760 } 1761 else 1762 { 1763 RTEXITCODE rcExit = readPasswordFile(pszPasswordNew, &strPasswordNew); 1764 if (rcExit == RTEXITCODE_FAILURE) 1765 { 1766 RTMsgError("Failed to read new password from file"); 1767 return rcExit; 1768 } 1769 } 1770 } 1771 1772 if (pszPasswordOld) 1773 { 1774 if (!RTStrCmp(pszPasswordOld, "-")) 1775 { 1776 /* Get password from console. */ 1777 vrc = getPassword("Enter old password:", &strPasswordOld); 1778 if (RT_FAILURE(vrc)) 1779 { 1780 RTMsgError("Failed to read old password from standard input"); 1781 return 1; 1782 } 1783 } 1784 else 1785 { 1786 RTEXITCODE rcExit = readPasswordFile(pszPasswordOld, &strPasswordOld); 1787 if (rcExit == RTEXITCODE_FAILURE) 1788 { 1789 RTMsgError("Failed to read old password from file"); 1790 return rcExit; 1791 } 1792 } 1793 } 1794 1720 1795 /* Always open the medium if necessary, there is no other way. */ 1721 1796 rc = openMedium(a, pszFilenameOrUuid, DeviceType_HardDisk, … … 1731 1806 1732 1807 ComPtr<IProgress> progress; 1733 CHECK_ERROR(hardDisk, ChangeEncryption(Bstr( pszPasswordNew).raw(), Bstr(pszPasswordOld).raw(),1808 CHECK_ERROR(hardDisk, ChangeEncryption(Bstr(strPasswordNew).raw(), Bstr(strPasswordOld).raw(), 1734 1809 Bstr(pszCipher).raw(), Bstr(pszNewPasswordId).raw(), 1735 1810 progress.asOutParam())); -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
r54591 r54725 639 639 RTStrmPrintf(pStrm, 640 640 "%s encryptmedium %s <uuid|filename>\n" 641 " [--newpassword < new password>]\n"642 " [--oldpassword < old password>]\n"641 " [--newpassword <file>|-]\n" 642 " [--oldpassword <file>|-]\n" 643 643 " [--cipher <cipher identifier>]\n" 644 644 " [--newpasswordid <password identifier>]\n"
Note:
See TracChangeset
for help on using the changeset viewer.