1 | /* $Id: ExtPackManagerImpl.cpp 74219 2018-09-12 11:40:50Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox Main - interface for Extension Packs, VBoxSVC & VBoxC.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2010-2017 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 |
|
---|
19 | /*********************************************************************************************************************************
|
---|
20 | * Header Files *
|
---|
21 | *********************************************************************************************************************************/
|
---|
22 | #include "ExtPackManagerImpl.h"
|
---|
23 | #include "ExtPackUtil.h"
|
---|
24 | #include "ThreadTask.h"
|
---|
25 |
|
---|
26 | #include <iprt/buildconfig.h>
|
---|
27 | #include <iprt/ctype.h>
|
---|
28 | #include <iprt/dir.h>
|
---|
29 | #include <iprt/env.h>
|
---|
30 | #include <iprt/file.h>
|
---|
31 | #include <iprt/ldr.h>
|
---|
32 | #include <iprt/manifest.h>
|
---|
33 | #include <iprt/param.h>
|
---|
34 | #include <iprt/path.h>
|
---|
35 | #include <iprt/pipe.h>
|
---|
36 | #include <iprt/process.h>
|
---|
37 | #include <iprt/string.h>
|
---|
38 |
|
---|
39 | #include <VBox/com/array.h>
|
---|
40 | #include <VBox/com/ErrorInfo.h>
|
---|
41 | #include <VBox/err.h>
|
---|
42 | #include <VBox/log.h>
|
---|
43 | #include <VBox/sup.h>
|
---|
44 | #include <VBox/version.h>
|
---|
45 | #include "AutoCaller.h"
|
---|
46 | #include "Global.h"
|
---|
47 | #include "ProgressImpl.h"
|
---|
48 | #ifdef VBOX_COM_INPROC
|
---|
49 | # include "ConsoleImpl.h"
|
---|
50 | #else
|
---|
51 | # include "VirtualBoxImpl.h"
|
---|
52 | #endif
|
---|
53 |
|
---|
54 |
|
---|
55 | /*********************************************************************************************************************************
|
---|
56 | * Defined Constants And Macros *
|
---|
57 | *********************************************************************************************************************************/
|
---|
58 | /** @def VBOX_EXTPACK_HELPER_NAME
|
---|
59 | * The name of the utility application we employ to install and uninstall the
|
---|
60 | * extension packs. This is a set-uid-to-root binary on unixy platforms, which
|
---|
61 | * is why it has to be a separate application.
|
---|
62 | */
|
---|
63 | #if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2)
|
---|
64 | # define VBOX_EXTPACK_HELPER_NAME "VBoxExtPackHelperApp.exe"
|
---|
65 | #else
|
---|
66 | # define VBOX_EXTPACK_HELPER_NAME "VBoxExtPackHelperApp"
|
---|
67 | #endif
|
---|
68 |
|
---|
69 |
|
---|
70 | /*********************************************************************************************************************************
|
---|
71 | * Structures and Typedefs *
|
---|
72 | *********************************************************************************************************************************/
|
---|
73 | struct ExtPackBaseData
|
---|
74 | {
|
---|
75 | public:
|
---|
76 | /** The extension pack descriptor (loaded from the XML, mostly). */
|
---|
77 | VBOXEXTPACKDESC Desc;
|
---|
78 | /** The file system object info of the XML file.
|
---|
79 | * This is for detecting changes and save time in refresh(). */
|
---|
80 | RTFSOBJINFO ObjInfoDesc;
|
---|
81 | /** Whether it's usable or not. */
|
---|
82 | bool fUsable;
|
---|
83 | /** Why it is unusable. */
|
---|
84 | Utf8Str strWhyUnusable;
|
---|
85 | };
|
---|
86 |
|
---|
87 | #ifndef VBOX_COM_INPROC
|
---|
88 | /**
|
---|
89 | * Private extension pack data.
|
---|
90 | */
|
---|
91 | struct ExtPackFile::Data : public ExtPackBaseData
|
---|
92 | {
|
---|
93 | public:
|
---|
94 | /** The path to the tarball. */
|
---|
95 | Utf8Str strExtPackFile;
|
---|
96 | /** The SHA-256 hash of the file (as string). */
|
---|
97 | Utf8Str strDigest;
|
---|
98 | /** The file handle of the extension pack file. */
|
---|
99 | RTFILE hExtPackFile;
|
---|
100 | /** Our manifest for the tarball. */
|
---|
101 | RTMANIFEST hOurManifest;
|
---|
102 | /** Pointer to the extension pack manager. */
|
---|
103 | ComObjPtr<ExtPackManager> ptrExtPackMgr;
|
---|
104 | /** Pointer to the VirtualBox object so we can create a progress object. */
|
---|
105 | VirtualBox *pVirtualBox;
|
---|
106 |
|
---|
107 | RTMEMEF_NEW_AND_DELETE_OPERATORS();
|
---|
108 | };
|
---|
109 | #endif
|
---|
110 |
|
---|
111 | /**
|
---|
112 | * Private extension pack data.
|
---|
113 | */
|
---|
114 | struct ExtPack::Data : public ExtPackBaseData
|
---|
115 | {
|
---|
116 | public:
|
---|
117 | /** Where the extension pack is located. */
|
---|
118 | Utf8Str strExtPackPath;
|
---|
119 | /** The file system object info of the extension pack directory.
|
---|
120 | * This is for detecting changes and save time in refresh(). */
|
---|
121 | RTFSOBJINFO ObjInfoExtPack;
|
---|
122 | /** The full path to the main module. */
|
---|
123 | Utf8Str strMainModPath;
|
---|
124 | /** The file system object info of the main module.
|
---|
125 | * This is used to determin whether to bother try reload it. */
|
---|
126 | RTFSOBJINFO ObjInfoMainMod;
|
---|
127 | /** The module handle of the main extension pack module. */
|
---|
128 | RTLDRMOD hMainMod;
|
---|
129 |
|
---|
130 | /** The helper callbacks for the extension pack. */
|
---|
131 | VBOXEXTPACKHLP Hlp;
|
---|
132 | /** Pointer back to the extension pack object (for Hlp methods). */
|
---|
133 | ExtPack *pThis;
|
---|
134 | #ifndef VBOX_COM_INPROC
|
---|
135 | /** The extension pack main registration structure. */
|
---|
136 | PCVBOXEXTPACKREG pReg;
|
---|
137 | #else
|
---|
138 | /** The extension pack main VM registration structure. */
|
---|
139 | PCVBOXEXTPACKVMREG pReg;
|
---|
140 | #endif
|
---|
141 | /** The current context. */
|
---|
142 | VBOXEXTPACKCTX enmContext;
|
---|
143 | /** Set if we've made the pfnVirtualBoxReady or pfnConsoleReady call. */
|
---|
144 | bool fMadeReadyCall;
|
---|
145 | #ifndef VBOX_COM_INPROC
|
---|
146 | /** Pointer to the VirtualBox object so we can create a progress object. */
|
---|
147 | VirtualBox *pVirtualBox;
|
---|
148 | #endif
|
---|
149 |
|
---|
150 | RTMEMEF_NEW_AND_DELETE_OPERATORS();
|
---|
151 | };
|
---|
152 |
|
---|
153 | /** List of extension packs. */
|
---|
154 | typedef std::list< ComObjPtr<ExtPack> > ExtPackList;
|
---|
155 |
|
---|
156 | /**
|
---|
157 | * Private extension pack manager data.
|
---|
158 | */
|
---|
159 | struct ExtPackManager::Data
|
---|
160 | {
|
---|
161 | Data()
|
---|
162 | : cUpdate(0)
|
---|
163 | {}
|
---|
164 |
|
---|
165 | /** The directory where the extension packs are installed. */
|
---|
166 | Utf8Str strBaseDir;
|
---|
167 | /** The directory where the certificates this installation recognizes are
|
---|
168 | * stored. */
|
---|
169 | Utf8Str strCertificatDirPath;
|
---|
170 | /** The list of installed extension packs. */
|
---|
171 | ExtPackList llInstalledExtPacks;
|
---|
172 | #ifndef VBOX_COM_INPROC
|
---|
173 | /** Pointer to the VirtualBox object, our parent. */
|
---|
174 | VirtualBox *pVirtualBox;
|
---|
175 | #endif
|
---|
176 | /** The current context. */
|
---|
177 | VBOXEXTPACKCTX enmContext;
|
---|
178 | /** Update counter for the installed extension packs, increased in every list update. */
|
---|
179 | uint64_t cUpdate;
|
---|
180 |
|
---|
181 | RTMEMEF_NEW_AND_DELETE_OPERATORS();
|
---|
182 | };
|
---|
183 |
|
---|
184 | #ifndef VBOX_COM_INPROC
|
---|
185 |
|
---|
186 | /**
|
---|
187 | * Extension pack installation job.
|
---|
188 | */
|
---|
189 | class ExtPackInstallTask : public ThreadTask
|
---|
190 | {
|
---|
191 | public:
|
---|
192 | explicit ExtPackInstallTask() : ThreadTask("ExtPackInst") { }
|
---|
193 | ~ExtPackInstallTask() { }
|
---|
194 |
|
---|
195 | void handler()
|
---|
196 | {
|
---|
197 | HRESULT hrc = ptrExtPackMgr->i_doInstall(ptrExtPackFile, fReplace, &strDisplayInfo);
|
---|
198 | ptrProgress->i_notifyComplete(hrc);
|
---|
199 | }
|
---|
200 |
|
---|
201 | HRESULT Init(const ComPtr<ExtPackFile> &a_strExtPackFile, bool a_fReplace,
|
---|
202 | const Utf8Str &strDispInfo, const ComPtr<ExtPackManager> &a_ptrExtPackMgr)
|
---|
203 | {
|
---|
204 | ptrExtPackFile = a_strExtPackFile;
|
---|
205 | fReplace = a_fReplace;
|
---|
206 | strDisplayInfo = strDispInfo;
|
---|
207 | ptrExtPackMgr = a_ptrExtPackMgr;
|
---|
208 |
|
---|
209 | HRESULT hrc = ptrProgress.createObject();
|
---|
210 | if (SUCCEEDED(hrc))
|
---|
211 | {
|
---|
212 | Bstr bstrDescription("Installing extension pack");
|
---|
213 | hrc = ptrProgress->init(ptrExtPackFile->m->pVirtualBox,
|
---|
214 | static_cast<IExtPackFile *>(ptrExtPackFile),
|
---|
215 | bstrDescription.raw(),
|
---|
216 | FALSE /*aCancelable*/);
|
---|
217 | }
|
---|
218 |
|
---|
219 | return hrc;
|
---|
220 | }
|
---|
221 |
|
---|
222 | /** Smart pointer to the progress object for this job. */
|
---|
223 | ComObjPtr<Progress> ptrProgress;
|
---|
224 | private:
|
---|
225 | /** Smart pointer to the extension pack file. */
|
---|
226 | ComPtr<ExtPackFile> ptrExtPackFile;
|
---|
227 | /** The replace argument. */
|
---|
228 | bool fReplace;
|
---|
229 | /** The display info argument. */
|
---|
230 | Utf8Str strDisplayInfo;
|
---|
231 | /** Smart pointer to the extension manager. */
|
---|
232 | ComPtr<ExtPackManager> ptrExtPackMgr;
|
---|
233 | };
|
---|
234 |
|
---|
235 | /**
|
---|
236 | * Extension pack uninstallation job.
|
---|
237 | */
|
---|
238 | class ExtPackUninstallTask : public ThreadTask
|
---|
239 | {
|
---|
240 | public:
|
---|
241 | explicit ExtPackUninstallTask() : ThreadTask("ExtPackUninst") { }
|
---|
242 | ~ExtPackUninstallTask() { }
|
---|
243 |
|
---|
244 | void handler()
|
---|
245 | {
|
---|
246 | HRESULT hrc = ptrExtPackMgr->i_doUninstall(&strName, fForcedRemoval, &strDisplayInfo);
|
---|
247 | ptrProgress->i_notifyComplete(hrc);
|
---|
248 | }
|
---|
249 |
|
---|
250 | HRESULT Init(const ComPtr<ExtPackManager> &a_ptrExtPackMgr, const Utf8Str &a_strName,
|
---|
251 | bool a_fForcedRemoval, const Utf8Str &a_strDisplayInfo)
|
---|
252 | {
|
---|
253 | ptrExtPackMgr = a_ptrExtPackMgr;
|
---|
254 | strName = a_strName;
|
---|
255 | fForcedRemoval = a_fForcedRemoval;
|
---|
256 | strDisplayInfo = a_strDisplayInfo;
|
---|
257 |
|
---|
258 | HRESULT hrc = ptrProgress.createObject();
|
---|
259 | if (SUCCEEDED(hrc))
|
---|
260 | {
|
---|
261 | Bstr bstrDescription("Uninstalling extension pack");
|
---|
262 | hrc = ptrProgress->init(ptrExtPackMgr->m->pVirtualBox,
|
---|
263 | static_cast<IExtPackManager *>(ptrExtPackMgr),
|
---|
264 | bstrDescription.raw(),
|
---|
265 | FALSE /*aCancelable*/);
|
---|
266 | }
|
---|
267 |
|
---|
268 | return hrc;
|
---|
269 | }
|
---|
270 |
|
---|
271 | /** Smart pointer to the progress object for this job. */
|
---|
272 | ComObjPtr<Progress> ptrProgress;
|
---|
273 | private:
|
---|
274 | /** Smart pointer to the extension manager. */
|
---|
275 | ComPtr<ExtPackManager> ptrExtPackMgr;
|
---|
276 | /** The name of the extension pack. */
|
---|
277 | Utf8Str strName;
|
---|
278 | /** The replace argument. */
|
---|
279 | bool fForcedRemoval;
|
---|
280 | /** The display info argument. */
|
---|
281 | Utf8Str strDisplayInfo;
|
---|
282 | };
|
---|
283 |
|
---|
284 | DEFINE_EMPTY_CTOR_DTOR(ExtPackFile)
|
---|
285 |
|
---|
286 | /**
|
---|
287 | * Called by ComObjPtr::createObject when creating the object.
|
---|
288 | *
|
---|
289 | * Just initialize the basic object state, do the rest in initWithDir().
|
---|
290 | *
|
---|
291 | * @returns S_OK.
|
---|
292 | */
|
---|
293 | HRESULT ExtPackFile::FinalConstruct()
|
---|
294 | {
|
---|
295 | m = NULL;
|
---|
296 | return BaseFinalConstruct();
|
---|
297 | }
|
---|
298 |
|
---|
299 | /**
|
---|
300 | * Initializes the extension pack by reading its file.
|
---|
301 | *
|
---|
302 | * @returns COM status code.
|
---|
303 | * @param a_pszFile The path to the extension pack file.
|
---|
304 | * @param a_pszDigest The SHA-256 digest of the file. Or an empty string.
|
---|
305 | * @param a_pExtPackMgr Pointer to the extension pack manager.
|
---|
306 | * @param a_pVirtualBox Pointer to the VirtualBox object.
|
---|
307 | */
|
---|
308 | HRESULT ExtPackFile::initWithFile(const char *a_pszFile, const char *a_pszDigest, ExtPackManager *a_pExtPackMgr,
|
---|
309 | VirtualBox *a_pVirtualBox)
|
---|
310 | {
|
---|
311 | AutoInitSpan autoInitSpan(this);
|
---|
312 | AssertReturn(autoInitSpan.isOk(), E_FAIL);
|
---|
313 |
|
---|
314 | /*
|
---|
315 | * Allocate + initialize our private data.
|
---|
316 | */
|
---|
317 | m = new ExtPackFile::Data;
|
---|
318 | VBoxExtPackInitDesc(&m->Desc);
|
---|
319 | RT_ZERO(m->ObjInfoDesc);
|
---|
320 | m->fUsable = false;
|
---|
321 | m->strWhyUnusable = tr("ExtPack::init failed");
|
---|
322 | m->strExtPackFile = a_pszFile;
|
---|
323 | m->strDigest = a_pszDigest;
|
---|
324 | m->hExtPackFile = NIL_RTFILE;
|
---|
325 | m->hOurManifest = NIL_RTMANIFEST;
|
---|
326 | m->ptrExtPackMgr = a_pExtPackMgr;
|
---|
327 | m->pVirtualBox = a_pVirtualBox;
|
---|
328 |
|
---|
329 | RTCString *pstrTarName = VBoxExtPackExtractNameFromTarballPath(a_pszFile);
|
---|
330 | if (pstrTarName)
|
---|
331 | {
|
---|
332 | m->Desc.strName = *pstrTarName;
|
---|
333 | delete pstrTarName;
|
---|
334 | pstrTarName = NULL;
|
---|
335 | }
|
---|
336 |
|
---|
337 | autoInitSpan.setSucceeded();
|
---|
338 |
|
---|
339 | /*
|
---|
340 | * Try open the extension pack and check that it is a regular file.
|
---|
341 | */
|
---|
342 | int vrc = RTFileOpen(&m->hExtPackFile, a_pszFile,
|
---|
343 | RTFILE_O_READ | RTFILE_O_DENY_WRITE | RTFILE_O_OPEN);
|
---|
344 | if (RT_FAILURE(vrc))
|
---|
345 | {
|
---|
346 | if (vrc == VERR_FILE_NOT_FOUND || vrc == VERR_PATH_NOT_FOUND)
|
---|
347 | return initFailed(tr("'%s' file not found"), a_pszFile);
|
---|
348 | return initFailed(tr("RTFileOpen('%s',,) failed with %Rrc"), a_pszFile, vrc);
|
---|
349 | }
|
---|
350 |
|
---|
351 | RTFSOBJINFO ObjInfo;
|
---|
352 | vrc = RTFileQueryInfo(m->hExtPackFile, &ObjInfo, RTFSOBJATTRADD_UNIX);
|
---|
353 | if (RT_FAILURE(vrc))
|
---|
354 | return initFailed(tr("RTFileQueryInfo failed with %Rrc on '%s'"), vrc, a_pszFile);
|
---|
355 | if (!RTFS_IS_FILE(ObjInfo.Attr.fMode))
|
---|
356 | return initFailed(tr("Not a regular file: %s"), a_pszFile);
|
---|
357 |
|
---|
358 | /*
|
---|
359 | * Validate the tarball and extract the XML file.
|
---|
360 | */
|
---|
361 | char szError[8192];
|
---|
362 | RTVFSFILE hXmlFile;
|
---|
363 | vrc = VBoxExtPackValidateTarball(m->hExtPackFile, NULL /*pszExtPackName*/, a_pszFile, a_pszDigest,
|
---|
364 | szError, sizeof(szError), &m->hOurManifest, &hXmlFile, &m->strDigest);
|
---|
365 | if (RT_FAILURE(vrc))
|
---|
366 | return initFailed(tr("%s"), szError);
|
---|
367 |
|
---|
368 | /*
|
---|
369 | * Parse the XML.
|
---|
370 | */
|
---|
371 | RTCString strSavedName(m->Desc.strName);
|
---|
372 | RTCString *pStrLoadErr = VBoxExtPackLoadDescFromVfsFile(hXmlFile, &m->Desc, &m->ObjInfoDesc);
|
---|
373 | RTVfsFileRelease(hXmlFile);
|
---|
374 | if (pStrLoadErr != NULL)
|
---|
375 | {
|
---|
376 | m->strWhyUnusable.printf(tr("Failed to the xml file: %s"), pStrLoadErr->c_str());
|
---|
377 | m->Desc.strName = strSavedName;
|
---|
378 | delete pStrLoadErr;
|
---|
379 | return S_OK;
|
---|
380 | }
|
---|
381 |
|
---|
382 | /*
|
---|
383 | * Match the tarball name with the name from the XML.
|
---|
384 | */
|
---|
385 | /** @todo drop this restriction after the old install interface is
|
---|
386 | * dropped. */
|
---|
387 | if (!strSavedName.equalsIgnoreCase(m->Desc.strName))
|
---|
388 | return initFailed(tr("Extension pack name mismatch between the downloaded file and the XML inside it (xml='%s' file='%s')"),
|
---|
389 | m->Desc.strName.c_str(), strSavedName.c_str());
|
---|
390 |
|
---|
391 |
|
---|
392 | m->fUsable = true;
|
---|
393 | m->strWhyUnusable.setNull();
|
---|
394 | return S_OK;
|
---|
395 | }
|
---|
396 |
|
---|
397 | /**
|
---|
398 | * Protected helper that formats the strWhyUnusable value.
|
---|
399 | *
|
---|
400 | * @returns S_OK
|
---|
401 | * @param a_pszWhyFmt Why it failed, format string.
|
---|
402 | * @param ... The format arguments.
|
---|
403 | */
|
---|
404 | HRESULT ExtPackFile::initFailed(const char *a_pszWhyFmt, ...)
|
---|
405 | {
|
---|
406 | va_list va;
|
---|
407 | va_start(va, a_pszWhyFmt);
|
---|
408 | m->strWhyUnusable.printfV(a_pszWhyFmt, va);
|
---|
409 | va_end(va);
|
---|
410 | return S_OK;
|
---|
411 | }
|
---|
412 |
|
---|
413 | /**
|
---|
414 | * COM cruft.
|
---|
415 | */
|
---|
416 | void ExtPackFile::FinalRelease()
|
---|
417 | {
|
---|
418 | uninit();
|
---|
419 | BaseFinalRelease();
|
---|
420 | }
|
---|
421 |
|
---|
422 | /**
|
---|
423 | * Do the actual cleanup.
|
---|
424 | */
|
---|
425 | void ExtPackFile::uninit()
|
---|
426 | {
|
---|
427 | /* Enclose the state transition Ready->InUninit->NotReady */
|
---|
428 | AutoUninitSpan autoUninitSpan(this);
|
---|
429 | if (!autoUninitSpan.uninitDone() && m != NULL)
|
---|
430 | {
|
---|
431 | VBoxExtPackFreeDesc(&m->Desc);
|
---|
432 | RTFileClose(m->hExtPackFile);
|
---|
433 | m->hExtPackFile = NIL_RTFILE;
|
---|
434 | RTManifestRelease(m->hOurManifest);
|
---|
435 | m->hOurManifest = NIL_RTMANIFEST;
|
---|
436 |
|
---|
437 | delete m;
|
---|
438 | m = NULL;
|
---|
439 | }
|
---|
440 | }
|
---|
441 |
|
---|
442 | HRESULT ExtPackFile::getName(com::Utf8Str &aName)
|
---|
443 | {
|
---|
444 | aName = m->Desc.strName;
|
---|
445 | return S_OK;
|
---|
446 | }
|
---|
447 |
|
---|
448 | HRESULT ExtPackFile::getDescription(com::Utf8Str &aDescription)
|
---|
449 | {
|
---|
450 | aDescription = m->Desc.strDescription;
|
---|
451 | return S_OK;
|
---|
452 | }
|
---|
453 |
|
---|
454 | HRESULT ExtPackFile::getVersion(com::Utf8Str &aVersion)
|
---|
455 | {
|
---|
456 | aVersion = m->Desc.strVersion;
|
---|
457 | return S_OK;
|
---|
458 | }
|
---|
459 |
|
---|
460 | HRESULT ExtPackFile::getEdition(com::Utf8Str &aEdition)
|
---|
461 | {
|
---|
462 | aEdition = m->Desc.strEdition;
|
---|
463 | return S_OK;
|
---|
464 | }
|
---|
465 |
|
---|
466 | HRESULT ExtPackFile::getRevision(ULONG *aRevision)
|
---|
467 | {
|
---|
468 | *aRevision = m->Desc.uRevision;
|
---|
469 | return S_OK;
|
---|
470 | }
|
---|
471 |
|
---|
472 | HRESULT ExtPackFile::getVRDEModule(com::Utf8Str &aVRDEModule)
|
---|
473 | {
|
---|
474 | aVRDEModule = m->Desc.strVrdeModule;
|
---|
475 | return S_OK;
|
---|
476 | }
|
---|
477 |
|
---|
478 | HRESULT ExtPackFile::getPlugIns(std::vector<ComPtr<IExtPackPlugIn> > &aPlugIns)
|
---|
479 | {
|
---|
480 | /** @todo implement plug-ins. */
|
---|
481 | #ifdef VBOX_WITH_XPCOM
|
---|
482 | NOREF(aPlugIns);
|
---|
483 | #endif
|
---|
484 | NOREF(aPlugIns);
|
---|
485 | ReturnComNotImplemented();
|
---|
486 | }
|
---|
487 |
|
---|
488 | HRESULT ExtPackFile::getUsable(BOOL *aUsable)
|
---|
489 | {
|
---|
490 | *aUsable = m->fUsable;
|
---|
491 | return S_OK;
|
---|
492 | }
|
---|
493 |
|
---|
494 | HRESULT ExtPackFile::getWhyUnusable(com::Utf8Str &aWhyUnusable)
|
---|
495 | {
|
---|
496 | aWhyUnusable = m->strWhyUnusable;
|
---|
497 | return S_OK;
|
---|
498 | }
|
---|
499 |
|
---|
500 | HRESULT ExtPackFile::getShowLicense(BOOL *aShowLicense)
|
---|
501 | {
|
---|
502 | *aShowLicense = m->Desc.fShowLicense;
|
---|
503 | return S_OK;
|
---|
504 | }
|
---|
505 |
|
---|
506 | HRESULT ExtPackFile::getLicense(com::Utf8Str &aLicense)
|
---|
507 | {
|
---|
508 | Utf8Str strHtml("html");
|
---|
509 | Utf8Str str("");
|
---|
510 | return queryLicense(str, str, strHtml, aLicense);
|
---|
511 | }
|
---|
512 |
|
---|
513 | /* Same as ExtPack::QueryLicense, should really explore the subject of base classes here... */
|
---|
514 | HRESULT ExtPackFile::queryLicense(const com::Utf8Str &aPreferredLocale, const com::Utf8Str &aPreferredLanguage,
|
---|
515 | const com::Utf8Str &aFormat, com::Utf8Str &aLicenseText)
|
---|
516 | {
|
---|
517 | HRESULT hrc = S_OK;
|
---|
518 |
|
---|
519 | /*
|
---|
520 | * Validate input.
|
---|
521 | */
|
---|
522 |
|
---|
523 | if (aPreferredLocale.length() != 2 && aPreferredLocale.length() != 0)
|
---|
524 | return setError(E_FAIL, tr("The preferred locale is a two character string or empty."));
|
---|
525 |
|
---|
526 | if (aPreferredLanguage.length() != 2 && aPreferredLanguage.length() != 0)
|
---|
527 | return setError(E_FAIL, tr("The preferred lanuage is a two character string or empty."));
|
---|
528 |
|
---|
529 | if ( !aFormat.equals("html")
|
---|
530 | && !aFormat.equals("rtf")
|
---|
531 | && !aFormat.equals("txt"))
|
---|
532 | return setError(E_FAIL, tr("The license format can only have the values 'html', 'rtf' and 'txt'."));
|
---|
533 |
|
---|
534 | /*
|
---|
535 | * Combine the options to form a file name before locking down anything.
|
---|
536 | */
|
---|
537 | char szName[sizeof(VBOX_EXTPACK_LICENSE_NAME_PREFIX "-de_DE.html") + 2];
|
---|
538 | if (aPreferredLocale.isNotEmpty() && aPreferredLanguage.isNotEmpty())
|
---|
539 | RTStrPrintf(szName, sizeof(szName), VBOX_EXTPACK_LICENSE_NAME_PREFIX "-%s_%s.%s",
|
---|
540 | aPreferredLocale.c_str(), aPreferredLanguage.c_str(), aFormat.c_str());
|
---|
541 | else if (aPreferredLocale.isNotEmpty())
|
---|
542 | RTStrPrintf(szName, sizeof(szName), VBOX_EXTPACK_LICENSE_NAME_PREFIX "-%s.%s",
|
---|
543 | aPreferredLocale.c_str(), aFormat.c_str());
|
---|
544 | else if (aPreferredLanguage.isNotEmpty())
|
---|
545 | RTStrPrintf(szName, sizeof(szName), VBOX_EXTPACK_LICENSE_NAME_PREFIX "-_%s.%s",
|
---|
546 | aPreferredLocale.c_str(), aFormat.c_str());
|
---|
547 | else
|
---|
548 | RTStrPrintf(szName, sizeof(szName), VBOX_EXTPACK_LICENSE_NAME_PREFIX ".%s",
|
---|
549 | aFormat.c_str());
|
---|
550 | /*
|
---|
551 | * Lock the extension pack. We need a write lock here as there must not be
|
---|
552 | * concurrent accesses to the tar file handle.
|
---|
553 | */
|
---|
554 | AutoWriteLock autoLock(this COMMA_LOCKVAL_SRC_POS);
|
---|
555 |
|
---|
556 | /*
|
---|
557 | * Do not permit this query on a pack that isn't considered usable (could
|
---|
558 | * be marked so because of bad license files).
|
---|
559 | */
|
---|
560 | if (!m->fUsable)
|
---|
561 | hrc = setError(E_FAIL, tr("%s"), m->strWhyUnusable.c_str());
|
---|
562 | else
|
---|
563 | {
|
---|
564 | /*
|
---|
565 | * Look it up in the manifest before scanning the tarball for it
|
---|
566 | */
|
---|
567 | if (RTManifestEntryExists(m->hOurManifest, szName))
|
---|
568 | {
|
---|
569 | RTVFSFSSTREAM hTarFss;
|
---|
570 | char szError[8192];
|
---|
571 | int vrc = VBoxExtPackOpenTarFss(m->hExtPackFile, szError, sizeof(szError), &hTarFss, NULL);
|
---|
572 | if (RT_SUCCESS(vrc))
|
---|
573 | {
|
---|
574 | for (;;)
|
---|
575 | {
|
---|
576 | /* Get the first/next. */
|
---|
577 | char *pszName;
|
---|
578 | RTVFSOBJ hVfsObj;
|
---|
579 | RTVFSOBJTYPE enmType;
|
---|
580 | vrc = RTVfsFsStrmNext(hTarFss, &pszName, &enmType, &hVfsObj);
|
---|
581 | if (RT_FAILURE(vrc))
|
---|
582 | {
|
---|
583 | if (vrc != VERR_EOF)
|
---|
584 | hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("RTVfsFsStrmNext failed: %Rrc"), vrc);
|
---|
585 | else
|
---|
586 | hrc = setErrorBoth(E_UNEXPECTED, vrc, tr("'%s' was found in the manifest but not in the tarball"), szName);
|
---|
587 | break;
|
---|
588 | }
|
---|
589 |
|
---|
590 | /* Is this it? */
|
---|
591 | const char *pszAdjName = pszName[0] == '.' && pszName[1] == '/' ? &pszName[2] : pszName;
|
---|
592 | if ( !strcmp(pszAdjName, szName)
|
---|
593 | && ( enmType == RTVFSOBJTYPE_IO_STREAM
|
---|
594 | || enmType == RTVFSOBJTYPE_FILE))
|
---|
595 | {
|
---|
596 | RTVFSIOSTREAM hVfsIos = RTVfsObjToIoStream(hVfsObj);
|
---|
597 | RTVfsObjRelease(hVfsObj);
|
---|
598 | RTStrFree(pszName);
|
---|
599 |
|
---|
600 | /* Load the file into memory. */
|
---|
601 | RTFSOBJINFO ObjInfo;
|
---|
602 | vrc = RTVfsIoStrmQueryInfo(hVfsIos, &ObjInfo, RTFSOBJATTRADD_NOTHING);
|
---|
603 | if (RT_SUCCESS(vrc))
|
---|
604 | {
|
---|
605 | size_t cbFile = (size_t)ObjInfo.cbObject;
|
---|
606 | void *pvFile = RTMemAllocZ(cbFile + 1);
|
---|
607 | if (pvFile)
|
---|
608 | {
|
---|
609 | vrc = RTVfsIoStrmRead(hVfsIos, pvFile, cbFile, true /*fBlocking*/, NULL);
|
---|
610 | if (RT_SUCCESS(vrc))
|
---|
611 | {
|
---|
612 | /* try translate it into a string we can return. */
|
---|
613 | Bstr bstrLicense((const char *)pvFile, cbFile);
|
---|
614 | if (bstrLicense.isNotEmpty())
|
---|
615 | {
|
---|
616 | aLicenseText = Utf8Str(bstrLicense);
|
---|
617 | hrc = S_OK;
|
---|
618 | }
|
---|
619 | else
|
---|
620 | hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc,
|
---|
621 | tr("The license file '%s' is empty or contains invalid UTF-8 encoding"),
|
---|
622 | szName);
|
---|
623 | }
|
---|
624 | else
|
---|
625 | hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Failed to read '%s': %Rrc"), szName, vrc);
|
---|
626 | RTMemFree(pvFile);
|
---|
627 | }
|
---|
628 | else
|
---|
629 | hrc = setError(E_OUTOFMEMORY, tr("Failed to allocate %zu bytes for '%s'"), cbFile, szName);
|
---|
630 | }
|
---|
631 | else
|
---|
632 | hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("RTVfsIoStrmQueryInfo on '%s': %Rrc"), szName, vrc);
|
---|
633 | RTVfsIoStrmRelease(hVfsIos);
|
---|
634 | break;
|
---|
635 | }
|
---|
636 |
|
---|
637 | /* Release current. */
|
---|
638 | RTVfsObjRelease(hVfsObj);
|
---|
639 | RTStrFree(pszName);
|
---|
640 | }
|
---|
641 | RTVfsFsStrmRelease(hTarFss);
|
---|
642 | }
|
---|
643 | else
|
---|
644 | hrc = setError(VBOX_E_OBJECT_NOT_FOUND, tr("%s"), szError);
|
---|
645 | }
|
---|
646 | else
|
---|
647 | hrc = setError(VBOX_E_OBJECT_NOT_FOUND, tr("The license file '%s' was not found in '%s'"),
|
---|
648 | szName, m->strExtPackFile.c_str());
|
---|
649 | }
|
---|
650 | return hrc;
|
---|
651 | }
|
---|
652 |
|
---|
653 | HRESULT ExtPackFile::getFilePath(com::Utf8Str &aFilePath)
|
---|
654 | {
|
---|
655 |
|
---|
656 | aFilePath = m->strExtPackFile;
|
---|
657 | return S_OK;
|
---|
658 | }
|
---|
659 |
|
---|
660 | HRESULT ExtPackFile::install(BOOL aReplace, const com::Utf8Str &aDisplayInfo, ComPtr<IProgress> &aProgress)
|
---|
661 | {
|
---|
662 | HRESULT hrc;
|
---|
663 | if (m->fUsable)
|
---|
664 | {
|
---|
665 | ExtPackInstallTask *pTask = NULL;
|
---|
666 | try
|
---|
667 | {
|
---|
668 | pTask = new ExtPackInstallTask();
|
---|
669 | hrc = pTask->Init(this, aReplace != FALSE, aDisplayInfo, m->ptrExtPackMgr);
|
---|
670 | if (SUCCEEDED(hrc))
|
---|
671 | {
|
---|
672 | ComPtr<Progress> ptrProgress = pTask->ptrProgress;
|
---|
673 | hrc = pTask->createThreadWithType(RTTHREADTYPE_DEFAULT);
|
---|
674 | pTask = NULL; /* The _completely_ _undocumented_ createThread method always consumes pTask. */
|
---|
675 | if (SUCCEEDED(hrc))
|
---|
676 | hrc = ptrProgress.queryInterfaceTo(aProgress.asOutParam());
|
---|
677 | else
|
---|
678 | hrc = setError(VBOX_E_IPRT_ERROR,
|
---|
679 | tr("Starting thread for an extension pack installation failed with %Rrc"), hrc);
|
---|
680 | }
|
---|
681 | else
|
---|
682 | hrc = setError(VBOX_E_IPRT_ERROR,
|
---|
683 | tr("Looks like creating a progress object for ExtraPackInstallTask object failed"));
|
---|
684 | }
|
---|
685 | catch (std::bad_alloc &)
|
---|
686 | {
|
---|
687 | hrc = E_OUTOFMEMORY;
|
---|
688 | }
|
---|
689 | catch (HRESULT hrcXcpt)
|
---|
690 | {
|
---|
691 | LogFlowThisFunc(("Exception was caught in the function ExtPackFile::install() \n"));
|
---|
692 | hrc = hrcXcpt;
|
---|
693 | }
|
---|
694 | if (pTask)
|
---|
695 | delete pTask;
|
---|
696 | }
|
---|
697 | else
|
---|
698 | hrc = setError(E_FAIL, "%s", m->strWhyUnusable.c_str());
|
---|
699 | return hrc;
|
---|
700 | }
|
---|
701 |
|
---|
702 | #endif /* !VBOX_COM_INPROC */
|
---|
703 |
|
---|
704 |
|
---|
705 |
|
---|
706 |
|
---|
707 | DEFINE_EMPTY_CTOR_DTOR(ExtPack)
|
---|
708 |
|
---|
709 | /**
|
---|
710 | * Called by ComObjPtr::createObject when creating the object.
|
---|
711 | *
|
---|
712 | * Just initialize the basic object state, do the rest in initWithDir().
|
---|
713 | *
|
---|
714 | * @returns S_OK.
|
---|
715 | */
|
---|
716 | HRESULT ExtPack::FinalConstruct()
|
---|
717 | {
|
---|
718 | m = NULL;
|
---|
719 | return BaseFinalConstruct();
|
---|
720 | }
|
---|
721 |
|
---|
722 | /**
|
---|
723 | * Initializes the extension pack by reading its file.
|
---|
724 | *
|
---|
725 | * @returns COM status code.
|
---|
726 | * @param a_pVirtualBox The VirtualBox object.
|
---|
727 | * @param a_enmContext The context we're in.
|
---|
728 | * @param a_pszName The name of the extension pack. This is also the
|
---|
729 | * name of the subdirector under @a a_pszParentDir
|
---|
730 | * where the extension pack is installed.
|
---|
731 | * @param a_pszDir The extension pack directory name.
|
---|
732 | */
|
---|
733 | HRESULT ExtPack::initWithDir(VirtualBox *a_pVirtualBox, VBOXEXTPACKCTX a_enmContext, const char *a_pszName, const char *a_pszDir)
|
---|
734 | {
|
---|
735 | AutoInitSpan autoInitSpan(this);
|
---|
736 | AssertReturn(autoInitSpan.isOk(), E_FAIL);
|
---|
737 |
|
---|
738 | static const VBOXEXTPACKHLP s_HlpTmpl =
|
---|
739 | {
|
---|
740 | /* u32Version = */ VBOXEXTPACKHLP_VERSION,
|
---|
741 | /* uVBoxFullVersion = */ VBOX_FULL_VERSION,
|
---|
742 | /* uVBoxVersionRevision = */ 0,
|
---|
743 | /* u32Padding = */ 0,
|
---|
744 | /* pszVBoxVersion = */ "",
|
---|
745 | /* pfnFindModule = */ ExtPack::i_hlpFindModule,
|
---|
746 | /* pfnGetFilePath = */ ExtPack::i_hlpGetFilePath,
|
---|
747 | /* pfnGetContext = */ ExtPack::i_hlpGetContext,
|
---|
748 | /* pfnLoadHGCMService = */ ExtPack::i_hlpLoadHGCMService,
|
---|
749 | /* pfnLoadVDPlugin = */ ExtPack::i_hlpLoadVDPlugin,
|
---|
750 | /* pfnUnloadVDPlugin = */ ExtPack::i_hlpUnloadVDPlugin,
|
---|
751 | /* pfnCreateProgress = */ ExtPack::i_hlpCreateProgress,
|
---|
752 | /* pfnGetCanceledProgress = */ ExtPack::i_hlpGetCanceledProgress,
|
---|
753 | /* pfnUpdateProgress = */ ExtPack::i_hlpUpdateProgress,
|
---|
754 | /* pfnNextOperationProgress = */ ExtPack::i_hlpNextOperationProgress,
|
---|
755 | /* pfnWaitOtherProgress = */ ExtPack::i_hlpWaitOtherProgress,
|
---|
756 | /* pfnCompleteProgress = */ ExtPack::i_hlpCompleteProgress,
|
---|
757 | /* pfnReserved1 = */ ExtPack::i_hlpReservedN,
|
---|
758 | /* pfnReserved2 = */ ExtPack::i_hlpReservedN,
|
---|
759 | /* pfnReserved3 = */ ExtPack::i_hlpReservedN,
|
---|
760 | /* pfnReserved4 = */ ExtPack::i_hlpReservedN,
|
---|
761 | /* pfnReserved5 = */ ExtPack::i_hlpReservedN,
|
---|
762 | /* pfnReserved6 = */ ExtPack::i_hlpReservedN,
|
---|
763 | /* u32EndMarker = */ VBOXEXTPACKHLP_VERSION
|
---|
764 | };
|
---|
765 |
|
---|
766 | /*
|
---|
767 | * Allocate + initialize our private data.
|
---|
768 | */
|
---|
769 | m = new Data;
|
---|
770 | VBoxExtPackInitDesc(&m->Desc);
|
---|
771 | m->Desc.strName = a_pszName;
|
---|
772 | RT_ZERO(m->ObjInfoDesc);
|
---|
773 | m->fUsable = false;
|
---|
774 | m->strWhyUnusable = tr("ExtPack::init failed");
|
---|
775 | m->strExtPackPath = a_pszDir;
|
---|
776 | RT_ZERO(m->ObjInfoExtPack);
|
---|
777 | m->strMainModPath.setNull();
|
---|
778 | RT_ZERO(m->ObjInfoMainMod);
|
---|
779 | m->hMainMod = NIL_RTLDRMOD;
|
---|
780 | m->Hlp = s_HlpTmpl;
|
---|
781 | m->Hlp.pszVBoxVersion = RTBldCfgVersion();
|
---|
782 | m->Hlp.uVBoxInternalRevision = RTBldCfgRevision();
|
---|
783 | m->pThis = this;
|
---|
784 | m->pReg = NULL;
|
---|
785 | m->enmContext = a_enmContext;
|
---|
786 | m->fMadeReadyCall = false;
|
---|
787 | #ifndef VBOX_COM_INPROC
|
---|
788 | m->pVirtualBox = a_pVirtualBox;
|
---|
789 | #else
|
---|
790 | RT_NOREF(a_pVirtualBox);
|
---|
791 | #endif
|
---|
792 |
|
---|
793 | /*
|
---|
794 | * Make sure the SUPR3Hardened API works (ignoring errors for now).
|
---|
795 | */
|
---|
796 | int rc = SUPR3HardenedVerifyInit();
|
---|
797 | if (RT_FAILURE(rc))
|
---|
798 | LogRel(("SUPR3HardenedVerifyInit failed: %Rrc\n", rc));
|
---|
799 |
|
---|
800 | /*
|
---|
801 | * Probe the extension pack (this code is shared with refresh()).
|
---|
802 | */
|
---|
803 | i_probeAndLoad();
|
---|
804 |
|
---|
805 | autoInitSpan.setSucceeded();
|
---|
806 | return S_OK;
|
---|
807 | }
|
---|
808 |
|
---|
809 | /**
|
---|
810 | * COM cruft.
|
---|
811 | */
|
---|
812 | void ExtPack::FinalRelease()
|
---|
813 | {
|
---|
814 | uninit();
|
---|
815 | BaseFinalRelease();
|
---|
816 | }
|
---|
817 |
|
---|
818 | /**
|
---|
819 | * Do the actual cleanup.
|
---|
820 | */
|
---|
821 | void ExtPack::uninit()
|
---|
822 | {
|
---|
823 | /* Enclose the state transition Ready->InUninit->NotReady */
|
---|
824 | AutoUninitSpan autoUninitSpan(this);
|
---|
825 | if (!autoUninitSpan.uninitDone() && m != NULL)
|
---|
826 | {
|
---|
827 | if (m->hMainMod != NIL_RTLDRMOD)
|
---|
828 | {
|
---|
829 | AssertPtr(m->pReg);
|
---|
830 | if (m->pReg->pfnUnload != NULL)
|
---|
831 | m->pReg->pfnUnload(m->pReg);
|
---|
832 |
|
---|
833 | RTLdrClose(m->hMainMod);
|
---|
834 | m->hMainMod = NIL_RTLDRMOD;
|
---|
835 | m->pReg = NULL;
|
---|
836 | }
|
---|
837 |
|
---|
838 | VBoxExtPackFreeDesc(&m->Desc);
|
---|
839 |
|
---|
840 | delete m;
|
---|
841 | m = NULL;
|
---|
842 | }
|
---|
843 | }
|
---|
844 |
|
---|
845 |
|
---|
846 | #ifndef VBOX_COM_INPROC
|
---|
847 | /**
|
---|
848 | * Calls the installed hook.
|
---|
849 | *
|
---|
850 | * @returns true if we left the lock, false if we didn't.
|
---|
851 | * @param a_pVirtualBox The VirtualBox interface.
|
---|
852 | * @param a_pLock The write lock held by the caller.
|
---|
853 | * @param pErrInfo Where to return error information.
|
---|
854 | */
|
---|
855 | bool ExtPack::i_callInstalledHook(IVirtualBox *a_pVirtualBox, AutoWriteLock *a_pLock, PRTERRINFO pErrInfo)
|
---|
856 | {
|
---|
857 | if ( m != NULL
|
---|
858 | && m->hMainMod != NIL_RTLDRMOD)
|
---|
859 | {
|
---|
860 | if (m->pReg->pfnInstalled)
|
---|
861 | {
|
---|
862 | ComPtr<ExtPack> ptrSelfRef = this;
|
---|
863 | a_pLock->release();
|
---|
864 | pErrInfo->rc = m->pReg->pfnInstalled(m->pReg, a_pVirtualBox, pErrInfo);
|
---|
865 | a_pLock->acquire();
|
---|
866 | return true;
|
---|
867 | }
|
---|
868 | }
|
---|
869 | pErrInfo->rc = VINF_SUCCESS;
|
---|
870 | return false;
|
---|
871 | }
|
---|
872 |
|
---|
873 | /**
|
---|
874 | * Calls the uninstall hook and closes the module.
|
---|
875 | *
|
---|
876 | * @returns S_OK or COM error status with error information.
|
---|
877 | * @param a_pVirtualBox The VirtualBox interface.
|
---|
878 | * @param a_fForcedRemoval When set, we'll ignore complaints from the
|
---|
879 | * uninstall hook.
|
---|
880 | * @remarks The caller holds the manager's write lock, not released.
|
---|
881 | */
|
---|
882 | HRESULT ExtPack::i_callUninstallHookAndClose(IVirtualBox *a_pVirtualBox, bool a_fForcedRemoval)
|
---|
883 | {
|
---|
884 | HRESULT hrc = S_OK;
|
---|
885 |
|
---|
886 | if ( m != NULL
|
---|
887 | && m->hMainMod != NIL_RTLDRMOD)
|
---|
888 | {
|
---|
889 | if (m->pReg->pfnUninstall && !a_fForcedRemoval)
|
---|
890 | {
|
---|
891 | int vrc = m->pReg->pfnUninstall(m->pReg, a_pVirtualBox);
|
---|
892 | if (RT_FAILURE(vrc))
|
---|
893 | {
|
---|
894 | LogRel(("ExtPack pfnUninstall returned %Rrc for %s\n", vrc, m->Desc.strName.c_str()));
|
---|
895 | if (!a_fForcedRemoval)
|
---|
896 | hrc = setErrorBoth(E_FAIL, vrc, tr("pfnUninstall returned %Rrc"), vrc);
|
---|
897 | }
|
---|
898 | }
|
---|
899 | if (SUCCEEDED(hrc))
|
---|
900 | {
|
---|
901 | RTLdrClose(m->hMainMod);
|
---|
902 | m->hMainMod = NIL_RTLDRMOD;
|
---|
903 | m->pReg = NULL;
|
---|
904 | }
|
---|
905 | }
|
---|
906 |
|
---|
907 | return hrc;
|
---|
908 | }
|
---|
909 |
|
---|
910 | /**
|
---|
911 | * Calls the pfnVirtualBoxReady hook.
|
---|
912 | *
|
---|
913 | * @returns true if we left the lock, false if we didn't.
|
---|
914 | * @param a_pVirtualBox The VirtualBox interface.
|
---|
915 | * @param a_pLock The write lock held by the caller.
|
---|
916 | */
|
---|
917 | bool ExtPack::i_callVirtualBoxReadyHook(IVirtualBox *a_pVirtualBox, AutoWriteLock *a_pLock)
|
---|
918 | {
|
---|
919 | if ( m != NULL
|
---|
920 | && m->fUsable
|
---|
921 | && m->hMainMod != NIL_RTLDRMOD
|
---|
922 | && !m->fMadeReadyCall)
|
---|
923 | {
|
---|
924 | m->fMadeReadyCall = true;
|
---|
925 | if (m->pReg->pfnVirtualBoxReady)
|
---|
926 | {
|
---|
927 | ComPtr<ExtPack> ptrSelfRef = this;
|
---|
928 | a_pLock->release();
|
---|
929 | m->pReg->pfnVirtualBoxReady(m->pReg, a_pVirtualBox);
|
---|
930 | a_pLock->acquire();
|
---|
931 | return true;
|
---|
932 | }
|
---|
933 | }
|
---|
934 | return false;
|
---|
935 | }
|
---|
936 | #endif /* !VBOX_COM_INPROC */
|
---|
937 |
|
---|
938 | #ifdef VBOX_COM_INPROC
|
---|
939 | /**
|
---|
940 | * Calls the pfnConsoleReady hook.
|
---|
941 | *
|
---|
942 | * @returns true if we left the lock, false if we didn't.
|
---|
943 | * @param a_pConsole The Console interface.
|
---|
944 | * @param a_pLock The write lock held by the caller.
|
---|
945 | */
|
---|
946 | bool ExtPack::i_callConsoleReadyHook(IConsole *a_pConsole, AutoWriteLock *a_pLock)
|
---|
947 | {
|
---|
948 | if ( m != NULL
|
---|
949 | && m->fUsable
|
---|
950 | && m->hMainMod != NIL_RTLDRMOD
|
---|
951 | && !m->fMadeReadyCall)
|
---|
952 | {
|
---|
953 | m->fMadeReadyCall = true;
|
---|
954 | if (m->pReg->pfnConsoleReady)
|
---|
955 | {
|
---|
956 | ComPtr<ExtPack> ptrSelfRef = this;
|
---|
957 | a_pLock->release();
|
---|
958 | m->pReg->pfnConsoleReady(m->pReg, a_pConsole);
|
---|
959 | a_pLock->acquire();
|
---|
960 | return true;
|
---|
961 | }
|
---|
962 | }
|
---|
963 | return false;
|
---|
964 | }
|
---|
965 | #endif /* VBOX_COM_INPROC */
|
---|
966 |
|
---|
967 | #ifndef VBOX_COM_INPROC
|
---|
968 | /**
|
---|
969 | * Calls the pfnVMCreate hook.
|
---|
970 | *
|
---|
971 | * @returns true if we left the lock, false if we didn't.
|
---|
972 | * @param a_pVirtualBox The VirtualBox interface.
|
---|
973 | * @param a_pMachine The machine interface of the new VM.
|
---|
974 | * @param a_pLock The write lock held by the caller.
|
---|
975 | */
|
---|
976 | bool ExtPack::i_callVmCreatedHook(IVirtualBox *a_pVirtualBox, IMachine *a_pMachine, AutoWriteLock *a_pLock)
|
---|
977 | {
|
---|
978 | if ( m != NULL
|
---|
979 | && m->hMainMod != NIL_RTLDRMOD
|
---|
980 | && m->fUsable)
|
---|
981 | {
|
---|
982 | if (m->pReg->pfnVMCreated)
|
---|
983 | {
|
---|
984 | ComPtr<ExtPack> ptrSelfRef = this;
|
---|
985 | a_pLock->release();
|
---|
986 | m->pReg->pfnVMCreated(m->pReg, a_pVirtualBox, a_pMachine);
|
---|
987 | a_pLock->acquire();
|
---|
988 | return true;
|
---|
989 | }
|
---|
990 | }
|
---|
991 | return false;
|
---|
992 | }
|
---|
993 | #endif /* !VBOX_COM_INPROC */
|
---|
994 |
|
---|
995 | #ifdef VBOX_COM_INPROC
|
---|
996 | /**
|
---|
997 | * Calls the pfnVMConfigureVMM hook.
|
---|
998 | *
|
---|
999 | * @returns true if we left the lock, false if we didn't.
|
---|
1000 | * @param a_pConsole The console interface.
|
---|
1001 | * @param a_pVM The VM handle.
|
---|
1002 | * @param a_pLock The write lock held by the caller.
|
---|
1003 | * @param a_pvrc Where to return the status code of the
|
---|
1004 | * callback. This is always set. LogRel is
|
---|
1005 | * called on if a failure status is returned.
|
---|
1006 | */
|
---|
1007 | bool ExtPack::i_callVmConfigureVmmHook(IConsole *a_pConsole, PVM a_pVM, AutoWriteLock *a_pLock, int *a_pvrc)
|
---|
1008 | {
|
---|
1009 | *a_pvrc = VINF_SUCCESS;
|
---|
1010 | if ( m != NULL
|
---|
1011 | && m->hMainMod != NIL_RTLDRMOD
|
---|
1012 | && m->fUsable)
|
---|
1013 | {
|
---|
1014 | if (m->pReg->pfnVMConfigureVMM)
|
---|
1015 | {
|
---|
1016 | ComPtr<ExtPack> ptrSelfRef = this;
|
---|
1017 | a_pLock->release();
|
---|
1018 | int vrc = m->pReg->pfnVMConfigureVMM(m->pReg, a_pConsole, a_pVM);
|
---|
1019 | *a_pvrc = vrc;
|
---|
1020 | a_pLock->acquire();
|
---|
1021 | if (RT_FAILURE(vrc))
|
---|
1022 | LogRel(("ExtPack pfnVMConfigureVMM returned %Rrc for %s\n", vrc, m->Desc.strName.c_str()));
|
---|
1023 | return true;
|
---|
1024 | }
|
---|
1025 | }
|
---|
1026 | return false;
|
---|
1027 | }
|
---|
1028 |
|
---|
1029 | /**
|
---|
1030 | * Calls the pfnVMPowerOn hook.
|
---|
1031 | *
|
---|
1032 | * @returns true if we left the lock, false if we didn't.
|
---|
1033 | * @param a_pConsole The console interface.
|
---|
1034 | * @param a_pVM The VM handle.
|
---|
1035 | * @param a_pLock The write lock held by the caller.
|
---|
1036 | * @param a_pvrc Where to return the status code of the
|
---|
1037 | * callback. This is always set. LogRel is
|
---|
1038 | * called on if a failure status is returned.
|
---|
1039 | */
|
---|
1040 | bool ExtPack::i_callVmPowerOnHook(IConsole *a_pConsole, PVM a_pVM, AutoWriteLock *a_pLock, int *a_pvrc)
|
---|
1041 | {
|
---|
1042 | *a_pvrc = VINF_SUCCESS;
|
---|
1043 | if ( m != NULL
|
---|
1044 | && m->hMainMod != NIL_RTLDRMOD
|
---|
1045 | && m->fUsable)
|
---|
1046 | {
|
---|
1047 | if (m->pReg->pfnVMPowerOn)
|
---|
1048 | {
|
---|
1049 | ComPtr<ExtPack> ptrSelfRef = this;
|
---|
1050 | a_pLock->release();
|
---|
1051 | int vrc = m->pReg->pfnVMPowerOn(m->pReg, a_pConsole, a_pVM);
|
---|
1052 | *a_pvrc = vrc;
|
---|
1053 | a_pLock->acquire();
|
---|
1054 | if (RT_FAILURE(vrc))
|
---|
1055 | LogRel(("ExtPack pfnVMPowerOn returned %Rrc for %s\n", vrc, m->Desc.strName.c_str()));
|
---|
1056 | return true;
|
---|
1057 | }
|
---|
1058 | }
|
---|
1059 | return false;
|
---|
1060 | }
|
---|
1061 |
|
---|
1062 | /**
|
---|
1063 | * Calls the pfnVMPowerOff hook.
|
---|
1064 | *
|
---|
1065 | * @returns true if we left the lock, false if we didn't.
|
---|
1066 | * @param a_pConsole The console interface.
|
---|
1067 | * @param a_pVM The VM handle.
|
---|
1068 | * @param a_pLock The write lock held by the caller.
|
---|
1069 | */
|
---|
1070 | bool ExtPack::i_callVmPowerOffHook(IConsole *a_pConsole, PVM a_pVM, AutoWriteLock *a_pLock)
|
---|
1071 | {
|
---|
1072 | if ( m != NULL
|
---|
1073 | && m->hMainMod != NIL_RTLDRMOD
|
---|
1074 | && m->fUsable)
|
---|
1075 | {
|
---|
1076 | if (m->pReg->pfnVMPowerOff)
|
---|
1077 | {
|
---|
1078 | ComPtr<ExtPack> ptrSelfRef = this;
|
---|
1079 | a_pLock->release();
|
---|
1080 | m->pReg->pfnVMPowerOff(m->pReg, a_pConsole, a_pVM);
|
---|
1081 | a_pLock->acquire();
|
---|
1082 | return true;
|
---|
1083 | }
|
---|
1084 | }
|
---|
1085 | return false;
|
---|
1086 | }
|
---|
1087 | #endif /* !VBOX_COM_INPROC */
|
---|
1088 |
|
---|
1089 | /**
|
---|
1090 | * Check if the extension pack is usable and has an VRDE module.
|
---|
1091 | *
|
---|
1092 | * @returns S_OK or COM error status with error information.
|
---|
1093 | *
|
---|
1094 | * @remarks Caller holds the extension manager lock for reading, no locking
|
---|
1095 | * necessary.
|
---|
1096 | */
|
---|
1097 | HRESULT ExtPack::i_checkVrde(void)
|
---|
1098 | {
|
---|
1099 | HRESULT hrc;
|
---|
1100 | if ( m != NULL
|
---|
1101 | && m->fUsable)
|
---|
1102 | {
|
---|
1103 | if (m->Desc.strVrdeModule.isNotEmpty())
|
---|
1104 | hrc = S_OK;
|
---|
1105 | else
|
---|
1106 | hrc = setError(E_FAIL, tr("The extension pack '%s' does not include a VRDE module"), m->Desc.strName.c_str());
|
---|
1107 | }
|
---|
1108 | else
|
---|
1109 | hrc = setError(E_FAIL, tr("%s"), m->strWhyUnusable.c_str());
|
---|
1110 | return hrc;
|
---|
1111 | }
|
---|
1112 |
|
---|
1113 | /**
|
---|
1114 | * Same as checkVrde(), except that it also resolves the path to the module.
|
---|
1115 | *
|
---|
1116 | * @returns S_OK or COM error status with error information.
|
---|
1117 | * @param a_pstrVrdeLibrary Where to return the path on success.
|
---|
1118 | *
|
---|
1119 | * @remarks Caller holds the extension manager lock for reading, no locking
|
---|
1120 | * necessary.
|
---|
1121 | */
|
---|
1122 | HRESULT ExtPack::i_getVrdpLibraryName(Utf8Str *a_pstrVrdeLibrary)
|
---|
1123 | {
|
---|
1124 | HRESULT hrc = i_checkVrde();
|
---|
1125 | if (SUCCEEDED(hrc))
|
---|
1126 | {
|
---|
1127 | if (i_findModule(m->Desc.strVrdeModule.c_str(), NULL, VBOXEXTPACKMODKIND_R3,
|
---|
1128 | a_pstrVrdeLibrary, NULL /*a_pfNative*/, NULL /*a_pObjInfo*/))
|
---|
1129 | hrc = S_OK;
|
---|
1130 | else
|
---|
1131 | hrc = setError(E_FAIL, tr("Failed to locate the VRDE module '%s' in extension pack '%s'"),
|
---|
1132 | m->Desc.strVrdeModule.c_str(), m->Desc.strName.c_str());
|
---|
1133 | }
|
---|
1134 | return hrc;
|
---|
1135 | }
|
---|
1136 |
|
---|
1137 | /**
|
---|
1138 | * Resolves the path to the module.
|
---|
1139 | *
|
---|
1140 | * @returns S_OK or COM error status with error information.
|
---|
1141 | * @param a_pszModuleName The library.
|
---|
1142 | * @param a_pstrLibrary Where to return the path on success.
|
---|
1143 | *
|
---|
1144 | * @remarks Caller holds the extension manager lock for reading, no locking
|
---|
1145 | * necessary.
|
---|
1146 | */
|
---|
1147 | HRESULT ExtPack::i_getLibraryName(const char *a_pszModuleName, Utf8Str *a_pstrLibrary)
|
---|
1148 | {
|
---|
1149 | HRESULT hrc;
|
---|
1150 | if (i_findModule(a_pszModuleName, NULL, VBOXEXTPACKMODKIND_R3,
|
---|
1151 | a_pstrLibrary, NULL /*a_pfNative*/, NULL /*a_pObjInfo*/))
|
---|
1152 | hrc = S_OK;
|
---|
1153 | else
|
---|
1154 | hrc = setError(E_FAIL, tr("Failed to locate the module '%s' in extension pack '%s'"),
|
---|
1155 | a_pszModuleName, m->Desc.strName.c_str());
|
---|
1156 | return hrc;
|
---|
1157 | }
|
---|
1158 |
|
---|
1159 | /**
|
---|
1160 | * Check if this extension pack wishes to be the default VRDE provider.
|
---|
1161 | *
|
---|
1162 | * @returns @c true if it wants to and it is in a usable state, otherwise
|
---|
1163 | * @c false.
|
---|
1164 | *
|
---|
1165 | * @remarks Caller holds the extension manager lock for reading, no locking
|
---|
1166 | * necessary.
|
---|
1167 | */
|
---|
1168 | bool ExtPack::i_wantsToBeDefaultVrde(void) const
|
---|
1169 | {
|
---|
1170 | return m->fUsable
|
---|
1171 | && m->Desc.strVrdeModule.isNotEmpty();
|
---|
1172 | }
|
---|
1173 |
|
---|
1174 | /**
|
---|
1175 | * Refreshes the extension pack state.
|
---|
1176 | *
|
---|
1177 | * This is called by the manager so that the on disk changes are picked up.
|
---|
1178 | *
|
---|
1179 | * @returns S_OK or COM error status with error information.
|
---|
1180 | *
|
---|
1181 | * @param a_pfCanDelete Optional can-delete-this-object output indicator.
|
---|
1182 | *
|
---|
1183 | * @remarks Caller holds the extension manager lock for writing.
|
---|
1184 | * @remarks Only called in VBoxSVC.
|
---|
1185 | */
|
---|
1186 | HRESULT ExtPack::i_refresh(bool *a_pfCanDelete)
|
---|
1187 | {
|
---|
1188 | if (a_pfCanDelete)
|
---|
1189 | *a_pfCanDelete = false;
|
---|
1190 |
|
---|
1191 | AutoWriteLock autoLock(this COMMA_LOCKVAL_SRC_POS); /* for the COMGETTERs */
|
---|
1192 |
|
---|
1193 | /*
|
---|
1194 | * Has the module been deleted?
|
---|
1195 | */
|
---|
1196 | RTFSOBJINFO ObjInfoExtPack;
|
---|
1197 | int vrc = RTPathQueryInfoEx(m->strExtPackPath.c_str(), &ObjInfoExtPack, RTFSOBJATTRADD_UNIX, RTPATH_F_ON_LINK);
|
---|
1198 | if ( RT_FAILURE(vrc)
|
---|
1199 | || !RTFS_IS_DIRECTORY(ObjInfoExtPack.Attr.fMode))
|
---|
1200 | {
|
---|
1201 | if (a_pfCanDelete)
|
---|
1202 | *a_pfCanDelete = true;
|
---|
1203 | return S_OK;
|
---|
1204 | }
|
---|
1205 |
|
---|
1206 | /*
|
---|
1207 | * We've got a directory, so try query file system object info for the
|
---|
1208 | * files we are interested in as well.
|
---|
1209 | */
|
---|
1210 | RTFSOBJINFO ObjInfoDesc;
|
---|
1211 | char szDescFilePath[RTPATH_MAX];
|
---|
1212 | vrc = RTPathJoin(szDescFilePath, sizeof(szDescFilePath), m->strExtPackPath.c_str(), VBOX_EXTPACK_DESCRIPTION_NAME);
|
---|
1213 | if (RT_SUCCESS(vrc))
|
---|
1214 | vrc = RTPathQueryInfoEx(szDescFilePath, &ObjInfoDesc, RTFSOBJATTRADD_UNIX, RTPATH_F_ON_LINK);
|
---|
1215 | if (RT_FAILURE(vrc))
|
---|
1216 | RT_ZERO(ObjInfoDesc);
|
---|
1217 |
|
---|
1218 | RTFSOBJINFO ObjInfoMainMod;
|
---|
1219 | if (m->strMainModPath.isNotEmpty())
|
---|
1220 | vrc = RTPathQueryInfoEx(m->strMainModPath.c_str(), &ObjInfoMainMod, RTFSOBJATTRADD_UNIX, RTPATH_F_ON_LINK);
|
---|
1221 | if (m->strMainModPath.isEmpty() || RT_FAILURE(vrc))
|
---|
1222 | RT_ZERO(ObjInfoMainMod);
|
---|
1223 |
|
---|
1224 | /*
|
---|
1225 | * If we have a usable module already, just verify that things haven't
|
---|
1226 | * changed since we loaded it.
|
---|
1227 | */
|
---|
1228 | if (m->fUsable)
|
---|
1229 | {
|
---|
1230 | if (m->hMainMod == NIL_RTLDRMOD)
|
---|
1231 | i_probeAndLoad();
|
---|
1232 | else if ( !i_objinfoIsEqual(&ObjInfoDesc, &m->ObjInfoDesc)
|
---|
1233 | || !i_objinfoIsEqual(&ObjInfoMainMod, &m->ObjInfoMainMod)
|
---|
1234 | || !i_objinfoIsEqual(&ObjInfoExtPack, &m->ObjInfoExtPack) )
|
---|
1235 | {
|
---|
1236 | /** @todo not important, so it can wait. */
|
---|
1237 | }
|
---|
1238 | }
|
---|
1239 | /*
|
---|
1240 | * Ok, it is currently not usable. If anything has changed since last time
|
---|
1241 | * reprobe the extension pack.
|
---|
1242 | */
|
---|
1243 | else if ( !i_objinfoIsEqual(&ObjInfoDesc, &m->ObjInfoDesc)
|
---|
1244 | || !i_objinfoIsEqual(&ObjInfoMainMod, &m->ObjInfoMainMod)
|
---|
1245 | || !i_objinfoIsEqual(&ObjInfoExtPack, &m->ObjInfoExtPack) )
|
---|
1246 | i_probeAndLoad();
|
---|
1247 |
|
---|
1248 | return S_OK;
|
---|
1249 | }
|
---|
1250 |
|
---|
1251 | /**
|
---|
1252 | * Probes the extension pack, loading the main dll and calling its registration
|
---|
1253 | * entry point.
|
---|
1254 | *
|
---|
1255 | * This updates the state accordingly, the strWhyUnusable and fUnusable members
|
---|
1256 | * being the most important ones.
|
---|
1257 | */
|
---|
1258 | void ExtPack::i_probeAndLoad(void)
|
---|
1259 | {
|
---|
1260 | m->fUsable = false;
|
---|
1261 | m->fMadeReadyCall = false;
|
---|
1262 |
|
---|
1263 | /*
|
---|
1264 | * Query the file system info for the extension pack directory. This and
|
---|
1265 | * all other file system info we save is for the benefit of refresh().
|
---|
1266 | */
|
---|
1267 | int vrc = RTPathQueryInfoEx(m->strExtPackPath.c_str(), &m->ObjInfoExtPack, RTFSOBJATTRADD_UNIX, RTPATH_F_ON_LINK);
|
---|
1268 | if (RT_FAILURE(vrc))
|
---|
1269 | {
|
---|
1270 | m->strWhyUnusable.printf(tr("RTPathQueryInfoEx on '%s' failed: %Rrc"), m->strExtPackPath.c_str(), vrc);
|
---|
1271 | return;
|
---|
1272 | }
|
---|
1273 | if (!RTFS_IS_DIRECTORY(m->ObjInfoExtPack.Attr.fMode))
|
---|
1274 | {
|
---|
1275 | if (RTFS_IS_SYMLINK(m->ObjInfoExtPack.Attr.fMode))
|
---|
1276 | m->strWhyUnusable.printf(tr("'%s' is a symbolic link, this is not allowed"),
|
---|
1277 | m->strExtPackPath.c_str(), vrc);
|
---|
1278 | else if (RTFS_IS_FILE(m->ObjInfoExtPack.Attr.fMode))
|
---|
1279 | m->strWhyUnusable.printf(tr("'%s' is a symbolic file, not a directory"),
|
---|
1280 | m->strExtPackPath.c_str(), vrc);
|
---|
1281 | else
|
---|
1282 | m->strWhyUnusable.printf(tr("'%s' is not a directory (fMode=%#x)"),
|
---|
1283 | m->strExtPackPath.c_str(), m->ObjInfoExtPack.Attr.fMode);
|
---|
1284 | return;
|
---|
1285 | }
|
---|
1286 |
|
---|
1287 | RTERRINFOSTATIC ErrInfo;
|
---|
1288 | RTErrInfoInitStatic(&ErrInfo);
|
---|
1289 | vrc = SUPR3HardenedVerifyDir(m->strExtPackPath.c_str(), true /*fRecursive*/, true /*fCheckFiles*/, &ErrInfo.Core);
|
---|
1290 | if (RT_FAILURE(vrc))
|
---|
1291 | {
|
---|
1292 | m->strWhyUnusable.printf(tr("%s (rc=%Rrc)"), ErrInfo.Core.pszMsg, vrc);
|
---|
1293 | return;
|
---|
1294 | }
|
---|
1295 |
|
---|
1296 | /*
|
---|
1297 | * Read the description file.
|
---|
1298 | */
|
---|
1299 | RTCString strSavedName(m->Desc.strName);
|
---|
1300 | RTCString *pStrLoadErr = VBoxExtPackLoadDesc(m->strExtPackPath.c_str(), &m->Desc, &m->ObjInfoDesc);
|
---|
1301 | if (pStrLoadErr != NULL)
|
---|
1302 | {
|
---|
1303 | m->strWhyUnusable.printf(tr("Failed to load '%s/%s': %s"),
|
---|
1304 | m->strExtPackPath.c_str(), VBOX_EXTPACK_DESCRIPTION_NAME, pStrLoadErr->c_str());
|
---|
1305 | m->Desc.strName = strSavedName;
|
---|
1306 | delete pStrLoadErr;
|
---|
1307 | return;
|
---|
1308 | }
|
---|
1309 |
|
---|
1310 | /*
|
---|
1311 | * Make sure the XML name and directory matches.
|
---|
1312 | */
|
---|
1313 | if (!m->Desc.strName.equalsIgnoreCase(strSavedName))
|
---|
1314 | {
|
---|
1315 | m->strWhyUnusable.printf(tr("The description name ('%s') and directory name ('%s') does not match"),
|
---|
1316 | m->Desc.strName.c_str(), strSavedName.c_str());
|
---|
1317 | m->Desc.strName = strSavedName;
|
---|
1318 | return;
|
---|
1319 | }
|
---|
1320 |
|
---|
1321 | /*
|
---|
1322 | * Load the main DLL and call the predefined entry point.
|
---|
1323 | */
|
---|
1324 | #ifndef VBOX_COM_INPROC
|
---|
1325 | const char *pszMainModule = m->Desc.strMainModule.c_str();
|
---|
1326 | #else
|
---|
1327 | const char *pszMainModule = m->Desc.strMainVMModule.c_str();
|
---|
1328 | if (m->Desc.strMainVMModule.isEmpty())
|
---|
1329 | {
|
---|
1330 | /*
|
---|
1331 | * We're good! The main module for VM processes is optional.
|
---|
1332 | */
|
---|
1333 | m->fUsable = true;
|
---|
1334 | m->strWhyUnusable.setNull();
|
---|
1335 | return;
|
---|
1336 | }
|
---|
1337 | #endif
|
---|
1338 | bool fIsNative;
|
---|
1339 | if (!i_findModule(pszMainModule, NULL /* default extension */, VBOXEXTPACKMODKIND_R3,
|
---|
1340 | &m->strMainModPath, &fIsNative, &m->ObjInfoMainMod))
|
---|
1341 | {
|
---|
1342 | m->strWhyUnusable.printf(tr("Failed to locate the main module ('%s')"), pszMainModule);
|
---|
1343 | return;
|
---|
1344 | }
|
---|
1345 |
|
---|
1346 | vrc = SUPR3HardenedVerifyPlugIn(m->strMainModPath.c_str(), &ErrInfo.Core);
|
---|
1347 | if (RT_FAILURE(vrc))
|
---|
1348 | {
|
---|
1349 | m->strWhyUnusable.printf(tr("%s"), ErrInfo.Core.pszMsg);
|
---|
1350 | return;
|
---|
1351 | }
|
---|
1352 |
|
---|
1353 | if (fIsNative)
|
---|
1354 | {
|
---|
1355 | vrc = SUPR3HardenedLdrLoadPlugIn(m->strMainModPath.c_str(), &m->hMainMod, &ErrInfo.Core);
|
---|
1356 | if (RT_FAILURE(vrc))
|
---|
1357 | {
|
---|
1358 | m->hMainMod = NIL_RTLDRMOD;
|
---|
1359 | m->strWhyUnusable.printf(tr("Failed to load the main module ('%s'): %Rrc - %s"),
|
---|
1360 | m->strMainModPath.c_str(), vrc, ErrInfo.Core.pszMsg);
|
---|
1361 | return;
|
---|
1362 | }
|
---|
1363 | }
|
---|
1364 | else
|
---|
1365 | {
|
---|
1366 | m->strWhyUnusable.printf(tr("Only native main modules are currently supported"));
|
---|
1367 | return;
|
---|
1368 | }
|
---|
1369 |
|
---|
1370 | /*
|
---|
1371 | * Resolve the predefined entry point.
|
---|
1372 | */
|
---|
1373 | #ifndef VBOX_COM_INPROC
|
---|
1374 | const char *pszMainEntryPoint = VBOX_EXTPACK_MAIN_MOD_ENTRY_POINT;
|
---|
1375 | PFNVBOXEXTPACKREGISTER pfnRegistration;
|
---|
1376 | uint32_t uVersion = VBOXEXTPACKREG_VERSION;
|
---|
1377 | #else
|
---|
1378 | const char *pszMainEntryPoint = VBOX_EXTPACK_MAIN_VM_MOD_ENTRY_POINT;
|
---|
1379 | PFNVBOXEXTPACKVMREGISTER pfnRegistration;
|
---|
1380 | uint32_t uVersion = VBOXEXTPACKVMREG_VERSION;
|
---|
1381 | #endif
|
---|
1382 | vrc = RTLdrGetSymbol(m->hMainMod, pszMainEntryPoint, (void **)&pfnRegistration);
|
---|
1383 | if (RT_SUCCESS(vrc))
|
---|
1384 | {
|
---|
1385 | RTErrInfoClear(&ErrInfo.Core);
|
---|
1386 | vrc = pfnRegistration(&m->Hlp, &m->pReg, &ErrInfo.Core);
|
---|
1387 | if ( RT_SUCCESS(vrc)
|
---|
1388 | && !RTErrInfoIsSet(&ErrInfo.Core)
|
---|
1389 | && VALID_PTR(m->pReg))
|
---|
1390 | {
|
---|
1391 | if ( VBOXEXTPACK_IS_MAJOR_VER_EQUAL(m->pReg->u32Version, uVersion)
|
---|
1392 | && m->pReg->u32EndMarker == m->pReg->u32Version)
|
---|
1393 | {
|
---|
1394 | #ifndef VBOX_COM_INPROC
|
---|
1395 | if ( (!m->pReg->pfnInstalled || RT_VALID_PTR(m->pReg->pfnInstalled))
|
---|
1396 | && (!m->pReg->pfnUninstall || RT_VALID_PTR(m->pReg->pfnUninstall))
|
---|
1397 | && (!m->pReg->pfnVirtualBoxReady || RT_VALID_PTR(m->pReg->pfnVirtualBoxReady))
|
---|
1398 | && (!m->pReg->pfnUnload || RT_VALID_PTR(m->pReg->pfnUnload))
|
---|
1399 | && (!m->pReg->pfnVMCreated || RT_VALID_PTR(m->pReg->pfnVMCreated))
|
---|
1400 | && (!m->pReg->pfnQueryObject || RT_VALID_PTR(m->pReg->pfnQueryObject))
|
---|
1401 | )
|
---|
1402 | {
|
---|
1403 | /*
|
---|
1404 | * We're good!
|
---|
1405 | */
|
---|
1406 | m->fUsable = true;
|
---|
1407 | m->strWhyUnusable.setNull();
|
---|
1408 | return;
|
---|
1409 | }
|
---|
1410 | #else
|
---|
1411 | if ( (!m->pReg->pfnConsoleReady || RT_VALID_PTR(m->pReg->pfnConsoleReady))
|
---|
1412 | && (!m->pReg->pfnUnload || RT_VALID_PTR(m->pReg->pfnUnload))
|
---|
1413 | && (!m->pReg->pfnVMConfigureVMM || RT_VALID_PTR(m->pReg->pfnVMConfigureVMM))
|
---|
1414 | && (!m->pReg->pfnVMPowerOn || RT_VALID_PTR(m->pReg->pfnVMPowerOn))
|
---|
1415 | && (!m->pReg->pfnVMPowerOff || RT_VALID_PTR(m->pReg->pfnVMPowerOff))
|
---|
1416 | && (!m->pReg->pfnQueryObject || RT_VALID_PTR(m->pReg->pfnQueryObject))
|
---|
1417 | )
|
---|
1418 | {
|
---|
1419 | /*
|
---|
1420 | * We're good!
|
---|
1421 | */
|
---|
1422 | m->fUsable = true;
|
---|
1423 | m->strWhyUnusable.setNull();
|
---|
1424 | return;
|
---|
1425 | }
|
---|
1426 | #endif
|
---|
1427 |
|
---|
1428 | m->strWhyUnusable = tr("The registration structure contains one or more invalid function pointers");
|
---|
1429 | }
|
---|
1430 | else
|
---|
1431 | m->strWhyUnusable.printf(tr("Unsupported registration structure version %u.%u"),
|
---|
1432 | RT_HIWORD(m->pReg->u32Version), RT_LOWORD(m->pReg->u32Version));
|
---|
1433 | }
|
---|
1434 | else
|
---|
1435 | m->strWhyUnusable.printf(tr("%s returned %Rrc, pReg=%p ErrInfo='%s'"),
|
---|
1436 | pszMainEntryPoint, vrc, m->pReg, ErrInfo.Core.pszMsg);
|
---|
1437 | m->pReg = NULL;
|
---|
1438 | }
|
---|
1439 | else
|
---|
1440 | m->strWhyUnusable.printf(tr("Failed to resolve exported symbol '%s' in the main module: %Rrc"),
|
---|
1441 | pszMainEntryPoint, vrc);
|
---|
1442 |
|
---|
1443 | RTLdrClose(m->hMainMod);
|
---|
1444 | m->hMainMod = NIL_RTLDRMOD;
|
---|
1445 | }
|
---|
1446 |
|
---|
1447 | /**
|
---|
1448 | * Finds a module.
|
---|
1449 | *
|
---|
1450 | * @returns true if found, false if not.
|
---|
1451 | * @param a_pszName The module base name (no extension).
|
---|
1452 | * @param a_pszExt The extension. If NULL we use default
|
---|
1453 | * extensions.
|
---|
1454 | * @param a_enmKind The kind of module to locate.
|
---|
1455 | * @param a_pStrFound Where to return the path to the module we've
|
---|
1456 | * found.
|
---|
1457 | * @param a_pfNative Where to return whether this is a native module
|
---|
1458 | * or an agnostic one. Optional.
|
---|
1459 | * @param a_pObjInfo Where to return the file system object info for
|
---|
1460 | * the module. Optional.
|
---|
1461 | */
|
---|
1462 | bool ExtPack::i_findModule(const char *a_pszName, const char *a_pszExt, VBOXEXTPACKMODKIND a_enmKind,
|
---|
1463 | Utf8Str *a_pStrFound, bool *a_pfNative, PRTFSOBJINFO a_pObjInfo) const
|
---|
1464 | {
|
---|
1465 | /*
|
---|
1466 | * Try the native path first.
|
---|
1467 | */
|
---|
1468 | char szPath[RTPATH_MAX];
|
---|
1469 | int vrc = RTPathJoin(szPath, sizeof(szPath), m->strExtPackPath.c_str(), RTBldCfgTargetDotArch());
|
---|
1470 | AssertLogRelRCReturn(vrc, false);
|
---|
1471 | vrc = RTPathAppend(szPath, sizeof(szPath), a_pszName);
|
---|
1472 | AssertLogRelRCReturn(vrc, false);
|
---|
1473 | if (!a_pszExt)
|
---|
1474 | {
|
---|
1475 | const char *pszDefExt;
|
---|
1476 | switch (a_enmKind)
|
---|
1477 | {
|
---|
1478 | case VBOXEXTPACKMODKIND_RC: pszDefExt = ".rc"; break;
|
---|
1479 | case VBOXEXTPACKMODKIND_R0: pszDefExt = ".r0"; break;
|
---|
1480 | case VBOXEXTPACKMODKIND_R3: pszDefExt = RTLdrGetSuff(); break;
|
---|
1481 | default:
|
---|
1482 | AssertFailedReturn(false);
|
---|
1483 | }
|
---|
1484 | vrc = RTStrCat(szPath, sizeof(szPath), pszDefExt);
|
---|
1485 | AssertLogRelRCReturn(vrc, false);
|
---|
1486 | }
|
---|
1487 |
|
---|
1488 | RTFSOBJINFO ObjInfo;
|
---|
1489 | if (!a_pObjInfo)
|
---|
1490 | a_pObjInfo = &ObjInfo;
|
---|
1491 | vrc = RTPathQueryInfo(szPath, a_pObjInfo, RTFSOBJATTRADD_UNIX);
|
---|
1492 | if (RT_SUCCESS(vrc) && RTFS_IS_FILE(a_pObjInfo->Attr.fMode))
|
---|
1493 | {
|
---|
1494 | if (a_pfNative)
|
---|
1495 | *a_pfNative = true;
|
---|
1496 | *a_pStrFound = szPath;
|
---|
1497 | return true;
|
---|
1498 | }
|
---|
1499 |
|
---|
1500 | /*
|
---|
1501 | * Try the platform agnostic modules.
|
---|
1502 | */
|
---|
1503 | /* gcc.x86/module.rel */
|
---|
1504 | char szSubDir[32];
|
---|
1505 | RTStrPrintf(szSubDir, sizeof(szSubDir), "%s.%s", RTBldCfgCompiler(), RTBldCfgTargetArch());
|
---|
1506 | vrc = RTPathJoin(szPath, sizeof(szPath), m->strExtPackPath.c_str(), szSubDir);
|
---|
1507 | AssertLogRelRCReturn(vrc, false);
|
---|
1508 | vrc = RTPathAppend(szPath, sizeof(szPath), a_pszName);
|
---|
1509 | AssertLogRelRCReturn(vrc, false);
|
---|
1510 | if (!a_pszExt)
|
---|
1511 | {
|
---|
1512 | vrc = RTStrCat(szPath, sizeof(szPath), ".rel");
|
---|
1513 | AssertLogRelRCReturn(vrc, false);
|
---|
1514 | }
|
---|
1515 | vrc = RTPathQueryInfo(szPath, a_pObjInfo, RTFSOBJATTRADD_UNIX);
|
---|
1516 | if (RT_SUCCESS(vrc) && RTFS_IS_FILE(a_pObjInfo->Attr.fMode))
|
---|
1517 | {
|
---|
1518 | if (a_pfNative)
|
---|
1519 | *a_pfNative = false;
|
---|
1520 | *a_pStrFound = szPath;
|
---|
1521 | return true;
|
---|
1522 | }
|
---|
1523 |
|
---|
1524 | /* x86/module.rel */
|
---|
1525 | vrc = RTPathJoin(szPath, sizeof(szPath), m->strExtPackPath.c_str(), RTBldCfgTargetArch());
|
---|
1526 | AssertLogRelRCReturn(vrc, false);
|
---|
1527 | vrc = RTPathAppend(szPath, sizeof(szPath), a_pszName);
|
---|
1528 | AssertLogRelRCReturn(vrc, false);
|
---|
1529 | if (!a_pszExt)
|
---|
1530 | {
|
---|
1531 | vrc = RTStrCat(szPath, sizeof(szPath), ".rel");
|
---|
1532 | AssertLogRelRCReturn(vrc, false);
|
---|
1533 | }
|
---|
1534 | vrc = RTPathQueryInfo(szPath, a_pObjInfo, RTFSOBJATTRADD_UNIX);
|
---|
1535 | if (RT_SUCCESS(vrc) && RTFS_IS_FILE(a_pObjInfo->Attr.fMode))
|
---|
1536 | {
|
---|
1537 | if (a_pfNative)
|
---|
1538 | *a_pfNative = false;
|
---|
1539 | *a_pStrFound = szPath;
|
---|
1540 | return true;
|
---|
1541 | }
|
---|
1542 |
|
---|
1543 | return false;
|
---|
1544 | }
|
---|
1545 |
|
---|
1546 | /**
|
---|
1547 | * Compares two file system object info structures.
|
---|
1548 | *
|
---|
1549 | * @returns true if equal, false if not.
|
---|
1550 | * @param pObjInfo1 The first.
|
---|
1551 | * @param pObjInfo2 The second.
|
---|
1552 | * @todo IPRT should do this, really.
|
---|
1553 | */
|
---|
1554 | /* static */ bool ExtPack::i_objinfoIsEqual(PCRTFSOBJINFO pObjInfo1, PCRTFSOBJINFO pObjInfo2)
|
---|
1555 | {
|
---|
1556 | if (!RTTimeSpecIsEqual(&pObjInfo1->ModificationTime, &pObjInfo2->ModificationTime))
|
---|
1557 | return false;
|
---|
1558 | if (!RTTimeSpecIsEqual(&pObjInfo1->ChangeTime, &pObjInfo2->ChangeTime))
|
---|
1559 | return false;
|
---|
1560 | if (!RTTimeSpecIsEqual(&pObjInfo1->BirthTime, &pObjInfo2->BirthTime))
|
---|
1561 | return false;
|
---|
1562 | if (pObjInfo1->cbObject != pObjInfo2->cbObject)
|
---|
1563 | return false;
|
---|
1564 | if (pObjInfo1->Attr.fMode != pObjInfo2->Attr.fMode)
|
---|
1565 | return false;
|
---|
1566 | if (pObjInfo1->Attr.enmAdditional == pObjInfo2->Attr.enmAdditional)
|
---|
1567 | {
|
---|
1568 | switch (pObjInfo1->Attr.enmAdditional)
|
---|
1569 | {
|
---|
1570 | case RTFSOBJATTRADD_UNIX:
|
---|
1571 | if (pObjInfo1->Attr.u.Unix.uid != pObjInfo2->Attr.u.Unix.uid)
|
---|
1572 | return false;
|
---|
1573 | if (pObjInfo1->Attr.u.Unix.gid != pObjInfo2->Attr.u.Unix.gid)
|
---|
1574 | return false;
|
---|
1575 | if (pObjInfo1->Attr.u.Unix.INodeIdDevice != pObjInfo2->Attr.u.Unix.INodeIdDevice)
|
---|
1576 | return false;
|
---|
1577 | if (pObjInfo1->Attr.u.Unix.INodeId != pObjInfo2->Attr.u.Unix.INodeId)
|
---|
1578 | return false;
|
---|
1579 | if (pObjInfo1->Attr.u.Unix.GenerationId != pObjInfo2->Attr.u.Unix.GenerationId)
|
---|
1580 | return false;
|
---|
1581 | break;
|
---|
1582 | default:
|
---|
1583 | break;
|
---|
1584 | }
|
---|
1585 | }
|
---|
1586 | return true;
|
---|
1587 | }
|
---|
1588 |
|
---|
1589 |
|
---|
1590 | /**
|
---|
1591 | * @interface_method_impl{VBOXEXTPACKHLP,pfnFindModule}
|
---|
1592 | */
|
---|
1593 | /*static*/ DECLCALLBACK(int)
|
---|
1594 | ExtPack::i_hlpFindModule(PCVBOXEXTPACKHLP pHlp, const char *pszName, const char *pszExt, VBOXEXTPACKMODKIND enmKind,
|
---|
1595 | char *pszFound, size_t cbFound, bool *pfNative)
|
---|
1596 | {
|
---|
1597 | /*
|
---|
1598 | * Validate the input and get our bearings.
|
---|
1599 | */
|
---|
1600 | AssertPtrReturn(pszName, VERR_INVALID_POINTER);
|
---|
1601 | AssertPtrNullReturn(pszExt, VERR_INVALID_POINTER);
|
---|
1602 | AssertPtrReturn(pszFound, VERR_INVALID_POINTER);
|
---|
1603 | AssertPtrNullReturn(pfNative, VERR_INVALID_POINTER);
|
---|
1604 | AssertReturn(enmKind > VBOXEXTPACKMODKIND_INVALID && enmKind < VBOXEXTPACKMODKIND_END, VERR_INVALID_PARAMETER);
|
---|
1605 |
|
---|
1606 | AssertPtrReturn(pHlp, VERR_INVALID_POINTER);
|
---|
1607 | AssertReturn(pHlp->u32Version == VBOXEXTPACKHLP_VERSION, VERR_INVALID_POINTER);
|
---|
1608 | ExtPack::Data *m = RT_FROM_CPP_MEMBER(pHlp, Data, Hlp);
|
---|
1609 | AssertPtrReturn(m, VERR_INVALID_POINTER);
|
---|
1610 | ExtPack *pThis = m->pThis;
|
---|
1611 | AssertPtrReturn(pThis, VERR_INVALID_POINTER);
|
---|
1612 |
|
---|
1613 | /*
|
---|
1614 | * This is just a wrapper around findModule.
|
---|
1615 | */
|
---|
1616 | Utf8Str strFound;
|
---|
1617 | if (pThis->i_findModule(pszName, pszExt, enmKind, &strFound, pfNative, NULL))
|
---|
1618 | return RTStrCopy(pszFound, cbFound, strFound.c_str());
|
---|
1619 | return VERR_FILE_NOT_FOUND;
|
---|
1620 | }
|
---|
1621 |
|
---|
1622 | /*static*/ DECLCALLBACK(int)
|
---|
1623 | ExtPack::i_hlpGetFilePath(PCVBOXEXTPACKHLP pHlp, const char *pszFilename, char *pszPath, size_t cbPath)
|
---|
1624 | {
|
---|
1625 | /*
|
---|
1626 | * Validate the input and get our bearings.
|
---|
1627 | */
|
---|
1628 | AssertPtrReturn(pszFilename, VERR_INVALID_POINTER);
|
---|
1629 | AssertPtrReturn(pszPath, VERR_INVALID_POINTER);
|
---|
1630 | AssertReturn(cbPath > 0, VERR_BUFFER_OVERFLOW);
|
---|
1631 |
|
---|
1632 | AssertPtrReturn(pHlp, VERR_INVALID_POINTER);
|
---|
1633 | AssertReturn(pHlp->u32Version == VBOXEXTPACKHLP_VERSION, VERR_INVALID_POINTER);
|
---|
1634 | ExtPack::Data *m = RT_FROM_CPP_MEMBER(pHlp, Data, Hlp);
|
---|
1635 | AssertPtrReturn(m, VERR_INVALID_POINTER);
|
---|
1636 | ExtPack *pThis = m->pThis;
|
---|
1637 | AssertPtrReturn(pThis, VERR_INVALID_POINTER);
|
---|
1638 |
|
---|
1639 | /*
|
---|
1640 | * This is a simple RTPathJoin, no checking if things exists or anything.
|
---|
1641 | */
|
---|
1642 | int vrc = RTPathJoin(pszPath, cbPath, pThis->m->strExtPackPath.c_str(), pszFilename);
|
---|
1643 | if (RT_FAILURE(vrc))
|
---|
1644 | RT_BZERO(pszPath, cbPath);
|
---|
1645 | return vrc;
|
---|
1646 | }
|
---|
1647 |
|
---|
1648 | /*static*/ DECLCALLBACK(VBOXEXTPACKCTX)
|
---|
1649 | ExtPack::i_hlpGetContext(PCVBOXEXTPACKHLP pHlp)
|
---|
1650 | {
|
---|
1651 | /*
|
---|
1652 | * Validate the input and get our bearings.
|
---|
1653 | */
|
---|
1654 | AssertPtrReturn(pHlp, VBOXEXTPACKCTX_INVALID);
|
---|
1655 | AssertReturn(pHlp->u32Version == VBOXEXTPACKHLP_VERSION, VBOXEXTPACKCTX_INVALID);
|
---|
1656 | ExtPack::Data *m = RT_FROM_CPP_MEMBER(pHlp, Data, Hlp);
|
---|
1657 | AssertPtrReturn(m, VBOXEXTPACKCTX_INVALID);
|
---|
1658 | ExtPack *pThis = m->pThis;
|
---|
1659 | AssertPtrReturn(pThis, VBOXEXTPACKCTX_INVALID);
|
---|
1660 |
|
---|
1661 | return pThis->m->enmContext;
|
---|
1662 | }
|
---|
1663 |
|
---|
1664 | /*static*/ DECLCALLBACK(int)
|
---|
1665 | ExtPack::i_hlpLoadHGCMService(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IConsole) *pConsole,
|
---|
1666 | const char *pszServiceLibrary, const char *pszServiceName)
|
---|
1667 | {
|
---|
1668 | #ifdef VBOX_COM_INPROC
|
---|
1669 | /*
|
---|
1670 | * Validate the input and get our bearings.
|
---|
1671 | */
|
---|
1672 | AssertPtrReturn(pszServiceLibrary, VERR_INVALID_POINTER);
|
---|
1673 | AssertPtrReturn(pszServiceName, VERR_INVALID_POINTER);
|
---|
1674 |
|
---|
1675 | AssertPtrReturn(pHlp, VERR_INVALID_POINTER);
|
---|
1676 | AssertReturn(pHlp->u32Version == VBOXEXTPACKHLP_VERSION, VERR_INVALID_POINTER);
|
---|
1677 | ExtPack::Data *m = RT_FROM_CPP_MEMBER(pHlp, Data, Hlp);
|
---|
1678 | AssertPtrReturn(m, VERR_INVALID_POINTER);
|
---|
1679 | ExtPack *pThis = m->pThis;
|
---|
1680 | AssertPtrReturn(pThis, VERR_INVALID_POINTER);
|
---|
1681 | AssertPtrReturn(pConsole, VERR_INVALID_POINTER);
|
---|
1682 |
|
---|
1683 | Console *pCon = (Console *)pConsole;
|
---|
1684 | return pCon->i_hgcmLoadService(pszServiceLibrary, pszServiceName);
|
---|
1685 | #else
|
---|
1686 | NOREF(pHlp); NOREF(pConsole); NOREF(pszServiceLibrary); NOREF(pszServiceName);
|
---|
1687 | return VERR_INVALID_STATE;
|
---|
1688 | #endif
|
---|
1689 | }
|
---|
1690 |
|
---|
1691 | /*static*/ DECLCALLBACK(int)
|
---|
1692 | ExtPack::i_hlpLoadVDPlugin(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox, const char *pszPluginLibrary)
|
---|
1693 | {
|
---|
1694 | #ifndef VBOX_COM_INPROC
|
---|
1695 | /*
|
---|
1696 | * Validate the input and get our bearings.
|
---|
1697 | */
|
---|
1698 | AssertPtrReturn(pszPluginLibrary, VERR_INVALID_POINTER);
|
---|
1699 |
|
---|
1700 | AssertPtrReturn(pHlp, VERR_INVALID_POINTER);
|
---|
1701 | AssertReturn(pHlp->u32Version == VBOXEXTPACKHLP_VERSION, VERR_INVALID_POINTER);
|
---|
1702 | ExtPack::Data *m = RT_FROM_CPP_MEMBER(pHlp, Data, Hlp);
|
---|
1703 | AssertPtrReturn(m, VERR_INVALID_POINTER);
|
---|
1704 | ExtPack *pThis = m->pThis;
|
---|
1705 | AssertPtrReturn(pThis, VERR_INVALID_POINTER);
|
---|
1706 | AssertPtrReturn(pVirtualBox, VERR_INVALID_POINTER);
|
---|
1707 |
|
---|
1708 | VirtualBox *pVBox = (VirtualBox *)pVirtualBox;
|
---|
1709 | return pVBox->i_loadVDPlugin(pszPluginLibrary);
|
---|
1710 | #else
|
---|
1711 | NOREF(pHlp); NOREF(pVirtualBox); NOREF(pszPluginLibrary);
|
---|
1712 | return VERR_INVALID_STATE;
|
---|
1713 | #endif
|
---|
1714 | }
|
---|
1715 |
|
---|
1716 | /*static*/ DECLCALLBACK(int)
|
---|
1717 | ExtPack::i_hlpUnloadVDPlugin(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox, const char *pszPluginLibrary)
|
---|
1718 | {
|
---|
1719 | #ifndef VBOX_COM_INPROC
|
---|
1720 | /*
|
---|
1721 | * Validate the input and get our bearings.
|
---|
1722 | */
|
---|
1723 | AssertPtrReturn(pszPluginLibrary, VERR_INVALID_POINTER);
|
---|
1724 |
|
---|
1725 | AssertPtrReturn(pHlp, VERR_INVALID_POINTER);
|
---|
1726 | AssertReturn(pHlp->u32Version == VBOXEXTPACKHLP_VERSION, VERR_INVALID_POINTER);
|
---|
1727 | ExtPack::Data *m = RT_FROM_CPP_MEMBER(pHlp, Data, Hlp);
|
---|
1728 | AssertPtrReturn(m, VERR_INVALID_POINTER);
|
---|
1729 | ExtPack *pThis = m->pThis;
|
---|
1730 | AssertPtrReturn(pThis, VERR_INVALID_POINTER);
|
---|
1731 | AssertPtrReturn(pVirtualBox, VERR_INVALID_POINTER);
|
---|
1732 |
|
---|
1733 | VirtualBox *pVBox = (VirtualBox *)pVirtualBox;
|
---|
1734 | return pVBox->i_unloadVDPlugin(pszPluginLibrary);
|
---|
1735 | #else
|
---|
1736 | NOREF(pHlp); NOREF(pVirtualBox); NOREF(pszPluginLibrary);
|
---|
1737 | return VERR_INVALID_STATE;
|
---|
1738 | #endif
|
---|
1739 | }
|
---|
1740 |
|
---|
1741 | /*static*/ DECLCALLBACK(uint32_t)
|
---|
1742 | ExtPack::i_hlpCreateProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IUnknown) *pInitiator,
|
---|
1743 | const char *pcszDescription, uint32_t cOperations,
|
---|
1744 | uint32_t uTotalOperationsWeight, const char *pcszFirstOperationDescription,
|
---|
1745 | uint32_t uFirstOperationWeight, VBOXEXTPACK_IF_CS(IProgress) **ppProgressOut)
|
---|
1746 | {
|
---|
1747 | /*
|
---|
1748 | * Validate the input and get our bearings.
|
---|
1749 | */
|
---|
1750 | AssertPtrReturn(pcszDescription, (uint32_t)E_INVALIDARG);
|
---|
1751 | AssertReturn(cOperations >= 1, (uint32_t)E_INVALIDARG);
|
---|
1752 | AssertReturn(uTotalOperationsWeight >= 1, (uint32_t)E_INVALIDARG);
|
---|
1753 | AssertPtrReturn(pcszFirstOperationDescription, (uint32_t)E_INVALIDARG);
|
---|
1754 | AssertReturn(uFirstOperationWeight >= 1, (uint32_t)E_INVALIDARG);
|
---|
1755 | AssertPtrReturn(ppProgressOut, (uint32_t)E_INVALIDARG);
|
---|
1756 |
|
---|
1757 | AssertPtrReturn(pHlp, (uint32_t)E_INVALIDARG);
|
---|
1758 | AssertReturn(pHlp->u32Version == VBOXEXTPACKHLP_VERSION, (uint32_t)E_INVALIDARG);
|
---|
1759 | #ifndef VBOX_COM_INPROC
|
---|
1760 | ExtPack::Data *m = RT_FROM_CPP_MEMBER(pHlp, Data, Hlp);
|
---|
1761 | #endif
|
---|
1762 |
|
---|
1763 | ComObjPtr<Progress> pProgress;
|
---|
1764 | HRESULT hrc = pProgress.createObject();
|
---|
1765 | if (FAILED(hrc))
|
---|
1766 | return hrc;
|
---|
1767 | hrc = pProgress->init(
|
---|
1768 | #ifndef VBOX_COM_INPROC
|
---|
1769 | m->pVirtualBox,
|
---|
1770 | #endif
|
---|
1771 | pInitiator, pcszDescription, TRUE /* aCancelable */,
|
---|
1772 | cOperations, uTotalOperationsWeight,
|
---|
1773 | pcszFirstOperationDescription, uFirstOperationWeight);
|
---|
1774 | if (FAILED(hrc))
|
---|
1775 | return hrc;
|
---|
1776 |
|
---|
1777 | return pProgress.queryInterfaceTo(ppProgressOut);
|
---|
1778 | }
|
---|
1779 |
|
---|
1780 | /*static*/ DECLCALLBACK(uint32_t)
|
---|
1781 | ExtPack::i_hlpGetCanceledProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress,
|
---|
1782 | bool *pfCanceled)
|
---|
1783 | {
|
---|
1784 | /*
|
---|
1785 | * Validate the input and get our bearings.
|
---|
1786 | */
|
---|
1787 | AssertPtrReturn(pProgress, (uint32_t)E_INVALIDARG);
|
---|
1788 | AssertPtrReturn(pfCanceled, (uint32_t)E_INVALIDARG);
|
---|
1789 |
|
---|
1790 | AssertPtrReturn(pHlp, (uint32_t)E_INVALIDARG);
|
---|
1791 | AssertReturn(pHlp->u32Version == VBOXEXTPACKHLP_VERSION, (uint32_t)E_INVALIDARG);
|
---|
1792 |
|
---|
1793 | BOOL fCanceled = FALSE;
|
---|
1794 | HRESULT hrc = pProgress->COMGETTER(Canceled)(&fCanceled);
|
---|
1795 | *pfCanceled = !!fCanceled;
|
---|
1796 | return hrc;
|
---|
1797 | }
|
---|
1798 |
|
---|
1799 | /*static*/ DECLCALLBACK(uint32_t)
|
---|
1800 | ExtPack::i_hlpUpdateProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress,
|
---|
1801 | uint32_t uPercent)
|
---|
1802 | {
|
---|
1803 | /*
|
---|
1804 | * Validate the input and get our bearings.
|
---|
1805 | */
|
---|
1806 | AssertPtrReturn(pProgress, (uint32_t)E_INVALIDARG);
|
---|
1807 | AssertReturn(uPercent <= 100, (uint32_t)E_INVALIDARG);
|
---|
1808 |
|
---|
1809 | AssertPtrReturn(pHlp, (uint32_t)E_INVALIDARG);
|
---|
1810 | AssertReturn(pHlp->u32Version == VBOXEXTPACKHLP_VERSION, (uint32_t)E_INVALIDARG);
|
---|
1811 |
|
---|
1812 | return pProgress->SetCurrentOperationProgress(uPercent);
|
---|
1813 | }
|
---|
1814 |
|
---|
1815 | /*static*/ DECLCALLBACK(uint32_t)
|
---|
1816 | ExtPack::i_hlpNextOperationProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress,
|
---|
1817 | const char *pcszNextOperationDescription,
|
---|
1818 | uint32_t uNextOperationWeight)
|
---|
1819 | {
|
---|
1820 | /*
|
---|
1821 | * Validate the input and get our bearings.
|
---|
1822 | */
|
---|
1823 | AssertPtrReturn(pProgress, (uint32_t)E_INVALIDARG);
|
---|
1824 | AssertPtrReturn(pcszNextOperationDescription, (uint32_t)E_INVALIDARG);
|
---|
1825 | AssertReturn(uNextOperationWeight >= 1, (uint32_t)E_INVALIDARG);
|
---|
1826 |
|
---|
1827 | AssertPtrReturn(pHlp, (uint32_t)E_INVALIDARG);
|
---|
1828 | AssertReturn(pHlp->u32Version == VBOXEXTPACKHLP_VERSION, (uint32_t)E_INVALIDARG);
|
---|
1829 |
|
---|
1830 | return pProgress->SetNextOperation(Bstr(pcszNextOperationDescription).raw(), uNextOperationWeight);
|
---|
1831 | }
|
---|
1832 |
|
---|
1833 | /*static*/ DECLCALLBACK(uint32_t)
|
---|
1834 | ExtPack::i_hlpWaitOtherProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress,
|
---|
1835 | VBOXEXTPACK_IF_CS(IProgress) *pProgressOther)
|
---|
1836 | {
|
---|
1837 | /*
|
---|
1838 | * Validate the input and get our bearings.
|
---|
1839 | */
|
---|
1840 | AssertPtrReturn(pProgress, (uint32_t)E_INVALIDARG);
|
---|
1841 | AssertPtrReturn(pProgressOther, (uint32_t)E_INVALIDARG);
|
---|
1842 |
|
---|
1843 | AssertPtrReturn(pHlp, (uint32_t)E_INVALIDARG);
|
---|
1844 | AssertReturn(pHlp->u32Version == VBOXEXTPACKHLP_VERSION, (uint32_t)E_INVALIDARG);
|
---|
1845 |
|
---|
1846 | Progress *pProgressInt = static_cast<Progress *>(pProgress);
|
---|
1847 | return pProgressInt->i_waitForOtherProgressCompletion(pProgressOther);
|
---|
1848 | }
|
---|
1849 |
|
---|
1850 | /*static*/ DECLCALLBACK(uint32_t)
|
---|
1851 | ExtPack::i_hlpCompleteProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress,
|
---|
1852 | uint32_t uResultCode)
|
---|
1853 | {
|
---|
1854 | /*
|
---|
1855 | * Validate the input and get our bearings.
|
---|
1856 | */
|
---|
1857 | AssertPtrReturn(pProgress, (uint32_t)E_INVALIDARG);
|
---|
1858 |
|
---|
1859 | AssertPtrReturn(pHlp, (uint32_t)E_INVALIDARG);
|
---|
1860 | AssertReturn(pHlp->u32Version == VBOXEXTPACKHLP_VERSION, (uint32_t)E_INVALIDARG);
|
---|
1861 |
|
---|
1862 | Progress *pProgressInt = static_cast<Progress *>(pProgress);
|
---|
1863 | return pProgressInt->i_notifyComplete(uResultCode);
|
---|
1864 | }
|
---|
1865 |
|
---|
1866 | /*static*/ DECLCALLBACK(int)
|
---|
1867 | ExtPack::i_hlpReservedN(PCVBOXEXTPACKHLP pHlp)
|
---|
1868 | {
|
---|
1869 | /*
|
---|
1870 | * Validate the input and get our bearings.
|
---|
1871 | */
|
---|
1872 | AssertPtrReturn(pHlp, VERR_INVALID_POINTER);
|
---|
1873 | AssertReturn(pHlp->u32Version == VBOXEXTPACKHLP_VERSION, VERR_INVALID_POINTER);
|
---|
1874 | ExtPack::Data *m = RT_FROM_CPP_MEMBER(pHlp, Data, Hlp);
|
---|
1875 | AssertPtrReturn(m, VERR_INVALID_POINTER);
|
---|
1876 | ExtPack *pThis = m->pThis;
|
---|
1877 | AssertPtrReturn(pThis, VERR_INVALID_POINTER);
|
---|
1878 |
|
---|
1879 | return VERR_NOT_IMPLEMENTED;
|
---|
1880 | }
|
---|
1881 |
|
---|
1882 |
|
---|
1883 |
|
---|
1884 |
|
---|
1885 | HRESULT ExtPack::getName(com::Utf8Str &aName)
|
---|
1886 | {
|
---|
1887 | aName = m->Desc.strName;
|
---|
1888 | return S_OK;
|
---|
1889 | }
|
---|
1890 |
|
---|
1891 | HRESULT ExtPack::getDescription(com::Utf8Str &aDescription)
|
---|
1892 | {
|
---|
1893 | aDescription = m->Desc.strDescription;
|
---|
1894 | return S_OK;
|
---|
1895 | }
|
---|
1896 |
|
---|
1897 | HRESULT ExtPack::getVersion(com::Utf8Str &aVersion)
|
---|
1898 | {
|
---|
1899 | aVersion = m->Desc.strVersion;
|
---|
1900 | return S_OK;
|
---|
1901 | }
|
---|
1902 |
|
---|
1903 | HRESULT ExtPack::getRevision(ULONG *aRevision)
|
---|
1904 | {
|
---|
1905 | *aRevision = m->Desc.uRevision;
|
---|
1906 | return S_OK;
|
---|
1907 | }
|
---|
1908 |
|
---|
1909 | HRESULT ExtPack::getEdition(com::Utf8Str &aEdition)
|
---|
1910 | {
|
---|
1911 | aEdition = m->Desc.strEdition;
|
---|
1912 | return S_OK;
|
---|
1913 | }
|
---|
1914 |
|
---|
1915 | HRESULT ExtPack::getVRDEModule(com::Utf8Str &aVRDEModule)
|
---|
1916 | {
|
---|
1917 | aVRDEModule = m->Desc.strVrdeModule;
|
---|
1918 | return S_OK;
|
---|
1919 | }
|
---|
1920 |
|
---|
1921 | HRESULT ExtPack::getPlugIns(std::vector<ComPtr<IExtPackPlugIn> > &aPlugIns)
|
---|
1922 | {
|
---|
1923 | /** @todo implement plug-ins. */
|
---|
1924 | NOREF(aPlugIns);
|
---|
1925 | ReturnComNotImplemented();
|
---|
1926 | }
|
---|
1927 |
|
---|
1928 | HRESULT ExtPack::getUsable(BOOL *aUsable)
|
---|
1929 | {
|
---|
1930 | *aUsable = m->fUsable;
|
---|
1931 | return S_OK;
|
---|
1932 | }
|
---|
1933 |
|
---|
1934 | HRESULT ExtPack::getWhyUnusable(com::Utf8Str &aWhyUnusable)
|
---|
1935 | {
|
---|
1936 | aWhyUnusable = m->strWhyUnusable;
|
---|
1937 | return S_OK;
|
---|
1938 | }
|
---|
1939 |
|
---|
1940 | HRESULT ExtPack::getShowLicense(BOOL *aShowLicense)
|
---|
1941 | {
|
---|
1942 | *aShowLicense = m->Desc.fShowLicense;
|
---|
1943 | return S_OK;
|
---|
1944 | }
|
---|
1945 |
|
---|
1946 | HRESULT ExtPack::getLicense(com::Utf8Str &aLicense)
|
---|
1947 | {
|
---|
1948 | Utf8Str strHtml("html");
|
---|
1949 | Utf8Str str("");
|
---|
1950 | return queryLicense(str, str, strHtml, aLicense);
|
---|
1951 | }
|
---|
1952 |
|
---|
1953 | HRESULT ExtPack::queryLicense(const com::Utf8Str &aPreferredLocale, const com::Utf8Str &aPreferredLanguage,
|
---|
1954 | const com::Utf8Str &aFormat, com::Utf8Str &aLicenseText)
|
---|
1955 | {
|
---|
1956 | HRESULT hrc = S_OK;
|
---|
1957 |
|
---|
1958 | /*
|
---|
1959 | * Validate input.
|
---|
1960 | */
|
---|
1961 | if (aPreferredLocale.length() != 2 && aPreferredLocale.length() != 0)
|
---|
1962 | return setError(E_FAIL, tr("The preferred locale is a two character string or empty."));
|
---|
1963 |
|
---|
1964 | if (aPreferredLanguage.length() != 2 && aPreferredLanguage.length() != 0)
|
---|
1965 | return setError(E_FAIL, tr("The preferred lanuage is a two character string or empty."));
|
---|
1966 |
|
---|
1967 | if ( !aFormat.equals("html")
|
---|
1968 | && !aFormat.equals("rtf")
|
---|
1969 | && !aFormat.equals("txt"))
|
---|
1970 | return setError(E_FAIL, tr("The license format can only have the values 'html', 'rtf' and 'txt'."));
|
---|
1971 |
|
---|
1972 | /*
|
---|
1973 | * Combine the options to form a file name before locking down anything.
|
---|
1974 | */
|
---|
1975 | char szName[sizeof(VBOX_EXTPACK_LICENSE_NAME_PREFIX "-de_DE.html") + 2];
|
---|
1976 | if (aPreferredLocale.isNotEmpty() && aPreferredLanguage.isNotEmpty())
|
---|
1977 | RTStrPrintf(szName, sizeof(szName), VBOX_EXTPACK_LICENSE_NAME_PREFIX "-%s_%s.%s",
|
---|
1978 | aPreferredLocale.c_str(), aPreferredLanguage.c_str(), aFormat.c_str());
|
---|
1979 | else if (aPreferredLocale.isNotEmpty())
|
---|
1980 | RTStrPrintf(szName, sizeof(szName), VBOX_EXTPACK_LICENSE_NAME_PREFIX "-%s.%s",
|
---|
1981 | aPreferredLocale.c_str(), aFormat.c_str());
|
---|
1982 | else if (aPreferredLanguage.isNotEmpty())
|
---|
1983 | RTStrPrintf(szName, sizeof(szName), VBOX_EXTPACK_LICENSE_NAME_PREFIX "-_%s.%s",
|
---|
1984 | aPreferredLocale.c_str(), aFormat.c_str());
|
---|
1985 | else
|
---|
1986 | RTStrPrintf(szName, sizeof(szName), VBOX_EXTPACK_LICENSE_NAME_PREFIX ".%s",
|
---|
1987 | aFormat.c_str());
|
---|
1988 |
|
---|
1989 | /*
|
---|
1990 | * Effectuate the query.
|
---|
1991 | */
|
---|
1992 | AutoReadLock autoLock(this COMMA_LOCKVAL_SRC_POS); /* paranoia */
|
---|
1993 |
|
---|
1994 | if (!m->fUsable)
|
---|
1995 | hrc = setError(E_FAIL, tr("%s"), m->strWhyUnusable.c_str());
|
---|
1996 | else
|
---|
1997 | {
|
---|
1998 | char szPath[RTPATH_MAX];
|
---|
1999 | int vrc = RTPathJoin(szPath, sizeof(szPath), m->strExtPackPath.c_str(), szName);
|
---|
2000 | if (RT_SUCCESS(vrc))
|
---|
2001 | {
|
---|
2002 | void *pvFile;
|
---|
2003 | size_t cbFile;
|
---|
2004 | vrc = RTFileReadAllEx(szPath, 0, RTFOFF_MAX, RTFILE_RDALL_O_DENY_READ, &pvFile, &cbFile);
|
---|
2005 | if (RT_SUCCESS(vrc))
|
---|
2006 | {
|
---|
2007 | Bstr bstrLicense((const char *)pvFile, cbFile);
|
---|
2008 | if (bstrLicense.isNotEmpty())
|
---|
2009 | {
|
---|
2010 | aLicenseText = Utf8Str(bstrLicense);
|
---|
2011 | hrc = S_OK;
|
---|
2012 | }
|
---|
2013 | else
|
---|
2014 | hrc = setError(VBOX_E_IPRT_ERROR, tr("The license file '%s' is empty or contains invalid UTF-8 encoding"),
|
---|
2015 | szPath);
|
---|
2016 | RTFileReadAllFree(pvFile, cbFile);
|
---|
2017 | }
|
---|
2018 | else if (vrc == VERR_FILE_NOT_FOUND || vrc == VERR_PATH_NOT_FOUND)
|
---|
2019 | hrc = setErrorBoth(VBOX_E_OBJECT_NOT_FOUND, vrc, tr("The license file '%s' was not found in extension pack '%s'"),
|
---|
2020 | szName, m->Desc.strName.c_str());
|
---|
2021 | else
|
---|
2022 | hrc = setErrorBoth(VBOX_E_FILE_ERROR, vrc, tr("Failed to open the license file '%s': %Rrc"), szPath, vrc);
|
---|
2023 | }
|
---|
2024 | else
|
---|
2025 | hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("RTPathJoin failed: %Rrc"), vrc);
|
---|
2026 | }
|
---|
2027 | return hrc;
|
---|
2028 | }
|
---|
2029 |
|
---|
2030 | HRESULT ExtPack::queryObject(const com::Utf8Str &aObjUuid, ComPtr<IUnknown> &aReturnInterface)
|
---|
2031 | {
|
---|
2032 | com::Guid ObjectId;
|
---|
2033 | CheckComArgGuid(aObjUuid, ObjectId);
|
---|
2034 |
|
---|
2035 | HRESULT hrc S_OK;
|
---|
2036 |
|
---|
2037 | if ( m->pReg
|
---|
2038 | && m->pReg->pfnQueryObject)
|
---|
2039 | {
|
---|
2040 | void *pvUnknown = m->pReg->pfnQueryObject(m->pReg, ObjectId.raw());
|
---|
2041 | if (pvUnknown)
|
---|
2042 | aReturnInterface = (IUnknown *)pvUnknown;
|
---|
2043 | else
|
---|
2044 | hrc = E_NOINTERFACE;
|
---|
2045 | }
|
---|
2046 | else
|
---|
2047 | hrc = E_NOINTERFACE;
|
---|
2048 | return hrc;
|
---|
2049 | }
|
---|
2050 |
|
---|
2051 | DEFINE_EMPTY_CTOR_DTOR(ExtPackManager)
|
---|
2052 |
|
---|
2053 | /**
|
---|
2054 | * Called by ComObjPtr::createObject when creating the object.
|
---|
2055 | *
|
---|
2056 | * Just initialize the basic object state, do the rest in init().
|
---|
2057 | *
|
---|
2058 | * @returns S_OK.
|
---|
2059 | */
|
---|
2060 | HRESULT ExtPackManager::FinalConstruct()
|
---|
2061 | {
|
---|
2062 | m = NULL;
|
---|
2063 | return BaseFinalConstruct();
|
---|
2064 | }
|
---|
2065 |
|
---|
2066 | /**
|
---|
2067 | * Initializes the extension pack manager.
|
---|
2068 | *
|
---|
2069 | * @returns COM status code.
|
---|
2070 | * @param a_pVirtualBox Pointer to the VirtualBox object.
|
---|
2071 | * @param a_enmContext The context we're in.
|
---|
2072 | */
|
---|
2073 | HRESULT ExtPackManager::initExtPackManager(VirtualBox *a_pVirtualBox, VBOXEXTPACKCTX a_enmContext)
|
---|
2074 | {
|
---|
2075 | AutoInitSpan autoInitSpan(this);
|
---|
2076 | AssertReturn(autoInitSpan.isOk(), E_FAIL);
|
---|
2077 |
|
---|
2078 | /*
|
---|
2079 | * Figure some stuff out before creating the instance data.
|
---|
2080 | */
|
---|
2081 | char szBaseDir[RTPATH_MAX];
|
---|
2082 | int rc = RTPathAppPrivateArchTop(szBaseDir, sizeof(szBaseDir));
|
---|
2083 | AssertLogRelRCReturn(rc, E_FAIL);
|
---|
2084 | rc = RTPathAppend(szBaseDir, sizeof(szBaseDir), VBOX_EXTPACK_INSTALL_DIR);
|
---|
2085 | AssertLogRelRCReturn(rc, E_FAIL);
|
---|
2086 |
|
---|
2087 | char szCertificatDir[RTPATH_MAX];
|
---|
2088 | rc = RTPathAppPrivateNoArch(szCertificatDir, sizeof(szCertificatDir));
|
---|
2089 | AssertLogRelRCReturn(rc, E_FAIL);
|
---|
2090 | rc = RTPathAppend(szCertificatDir, sizeof(szCertificatDir), VBOX_EXTPACK_CERT_DIR);
|
---|
2091 | AssertLogRelRCReturn(rc, E_FAIL);
|
---|
2092 |
|
---|
2093 | /*
|
---|
2094 | * Allocate and initialize the instance data.
|
---|
2095 | */
|
---|
2096 | m = new Data;
|
---|
2097 | m->strBaseDir = szBaseDir;
|
---|
2098 | m->strCertificatDirPath = szCertificatDir;
|
---|
2099 | m->enmContext = a_enmContext;
|
---|
2100 | #ifndef VBOX_COM_INPROC
|
---|
2101 | m->pVirtualBox = a_pVirtualBox;
|
---|
2102 | #else
|
---|
2103 | RT_NOREF_PV(a_pVirtualBox);
|
---|
2104 | #endif
|
---|
2105 |
|
---|
2106 | /*
|
---|
2107 | * Go looking for extensions. The RTDirOpen may fail if nothing has been
|
---|
2108 | * installed yet, or if root is paranoid and has revoked our access to them.
|
---|
2109 | *
|
---|
2110 | * We ASSUME that there are no files, directories or stuff in the directory
|
---|
2111 | * that exceed the max name length in RTDIRENTRYEX.
|
---|
2112 | */
|
---|
2113 | HRESULT hrc = S_OK;
|
---|
2114 | RTDIR hDir;
|
---|
2115 | int vrc = RTDirOpen(&hDir, szBaseDir);
|
---|
2116 | if (RT_SUCCESS(vrc))
|
---|
2117 | {
|
---|
2118 | for (;;)
|
---|
2119 | {
|
---|
2120 | RTDIRENTRYEX Entry;
|
---|
2121 | vrc = RTDirReadEx(hDir, &Entry, NULL /*pcbDirEntry*/, RTFSOBJATTRADD_NOTHING, RTPATH_F_ON_LINK);
|
---|
2122 | if (RT_FAILURE(vrc))
|
---|
2123 | {
|
---|
2124 | AssertLogRelMsg(vrc == VERR_NO_MORE_FILES, ("%Rrc\n", vrc));
|
---|
2125 | break;
|
---|
2126 | }
|
---|
2127 | if ( RTFS_IS_DIRECTORY(Entry.Info.Attr.fMode)
|
---|
2128 | && strcmp(Entry.szName, ".") != 0
|
---|
2129 | && strcmp(Entry.szName, "..") != 0
|
---|
2130 | && VBoxExtPackIsValidMangledName(Entry.szName) )
|
---|
2131 | {
|
---|
2132 | /*
|
---|
2133 | * All directories are extensions, the shall be nothing but
|
---|
2134 | * extensions in this subdirectory.
|
---|
2135 | */
|
---|
2136 | char szExtPackDir[RTPATH_MAX];
|
---|
2137 | vrc = RTPathJoin(szExtPackDir, sizeof(szExtPackDir), m->strBaseDir.c_str(), Entry.szName);
|
---|
2138 | AssertLogRelRC(vrc);
|
---|
2139 | if (RT_SUCCESS(vrc))
|
---|
2140 | {
|
---|
2141 | RTCString *pstrName = VBoxExtPackUnmangleName(Entry.szName, RTSTR_MAX);
|
---|
2142 | AssertLogRel(pstrName);
|
---|
2143 | if (pstrName)
|
---|
2144 | {
|
---|
2145 | ComObjPtr<ExtPack> NewExtPack;
|
---|
2146 | HRESULT hrc2 = NewExtPack.createObject();
|
---|
2147 | if (SUCCEEDED(hrc2))
|
---|
2148 | hrc2 = NewExtPack->initWithDir(a_pVirtualBox, a_enmContext, pstrName->c_str(), szExtPackDir);
|
---|
2149 | delete pstrName;
|
---|
2150 | if (SUCCEEDED(hrc2))
|
---|
2151 | {
|
---|
2152 | m->llInstalledExtPacks.push_back(NewExtPack);
|
---|
2153 | /* Paranoia, there should be no API clients before this method is finished. */
|
---|
2154 |
|
---|
2155 | m->cUpdate++;
|
---|
2156 | }
|
---|
2157 | else if (SUCCEEDED(rc))
|
---|
2158 | hrc = hrc2;
|
---|
2159 | }
|
---|
2160 | else
|
---|
2161 | hrc = E_UNEXPECTED;
|
---|
2162 | }
|
---|
2163 | else
|
---|
2164 | hrc = E_UNEXPECTED;
|
---|
2165 | }
|
---|
2166 | }
|
---|
2167 | RTDirClose(hDir);
|
---|
2168 | }
|
---|
2169 | /* else: ignore, the directory probably does not exist or something. */
|
---|
2170 |
|
---|
2171 | if (SUCCEEDED(hrc))
|
---|
2172 | autoInitSpan.setSucceeded();
|
---|
2173 | return hrc;
|
---|
2174 | }
|
---|
2175 |
|
---|
2176 | /**
|
---|
2177 | * COM cruft.
|
---|
2178 | */
|
---|
2179 | void ExtPackManager::FinalRelease()
|
---|
2180 | {
|
---|
2181 | uninit();
|
---|
2182 | BaseFinalRelease();
|
---|
2183 | }
|
---|
2184 |
|
---|
2185 | /**
|
---|
2186 | * Do the actual cleanup.
|
---|
2187 | */
|
---|
2188 | void ExtPackManager::uninit()
|
---|
2189 | {
|
---|
2190 | /* Enclose the state transition Ready->InUninit->NotReady */
|
---|
2191 | AutoUninitSpan autoUninitSpan(this);
|
---|
2192 | if (!autoUninitSpan.uninitDone() && m != NULL)
|
---|
2193 | {
|
---|
2194 | delete m;
|
---|
2195 | m = NULL;
|
---|
2196 | }
|
---|
2197 | }
|
---|
2198 |
|
---|
2199 | HRESULT ExtPackManager::getInstalledExtPacks(std::vector<ComPtr<IExtPack> > &aInstalledExtPacks)
|
---|
2200 | {
|
---|
2201 | Assert(m->enmContext == VBOXEXTPACKCTX_PER_USER_DAEMON);
|
---|
2202 |
|
---|
2203 | AutoReadLock autoLock(this COMMA_LOCKVAL_SRC_POS);
|
---|
2204 |
|
---|
2205 |
|
---|
2206 | SafeIfaceArray<IExtPack> SaExtPacks(m->llInstalledExtPacks);
|
---|
2207 | aInstalledExtPacks.resize(SaExtPacks.size());
|
---|
2208 | for(size_t i = 0; i < SaExtPacks.size(); ++i)
|
---|
2209 | aInstalledExtPacks[i] = SaExtPacks[i];
|
---|
2210 |
|
---|
2211 | return S_OK;
|
---|
2212 | }
|
---|
2213 |
|
---|
2214 | HRESULT ExtPackManager::find(const com::Utf8Str &aName, ComPtr<IExtPack> &aReturnData)
|
---|
2215 | {
|
---|
2216 | HRESULT hrc = S_OK;
|
---|
2217 |
|
---|
2218 | Assert(m->enmContext == VBOXEXTPACKCTX_PER_USER_DAEMON);
|
---|
2219 |
|
---|
2220 | AutoReadLock autoLock(this COMMA_LOCKVAL_SRC_POS);
|
---|
2221 |
|
---|
2222 | ComPtr<ExtPack> ptrExtPack = i_findExtPack(aName.c_str());
|
---|
2223 | if (!ptrExtPack.isNull())
|
---|
2224 | ptrExtPack.queryInterfaceTo(aReturnData.asOutParam());
|
---|
2225 | else
|
---|
2226 | hrc = VBOX_E_OBJECT_NOT_FOUND;
|
---|
2227 |
|
---|
2228 | return hrc;
|
---|
2229 | }
|
---|
2230 |
|
---|
2231 | HRESULT ExtPackManager::openExtPackFile(const com::Utf8Str &aPath, ComPtr<IExtPackFile> &aFile)
|
---|
2232 | {
|
---|
2233 | AssertReturn(m->enmContext == VBOXEXTPACKCTX_PER_USER_DAEMON, E_UNEXPECTED);
|
---|
2234 |
|
---|
2235 | #ifndef VBOX_COM_INPROC
|
---|
2236 | /* The API can optionally take a ::SHA-256=<hex-digest> attribute at the
|
---|
2237 | end of the file name. This is just a temporary measure for
|
---|
2238 | backporting, in 4.2 we'll add another parameter to the method. */
|
---|
2239 | Utf8Str strTarball;
|
---|
2240 | Utf8Str strDigest;
|
---|
2241 | size_t offSha256 = aPath.find("::SHA-256=");
|
---|
2242 | if (offSha256 == Utf8Str::npos)
|
---|
2243 | strTarball = aPath;
|
---|
2244 | else
|
---|
2245 | {
|
---|
2246 | strTarball = aPath.substr(0, offSha256);
|
---|
2247 | strDigest = aPath.substr(offSha256 + sizeof("::SHA-256=") - 1);
|
---|
2248 | }
|
---|
2249 |
|
---|
2250 | ComObjPtr<ExtPackFile> NewExtPackFile;
|
---|
2251 | HRESULT hrc = NewExtPackFile.createObject();
|
---|
2252 | if (SUCCEEDED(hrc))
|
---|
2253 | hrc = NewExtPackFile->initWithFile(strTarball.c_str(), strDigest.c_str(), this, m->pVirtualBox);
|
---|
2254 | if (SUCCEEDED(hrc))
|
---|
2255 | NewExtPackFile.queryInterfaceTo(aFile.asOutParam());
|
---|
2256 |
|
---|
2257 | return hrc;
|
---|
2258 | #else
|
---|
2259 | RT_NOREF(aPath, aFile);
|
---|
2260 | return E_NOTIMPL;
|
---|
2261 | #endif
|
---|
2262 | }
|
---|
2263 |
|
---|
2264 | HRESULT ExtPackManager::uninstall(const com::Utf8Str &aName, BOOL aForcedRemoval,
|
---|
2265 | const com::Utf8Str &aDisplayInfo, ComPtr<IProgress> &aProgress)
|
---|
2266 | {
|
---|
2267 | Assert(m->enmContext == VBOXEXTPACKCTX_PER_USER_DAEMON);
|
---|
2268 |
|
---|
2269 | #ifndef VBOX_COM_INPROC
|
---|
2270 |
|
---|
2271 | HRESULT hrc;
|
---|
2272 | ExtPackUninstallTask *pTask = NULL;
|
---|
2273 | try
|
---|
2274 | {
|
---|
2275 | pTask = new ExtPackUninstallTask();
|
---|
2276 | hrc = pTask->Init(this, aName, aForcedRemoval != FALSE, aDisplayInfo);
|
---|
2277 | if (SUCCEEDED(hrc))
|
---|
2278 | {
|
---|
2279 | ComPtr<Progress> ptrProgress = pTask->ptrProgress;
|
---|
2280 | hrc = pTask->createThreadWithType(RTTHREADTYPE_DEFAULT);
|
---|
2281 | pTask = NULL; /* always consumed by createThread */
|
---|
2282 | if (SUCCEEDED(hrc))
|
---|
2283 | hrc = ptrProgress.queryInterfaceTo(aProgress.asOutParam());
|
---|
2284 | else
|
---|
2285 | hrc = setError(VBOX_E_IPRT_ERROR,
|
---|
2286 | tr("Starting thread for an extension pack uninstallation failed with %Rrc"), hrc);
|
---|
2287 | }
|
---|
2288 | else
|
---|
2289 | hrc = setError(hrc, tr("Looks like creating a progress object for ExtraPackUninstallTask object failed"));
|
---|
2290 | }
|
---|
2291 | catch (std::bad_alloc &)
|
---|
2292 | {
|
---|
2293 | hrc = E_OUTOFMEMORY;
|
---|
2294 | }
|
---|
2295 | catch (HRESULT hrcXcpt)
|
---|
2296 | {
|
---|
2297 | LogFlowThisFunc(("Exception was caught in the function ExtPackManager::uninstall()\n"));
|
---|
2298 | hrc = hrcXcpt;
|
---|
2299 | }
|
---|
2300 | if (pTask)
|
---|
2301 | delete pTask;
|
---|
2302 | return hrc;
|
---|
2303 | #else
|
---|
2304 | RT_NOREF(aName, aForcedRemoval, aDisplayInfo, aProgress);
|
---|
2305 | return E_NOTIMPL;
|
---|
2306 | #endif
|
---|
2307 | }
|
---|
2308 |
|
---|
2309 | HRESULT ExtPackManager::cleanup(void)
|
---|
2310 | {
|
---|
2311 | Assert(m->enmContext == VBOXEXTPACKCTX_PER_USER_DAEMON);
|
---|
2312 |
|
---|
2313 | AutoCaller autoCaller(this);
|
---|
2314 | HRESULT hrc = autoCaller.rc();
|
---|
2315 | if (SUCCEEDED(hrc))
|
---|
2316 | {
|
---|
2317 | /*
|
---|
2318 | * Run the set-uid-to-root binary that performs the cleanup.
|
---|
2319 | *
|
---|
2320 | * Take the write lock to prevent conflicts with other calls to this
|
---|
2321 | * VBoxSVC instance.
|
---|
2322 | */
|
---|
2323 | AutoWriteLock autoLock(this COMMA_LOCKVAL_SRC_POS);
|
---|
2324 | hrc = i_runSetUidToRootHelper(NULL,
|
---|
2325 | "cleanup",
|
---|
2326 | "--base-dir", m->strBaseDir.c_str(),
|
---|
2327 | (const char *)NULL);
|
---|
2328 | }
|
---|
2329 |
|
---|
2330 | return hrc;
|
---|
2331 | }
|
---|
2332 |
|
---|
2333 | HRESULT ExtPackManager::queryAllPlugInsForFrontend(const com::Utf8Str &aFrontendName, std::vector<com::Utf8Str> &aPlugInModules)
|
---|
2334 | {
|
---|
2335 | NOREF(aFrontendName);
|
---|
2336 | aPlugInModules.resize(0);
|
---|
2337 | return S_OK;
|
---|
2338 | }
|
---|
2339 |
|
---|
2340 | HRESULT ExtPackManager::isExtPackUsable(const com::Utf8Str &aName, BOOL *aUsable)
|
---|
2341 | {
|
---|
2342 | *aUsable = i_isExtPackUsable(aName.c_str());
|
---|
2343 | return S_OK;
|
---|
2344 | }
|
---|
2345 |
|
---|
2346 | /**
|
---|
2347 | * Finds the success indicator string in the stderr output ofr hte helper app.
|
---|
2348 | *
|
---|
2349 | * @returns Pointer to the indicator.
|
---|
2350 | * @param psz The stderr output string. Can be NULL.
|
---|
2351 | * @param cch The size of the string.
|
---|
2352 | */
|
---|
2353 | static char *findSuccessIndicator(char *psz, size_t cch)
|
---|
2354 | {
|
---|
2355 | static const char s_szSuccessInd[] = "rcExit=RTEXITCODE_SUCCESS";
|
---|
2356 | Assert(!cch || strlen(psz) == cch);
|
---|
2357 | if (cch < sizeof(s_szSuccessInd) - 1)
|
---|
2358 | return NULL;
|
---|
2359 | char *pszInd = &psz[cch - sizeof(s_szSuccessInd) + 1];
|
---|
2360 | if (strcmp(s_szSuccessInd, pszInd))
|
---|
2361 | return NULL;
|
---|
2362 | return pszInd;
|
---|
2363 | }
|
---|
2364 |
|
---|
2365 | /**
|
---|
2366 | * Runs the helper application that does the privileged operations.
|
---|
2367 | *
|
---|
2368 | * @returns S_OK or a failure status with error information set.
|
---|
2369 | * @param a_pstrDisplayInfo Platform specific display info hacks.
|
---|
2370 | * @param a_pszCommand The command to execute.
|
---|
2371 | * @param ... The argument strings that goes along with the
|
---|
2372 | * command. Maximum is about 16. Terminated by a
|
---|
2373 | * NULL.
|
---|
2374 | */
|
---|
2375 | HRESULT ExtPackManager::i_runSetUidToRootHelper(Utf8Str const *a_pstrDisplayInfo, const char *a_pszCommand, ...)
|
---|
2376 | {
|
---|
2377 | /*
|
---|
2378 | * Calculate the path to the helper application.
|
---|
2379 | */
|
---|
2380 | char szExecName[RTPATH_MAX];
|
---|
2381 | int vrc = RTPathAppPrivateArch(szExecName, sizeof(szExecName));
|
---|
2382 | AssertLogRelRCReturn(vrc, E_UNEXPECTED);
|
---|
2383 |
|
---|
2384 | vrc = RTPathAppend(szExecName, sizeof(szExecName), VBOX_EXTPACK_HELPER_NAME);
|
---|
2385 | AssertLogRelRCReturn(vrc, E_UNEXPECTED);
|
---|
2386 |
|
---|
2387 | /*
|
---|
2388 | * Convert the variable argument list to a RTProcCreate argument vector.
|
---|
2389 | */
|
---|
2390 | const char *apszArgs[20];
|
---|
2391 | unsigned cArgs = 0;
|
---|
2392 |
|
---|
2393 | LogRel(("ExtPack: Executing '%s'", szExecName));
|
---|
2394 | apszArgs[cArgs++] = &szExecName[0];
|
---|
2395 |
|
---|
2396 | if ( a_pstrDisplayInfo
|
---|
2397 | && a_pstrDisplayInfo->isNotEmpty())
|
---|
2398 | {
|
---|
2399 | LogRel((" '--display-info-hack' '%s'", a_pstrDisplayInfo->c_str()));
|
---|
2400 | apszArgs[cArgs++] = "--display-info-hack";
|
---|
2401 | apszArgs[cArgs++] = a_pstrDisplayInfo->c_str();
|
---|
2402 | }
|
---|
2403 |
|
---|
2404 | LogRel((" '%s'", a_pszCommand));
|
---|
2405 | apszArgs[cArgs++] = a_pszCommand;
|
---|
2406 |
|
---|
2407 | va_list va;
|
---|
2408 | va_start(va, a_pszCommand);
|
---|
2409 | const char *pszLastArg;
|
---|
2410 | for (;;)
|
---|
2411 | {
|
---|
2412 | AssertReturn(cArgs < RT_ELEMENTS(apszArgs) - 1, E_UNEXPECTED);
|
---|
2413 | pszLastArg = va_arg(va, const char *);
|
---|
2414 | if (!pszLastArg)
|
---|
2415 | break;
|
---|
2416 | LogRel((" '%s'", pszLastArg));
|
---|
2417 | apszArgs[cArgs++] = pszLastArg;
|
---|
2418 | };
|
---|
2419 | va_end(va);
|
---|
2420 |
|
---|
2421 | LogRel(("\n"));
|
---|
2422 | apszArgs[cArgs] = NULL;
|
---|
2423 |
|
---|
2424 | /*
|
---|
2425 | * Create a PIPE which we attach to stderr so that we can read the error
|
---|
2426 | * message on failure and report it back to the caller.
|
---|
2427 | */
|
---|
2428 | RTPIPE hPipeR;
|
---|
2429 | RTHANDLE hStdErrPipe;
|
---|
2430 | hStdErrPipe.enmType = RTHANDLETYPE_PIPE;
|
---|
2431 | vrc = RTPipeCreate(&hPipeR, &hStdErrPipe.u.hPipe, RTPIPE_C_INHERIT_WRITE);
|
---|
2432 | AssertLogRelRCReturn(vrc, E_UNEXPECTED);
|
---|
2433 |
|
---|
2434 | /*
|
---|
2435 | * Spawn the process.
|
---|
2436 | */
|
---|
2437 | HRESULT hrc;
|
---|
2438 | RTPROCESS hProcess;
|
---|
2439 | vrc = RTProcCreateEx(szExecName,
|
---|
2440 | apszArgs,
|
---|
2441 | RTENV_DEFAULT,
|
---|
2442 | 0 /*fFlags*/,
|
---|
2443 | NULL /*phStdIn*/,
|
---|
2444 | NULL /*phStdOut*/,
|
---|
2445 | &hStdErrPipe,
|
---|
2446 | NULL /*pszAsUser*/,
|
---|
2447 | NULL /*pszPassword*/,
|
---|
2448 | &hProcess);
|
---|
2449 | if (RT_SUCCESS(vrc))
|
---|
2450 | {
|
---|
2451 | vrc = RTPipeClose(hStdErrPipe.u.hPipe);
|
---|
2452 | hStdErrPipe.u.hPipe = NIL_RTPIPE;
|
---|
2453 |
|
---|
2454 | /*
|
---|
2455 | * Read the pipe output until the process completes.
|
---|
2456 | */
|
---|
2457 | RTPROCSTATUS ProcStatus = { -42, RTPROCEXITREASON_ABEND };
|
---|
2458 | size_t cbStdErrBuf = 0;
|
---|
2459 | size_t offStdErrBuf = 0;
|
---|
2460 | char *pszStdErrBuf = NULL;
|
---|
2461 | do
|
---|
2462 | {
|
---|
2463 | /*
|
---|
2464 | * Service the pipe. Block waiting for output or the pipe breaking
|
---|
2465 | * when the process terminates.
|
---|
2466 | */
|
---|
2467 | if (hPipeR != NIL_RTPIPE)
|
---|
2468 | {
|
---|
2469 | char achBuf[1024];
|
---|
2470 | size_t cbRead;
|
---|
2471 | vrc = RTPipeReadBlocking(hPipeR, achBuf, sizeof(achBuf), &cbRead);
|
---|
2472 | if (RT_SUCCESS(vrc))
|
---|
2473 | {
|
---|
2474 | /* grow the buffer? */
|
---|
2475 | size_t cbBufReq = offStdErrBuf + cbRead + 1;
|
---|
2476 | if ( cbBufReq > cbStdErrBuf
|
---|
2477 | && cbBufReq < _256K)
|
---|
2478 | {
|
---|
2479 | size_t cbNew = RT_ALIGN_Z(cbBufReq, 16); // 1024
|
---|
2480 | void *pvNew = RTMemRealloc(pszStdErrBuf, cbNew);
|
---|
2481 | if (pvNew)
|
---|
2482 | {
|
---|
2483 | pszStdErrBuf = (char *)pvNew;
|
---|
2484 | cbStdErrBuf = cbNew;
|
---|
2485 | }
|
---|
2486 | }
|
---|
2487 |
|
---|
2488 | /* append if we've got room. */
|
---|
2489 | if (cbBufReq <= cbStdErrBuf)
|
---|
2490 | {
|
---|
2491 | memcpy(&pszStdErrBuf[offStdErrBuf], achBuf, cbRead);
|
---|
2492 | offStdErrBuf = offStdErrBuf + cbRead;
|
---|
2493 | pszStdErrBuf[offStdErrBuf] = '\0';
|
---|
2494 | }
|
---|
2495 | }
|
---|
2496 | else
|
---|
2497 | {
|
---|
2498 | AssertLogRelMsg(vrc == VERR_BROKEN_PIPE, ("%Rrc\n", vrc));
|
---|
2499 | RTPipeClose(hPipeR);
|
---|
2500 | hPipeR = NIL_RTPIPE;
|
---|
2501 | }
|
---|
2502 | }
|
---|
2503 |
|
---|
2504 | /*
|
---|
2505 | * Service the process. Block if we have no pipe.
|
---|
2506 | */
|
---|
2507 | if (hProcess != NIL_RTPROCESS)
|
---|
2508 | {
|
---|
2509 | vrc = RTProcWait(hProcess,
|
---|
2510 | hPipeR == NIL_RTPIPE ? RTPROCWAIT_FLAGS_BLOCK : RTPROCWAIT_FLAGS_NOBLOCK,
|
---|
2511 | &ProcStatus);
|
---|
2512 | if (RT_SUCCESS(vrc))
|
---|
2513 | hProcess = NIL_RTPROCESS;
|
---|
2514 | else
|
---|
2515 | AssertLogRelMsgStmt(vrc == VERR_PROCESS_RUNNING, ("%Rrc\n", vrc), hProcess = NIL_RTPROCESS);
|
---|
2516 | }
|
---|
2517 | } while ( hPipeR != NIL_RTPIPE
|
---|
2518 | || hProcess != NIL_RTPROCESS);
|
---|
2519 |
|
---|
2520 | LogRel(("ExtPack: enmReason=%d iStatus=%d stderr='%s'\n",
|
---|
2521 | ProcStatus.enmReason, ProcStatus.iStatus, offStdErrBuf ? pszStdErrBuf : ""));
|
---|
2522 |
|
---|
2523 | /*
|
---|
2524 | * Look for rcExit=RTEXITCODE_SUCCESS at the end of the error output,
|
---|
2525 | * cut it as it is only there to attest the success.
|
---|
2526 | */
|
---|
2527 | if (offStdErrBuf > 0)
|
---|
2528 | {
|
---|
2529 | RTStrStripR(pszStdErrBuf);
|
---|
2530 | offStdErrBuf = strlen(pszStdErrBuf);
|
---|
2531 | }
|
---|
2532 |
|
---|
2533 | char *pszSuccessInd = findSuccessIndicator(pszStdErrBuf, offStdErrBuf);
|
---|
2534 | if (pszSuccessInd)
|
---|
2535 | {
|
---|
2536 | *pszSuccessInd = '\0';
|
---|
2537 | offStdErrBuf = pszSuccessInd - pszStdErrBuf;
|
---|
2538 | }
|
---|
2539 | else if ( ProcStatus.enmReason == RTPROCEXITREASON_NORMAL
|
---|
2540 | && ProcStatus.iStatus == 0)
|
---|
2541 | ProcStatus.iStatus = offStdErrBuf ? 667 : 666;
|
---|
2542 |
|
---|
2543 | /*
|
---|
2544 | * Compose the status code and, on failure, error message.
|
---|
2545 | */
|
---|
2546 | if ( ProcStatus.enmReason == RTPROCEXITREASON_NORMAL
|
---|
2547 | && ProcStatus.iStatus == 0)
|
---|
2548 | hrc = S_OK;
|
---|
2549 | else if (ProcStatus.enmReason == RTPROCEXITREASON_NORMAL)
|
---|
2550 | {
|
---|
2551 | AssertMsg(ProcStatus.iStatus != 0, ("%s\n", pszStdErrBuf));
|
---|
2552 | hrc = setError(E_FAIL, tr("The installer failed with exit code %d: %s"),
|
---|
2553 | ProcStatus.iStatus, offStdErrBuf ? pszStdErrBuf : "");
|
---|
2554 | }
|
---|
2555 | else if (ProcStatus.enmReason == RTPROCEXITREASON_SIGNAL)
|
---|
2556 | hrc = setError(E_UNEXPECTED, tr("The installer was killed by signal #d (stderr: %s)"),
|
---|
2557 | ProcStatus.iStatus, offStdErrBuf ? pszStdErrBuf : "");
|
---|
2558 | else if (ProcStatus.enmReason == RTPROCEXITREASON_ABEND)
|
---|
2559 | hrc = setError(E_UNEXPECTED, tr("The installer aborted abnormally (stderr: %s)"),
|
---|
2560 | offStdErrBuf ? pszStdErrBuf : "");
|
---|
2561 | else
|
---|
2562 | hrc = setError(E_UNEXPECTED, tr("internal error: enmReason=%d iStatus=%d stderr='%s'"),
|
---|
2563 | ProcStatus.enmReason, ProcStatus.iStatus, offStdErrBuf ? pszStdErrBuf : "");
|
---|
2564 |
|
---|
2565 | RTMemFree(pszStdErrBuf);
|
---|
2566 | }
|
---|
2567 | else
|
---|
2568 | hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Failed to launch the helper application '%s' (%Rrc)"), szExecName, vrc);
|
---|
2569 |
|
---|
2570 | RTPipeClose(hPipeR);
|
---|
2571 | RTPipeClose(hStdErrPipe.u.hPipe);
|
---|
2572 |
|
---|
2573 | return hrc;
|
---|
2574 | }
|
---|
2575 |
|
---|
2576 | /**
|
---|
2577 | * Finds an installed extension pack.
|
---|
2578 | *
|
---|
2579 | * @returns Pointer to the extension pack if found, NULL if not. (No reference
|
---|
2580 | * counting problem here since the caller must be holding the lock.)
|
---|
2581 | * @param a_pszName The name of the extension pack.
|
---|
2582 | */
|
---|
2583 | ExtPack *ExtPackManager::i_findExtPack(const char *a_pszName)
|
---|
2584 | {
|
---|
2585 | size_t cchName = strlen(a_pszName);
|
---|
2586 |
|
---|
2587 | for (ExtPackList::iterator it = m->llInstalledExtPacks.begin();
|
---|
2588 | it != m->llInstalledExtPacks.end();
|
---|
2589 | ++it)
|
---|
2590 | {
|
---|
2591 | ExtPack::Data *pExtPackData = (*it)->m;
|
---|
2592 | if ( pExtPackData
|
---|
2593 | && pExtPackData->Desc.strName.length() == cchName
|
---|
2594 | && pExtPackData->Desc.strName.equalsIgnoreCase(a_pszName))
|
---|
2595 | return (*it);
|
---|
2596 | }
|
---|
2597 | return NULL;
|
---|
2598 | }
|
---|
2599 |
|
---|
2600 | /**
|
---|
2601 | * Removes an installed extension pack from the internal list.
|
---|
2602 | *
|
---|
2603 | * The package is expected to exist!
|
---|
2604 | *
|
---|
2605 | * @param a_pszName The name of the extension pack.
|
---|
2606 | */
|
---|
2607 | void ExtPackManager::i_removeExtPack(const char *a_pszName)
|
---|
2608 | {
|
---|
2609 | size_t cchName = strlen(a_pszName);
|
---|
2610 |
|
---|
2611 | for (ExtPackList::iterator it = m->llInstalledExtPacks.begin();
|
---|
2612 | it != m->llInstalledExtPacks.end();
|
---|
2613 | ++it)
|
---|
2614 | {
|
---|
2615 | ExtPack::Data *pExtPackData = (*it)->m;
|
---|
2616 | if ( pExtPackData
|
---|
2617 | && pExtPackData->Desc.strName.length() == cchName
|
---|
2618 | && pExtPackData->Desc.strName.equalsIgnoreCase(a_pszName))
|
---|
2619 | {
|
---|
2620 | m->llInstalledExtPacks.erase(it);
|
---|
2621 | m->cUpdate++;
|
---|
2622 | return;
|
---|
2623 | }
|
---|
2624 | }
|
---|
2625 | AssertMsgFailed(("%s\n", a_pszName));
|
---|
2626 | }
|
---|
2627 |
|
---|
2628 | #ifndef VBOX_COM_INPROC
|
---|
2629 |
|
---|
2630 | /**
|
---|
2631 | * Refreshes the specified extension pack.
|
---|
2632 | *
|
---|
2633 | * This may remove the extension pack from the list, so any non-smart pointers
|
---|
2634 | * to the extension pack object may become invalid.
|
---|
2635 | *
|
---|
2636 | * @returns S_OK and *a_ppExtPack on success, COM status code and error
|
---|
2637 | * message on failure. Note that *a_ppExtPack can be NULL.
|
---|
2638 | *
|
---|
2639 | * @param a_pszName The extension to update..
|
---|
2640 | * @param a_fUnusableIsError If @c true, report an unusable extension pack
|
---|
2641 | * as an error.
|
---|
2642 | * @param a_ppExtPack Where to store the pointer to the extension
|
---|
2643 | * pack of it is still around after the refresh.
|
---|
2644 | * This is optional.
|
---|
2645 | *
|
---|
2646 | * @remarks Caller holds the extension manager lock.
|
---|
2647 | * @remarks Only called in VBoxSVC.
|
---|
2648 | */
|
---|
2649 | HRESULT ExtPackManager::i_refreshExtPack(const char *a_pszName, bool a_fUnusableIsError, ExtPack **a_ppExtPack)
|
---|
2650 | {
|
---|
2651 | Assert(m->pVirtualBox != NULL); /* Only called from VBoxSVC. */
|
---|
2652 |
|
---|
2653 | HRESULT hrc;
|
---|
2654 | ExtPack *pExtPack = i_findExtPack(a_pszName);
|
---|
2655 | if (pExtPack)
|
---|
2656 | {
|
---|
2657 | /*
|
---|
2658 | * Refresh existing object.
|
---|
2659 | */
|
---|
2660 | bool fCanDelete;
|
---|
2661 | hrc = pExtPack->i_refresh(&fCanDelete);
|
---|
2662 | if (SUCCEEDED(hrc))
|
---|
2663 | {
|
---|
2664 | if (fCanDelete)
|
---|
2665 | {
|
---|
2666 | i_removeExtPack(a_pszName);
|
---|
2667 | pExtPack = NULL;
|
---|
2668 | }
|
---|
2669 | }
|
---|
2670 | }
|
---|
2671 | else
|
---|
2672 | {
|
---|
2673 | /*
|
---|
2674 | * Do this check here, otherwise VBoxExtPackCalcDir() will fail with a strange
|
---|
2675 | * error.
|
---|
2676 | */
|
---|
2677 | bool fValid = VBoxExtPackIsValidName(a_pszName);
|
---|
2678 | if (!fValid)
|
---|
2679 | return setError(E_FAIL, "Invalid extension pack name specified");
|
---|
2680 |
|
---|
2681 | /*
|
---|
2682 | * Does the dir exist? Make some special effort to deal with case
|
---|
2683 | * sensitivie file systems (a_pszName is case insensitive and mangled).
|
---|
2684 | */
|
---|
2685 | char szDir[RTPATH_MAX];
|
---|
2686 | int vrc = VBoxExtPackCalcDir(szDir, sizeof(szDir), m->strBaseDir.c_str(), a_pszName);
|
---|
2687 | AssertLogRelRCReturn(vrc, E_FAIL);
|
---|
2688 |
|
---|
2689 | RTDIRENTRYEX Entry;
|
---|
2690 | RTFSOBJINFO ObjInfo;
|
---|
2691 | vrc = RTPathQueryInfoEx(szDir, &ObjInfo, RTFSOBJATTRADD_NOTHING, RTPATH_F_ON_LINK);
|
---|
2692 | bool fExists = RT_SUCCESS(vrc) && RTFS_IS_DIRECTORY(ObjInfo.Attr.fMode);
|
---|
2693 | if (!fExists)
|
---|
2694 | {
|
---|
2695 | RTDIR hDir;
|
---|
2696 | vrc = RTDirOpen(&hDir, m->strBaseDir.c_str());
|
---|
2697 | if (RT_SUCCESS(vrc))
|
---|
2698 | {
|
---|
2699 | const char *pszMangledName = RTPathFilename(szDir);
|
---|
2700 | for (;;)
|
---|
2701 | {
|
---|
2702 | vrc = RTDirReadEx(hDir, &Entry, NULL /*pcbDirEntry*/, RTFSOBJATTRADD_NOTHING, RTPATH_F_ON_LINK);
|
---|
2703 | if (RT_FAILURE(vrc))
|
---|
2704 | {
|
---|
2705 | AssertLogRelMsg(vrc == VERR_NO_MORE_FILES, ("%Rrc\n", vrc));
|
---|
2706 | break;
|
---|
2707 | }
|
---|
2708 | if ( RTFS_IS_DIRECTORY(Entry.Info.Attr.fMode)
|
---|
2709 | && !RTStrICmp(Entry.szName, pszMangledName))
|
---|
2710 | {
|
---|
2711 | /*
|
---|
2712 | * The installed extension pack has a uses different case.
|
---|
2713 | * Update the name and directory variables.
|
---|
2714 | */
|
---|
2715 | vrc = RTPathJoin(szDir, sizeof(szDir), m->strBaseDir.c_str(), Entry.szName); /* not really necessary */
|
---|
2716 | AssertLogRelRCReturnStmt(vrc, RTDirClose(hDir), E_UNEXPECTED);
|
---|
2717 | a_pszName = Entry.szName;
|
---|
2718 | fExists = true;
|
---|
2719 | break;
|
---|
2720 | }
|
---|
2721 | }
|
---|
2722 | RTDirClose(hDir);
|
---|
2723 | }
|
---|
2724 | }
|
---|
2725 | if (fExists)
|
---|
2726 | {
|
---|
2727 | /*
|
---|
2728 | * We've got something, create a new extension pack object for it.
|
---|
2729 | */
|
---|
2730 | ComObjPtr<ExtPack> ptrNewExtPack;
|
---|
2731 | hrc = ptrNewExtPack.createObject();
|
---|
2732 | if (SUCCEEDED(hrc))
|
---|
2733 | hrc = ptrNewExtPack->initWithDir(m->pVirtualBox, m->enmContext, a_pszName, szDir);
|
---|
2734 | if (SUCCEEDED(hrc))
|
---|
2735 | {
|
---|
2736 | m->llInstalledExtPacks.push_back(ptrNewExtPack);
|
---|
2737 | m->cUpdate++;
|
---|
2738 | if (ptrNewExtPack->m->fUsable)
|
---|
2739 | LogRel(("ExtPackManager: Found extension pack '%s'.\n", a_pszName));
|
---|
2740 | else
|
---|
2741 | LogRel(("ExtPackManager: Found bad extension pack '%s': %s\n",
|
---|
2742 | a_pszName, ptrNewExtPack->m->strWhyUnusable.c_str() ));
|
---|
2743 | pExtPack = ptrNewExtPack;
|
---|
2744 | }
|
---|
2745 | }
|
---|
2746 | else
|
---|
2747 | hrc = S_OK;
|
---|
2748 | }
|
---|
2749 |
|
---|
2750 | /*
|
---|
2751 | * Report error if not usable, if that is desired.
|
---|
2752 | */
|
---|
2753 | if ( SUCCEEDED(hrc)
|
---|
2754 | && pExtPack
|
---|
2755 | && a_fUnusableIsError
|
---|
2756 | && !pExtPack->m->fUsable)
|
---|
2757 | hrc = setError(E_FAIL, "%s", pExtPack->m->strWhyUnusable.c_str());
|
---|
2758 |
|
---|
2759 | if (a_ppExtPack)
|
---|
2760 | *a_ppExtPack = pExtPack;
|
---|
2761 | return hrc;
|
---|
2762 | }
|
---|
2763 |
|
---|
2764 | /**
|
---|
2765 | * Checks if there are any running VMs.
|
---|
2766 | *
|
---|
2767 | * This is called when uninstalling or replacing an extension pack.
|
---|
2768 | *
|
---|
2769 | * @returns true / false
|
---|
2770 | */
|
---|
2771 | bool ExtPackManager::i_areThereAnyRunningVMs(void) const
|
---|
2772 | {
|
---|
2773 | Assert(m->pVirtualBox != NULL); /* Only called from VBoxSVC. */
|
---|
2774 |
|
---|
2775 | /*
|
---|
2776 | * Get list of machines and their states.
|
---|
2777 | */
|
---|
2778 | com::SafeIfaceArray<IMachine> SaMachines;
|
---|
2779 | HRESULT hrc = m->pVirtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(SaMachines));
|
---|
2780 | if (SUCCEEDED(hrc))
|
---|
2781 | {
|
---|
2782 | com::SafeArray<MachineState_T> SaStates;
|
---|
2783 | hrc = m->pVirtualBox->GetMachineStates(ComSafeArrayAsInParam(SaMachines), ComSafeArrayAsOutParam(SaStates));
|
---|
2784 | if (SUCCEEDED(hrc))
|
---|
2785 | {
|
---|
2786 | /*
|
---|
2787 | * Scan the two parallel arrays for machines in the running state.
|
---|
2788 | */
|
---|
2789 | Assert(SaStates.size() == SaMachines.size());
|
---|
2790 | for (size_t i = 0; i < SaMachines.size(); ++i)
|
---|
2791 | if (SaMachines[i] && Global::IsOnline(SaStates[i]))
|
---|
2792 | return true;
|
---|
2793 | }
|
---|
2794 | }
|
---|
2795 | return false;
|
---|
2796 | }
|
---|
2797 |
|
---|
2798 | /**
|
---|
2799 | * Worker for IExtPackFile::Install.
|
---|
2800 | *
|
---|
2801 | * Called on a worker thread via doInstallThreadProc.
|
---|
2802 | *
|
---|
2803 | * @returns COM status code.
|
---|
2804 | * @param a_pExtPackFile The extension pack file, caller checks that
|
---|
2805 | * it's usable.
|
---|
2806 | * @param a_fReplace Whether to replace any existing extpack or just
|
---|
2807 | * fail.
|
---|
2808 | * @param a_pstrDisplayInfo Host specific display information hacks.
|
---|
2809 | * be NULL.
|
---|
2810 | */
|
---|
2811 | HRESULT ExtPackManager::i_doInstall(ExtPackFile *a_pExtPackFile, bool a_fReplace, Utf8Str const *a_pstrDisplayInfo)
|
---|
2812 | {
|
---|
2813 | AssertReturn(m->enmContext == VBOXEXTPACKCTX_PER_USER_DAEMON, E_UNEXPECTED);
|
---|
2814 | RTCString const * const pStrName = &a_pExtPackFile->m->Desc.strName;
|
---|
2815 | RTCString const * const pStrTarball = &a_pExtPackFile->m->strExtPackFile;
|
---|
2816 | RTCString const * const pStrTarballDigest = &a_pExtPackFile->m->strDigest;
|
---|
2817 |
|
---|
2818 | AutoCaller autoCaller(this);
|
---|
2819 | HRESULT hrc = autoCaller.rc();
|
---|
2820 | if (SUCCEEDED(hrc))
|
---|
2821 | {
|
---|
2822 | AutoWriteLock autoLock(this COMMA_LOCKVAL_SRC_POS);
|
---|
2823 |
|
---|
2824 | /*
|
---|
2825 | * Refresh the data we have on the extension pack as it
|
---|
2826 | * may be made stale by direct meddling or some other user.
|
---|
2827 | */
|
---|
2828 | ExtPack *pExtPack;
|
---|
2829 | hrc = i_refreshExtPack(pStrName->c_str(), false /*a_fUnusableIsError*/, &pExtPack);
|
---|
2830 | if (SUCCEEDED(hrc))
|
---|
2831 | {
|
---|
2832 | if (pExtPack && a_fReplace)
|
---|
2833 | {
|
---|
2834 | /* We must leave the lock when calling i_areThereAnyRunningVMs,
|
---|
2835 | which means we have to redo the refresh call afterwards. */
|
---|
2836 | autoLock.release();
|
---|
2837 | bool fRunningVMs = i_areThereAnyRunningVMs();
|
---|
2838 | autoLock.acquire();
|
---|
2839 | hrc = i_refreshExtPack(pStrName->c_str(), false /*a_fUnusableIsError*/, &pExtPack);
|
---|
2840 | if (fRunningVMs)
|
---|
2841 | {
|
---|
2842 | LogRel(("Install extension pack '%s' failed because at least one VM is still running.", pStrName->c_str()));
|
---|
2843 | hrc = setError(E_FAIL, tr("Install extension pack '%s' failed because at least one VM is still running"),
|
---|
2844 | pStrName->c_str());
|
---|
2845 | }
|
---|
2846 | else if (SUCCEEDED(hrc) && pExtPack)
|
---|
2847 | hrc = pExtPack->i_callUninstallHookAndClose(m->pVirtualBox, false /*a_ForcedRemoval*/);
|
---|
2848 | }
|
---|
2849 | else if (pExtPack)
|
---|
2850 | hrc = setError(E_FAIL,
|
---|
2851 | tr("Extension pack '%s' is already installed."
|
---|
2852 | " In case of a reinstallation, please uninstall it first"),
|
---|
2853 | pStrName->c_str());
|
---|
2854 | }
|
---|
2855 | if (SUCCEEDED(hrc))
|
---|
2856 | {
|
---|
2857 | /*
|
---|
2858 | * Run the privileged helper binary that performs the actual
|
---|
2859 | * installation. Then create an object for the packet (we do this
|
---|
2860 | * even on failure, to be on the safe side).
|
---|
2861 | */
|
---|
2862 | hrc = i_runSetUidToRootHelper(a_pstrDisplayInfo,
|
---|
2863 | "install",
|
---|
2864 | "--base-dir", m->strBaseDir.c_str(),
|
---|
2865 | "--cert-dir", m->strCertificatDirPath.c_str(),
|
---|
2866 | "--name", pStrName->c_str(),
|
---|
2867 | "--tarball", pStrTarball->c_str(),
|
---|
2868 | "--sha-256", pStrTarballDigest->c_str(),
|
---|
2869 | pExtPack ? "--replace" : (const char *)NULL,
|
---|
2870 | (const char *)NULL);
|
---|
2871 | if (SUCCEEDED(hrc))
|
---|
2872 | {
|
---|
2873 | hrc = i_refreshExtPack(pStrName->c_str(), true /*a_fUnusableIsError*/, &pExtPack);
|
---|
2874 | if (SUCCEEDED(hrc) && pExtPack)
|
---|
2875 | {
|
---|
2876 | RTERRINFOSTATIC ErrInfo;
|
---|
2877 | RTErrInfoInitStatic(&ErrInfo);
|
---|
2878 | pExtPack->i_callInstalledHook(m->pVirtualBox, &autoLock, &ErrInfo.Core);
|
---|
2879 | if (RT_SUCCESS(ErrInfo.Core.rc))
|
---|
2880 | LogRel(("ExtPackManager: Successfully installed extension pack '%s'.\n", pStrName->c_str()));
|
---|
2881 | else
|
---|
2882 | {
|
---|
2883 | LogRel(("ExtPackManager: Installed hook for '%s' failed: %Rrc - %s\n",
|
---|
2884 | pStrName->c_str(), ErrInfo.Core.rc, ErrInfo.Core.pszMsg));
|
---|
2885 |
|
---|
2886 | /*
|
---|
2887 | * Uninstall the extpack if the error indicates that.
|
---|
2888 | */
|
---|
2889 | if (ErrInfo.Core.rc == VERR_EXTPACK_UNSUPPORTED_HOST_UNINSTALL)
|
---|
2890 | i_runSetUidToRootHelper(a_pstrDisplayInfo,
|
---|
2891 | "uninstall",
|
---|
2892 | "--base-dir", m->strBaseDir.c_str(),
|
---|
2893 | "--name", pStrName->c_str(),
|
---|
2894 | "--forced",
|
---|
2895 | (const char *)NULL);
|
---|
2896 | hrc = setErrorBoth(E_FAIL, ErrInfo.Core.rc, tr("The installation hook failed: %Rrc - %s"),
|
---|
2897 | ErrInfo.Core.rc, ErrInfo.Core.pszMsg);
|
---|
2898 | }
|
---|
2899 | }
|
---|
2900 | else if (SUCCEEDED(hrc))
|
---|
2901 | hrc = setError(E_FAIL, tr("Installing extension pack '%s' failed under mysterious circumstances"),
|
---|
2902 | pStrName->c_str());
|
---|
2903 | }
|
---|
2904 | else
|
---|
2905 | {
|
---|
2906 | ErrorInfoKeeper Eik;
|
---|
2907 | i_refreshExtPack(pStrName->c_str(), false /*a_fUnusableIsError*/, NULL);
|
---|
2908 | }
|
---|
2909 | }
|
---|
2910 |
|
---|
2911 | /*
|
---|
2912 | * Do VirtualBoxReady callbacks now for any freshly installed
|
---|
2913 | * extension pack (old ones will not be called).
|
---|
2914 | */
|
---|
2915 | if (m->enmContext == VBOXEXTPACKCTX_PER_USER_DAEMON)
|
---|
2916 | {
|
---|
2917 | autoLock.release();
|
---|
2918 | i_callAllVirtualBoxReadyHooks();
|
---|
2919 | }
|
---|
2920 | }
|
---|
2921 |
|
---|
2922 | return hrc;
|
---|
2923 | }
|
---|
2924 |
|
---|
2925 | /**
|
---|
2926 | * Worker for IExtPackManager::Uninstall.
|
---|
2927 | *
|
---|
2928 | * Called on a worker thread via doUninstallThreadProc.
|
---|
2929 | *
|
---|
2930 | * @returns COM status code.
|
---|
2931 | * @param a_pstrName The name of the extension pack to uninstall.
|
---|
2932 | * @param a_fForcedRemoval Whether to be skip and ignore certain bits of
|
---|
2933 | * the extpack feedback. To deal with misbehaving
|
---|
2934 | * extension pack hooks.
|
---|
2935 | * @param a_pstrDisplayInfo Host specific display information hacks.
|
---|
2936 | */
|
---|
2937 | HRESULT ExtPackManager::i_doUninstall(Utf8Str const *a_pstrName, bool a_fForcedRemoval, Utf8Str const *a_pstrDisplayInfo)
|
---|
2938 | {
|
---|
2939 | Assert(m->enmContext == VBOXEXTPACKCTX_PER_USER_DAEMON);
|
---|
2940 |
|
---|
2941 | AutoCaller autoCaller(this);
|
---|
2942 | HRESULT hrc = autoCaller.rc();
|
---|
2943 | if (SUCCEEDED(hrc))
|
---|
2944 | {
|
---|
2945 | if (a_fForcedRemoval || !i_areThereAnyRunningVMs())
|
---|
2946 | {
|
---|
2947 | AutoWriteLock autoLock(this COMMA_LOCKVAL_SRC_POS);
|
---|
2948 |
|
---|
2949 | /*
|
---|
2950 | * Refresh the data we have on the extension pack as it may be made
|
---|
2951 | * stale by direct meddling or some other user.
|
---|
2952 | */
|
---|
2953 | ExtPack *pExtPack;
|
---|
2954 | hrc = i_refreshExtPack(a_pstrName->c_str(), false /*a_fUnusableIsError*/, &pExtPack);
|
---|
2955 | if (SUCCEEDED(hrc))
|
---|
2956 | {
|
---|
2957 | if (!pExtPack)
|
---|
2958 | {
|
---|
2959 | LogRel(("ExtPackManager: Extension pack '%s' is not installed, so nothing to uninstall.\n", a_pstrName->c_str()));
|
---|
2960 | hrc = S_OK; /* nothing to uninstall */
|
---|
2961 | }
|
---|
2962 | else
|
---|
2963 | {
|
---|
2964 | /*
|
---|
2965 | * Call the uninstall hook and unload the main dll.
|
---|
2966 | */
|
---|
2967 | hrc = pExtPack->i_callUninstallHookAndClose(m->pVirtualBox, a_fForcedRemoval);
|
---|
2968 | if (SUCCEEDED(hrc))
|
---|
2969 | {
|
---|
2970 | /*
|
---|
2971 | * Run the set-uid-to-root binary that performs the
|
---|
2972 | * uninstallation. Then refresh the object.
|
---|
2973 | *
|
---|
2974 | * This refresh is theorically subject to races, but it's of
|
---|
2975 | * the don't-do-that variety.
|
---|
2976 | */
|
---|
2977 | const char *pszForcedOpt = a_fForcedRemoval ? "--forced" : NULL;
|
---|
2978 | hrc = i_runSetUidToRootHelper(a_pstrDisplayInfo,
|
---|
2979 | "uninstall",
|
---|
2980 | "--base-dir", m->strBaseDir.c_str(),
|
---|
2981 | "--name", a_pstrName->c_str(),
|
---|
2982 | pszForcedOpt, /* Last as it may be NULL. */
|
---|
2983 | (const char *)NULL);
|
---|
2984 | if (SUCCEEDED(hrc))
|
---|
2985 | {
|
---|
2986 | hrc = i_refreshExtPack(a_pstrName->c_str(), false /*a_fUnusableIsError*/, &pExtPack);
|
---|
2987 | if (SUCCEEDED(hrc))
|
---|
2988 | {
|
---|
2989 | if (!pExtPack)
|
---|
2990 | LogRel(("ExtPackManager: Successfully uninstalled extension pack '%s'.\n", a_pstrName->c_str()));
|
---|
2991 | else
|
---|
2992 | hrc = setError(E_FAIL,
|
---|
2993 | tr("Uninstall extension pack '%s' failed under mysterious circumstances"),
|
---|
2994 | a_pstrName->c_str());
|
---|
2995 | }
|
---|
2996 | }
|
---|
2997 | else
|
---|
2998 | {
|
---|
2999 | ErrorInfoKeeper Eik;
|
---|
3000 | i_refreshExtPack(a_pstrName->c_str(), false /*a_fUnusableIsError*/, NULL);
|
---|
3001 | }
|
---|
3002 | }
|
---|
3003 | }
|
---|
3004 | }
|
---|
3005 | }
|
---|
3006 | else
|
---|
3007 | {
|
---|
3008 | LogRel(("Uninstall extension pack '%s' failed because at least one VM is still running.", a_pstrName->c_str()));
|
---|
3009 | hrc = setError(E_FAIL, tr("Uninstall extension pack '%s' failed because at least one VM is still running"),
|
---|
3010 | a_pstrName->c_str());
|
---|
3011 | }
|
---|
3012 |
|
---|
3013 | /*
|
---|
3014 | * Do VirtualBoxReady callbacks now for any freshly installed
|
---|
3015 | * extension pack (old ones will not be called).
|
---|
3016 | */
|
---|
3017 | if (m->enmContext == VBOXEXTPACKCTX_PER_USER_DAEMON)
|
---|
3018 | i_callAllVirtualBoxReadyHooks();
|
---|
3019 | }
|
---|
3020 |
|
---|
3021 | return hrc;
|
---|
3022 | }
|
---|
3023 |
|
---|
3024 |
|
---|
3025 | /**
|
---|
3026 | * Calls the pfnVirtualBoxReady hook for all working extension packs.
|
---|
3027 | *
|
---|
3028 | * @remarks The caller must not hold any locks.
|
---|
3029 | */
|
---|
3030 | void ExtPackManager::i_callAllVirtualBoxReadyHooks(void)
|
---|
3031 | {
|
---|
3032 | AutoCaller autoCaller(this);
|
---|
3033 | HRESULT hrc = autoCaller.rc();
|
---|
3034 | if (FAILED(hrc))
|
---|
3035 | return;
|
---|
3036 | AutoWriteLock autoLock(this COMMA_LOCKVAL_SRC_POS);
|
---|
3037 | ComPtr<ExtPackManager> ptrSelfRef = this;
|
---|
3038 |
|
---|
3039 | for (ExtPackList::iterator it = m->llInstalledExtPacks.begin();
|
---|
3040 | it != m->llInstalledExtPacks.end();
|
---|
3041 | /* advancing below */)
|
---|
3042 | {
|
---|
3043 | if ((*it)->i_callVirtualBoxReadyHook(m->pVirtualBox, &autoLock))
|
---|
3044 | it = m->llInstalledExtPacks.begin();
|
---|
3045 | else
|
---|
3046 | ++it;
|
---|
3047 | }
|
---|
3048 | }
|
---|
3049 |
|
---|
3050 |
|
---|
3051 | /**
|
---|
3052 | * Queries objects of type @a aObjUuid from all the extension packs.
|
---|
3053 | *
|
---|
3054 | * @returns COM status code.
|
---|
3055 | * @param aObjUuid The UUID of the kind of objects we're querying.
|
---|
3056 | * @param aObjects Where to return the objects.
|
---|
3057 | * @param a_pstrExtPackNames Where to return the corresponding extpack names (may be NULL).
|
---|
3058 | *
|
---|
3059 | * @remarks The caller must not hold any locks.
|
---|
3060 | */
|
---|
3061 | HRESULT ExtPackManager::i_queryObjects(const com::Utf8Str &aObjUuid, std::vector<ComPtr<IUnknown> > &aObjects, std::vector<com::Utf8Str> *a_pstrExtPackNames)
|
---|
3062 | {
|
---|
3063 | aObjects.clear();
|
---|
3064 | if (a_pstrExtPackNames)
|
---|
3065 | a_pstrExtPackNames->clear();
|
---|
3066 |
|
---|
3067 | AutoCaller autoCaller(this);
|
---|
3068 | HRESULT hrc = autoCaller.rc();
|
---|
3069 | if (SUCCEEDED(hrc))
|
---|
3070 | {
|
---|
3071 | AutoWriteLock autoLock(this COMMA_LOCKVAL_SRC_POS);
|
---|
3072 | ComPtr<ExtPackManager> ptrSelfRef = this;
|
---|
3073 |
|
---|
3074 | for (ExtPackList::iterator it = m->llInstalledExtPacks.begin();
|
---|
3075 | it != m->llInstalledExtPacks.end();
|
---|
3076 | ++it)
|
---|
3077 | {
|
---|
3078 | ComPtr<IUnknown> ptrIf;
|
---|
3079 | HRESULT hrc2 = (*it)->queryObject(aObjUuid, ptrIf);
|
---|
3080 | if (SUCCEEDED(hrc2))
|
---|
3081 | {
|
---|
3082 | aObjects.push_back(ptrIf);
|
---|
3083 | if (a_pstrExtPackNames)
|
---|
3084 | a_pstrExtPackNames->push_back((*it)->m->Desc.strName);
|
---|
3085 | }
|
---|
3086 | else if (hrc2 != E_NOINTERFACE)
|
---|
3087 | hrc = hrc2;
|
---|
3088 | }
|
---|
3089 |
|
---|
3090 | if (aObjects.size() > 0)
|
---|
3091 | hrc = S_OK;
|
---|
3092 | }
|
---|
3093 | return hrc;
|
---|
3094 | }
|
---|
3095 |
|
---|
3096 | #endif /* !VBOX_COM_INPROC */
|
---|
3097 |
|
---|
3098 | #ifdef VBOX_COM_INPROC
|
---|
3099 | /**
|
---|
3100 | * Calls the pfnConsoleReady hook for all working extension packs.
|
---|
3101 | *
|
---|
3102 | * @param a_pConsole The console interface.
|
---|
3103 | * @remarks The caller must not hold any locks.
|
---|
3104 | */
|
---|
3105 | void ExtPackManager::i_callAllConsoleReadyHooks(IConsole *a_pConsole)
|
---|
3106 | {
|
---|
3107 | AutoCaller autoCaller(this);
|
---|
3108 | HRESULT hrc = autoCaller.rc();
|
---|
3109 | if (FAILED(hrc))
|
---|
3110 | return;
|
---|
3111 | AutoWriteLock autoLock(this COMMA_LOCKVAL_SRC_POS);
|
---|
3112 | ComPtr<ExtPackManager> ptrSelfRef = this;
|
---|
3113 |
|
---|
3114 | for (ExtPackList::iterator it = m->llInstalledExtPacks.begin();
|
---|
3115 | it != m->llInstalledExtPacks.end();
|
---|
3116 | /* advancing below */)
|
---|
3117 | {
|
---|
3118 | if ((*it)->i_callConsoleReadyHook(a_pConsole, &autoLock))
|
---|
3119 | it = m->llInstalledExtPacks.begin();
|
---|
3120 | else
|
---|
3121 | ++it;
|
---|
3122 | }
|
---|
3123 | }
|
---|
3124 | #endif
|
---|
3125 |
|
---|
3126 | #ifndef VBOX_COM_INPROC
|
---|
3127 | /**
|
---|
3128 | * Calls the pfnVMCreated hook for all working extension packs.
|
---|
3129 | *
|
---|
3130 | * @param a_pMachine The machine interface of the new VM.
|
---|
3131 | */
|
---|
3132 | void ExtPackManager::i_callAllVmCreatedHooks(IMachine *a_pMachine)
|
---|
3133 | {
|
---|
3134 | AutoCaller autoCaller(this);
|
---|
3135 | HRESULT hrc = autoCaller.rc();
|
---|
3136 | if (FAILED(hrc))
|
---|
3137 | return;
|
---|
3138 | AutoWriteLock autoLock(this COMMA_LOCKVAL_SRC_POS);
|
---|
3139 | ComPtr<ExtPackManager> ptrSelfRef = this; /* paranoia */
|
---|
3140 | ExtPackList llExtPacks = m->llInstalledExtPacks;
|
---|
3141 |
|
---|
3142 | for (ExtPackList::iterator it = llExtPacks.begin(); it != llExtPacks.end(); ++it)
|
---|
3143 | (*it)->i_callVmCreatedHook(m->pVirtualBox, a_pMachine, &autoLock);
|
---|
3144 | }
|
---|
3145 | #endif
|
---|
3146 |
|
---|
3147 | #ifdef VBOX_COM_INPROC
|
---|
3148 | /**
|
---|
3149 | * Calls the pfnVMConfigureVMM hook for all working extension packs.
|
---|
3150 | *
|
---|
3151 | * @returns VBox status code. Stops on the first failure, expecting the caller
|
---|
3152 | * to signal this to the caller of the CFGM constructor.
|
---|
3153 | * @param a_pConsole The console interface for the VM.
|
---|
3154 | * @param a_pVM The VM handle.
|
---|
3155 | */
|
---|
3156 | int ExtPackManager::i_callAllVmConfigureVmmHooks(IConsole *a_pConsole, PVM a_pVM)
|
---|
3157 | {
|
---|
3158 | AutoCaller autoCaller(this);
|
---|
3159 | HRESULT hrc = autoCaller.rc();
|
---|
3160 | if (FAILED(hrc))
|
---|
3161 | return Global::vboxStatusCodeFromCOM(hrc);
|
---|
3162 | AutoWriteLock autoLock(this COMMA_LOCKVAL_SRC_POS);
|
---|
3163 | ComPtr<ExtPackManager> ptrSelfRef = this; /* paranoia */
|
---|
3164 | ExtPackList llExtPacks = m->llInstalledExtPacks;
|
---|
3165 |
|
---|
3166 | for (ExtPackList::iterator it = llExtPacks.begin(); it != llExtPacks.end(); ++it)
|
---|
3167 | {
|
---|
3168 | int vrc;
|
---|
3169 | (*it)->i_callVmConfigureVmmHook(a_pConsole, a_pVM, &autoLock, &vrc);
|
---|
3170 | if (RT_FAILURE(vrc))
|
---|
3171 | return vrc;
|
---|
3172 | }
|
---|
3173 |
|
---|
3174 | return VINF_SUCCESS;
|
---|
3175 | }
|
---|
3176 |
|
---|
3177 | /**
|
---|
3178 | * Calls the pfnVMPowerOn hook for all working extension packs.
|
---|
3179 | *
|
---|
3180 | * @returns VBox status code. Stops on the first failure, expecting the caller
|
---|
3181 | * to not power on the VM.
|
---|
3182 | * @param a_pConsole The console interface for the VM.
|
---|
3183 | * @param a_pVM The VM handle.
|
---|
3184 | */
|
---|
3185 | int ExtPackManager::i_callAllVmPowerOnHooks(IConsole *a_pConsole, PVM a_pVM)
|
---|
3186 | {
|
---|
3187 | AutoCaller autoCaller(this);
|
---|
3188 | HRESULT hrc = autoCaller.rc();
|
---|
3189 | if (FAILED(hrc))
|
---|
3190 | return Global::vboxStatusCodeFromCOM(hrc);
|
---|
3191 | AutoWriteLock autoLock(this COMMA_LOCKVAL_SRC_POS);
|
---|
3192 | ComPtr<ExtPackManager> ptrSelfRef = this; /* paranoia */
|
---|
3193 | ExtPackList llExtPacks = m->llInstalledExtPacks;
|
---|
3194 |
|
---|
3195 | for (ExtPackList::iterator it = llExtPacks.begin(); it != llExtPacks.end(); ++it)
|
---|
3196 | {
|
---|
3197 | int vrc;
|
---|
3198 | (*it)->i_callVmPowerOnHook(a_pConsole, a_pVM, &autoLock, &vrc);
|
---|
3199 | if (RT_FAILURE(vrc))
|
---|
3200 | return vrc;
|
---|
3201 | }
|
---|
3202 |
|
---|
3203 | return VINF_SUCCESS;
|
---|
3204 | }
|
---|
3205 |
|
---|
3206 | /**
|
---|
3207 | * Calls the pfnVMPowerOff hook for all working extension packs.
|
---|
3208 | *
|
---|
3209 | * @param a_pConsole The console interface for the VM.
|
---|
3210 | * @param a_pVM The VM handle. Can be NULL.
|
---|
3211 | */
|
---|
3212 | void ExtPackManager::i_callAllVmPowerOffHooks(IConsole *a_pConsole, PVM a_pVM)
|
---|
3213 | {
|
---|
3214 | AutoCaller autoCaller(this);
|
---|
3215 | HRESULT hrc = autoCaller.rc();
|
---|
3216 | if (FAILED(hrc))
|
---|
3217 | return;
|
---|
3218 | AutoWriteLock autoLock(this COMMA_LOCKVAL_SRC_POS);
|
---|
3219 | ComPtr<ExtPackManager> ptrSelfRef = this; /* paranoia */
|
---|
3220 | ExtPackList llExtPacks = m->llInstalledExtPacks;
|
---|
3221 |
|
---|
3222 | for (ExtPackList::iterator it = llExtPacks.begin(); it != llExtPacks.end(); ++it)
|
---|
3223 | (*it)->i_callVmPowerOffHook(a_pConsole, a_pVM, &autoLock);
|
---|
3224 | }
|
---|
3225 | #endif
|
---|
3226 |
|
---|
3227 |
|
---|
3228 | /**
|
---|
3229 | * Checks that the specified extension pack contains a VRDE module and that it
|
---|
3230 | * is shipshape.
|
---|
3231 | *
|
---|
3232 | * @returns S_OK if ok, appropriate failure status code with details.
|
---|
3233 | * @param a_pstrExtPack The name of the extension pack.
|
---|
3234 | */
|
---|
3235 | HRESULT ExtPackManager::i_checkVrdeExtPack(Utf8Str const *a_pstrExtPack)
|
---|
3236 | {
|
---|
3237 | AutoCaller autoCaller(this);
|
---|
3238 | HRESULT hrc = autoCaller.rc();
|
---|
3239 | if (SUCCEEDED(hrc))
|
---|
3240 | {
|
---|
3241 | AutoReadLock autoLock(this COMMA_LOCKVAL_SRC_POS);
|
---|
3242 |
|
---|
3243 | ExtPack *pExtPack = i_findExtPack(a_pstrExtPack->c_str());
|
---|
3244 | if (pExtPack)
|
---|
3245 | hrc = pExtPack->i_checkVrde();
|
---|
3246 | else
|
---|
3247 | hrc = setError(VBOX_E_OBJECT_NOT_FOUND, tr("No extension pack by the name '%s' was found"), a_pstrExtPack->c_str());
|
---|
3248 | }
|
---|
3249 |
|
---|
3250 | return hrc;
|
---|
3251 | }
|
---|
3252 |
|
---|
3253 | /**
|
---|
3254 | * Gets the full path to the VRDE library of the specified extension pack.
|
---|
3255 | *
|
---|
3256 | * This will do extacly the same as checkVrdeExtPack and then resolve the
|
---|
3257 | * library path.
|
---|
3258 | *
|
---|
3259 | * @returns S_OK if a path is returned, COM error status and message return if
|
---|
3260 | * not.
|
---|
3261 | * @param a_pstrExtPack The extension pack.
|
---|
3262 | * @param a_pstrVrdeLibrary Where to return the path.
|
---|
3263 | */
|
---|
3264 | int ExtPackManager::i_getVrdeLibraryPathForExtPack(Utf8Str const *a_pstrExtPack, Utf8Str *a_pstrVrdeLibrary)
|
---|
3265 | {
|
---|
3266 | AutoCaller autoCaller(this);
|
---|
3267 | HRESULT hrc = autoCaller.rc();
|
---|
3268 | if (SUCCEEDED(hrc))
|
---|
3269 | {
|
---|
3270 | AutoReadLock autoLock(this COMMA_LOCKVAL_SRC_POS);
|
---|
3271 |
|
---|
3272 | ExtPack *pExtPack = i_findExtPack(a_pstrExtPack->c_str());
|
---|
3273 | if (pExtPack)
|
---|
3274 | hrc = pExtPack->i_getVrdpLibraryName(a_pstrVrdeLibrary);
|
---|
3275 | else
|
---|
3276 | hrc = setError(VBOX_E_OBJECT_NOT_FOUND, tr("No extension pack by the name '%s' was found"),
|
---|
3277 | a_pstrExtPack->c_str());
|
---|
3278 | }
|
---|
3279 |
|
---|
3280 | return hrc;
|
---|
3281 | }
|
---|
3282 |
|
---|
3283 | /**
|
---|
3284 | * Gets the full path to the specified library of the specified extension pack.
|
---|
3285 | *
|
---|
3286 | * @returns S_OK if a path is returned, COM error status and message return if
|
---|
3287 | * not.
|
---|
3288 | * @param a_pszModuleName The library.
|
---|
3289 | * @param a_pszExtPack The extension pack.
|
---|
3290 | * @param a_pstrLibrary Where to return the path.
|
---|
3291 | */
|
---|
3292 | HRESULT ExtPackManager::i_getLibraryPathForExtPack(const char *a_pszModuleName, const char *a_pszExtPack, Utf8Str *a_pstrLibrary)
|
---|
3293 | {
|
---|
3294 | AutoCaller autoCaller(this);
|
---|
3295 | HRESULT hrc = autoCaller.rc();
|
---|
3296 | if (SUCCEEDED(hrc))
|
---|
3297 | {
|
---|
3298 | AutoReadLock autoLock(this COMMA_LOCKVAL_SRC_POS);
|
---|
3299 |
|
---|
3300 | ExtPack *pExtPack = i_findExtPack(a_pszExtPack);
|
---|
3301 | if (pExtPack)
|
---|
3302 | hrc = pExtPack->i_getLibraryName(a_pszModuleName, a_pstrLibrary);
|
---|
3303 | else
|
---|
3304 | hrc = setError(VBOX_E_OBJECT_NOT_FOUND, tr("No extension pack by the name '%s' was found"), a_pszExtPack);
|
---|
3305 | }
|
---|
3306 |
|
---|
3307 | return hrc;
|
---|
3308 | }
|
---|
3309 |
|
---|
3310 | /**
|
---|
3311 | * Gets the name of the default VRDE extension pack.
|
---|
3312 | *
|
---|
3313 | * @returns S_OK or some COM error status on red tape failure.
|
---|
3314 | * @param a_pstrExtPack Where to return the extension pack name. Returns
|
---|
3315 | * empty if no extension pack wishes to be the default
|
---|
3316 | * VRDP provider.
|
---|
3317 | */
|
---|
3318 | HRESULT ExtPackManager::i_getDefaultVrdeExtPack(Utf8Str *a_pstrExtPack)
|
---|
3319 | {
|
---|
3320 | a_pstrExtPack->setNull();
|
---|
3321 |
|
---|
3322 | AutoCaller autoCaller(this);
|
---|
3323 | HRESULT hrc = autoCaller.rc();
|
---|
3324 | if (SUCCEEDED(hrc))
|
---|
3325 | {
|
---|
3326 | AutoReadLock autoLock(this COMMA_LOCKVAL_SRC_POS);
|
---|
3327 |
|
---|
3328 | for (ExtPackList::iterator it = m->llInstalledExtPacks.begin();
|
---|
3329 | it != m->llInstalledExtPacks.end();
|
---|
3330 | ++it)
|
---|
3331 | {
|
---|
3332 | if ((*it)->i_wantsToBeDefaultVrde())
|
---|
3333 | {
|
---|
3334 | *a_pstrExtPack = (*it)->m->Desc.strName;
|
---|
3335 | break;
|
---|
3336 | }
|
---|
3337 | }
|
---|
3338 | }
|
---|
3339 | return hrc;
|
---|
3340 | }
|
---|
3341 |
|
---|
3342 | /**
|
---|
3343 | * Checks if an extension pack is (present and) usable.
|
---|
3344 | *
|
---|
3345 | * @returns @c true if it is, otherwise @c false.
|
---|
3346 | * @param a_pszExtPack The name of the extension pack.
|
---|
3347 | */
|
---|
3348 | bool ExtPackManager::i_isExtPackUsable(const char *a_pszExtPack)
|
---|
3349 | {
|
---|
3350 | AutoCaller autoCaller(this);
|
---|
3351 | HRESULT hrc = autoCaller.rc();
|
---|
3352 | if (FAILED(hrc))
|
---|
3353 | return false;
|
---|
3354 | AutoReadLock autoLock(this COMMA_LOCKVAL_SRC_POS);
|
---|
3355 |
|
---|
3356 | ExtPack *pExtPack = i_findExtPack(a_pszExtPack);
|
---|
3357 | return pExtPack != NULL
|
---|
3358 | && pExtPack->m->fUsable;
|
---|
3359 | }
|
---|
3360 |
|
---|
3361 | /**
|
---|
3362 | * Dumps all extension packs to the release log.
|
---|
3363 | */
|
---|
3364 | void ExtPackManager::i_dumpAllToReleaseLog(void)
|
---|
3365 | {
|
---|
3366 | AutoCaller autoCaller(this);
|
---|
3367 | HRESULT hrc = autoCaller.rc();
|
---|
3368 | if (FAILED(hrc))
|
---|
3369 | return;
|
---|
3370 | AutoReadLock autoLock(this COMMA_LOCKVAL_SRC_POS);
|
---|
3371 |
|
---|
3372 | LogRel(("Installed Extension Packs:\n"));
|
---|
3373 | for (ExtPackList::iterator it = m->llInstalledExtPacks.begin();
|
---|
3374 | it != m->llInstalledExtPacks.end();
|
---|
3375 | ++it)
|
---|
3376 | {
|
---|
3377 | ExtPack::Data *pExtPackData = (*it)->m;
|
---|
3378 | if (pExtPackData)
|
---|
3379 | {
|
---|
3380 | if (pExtPackData->fUsable)
|
---|
3381 | LogRel((" %s (Version: %s r%u%s%s; VRDE Module: %s)\n",
|
---|
3382 | pExtPackData->Desc.strName.c_str(),
|
---|
3383 | pExtPackData->Desc.strVersion.c_str(),
|
---|
3384 | pExtPackData->Desc.uRevision,
|
---|
3385 | pExtPackData->Desc.strEdition.isEmpty() ? "" : " ",
|
---|
3386 | pExtPackData->Desc.strEdition.c_str(),
|
---|
3387 | pExtPackData->Desc.strVrdeModule.c_str() ));
|
---|
3388 | else
|
---|
3389 | LogRel((" %s (Version: %s r%u%s%s; VRDE Module: %s unusable because of '%s')\n",
|
---|
3390 | pExtPackData->Desc.strName.c_str(),
|
---|
3391 | pExtPackData->Desc.strVersion.c_str(),
|
---|
3392 | pExtPackData->Desc.uRevision,
|
---|
3393 | pExtPackData->Desc.strEdition.isEmpty() ? "" : " ",
|
---|
3394 | pExtPackData->Desc.strEdition.c_str(),
|
---|
3395 | pExtPackData->Desc.strVrdeModule.c_str(),
|
---|
3396 | pExtPackData->strWhyUnusable.c_str() ));
|
---|
3397 | }
|
---|
3398 | else
|
---|
3399 | LogRel((" pExtPackData is NULL\n"));
|
---|
3400 | }
|
---|
3401 |
|
---|
3402 | if (!m->llInstalledExtPacks.size())
|
---|
3403 | LogRel((" None installed!\n"));
|
---|
3404 | }
|
---|
3405 |
|
---|
3406 | /**
|
---|
3407 | * Gets the update counter (reflecting extpack list updates).
|
---|
3408 | */
|
---|
3409 | uint64_t ExtPackManager::i_getUpdateCounter(void)
|
---|
3410 | {
|
---|
3411 | AutoCaller autoCaller(this);
|
---|
3412 | HRESULT hrc = autoCaller.rc();
|
---|
3413 | if (FAILED(hrc))
|
---|
3414 | return 0;
|
---|
3415 | AutoReadLock autoLock(this COMMA_LOCKVAL_SRC_POS);
|
---|
3416 | return m->cUpdate;
|
---|
3417 | }
|
---|
3418 |
|
---|
3419 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|