VirtualBox

Changeset 104286 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Apr 11, 2024 1:56:27 AM (8 months ago)
Author:
vboxsync
Message:

IPRT/log,Main: Open the parent directory of the log file on Windows before we opening the log file and do any log rotating to prevent reparse hacks. bugref:10632

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r101477 r104286  
    10131013    /** @name Encrypted log interface
    10141014     * @{ */
    1015     static DECLCALLBACK(int)    i_logEncryptedOpen(PCRTLOGOUTPUTIF pIf, void *pvUser, const char *pszFilename, uint32_t fFlags);
     1015    static DECLCALLBACK(int)    i_logEncryptedDirCtxOpen(PCRTLOGOUTPUTIF pIf, void *pvUser, const char *pszFilename, void **pvDirCtx);
     1016    static DECLCALLBACK(int)    i_logEncryptedDirCtxClose(PCRTLOGOUTPUTIF pIf, void *pvUser, void *pvDirCtx);
     1017    static DECLCALLBACK(int)    i_logEncryptedDelete(PCRTLOGOUTPUTIF pIf, void *pvUser, void *pvDirCtx, const char *pszFilename);
     1018    static DECLCALLBACK(int)    i_logEncryptedRename(PCRTLOGOUTPUTIF pIf, void *pvUser, void *pvDirCtx,
     1019                                                     const char *pszFilenameOld, const char *pszFilenameNew, uint32_t fFlags);
     1020    static DECLCALLBACK(int)    i_logEncryptedOpen(PCRTLOGOUTPUTIF pIf, void *pvUser, void *pvDirCtx, const char *pszFilename, uint32_t fFlags);
    10161021    static DECLCALLBACK(int)    i_logEncryptedClose(PCRTLOGOUTPUTIF pIf, void *pvUser);
    1017     static DECLCALLBACK(int)    i_logEncryptedDelete(PCRTLOGOUTPUTIF pIf, void *pvUser, const char *pszFilename);
    1018     static DECLCALLBACK(int)    i_logEncryptedRename(PCRTLOGOUTPUTIF pIf, void *pvUser, const char *pszFilenameOld,
    1019                                                      const char *pszFilenameNew, uint32_t fFlags);
    10201022    static DECLCALLBACK(int)    i_logEncryptedQuerySize(PCRTLOGOUTPUTIF pIf, void *pvUser, uint64_t *pcbSize);
    10211023    static DECLCALLBACK(int)    i_logEncryptedWrite(PCRTLOGOUTPUTIF pIf, void *pvUser, const void *pvBuf,
    10221024                                                    size_t cbWrite, size_t *pcbWritten);
    10231025    static DECLCALLBACK(int)    i_logEncryptedFlush(PCRTLOGOUTPUTIF pIf, void *pvUser);
     1026    /** The logging output interface for encrypted logs. */
     1027    static RTLOGOUTPUTIF const  s_ConsoleEncryptedLogOutputIf;
    10241028    /** @} */
    10251029#endif
     
    12151219    /** The file handle of the encrypted log. */
    12161220    RTVFSFILE                           m_hVfsFileLog;
    1217     /** The logging output interface for encrypted logs. */
    1218     RTLOGOUTPUTIF                       m_LogOutputIf;
    12191221    /** The log file key ID. */
    12201222    Utf8Str                             m_strLogKeyId;
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r103856 r104286  
    81618161}
    81628162
    8163 
    81648163#ifdef VBOX_WITH_FULL_VM_ENCRYPTION
    8165 /*static*/
    8166 DECLCALLBACK(int) Console::i_logEncryptedOpen(PCRTLOGOUTPUTIF pIf, void *pvUser, const char *pszFilename, uint32_t fFlags)
    8167 {
    8168     RT_NOREF(pIf);
     8164
     8165/*static*/ DECLCALLBACK(int)
     8166Console::i_logEncryptedDirCtxOpen(PCRTLOGOUTPUTIF pIf, void *pvUser, const char *pszFilename, void **ppvDirCtx)
     8167{
     8168    RT_NOREF(pIf, pvUser, pszFilename, ppvDirCtx);
     8169    *ppvDirCtx = (void *)(intptr_t)22;
     8170    return VINF_SUCCESS;
     8171}
     8172
     8173/*static*/ DECLCALLBACK(int)
     8174Console::i_logEncryptedDirCtxClose(PCRTLOGOUTPUTIF pIf, void *pvUser, void *pvDirCtx)
     8175{
     8176    RT_NOREF(pIf, pvUser, pvDirCtx);
     8177    Assert((intptr_t)pvDirCtx == 22);
     8178    return VINF_SUCCESS;
     8179}
     8180
     8181/*static*/ DECLCALLBACK(int)
     8182Console::i_logEncryptedDelete(PCRTLOGOUTPUTIF pIf, void *pvUser, void *pvDirCtx, const char *pszFilename)
     8183{
     8184    RT_NOREF(pIf, pvDirCtx, pvUser);
     8185    return RTFileDelete(pszFilename);
     8186}
     8187
     8188
     8189/*static*/ DECLCALLBACK(int)
     8190Console::i_logEncryptedRename(PCRTLOGOUTPUTIF pIf, void *pvUser, void *pvDirCtx,
     8191                              const char *pszFilenameOld, const char *pszFilenameNew, uint32_t fFlags)
     8192{
     8193    RT_NOREF(pIf, pvDirCtx, pvUser);
     8194    return RTFileRename(pszFilenameOld, pszFilenameNew, fFlags);
     8195}
     8196
     8197/*static*/ DECLCALLBACK(int)
     8198Console::i_logEncryptedOpen(PCRTLOGOUTPUTIF pIf, void *pvUser, void *pvDirCtx, const char *pszFilename, uint32_t fFlags)
     8199{
     8200    RT_NOREF(pIf, pvDirCtx);
    81698201    Console *pConsole = static_cast<Console *>(pvUser);
    81708202    RTVFSFILE hVfsFile = NIL_RTVFSFILE;
     
    82048236
    82058237
    8206 /*static*/
    8207 DECLCALLBACK(int) Console::i_logEncryptedClose(PCRTLOGOUTPUTIF pIf, void *pvUser)
     8238/*static*/ DECLCALLBACK(int)
     8239Console::i_logEncryptedClose(PCRTLOGOUTPUTIF pIf, void *pvUser)
    82088240{
    82098241    RT_NOREF(pIf);
     
    82168248
    82178249
    8218 /*static*/
    8219 DECLCALLBACK(int) Console::i_logEncryptedDelete(PCRTLOGOUTPUTIF pIf, void *pvUser, const char *pszFilename)
    8220 {
    8221     RT_NOREF(pIf, pvUser);
    8222     return RTFileDelete(pszFilename);
    8223 }
    8224 
    8225 
    8226 /*static*/
    8227 DECLCALLBACK(int) Console::i_logEncryptedRename(PCRTLOGOUTPUTIF pIf, void *pvUser, const char *pszFilenameOld,
    8228                                                 const char *pszFilenameNew, uint32_t fFlags)
    8229 {
    8230     RT_NOREF(pIf, pvUser);
    8231     return RTFileRename(pszFilenameOld, pszFilenameNew, fFlags);
    8232 }
    8233 
    8234 
    8235 /*static*/
    8236 DECLCALLBACK(int) Console::i_logEncryptedQuerySize(PCRTLOGOUTPUTIF pIf, void *pvUser, uint64_t *pcbSize)
     8250/*static*/ DECLCALLBACK(int)
     8251Console::i_logEncryptedQuerySize(PCRTLOGOUTPUTIF pIf, void *pvUser, uint64_t *pcbSize)
    82378252{
    82388253    RT_NOREF(pIf);
     
    82438258
    82448259
    8245 /*static*/
    8246 DECLCALLBACK(int) Console::i_logEncryptedWrite(PCRTLOGOUTPUTIF pIf, void *pvUser, const void *pvBuf,
    8247                                                size_t cbWrite, size_t *pcbWritten)
     8260/*static*/ DECLCALLBACK(int)
     8261Console::i_logEncryptedWrite(PCRTLOGOUTPUTIF pIf, void *pvUser, const void *pvBuf, size_t cbWrite, size_t *pcbWritten)
    82488262{
    82498263    RT_NOREF(pIf);
     
    82548268
    82558269
    8256 /*static*/
    8257 DECLCALLBACK(int) Console::i_logEncryptedFlush(PCRTLOGOUTPUTIF pIf, void *pvUser)
     8270/*static*/ DECLCALLBACK(int)
     8271Console::i_logEncryptedFlush(PCRTLOGOUTPUTIF pIf, void *pvUser)
    82588272{
    82598273    RT_NOREF(pIf);
     
    82628276    return RTVfsFileFlush(pConsole->m_hVfsFileLog);
    82638277}
    8264 #endif
    8265 
     8278
     8279
     8280/*static*/ RTLOGOUTPUTIF const Console::s_ConsoleEncryptedLogOutputIf =
     8281{
     8282    Console::i_logEncryptedDirCtxOpen,
     8283    Console::i_logEncryptedDirCtxClose,
     8284    Console::i_logEncryptedDelete,
     8285    Console::i_logEncryptedRename,
     8286    Console::i_logEncryptedOpen,
     8287    Console::i_logEncryptedClose,
     8288    Console::i_logEncryptedQuerySize,
     8289    Console::i_logEncryptedWrite,
     8290    Console::i_logEncryptedFlush
     8291};
     8292
     8293#endif /* VBOX_WITH_FULL_VM_ENCRYPTION */
    82668294
    82678295/**
     
    83368364            && bstrLogKeyStore.isNotEmpty())
    83378365        {
    8338             m_LogOutputIf.pfnOpen      = Console::i_logEncryptedOpen;
    8339             m_LogOutputIf.pfnClose     = Console::i_logEncryptedClose;
    8340             m_LogOutputIf.pfnDelete    = Console::i_logEncryptedDelete;
    8341             m_LogOutputIf.pfnRename    = Console::i_logEncryptedRename;
    8342             m_LogOutputIf.pfnQuerySize = Console::i_logEncryptedQuerySize;
    8343             m_LogOutputIf.pfnWrite     = Console::i_logEncryptedWrite;
    8344             m_LogOutputIf.pfnFlush     = Console::i_logEncryptedFlush;
    8345 
    83468366            m_strLogKeyId    = Utf8Str(bstrLogKeyId);
    83478367            m_strLogKeyStore = Utf8Str(bstrLogKeyStore);
    83488368
    8349             pLogOutputIf    = &m_LogOutputIf;
     8369            pLogOutputIf    = &s_ConsoleEncryptedLogOutputIf;
    83508370            pvLogOutputUser = this;
    83518371            m_fEncryptedLog = true;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette