1 | /* $Id: ExtPackUtil.h 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox Main - Extension Pack Utilities and definitions, VBoxC, VBoxSVC, ++.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2010-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef MAIN_INCLUDED_ExtPackUtil_h
|
---|
29 | #define MAIN_INCLUDED_ExtPackUtil_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | #ifdef __cplusplus
|
---|
35 | # include <iprt/cpp/ministring.h>
|
---|
36 | #endif
|
---|
37 | #include <iprt/fs.h>
|
---|
38 | #include <iprt/vfs.h>
|
---|
39 |
|
---|
40 |
|
---|
41 | /** @name VBOX_EXTPACK_DESCRIPTION_NAME
|
---|
42 | * The name of the description file in an extension pack. */
|
---|
43 | #define VBOX_EXTPACK_DESCRIPTION_NAME "ExtPack.xml"
|
---|
44 | /** @name VBOX_EXTPACK_DESCRIPTION_NAME
|
---|
45 | * The name of the manifest file in an extension pack. */
|
---|
46 | #define VBOX_EXTPACK_MANIFEST_NAME "ExtPack.manifest"
|
---|
47 | /** @name VBOX_EXTPACK_SIGNATURE_NAME
|
---|
48 | * The name of the signature file in an extension pack. */
|
---|
49 | #define VBOX_EXTPACK_SIGNATURE_NAME "ExtPack.signature"
|
---|
50 | /** @name VBOX_EXTPACK_LICENSE_NAME_PREFIX
|
---|
51 | * The name prefix of a license file in an extension pack. There can be
|
---|
52 | * several license files in a pack, the variations being on locale, language
|
---|
53 | * and format (HTML, RTF, plain text). All extension packages shall include
|
---|
54 | * a */
|
---|
55 | #define VBOX_EXTPACK_LICENSE_NAME_PREFIX "ExtPack-license"
|
---|
56 | /** @name VBOX_EXTPACK_SUFFIX
|
---|
57 | * The suffix of a extension pack tarball. */
|
---|
58 | #define VBOX_EXTPACK_SUFFIX ".vbox-extpack"
|
---|
59 |
|
---|
60 | /** The minimum length (strlen) of a extension pack name. */
|
---|
61 | #define VBOX_EXTPACK_NAME_MIN_LEN 3
|
---|
62 | /** The max length (strlen) of a extension pack name. */
|
---|
63 | #define VBOX_EXTPACK_NAME_MAX_LEN 64
|
---|
64 |
|
---|
65 | /** The architecture-dependent application data subdirectory where the
|
---|
66 | * extension packs are installed. Relative to RTPathAppPrivateArch. */
|
---|
67 | #define VBOX_EXTPACK_INSTALL_DIR "ExtensionPacks"
|
---|
68 | /** The architecture-independent application data subdirectory where the
|
---|
69 | * certificates are installed. Relative to RTPathAppPrivateNoArch. */
|
---|
70 | #define VBOX_EXTPACK_CERT_DIR "ExtPackCertificates"
|
---|
71 |
|
---|
72 | /** The maximum entry name length.
|
---|
73 | * Play short and safe. */
|
---|
74 | #define VBOX_EXTPACK_MAX_MEMBER_NAME_LENGTH 128
|
---|
75 |
|
---|
76 |
|
---|
77 | #ifdef __cplusplus
|
---|
78 |
|
---|
79 | /**
|
---|
80 | * Plug-in descriptor.
|
---|
81 | */
|
---|
82 | typedef struct VBOXEXTPACKPLUGINDESC
|
---|
83 | {
|
---|
84 | /** The name. */
|
---|
85 | RTCString strName;
|
---|
86 | /** The module name. */
|
---|
87 | RTCString strModule;
|
---|
88 | /** The description. */
|
---|
89 | RTCString strDescription;
|
---|
90 | /** The frontend or component which it plugs into. */
|
---|
91 | RTCString strFrontend;
|
---|
92 | } VBOXEXTPACKPLUGINDESC;
|
---|
93 | /** Pointer to a plug-in descriptor. */
|
---|
94 | typedef VBOXEXTPACKPLUGINDESC *PVBOXEXTPACKPLUGINDESC;
|
---|
95 |
|
---|
96 | /**
|
---|
97 | * Extension pack descriptor
|
---|
98 | *
|
---|
99 | * This is the internal representation of the ExtPack.xml.
|
---|
100 | */
|
---|
101 | typedef struct VBOXEXTPACKDESC
|
---|
102 | {
|
---|
103 | /** The name. */
|
---|
104 | RTCString strName;
|
---|
105 | /** The description. */
|
---|
106 | RTCString strDescription;
|
---|
107 | /** The version string. */
|
---|
108 | RTCString strVersion;
|
---|
109 | /** The edition string. */
|
---|
110 | RTCString strEdition;
|
---|
111 | /** The internal revision number. */
|
---|
112 | uint32_t uRevision;
|
---|
113 | /** The name of the main module. */
|
---|
114 | RTCString strMainModule;
|
---|
115 | /** The name of the main VM module, empty if none. */
|
---|
116 | RTCString strMainVMModule;
|
---|
117 | /** The name of the VRDE module, empty if none. */
|
---|
118 | RTCString strVrdeModule;
|
---|
119 | /** The name of the cryptographic module, empty if none. */
|
---|
120 | RTCString strCryptoModule;
|
---|
121 | /** The number of plug-in descriptors. */
|
---|
122 | uint32_t cPlugIns;
|
---|
123 | /** Pointer to an array of plug-in descriptors. */
|
---|
124 | PVBOXEXTPACKPLUGINDESC paPlugIns;
|
---|
125 | /** Whether to show the license prior to installation. */
|
---|
126 | bool fShowLicense;
|
---|
127 | } VBOXEXTPACKDESC;
|
---|
128 |
|
---|
129 | /** Pointer to a extension pack descriptor. */
|
---|
130 | typedef VBOXEXTPACKDESC *PVBOXEXTPACKDESC;
|
---|
131 | /** Pointer to a const extension pack descriptor. */
|
---|
132 | typedef VBOXEXTPACKDESC const *PCVBOXEXTPACKDESC;
|
---|
133 |
|
---|
134 |
|
---|
135 | void VBoxExtPackInitDesc(PVBOXEXTPACKDESC a_pExtPackDesc);
|
---|
136 | RTCString *VBoxExtPackLoadDesc(const char *a_pszDir, PVBOXEXTPACKDESC a_pExtPackDesc, PRTFSOBJINFO a_pObjInfo);
|
---|
137 | RTCString *VBoxExtPackLoadDescFromVfsFile(RTVFSFILE hVfsFile, PVBOXEXTPACKDESC a_pExtPackDesc, PRTFSOBJINFO a_pObjInfo);
|
---|
138 | RTCString *VBoxExtPackExtractNameFromTarballPath(const char *pszTarball);
|
---|
139 | void VBoxExtPackFreeDesc(PVBOXEXTPACKDESC a_pExtPackDesc);
|
---|
140 | bool VBoxExtPackIsValidName(const char *pszName);
|
---|
141 | bool VBoxExtPackIsValidMangledName(const char *pszMangledName, size_t cchMax = RTSTR_MAX);
|
---|
142 | RTCString *VBoxExtPackMangleName(const char *pszName);
|
---|
143 | RTCString *VBoxExtPackUnmangleName(const char *pszMangledName, size_t cbMax);
|
---|
144 | int VBoxExtPackCalcDir(char *pszExtPackDir, size_t cbExtPackDir, const char *pszParentDir, const char *pszName);
|
---|
145 | bool VBoxExtPackIsValidVersionString(const char *pszVersion);
|
---|
146 | bool VBoxExtPackIsValidEditionString(const char *pszEdition);
|
---|
147 | bool VBoxExtPackIsValidModuleString(const char *pszModule);
|
---|
148 |
|
---|
149 | int VBoxExtPackValidateMember(const char *pszName, RTVFSOBJTYPE enmType, RTVFSOBJ hVfsObj, char *pszError, size_t cbError);
|
---|
150 | int VBoxExtPackOpenTarFss(RTFILE hTarballFile, char *pszError, size_t cbError, PRTVFSFSSTREAM phTarFss, PRTMANIFEST phFileManifest);
|
---|
151 | int VBoxExtPackValidateTarball(RTFILE hTarballFile, const char *pszExtPackName,
|
---|
152 | const char *pszTarball, const char *pszTarballDigest,
|
---|
153 | char *pszError, size_t cbError,
|
---|
154 | PRTMANIFEST phValidManifest, PRTVFSFILE phXmlFile, RTCString *pStrDigest);
|
---|
155 | #endif /* __cplusplus */
|
---|
156 |
|
---|
157 | #endif /* !MAIN_INCLUDED_ExtPackUtil_h */
|
---|
158 |
|
---|