Changeset 94804 in vbox
- Timestamp:
- May 4, 2022 8:02:56 AM (3 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/ConsoleImpl.h
r94793 r94804 67 67 68 68 #include <iprt/uuid.h> 69 #include <iprt/log.h> 69 70 #include <iprt/memsafer.h> 70 71 #include <VBox/RemoteDesktop/VRDE.h> … … 947 948 /** @} */ 948 949 950 #ifdef VBOX_WITH_FULL_VM_ENCRYPTION 951 /** @name Encrypted log interface 952 * @{ */ 953 static DECLCALLBACK(int) i_logEncryptedOpen(PCRTLOGOUTPUTIF pIf, void *pvUser, const char *pszFilename, uint32_t fFlags); 954 static DECLCALLBACK(int) i_logEncryptedClose(PCRTLOGOUTPUTIF pIf, void *pvUser); 955 static DECLCALLBACK(int) i_logEncryptedDelete(PCRTLOGOUTPUTIF pIf, void *pvUser, const char *pszFilename); 956 static DECLCALLBACK(int) i_logEncryptedRename(PCRTLOGOUTPUTIF pIf, void *pvUser, const char *pszFilenameOld, 957 const char *pszFilenameNew, uint32_t fFlags); 958 static DECLCALLBACK(int) i_logEncryptedQuerySize(PCRTLOGOUTPUTIF pIf, void *pvUser, uint64_t *pcbSize); 959 static DECLCALLBACK(int) i_logEncryptedWrite(PCRTLOGOUTPUTIF pIf, void *pvUser, const void *pvBuf, 960 size_t cbWrite, size_t *pcbWritten); 961 static DECLCALLBACK(int) i_logEncryptedFlush(PCRTLOGOUTPUTIF pIf, void *pvUser); 962 /** @} */ 963 #endif 964 949 965 bool mSavedStateDataLoaded : 1; 950 966 … … 1101 1117 /** @} */ 1102 1118 1119 #ifdef VBOX_WITH_FULL_VM_ENCRYPTION 1120 /** Flag whether the log is encrypted. */ 1121 bool m_fEncryptedLog; 1122 /** The file handle of the encrypted log. */ 1123 RTVFSFILE m_hVfsFileLog; 1124 /** The logging output interface for encrypted logs. */ 1125 RTLOGOUTPUTIF m_LogOutputIf; 1126 /** The log file key ID. */ 1127 Utf8Str m_strLogKeyId; 1128 /** The log file key store. */ 1129 Utf8Str m_strLogKeyStore; 1130 #endif 1131 1103 1132 #ifdef VBOX_WITH_DRAG_AND_DROP 1104 1133 HGCMSVCEXTHANDLE m_hHgcmSvcExtDragAndDrop; -
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r94793 r94804 742 742 } 743 743 744 HRESULT rc = i_unloadCryptoIfModule();745 AssertComRC(rc);746 747 744 #ifdef VBOX_WITH_USB_CARDREADER 748 745 if (mUsbCardReader) … … 881 878 } 882 879 mcLedSets = 0; 880 881 #ifdef VBOX_WITH_FULL_VM_ENCRYPTION 882 /* Close the release log before unloading the cryptographic module. */ 883 if (m_fEncryptedLog) 884 { 885 PRTLOGGER pLogEnc = RTLogRelSetDefaultInstance(NULL); 886 int vrc = RTLogDestroy(pLogEnc); 887 AssertRC(vrc); 888 } 889 #endif 890 891 HRESULT rc = i_unloadCryptoIfModule(); 892 AssertComRC(rc); 883 893 884 894 LogFlowThisFuncLeave(); … … 7848 7858 7849 7859 7860 #ifdef VBOX_WITH_FULL_VM_ENCRYPTION 7861 /*static*/ 7862 DECLCALLBACK(int) Console::i_logEncryptedOpen(PCRTLOGOUTPUTIF pIf, void *pvUser, const char *pszFilename, uint32_t fFlags) 7863 { 7864 RT_NOREF(pIf); 7865 Console *pConsole = static_cast<Console *>(pvUser); 7866 RTVFSFILE hVfsFile = NIL_RTVFSFILE; 7867 7868 int vrc = RTVfsFileOpenNormal(pszFilename, fFlags, &hVfsFile); 7869 if (RT_SUCCESS(vrc)) 7870 { 7871 PCVBOXCRYPTOIF pCryptoIf = NULL; 7872 vrc = pConsole->i_retainCryptoIf(&pCryptoIf); 7873 if (RT_SUCCESS(vrc)) 7874 { 7875 SecretKey *pKey = NULL; 7876 7877 vrc = pConsole->m_pKeyStore->retainSecretKey(pConsole->m_strLogKeyId, &pKey); 7878 if (RT_SUCCESS(vrc)) 7879 { 7880 const char *pszPassword = (const char *)pKey->getKeyBuffer(); 7881 7882 vrc = pCryptoIf->pfnCryptoFileFromVfsFile(hVfsFile, pConsole->m_strLogKeyStore.c_str(), pszPassword, 7883 &pConsole->m_hVfsFileLog); 7884 pKey->release(); 7885 } 7886 7887 /* On success we keep the reference to keep the cryptographic module loaded. */ 7888 if (RT_FAILURE(vrc)) 7889 pConsole->i_releaseCryptoIf(pCryptoIf); 7890 } 7891 7892 /* Always do this because the encrypted log has retained a reference to the underlying file. */ 7893 RTVfsFileRelease(hVfsFile); 7894 if (RT_FAILURE(vrc)) 7895 RTFileDelete(pszFilename); 7896 } 7897 7898 return vrc; 7899 } 7900 7901 7902 /*static*/ 7903 DECLCALLBACK(int) Console::i_logEncryptedClose(PCRTLOGOUTPUTIF pIf, void *pvUser) 7904 { 7905 RT_NOREF(pIf); 7906 Console *pConsole = static_cast<Console *>(pvUser); 7907 7908 RTVfsFileRelease(pConsole->m_hVfsFileLog); 7909 pConsole->m_hVfsFileLog = NIL_RTVFSFILE; 7910 return VINF_SUCCESS; 7911 } 7912 7913 7914 /*static*/ 7915 DECLCALLBACK(int) Console::i_logEncryptedDelete(PCRTLOGOUTPUTIF pIf, void *pvUser, const char *pszFilename) 7916 { 7917 RT_NOREF(pIf, pvUser); 7918 return RTFileDelete(pszFilename); 7919 } 7920 7921 7922 /*static*/ 7923 DECLCALLBACK(int) Console::i_logEncryptedRename(PCRTLOGOUTPUTIF pIf, void *pvUser, const char *pszFilenameOld, 7924 const char *pszFilenameNew, uint32_t fFlags) 7925 { 7926 RT_NOREF(pIf, pvUser); 7927 return RTFileRename(pszFilenameOld, pszFilenameNew, fFlags); 7928 } 7929 7930 7931 /*static*/ 7932 DECLCALLBACK(int) Console::i_logEncryptedQuerySize(PCRTLOGOUTPUTIF pIf, void *pvUser, uint64_t *pcbSize) 7933 { 7934 RT_NOREF(pIf); 7935 Console *pConsole = static_cast<Console *>(pvUser); 7936 7937 return RTVfsFileQuerySize(pConsole->m_hVfsFileLog, pcbSize); 7938 } 7939 7940 7941 /*static*/ 7942 DECLCALLBACK(int) Console::i_logEncryptedWrite(PCRTLOGOUTPUTIF pIf, void *pvUser, const void *pvBuf, 7943 size_t cbWrite, size_t *pcbWritten) 7944 { 7945 RT_NOREF(pIf); 7946 Console *pConsole = static_cast<Console *>(pvUser); 7947 7948 return RTVfsFileWrite(pConsole->m_hVfsFileLog, pvBuf, cbWrite, pcbWritten); 7949 } 7950 7951 7952 /*static*/ 7953 DECLCALLBACK(int) Console::i_logEncryptedFlush(PCRTLOGOUTPUTIF pIf, void *pvUser) 7954 { 7955 RT_NOREF(pIf); 7956 Console *pConsole = static_cast<Console *>(pvUser); 7957 7958 return RTVfsFileFlush(pConsole->m_hVfsFileLog); 7959 } 7960 #endif 7961 7962 7850 7963 /** 7851 7964 * Initialize the release logging facility. In case something … … 7905 8018 } 7906 8019 7907 RTERRINFOSTATIC ErrInfo; 7908 int vrc = com::VBoxLogRelCreate("VM", logFile.c_str(), 7909 RTLOGFLAGS_PREFIX_TIME_PROG | RTLOGFLAGS_RESTRICT_GROUPS, 7910 "all all.restrict -default.restrict", 7911 "VBOX_RELEASE_LOG", RTLOGDEST_FILE, 7912 32768 /* cMaxEntriesPerGroup */, 7913 0 /* cHistory */, 0 /* uHistoryFileTime */, 7914 0 /* uHistoryFileSize */, RTErrInfoInitStatic(&ErrInfo)); 8020 Bstr bstrLogKeyId; 8021 Bstr bstrLogKeyStore; 8022 PCRTLOGOUTPUTIF pLogOutputIf = NULL; 8023 void *pvLogOutputUser = NULL; 8024 int vrc = aMachine->COMGETTER(LogKeyId)(bstrLogKeyId.asOutParam()); 8025 if (RT_SUCCESS(vrc)) 8026 { 8027 vrc = aMachine->COMGETTER(LogKeyStore)(bstrLogKeyStore.asOutParam()); 8028 if ( RT_SUCCESS(vrc) 8029 && bstrLogKeyId.isNotEmpty() 8030 && bstrLogKeyStore.isNotEmpty()) 8031 { 8032 m_LogOutputIf.pfnOpen = Console::i_logEncryptedOpen; 8033 m_LogOutputIf.pfnClose = Console::i_logEncryptedClose; 8034 m_LogOutputIf.pfnDelete = Console::i_logEncryptedDelete; 8035 m_LogOutputIf.pfnRename = Console::i_logEncryptedRename; 8036 m_LogOutputIf.pfnQuerySize = Console::i_logEncryptedQuerySize; 8037 m_LogOutputIf.pfnWrite = Console::i_logEncryptedWrite; 8038 m_LogOutputIf.pfnFlush = Console::i_logEncryptedFlush; 8039 8040 m_strLogKeyId = Utf8Str(bstrLogKeyId); 8041 m_strLogKeyStore = Utf8Str(bstrLogKeyStore); 8042 8043 pLogOutputIf = &m_LogOutputIf; 8044 pvLogOutputUser = this; 8045 } 8046 } 8047 7915 8048 if (RT_FAILURE(vrc)) 7916 hrc = setErrorBoth(E_FAIL, vrc, tr("Failed to open release log (%s, %Rrc)"), ErrInfo.Core.pszMsg, vrc); 8049 hrc = setErrorBoth(E_FAIL, vrc, tr("Failed to set encryption for release log (%Rrc)"), vrc); 8050 else 8051 { 8052 RTERRINFOSTATIC ErrInfo; 8053 vrc = com::VBoxLogRelCreateEx("VM", logFile.c_str(), 8054 RTLOGFLAGS_PREFIX_TIME_PROG | RTLOGFLAGS_RESTRICT_GROUPS, 8055 "all all.restrict -default.restrict", 8056 "VBOX_RELEASE_LOG", RTLOGDEST_FILE, 8057 32768 /* cMaxEntriesPerGroup */, 8058 0 /* cHistory */, 0 /* uHistoryFileTime */, 8059 0 /* uHistoryFileSize */, 8060 pLogOutputIf, pvLogOutputUser, 8061 RTErrInfoInitStatic(&ErrInfo)); 8062 if (RT_FAILURE(vrc)) 8063 hrc = setErrorBoth(E_FAIL, vrc, tr("Failed to open release log (%s, %Rrc)"), ErrInfo.Core.pszMsg, vrc); 8064 } 7917 8065 7918 8066 /* If we've made any directory changes, flush the directory to increase
Note:
See TracChangeset
for help on using the changeset viewer.