ExtPackManagerImpl.cpp revision b10a13ee0c4f4df2aa7cf2b164f0073fbd42e93c
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync * VirtualBox Main - interface for Extension Packs, VBoxSVC & VBoxC.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync * Copyright (C) 2010-2013 Oracle Corporation
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync * available from http://www.virtualbox.org. This file is free software;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync * you can redistribute it and/or modify it under the terms of the GNU
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync * General Public License (GPL) as published by the Free Software
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/*******************************************************************************
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync* Header Files *
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync*******************************************************************************/
#include "Global.h"
#include "ProgressImpl.h"
#if defined(VBOX_COM_INPROC)
# include "ConsoleImpl.h"
# include "VirtualBoxImpl.h"
struct ExtPackBaseData
bool fUsable;
#if !defined(VBOX_COM_INPROC)
bool fMadeReadyCall;
#if !defined(VBOX_COM_INPROC)
#if !defined(VBOX_COM_INPROC)
typedef struct EXTPACKINSTALLJOB
bool fReplace;
typedef struct EXTPACKUNINSTALLJOB
bool fForcedRemoval;
m = NULL;
return BaseFinalConstruct();
HRESULT ExtPackFile::initWithFile(const char *a_pszFile, const char *a_pszDigest, ExtPackManager *a_pExtPackMgr,
m->fUsable = false;
if (pstrTarName)
delete pstrTarName;
delete pStrLoadErr;
return S_OK;
m->fUsable = true;
return S_OK;
return S_OK;
uninit();
m = NULL;
return hrc;
return hrc;
return hrc;
return hrc;
return hrc;
return hrc;
#ifdef VBOX_WITH_XPCOM
return hrc;
return hrc;
return hrc;
STDMETHODIMP ExtPackFile::QueryLicense(IN_BSTR a_bstrPreferredLocale, IN_BSTR a_bstrPreferredLanguage, IN_BSTR a_bstrFormat,
return setError(E_FAIL, tr("The license format can only have the values 'html', 'rtf' and 'txt'."));
if (!m->fUsable)
char *pszName;
if (pvFile)
szName);
return hrc;
return hrc;
STDMETHODIMP ExtPackFile::Install(BOOL a_fReplace, IN_BSTR a_bstrDisplayInfo, IProgress **a_ppProgress)
if (a_ppProgress)
if (m->fUsable)
#ifndef VBOX_COM_INPROC
m->pVirtualBox,
static_cast<IExtPackFile *>(this),
if (pJob)
delete pJob;
return hrc;
m = NULL;
return S_OK;
HRESULT ExtPack::initWithDir(VBOXEXTPACKCTX a_enmContext, const char *a_pszName, const char *a_pszDir)
m = new Data;
m->fUsable = false;
m->pThis = this;
m->fMadeReadyCall = false;
probeAndLoad();
return S_OK;
uninit();
m = NULL;
bool ExtPack::callInstalledHook(IVirtualBox *a_pVirtualBox, AutoWriteLock *a_pLock, PRTERRINFO pErrInfo)
if ( m != NULL
if ( m != NULL
if (!a_fForcedRemoval)
return hrc;
if ( m != NULL
&& m->fUsable
&& !m->fMadeReadyCall)
m->fMadeReadyCall = true;
if ( m != NULL
&& m->fUsable
&& !m->fMadeReadyCall)
m->fMadeReadyCall = true;
bool ExtPack::callVmCreatedHook(IVirtualBox *a_pVirtualBox, IMachine *a_pMachine, AutoWriteLock *a_pLock)
if ( m != NULL
&& m->fUsable)
bool ExtPack::callVmConfigureVmmHook(IConsole *a_pConsole, PVM a_pVM, AutoWriteLock *a_pLock, int *a_pvrc)
if ( m != NULL
&& m->fUsable)
bool ExtPack::callVmPowerOnHook(IConsole *a_pConsole, PVM a_pVM, AutoWriteLock *a_pLock, int *a_pvrc)
if ( m != NULL
&& m->fUsable)
if ( m != NULL
&& m->fUsable)
if ( m != NULL
&& m->fUsable)
hrc = setError(E_FAIL, tr("The extension pack '%s' does not include a VRDE module"), m->Desc.strName.c_str());
return hrc;
return hrc;
return hrc;
return m->fUsable
if (a_pfCanDelete)
*a_pfCanDelete = false;
int vrc = RTPathQueryInfoEx(m->strExtPackPath.c_str(), &ObjInfoExtPack, RTFSOBJATTRADD_UNIX, RTPATH_F_ON_LINK);
if (a_pfCanDelete)
*a_pfCanDelete = true;
return S_OK;
vrc = RTPathJoin(szDescFilePath, sizeof(szDescFilePath), m->strExtPackPath.c_str(), VBOX_EXTPACK_DESCRIPTION_NAME);
vrc = RTPathQueryInfoEx(m->strMainModPath.c_str(), &ObjInfoMainMod, RTFSOBJATTRADD_UNIX, RTPATH_F_ON_LINK);
if (m->fUsable)
probeAndLoad();
probeAndLoad();
return S_OK;
m->fUsable = false;
m->fMadeReadyCall = false;
int vrc = RTPathQueryInfoEx(m->strExtPackPath.c_str(), &m->ObjInfoExtPack, RTFSOBJATTRADD_UNIX, RTPATH_F_ON_LINK);
m->strWhyUnusable.printf(tr("RTPathQueryInfoEx on '%s' failed: %Rrc"), m->strExtPackPath.c_str(), vrc);
vrc = SUPR3HardenedVerifyDir(m->strExtPackPath.c_str(), true /*fRecursive*/, true /*fCheckFiles*/, &ErrInfo.Core);
delete pStrLoadErr;
m->strWhyUnusable.printf(tr("The description name ('%s') and directory name ('%s') does not match"),
bool fIsNative;
m->strWhyUnusable.printf(tr("Failed to locate the main module ('%s')"), m->Desc.strMainModule.c_str());
if (fIsNative)
m->fUsable = true;
if (!a_pszExt)
const char *pszDefExt;
switch (a_enmKind)
AssertFailedReturn(false);
if (!a_pObjInfo)
if (a_pfNative)
*a_pfNative = true;
/* gcc.x86/module.rel */
if (!a_pszExt)
if (a_pfNative)
*a_pfNative = false;
/* x86/module.rel */
if (!a_pszExt)
if (a_pfNative)
*a_pfNative = false;
case RTFSOBJATTRADD_UNIX:
ExtPack::hlpFindModule(PCVBOXEXTPACKHLP pHlp, const char *pszName, const char *pszExt, VBOXEXTPACKMODKIND enmKind,
AssertReturn(enmKind > VBOXEXTPACKMODKIND_INVALID && enmKind < VBOXEXTPACKMODKIND_END, VERR_INVALID_PARAMETER);
return VERR_FILE_NOT_FOUND;
ExtPack::hlpGetFilePath(PCVBOXEXTPACKHLP pHlp, const char *pszFilename, char *pszPath, size_t cbPath)
return vrc;
#ifdef VBOX_COM_INPROC
return VERR_INVALID_STATE;
return VERR_NOT_IMPLEMENTED;
return hrc;
return hrc;
return hrc;
return hrc;
return hrc;
return hrc;
#ifdef VBOX_WITH_XPCOM
return hrc;
return hrc;
return hrc;
STDMETHODIMP ExtPack::QueryLicense(IN_BSTR a_bstrPreferredLocale, IN_BSTR a_bstrPreferredLanguage, IN_BSTR a_bstrFormat,
return setError(E_FAIL, tr("The license format can only have the values 'html', 'rtf' and 'txt'."));
if (!m->fUsable)
void *pvFile;
hrc = setError(VBOX_E_IPRT_ERROR, tr("The license file '%s' is empty or contains invalid UTF-8 encoding"),
szPath);
hrc = setError(VBOX_E_OBJECT_NOT_FOUND, tr("The license file '%s' was not found in extension pack '%s'"),
return hrc;
if ( m->pReg
if (pvUnknown)
return hrc;
m = NULL;
return S_OK;
m = new Data;
#if !defined(VBOX_COM_INPROC)
if (pstrName)
delete pstrName;
return hrc;
uninit();
m = NULL;
STDMETHODIMP ExtPackManager::COMGETTER(InstalledExtPacks)(ComSafeArrayOut(IExtPack *, a_paExtPacks))
return hrc;
return hrc;
STDMETHODIMP ExtPackManager::OpenExtPackFile(IN_BSTR a_bstrTarballAndDigest, IExtPackFile **a_ppExtPackFile)
#if !defined(VBOX_COM_INPROC)
return hrc;
return E_NOTIMPL;
STDMETHODIMP ExtPackManager::Uninstall(IN_BSTR a_bstrName, BOOL a_fForcedRemoval, IN_BSTR a_bstrDisplayInfo,
if (a_ppProgress)
#if !defined(VBOX_COM_INPROC)
#ifndef VBOX_COM_INPROC
m->pVirtualBox,
static_cast<IExtPackManager *>(this),
if (pJob)
delete pJob;
return hrc;
return E_NOTIMPL;
(const char *)NULL);
return hrc;
STDMETHODIMP ExtPackManager::QueryAllPlugInsForFrontend(IN_BSTR a_bstrFrontend, ComSafeArrayOut(BSTR, a_pabstrPlugInModules))
return hrc;
return S_OK;
return NULL;
return NULL;
return pszInd;
HRESULT ExtPackManager::runSetUidToRootHelper(Utf8Str const *a_pstrDisplayInfo, const char *a_pszCommand, ...)
unsigned cArgs = 0;
if ( a_pstrDisplayInfo
const char *pszLastArg;
if (!pszLastArg)
&hProcess);
if (pvNew)
&ProcStatus);
if (offStdErrBuf > 0)
if (pszSuccessInd)
hrc = setError(VBOX_E_IPRT_ERROR, tr("Failed to launch the helper application '%s' (%Rrc)"), szExecName, vrc);
return hrc;
it++)
if ( pExtPackData
return (*it);
return NULL;
it++)
if ( pExtPackData
#if !defined(VBOX_COM_INPROC)
HRESULT ExtPackManager::refreshExtPack(const char *a_pszName, bool a_fUnusableIsError, ExtPack **a_ppExtPack)
if (pExtPack)
bool fCanDelete;
if (fCanDelete)
if (!fValid)
if (!fExists)
vrc = RTPathJoin(szDir, sizeof(szDir), m->strBaseDir.c_str(), Entry.szName); /* not really necessary */
fExists = true;
if (fExists)
&& pExtPack
if (a_ppExtPack)
return hrc;
HRESULT hrc = pJob->ptrExtPackMgr->doInstall(pJob->ptrExtPackFile, pJob->fReplace, &pJob->strDisplayInfo);
delete pJob;
return VINF_SUCCESS;
HRESULT ExtPackManager::doInstall(ExtPackFile *a_pExtPackFile, bool a_fReplace, Utf8Str const *a_pstrDisplayInfo)
else if (pExtPack)
(const char *)NULL);
(const char *)NULL);
return hrc;
HRESULT hrc = pJob->ptrExtPackMgr->doUninstall(&pJob->strName, pJob->fForcedRemoval, &pJob->strDisplayInfo);
delete pJob;
return VINF_SUCCESS;
HRESULT ExtPackManager::doUninstall(Utf8Str const *a_pstrName, bool a_fForcedRemoval, Utf8Str const *a_pstrDisplayInfo)
if (!pExtPack)
LogRel(("ExtPackManager: Extension pack '%s' is not installed, so nothing to uninstall.\n", a_pstrName->c_str()));
(const char *)NULL);
if (!pExtPack)
return hrc;
it++;
it++;
#if !defined(VBOX_COM_INPROC)
int vrc;
return vrc;
return VINF_SUCCESS;
int vrc;
return vrc;
return VINF_SUCCESS;
if (pExtPack)
hrc = setError(VBOX_E_OBJECT_NOT_FOUND, tr("No extension pack by the name '%s' was found"), a_pstrExtPack->c_str());
return hrc;
int ExtPackManager::getVrdeLibraryPathForExtPack(Utf8Str const *a_pstrExtPack, Utf8Str *a_pstrVrdeLibrary)
if (pExtPack)
return hrc;
HRESULT ExtPackManager::getLibraryPathForExtPack(const char *a_pszModuleName, Utf8Str const *a_pstrExtPack,
if (pExtPack)
hrc = setError(VBOX_E_OBJECT_NOT_FOUND, tr("No extension pack by the name '%s' was found"), a_pstrExtPack->c_str());
return hrc;
it++)
return hrc;
it++)
if (pExtPackData)