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