VirtualBox

Changeset 42181 in vbox


Ignore:
Timestamp:
Jul 17, 2012 12:54:11 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
79180
Message:

Another fix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/generic/AutostartDb-generic.cpp

    r42118 r42181  
    2727#include "AutostartDb.h"
    2828
    29 /** @todo: Make configurable through kmk/installer. */
    30 #define AUTOSTART_DATABASE "/etc/vbox/autostart.d"
    31 
    3229#if defined(RT_OS_LINUX)
    3330/**
     
    3835 * @param   fAddVM        Flag whether a VM is added or removed from the database.
    3936 */
    40 static int autostartModifyDb(bool fAutostart, bool fAddVM)
     37int AutostartDb::autostartModifyDb(bool fAutostart, bool fAddVM)
    4138{
    4239    int rc = VINF_SUCCESS;
    4340    char *pszUser = NULL;
     41
     42    /* Check if the path is set. */
     43    if (!m_pszAutostartDbPath)
     44        return VERR_PATH_NOT_FOUND;
    4445
    4546    rc = RTProcQueryUsernameA(RTProcSelf(), &pszUser);
     
    5859
    5960        rc = RTStrAPrintf(&pszFile, "%s/%s.%s",
    60                           AUTOSTART_DATABASE, pszUser, fAutostart ? "start" : "stop");
     61                          m_pszAutostartDbPath, pszUser, fAutostart ? "start" : "stop");
    6162        if (RT_SUCCESS(rc))
    6263        {
     
    141142    int rc = RTCritSectInit(&this->CritSect);
    142143    NOREF(rc);
     144    m_pszAutostartDbPath = NULL;
    143145#endif
    144146}
     
    148150#ifdef RT_OS_LINUX
    149151    RTCritSectDelete(&this->CritSect);
     152    if (m_pszAutostartDbPath)
     153        RTStrFree(m_pszAutostartDbPath);
     154#endif
     155}
     156
     157int AutostartDb::setAutostartDbPath(const char *pszAutostartDbPathNew)
     158{
     159#if defined(RT_OS_LINUX)
     160    char *pszAutostartDbPathTmp = NULL;
     161
     162    if (pszAutostartDbPathNew)
     163    {
     164        pszAutostartDbPathTmp = RTStrDup(pszAutostartDbPathNew);
     165        if (!pszAutostartDbPathTmp)
     166            return VERR_NO_MEMORY;
     167    }
     168
     169    RTCritSectEnter(&this->CritSect);
     170    if (m_pszAutostartDbPath)
     171        RTStrFree(m_pszAutostartDbPath);
     172
     173    m_pszAutostartDbPath = pszAutostartDbPathTmp;
     174    RTCritSectLeave(&this->CritSect);
     175    return VINF_SUCCESS;
     176#else
     177    NOREF(pszAutostartDbPathNew);
     178    return VERR_NOT_SUPPORTED
    150179#endif
    151180}
Note: See TracChangeset for help on using the changeset viewer.

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