1 | /* $Id: GuestControl.h 96407 2022-08-22 17:43:14Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Guest Control - Common Guest and Host Code.
|
---|
4 | *
|
---|
5 | * @todo r=bird: Just merge this with GuestControlSvc.h!
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2016-2022 Oracle and/or its affiliates.
|
---|
10 | *
|
---|
11 | * This file is part of VirtualBox base platform packages, as
|
---|
12 | * available from https://www.virtualbox.org.
|
---|
13 | *
|
---|
14 | * This program is free software; you can redistribute it and/or
|
---|
15 | * modify it under the terms of the GNU General Public License
|
---|
16 | * as published by the Free Software Foundation, in version 3 of the
|
---|
17 | * License.
|
---|
18 | *
|
---|
19 | * This program is distributed in the hope that it will be useful, but
|
---|
20 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
22 | * General Public License for more details.
|
---|
23 | *
|
---|
24 | * You should have received a copy of the GNU General Public License
|
---|
25 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
26 | *
|
---|
27 | * The contents of this file may alternatively be used under the terms
|
---|
28 | * of the Common Development and Distribution License Version 1.0
|
---|
29 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
30 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
31 | * CDDL are applicable instead of those of the GPL.
|
---|
32 | *
|
---|
33 | * You may elect to license modified versions of this file under the
|
---|
34 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
35 | *
|
---|
36 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
37 | */
|
---|
38 |
|
---|
39 | #ifndef VBOX_INCLUDED_GuestHost_GuestControl_h
|
---|
40 | #define VBOX_INCLUDED_GuestHost_GuestControl_h
|
---|
41 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
42 | # pragma once
|
---|
43 | #endif
|
---|
44 |
|
---|
45 | #include <iprt/types.h>
|
---|
46 |
|
---|
47 | /* Everything defined in this file lives in this namespace. */
|
---|
48 | namespace guestControl {
|
---|
49 |
|
---|
50 | /**
|
---|
51 | * Process status when executed in the guest.
|
---|
52 | */
|
---|
53 | enum eProcessStatus
|
---|
54 | {
|
---|
55 | /** Process is in an undefined state. */
|
---|
56 | PROC_STS_UNDEFINED = 0,
|
---|
57 | /** Process has been started. */
|
---|
58 | PROC_STS_STARTED = 1,
|
---|
59 | /** Process terminated normally. */
|
---|
60 | PROC_STS_TEN = 2,
|
---|
61 | /** Process terminated via signal. */
|
---|
62 | PROC_STS_TES = 3,
|
---|
63 | /** Process terminated abnormally. */
|
---|
64 | PROC_STS_TEA = 4,
|
---|
65 | /** Process timed out and was killed. */
|
---|
66 | PROC_STS_TOK = 5,
|
---|
67 | /** Process timed out and was not killed successfully. */
|
---|
68 | PROC_STS_TOA = 6,
|
---|
69 | /** Service/OS is stopping, process was killed. */
|
---|
70 | PROC_STS_DWN = 7,
|
---|
71 | /** Something went wrong (error code in flags). */
|
---|
72 | PROC_STS_ERROR = 8
|
---|
73 | };
|
---|
74 |
|
---|
75 | /**
|
---|
76 | * Input flags, set by the host. This is needed for
|
---|
77 | * handling flags on the guest side.
|
---|
78 | * Note: Has to match Main's ProcessInputFlag_* flags!
|
---|
79 | */
|
---|
80 | #define GUEST_PROC_IN_FLAG_NONE 0x0
|
---|
81 | #define GUEST_PROC_IN_FLAG_EOF RT_BIT(0)
|
---|
82 |
|
---|
83 | /**
|
---|
84 | * Guest session creation flags.
|
---|
85 | * Only handled internally at the moment.
|
---|
86 | */
|
---|
87 | #define SESSIONCREATIONFLAG_NONE 0x0
|
---|
88 |
|
---|
89 | /** @name DIRREMOVEREC_FLAG_XXX - Guest directory removement flags.
|
---|
90 | * Essentially using what IPRT's RTDIRRMREC_F_
|
---|
91 | * defines have to offer.
|
---|
92 | * @{
|
---|
93 | */
|
---|
94 | /** No remove flags specified. */
|
---|
95 | #define DIRREMOVEREC_FLAG_NONE UINT32_C(0x0)
|
---|
96 | /** Recursively deletes the directory contents. */
|
---|
97 | #define DIRREMOVEREC_FLAG_RECURSIVE RT_BIT(0)
|
---|
98 | /** Delete the content of the directory and the directory itself. */
|
---|
99 | #define DIRREMOVEREC_FLAG_CONTENT_AND_DIR RT_BIT(1)
|
---|
100 | /** Only delete the content of the directory, omit the directory it self. */
|
---|
101 | #define DIRREMOVEREC_FLAG_CONTENT_ONLY RT_BIT(2)
|
---|
102 | /** Mask of valid flags. */
|
---|
103 | #define DIRREMOVEREC_FLAG_VALID_MASK UINT32_C(0x00000007)
|
---|
104 | /** @} */
|
---|
105 |
|
---|
106 | /** @name GUEST_PROC_CREATE_FLAG_XXX - Guest process creation flags.
|
---|
107 | * @note Has to match Main's ProcessCreateFlag_* flags!
|
---|
108 | * @{
|
---|
109 | */
|
---|
110 | #define GUEST_PROC_CREATE_FLAG_NONE UINT32_C(0x0)
|
---|
111 | #define GUEST_PROC_CREATE_FLAG_WAIT_START RT_BIT(0)
|
---|
112 | #define GUEST_PROC_CREATE_FLAG_IGNORE_ORPHANED RT_BIT(1)
|
---|
113 | #define GUEST_PROC_CREATE_FLAG_HIDDEN RT_BIT(2)
|
---|
114 | #define GUEST_PROC_CREATE_FLAG_PROFILE RT_BIT(3)
|
---|
115 | #define GUEST_PROC_CREATE_FLAG_WAIT_STDOUT RT_BIT(4)
|
---|
116 | #define GUEST_PROC_CREATE_FLAG_WAIT_STDERR RT_BIT(5)
|
---|
117 | #define GUEST_PROC_CREATE_FLAG_EXPAND_ARGUMENTS RT_BIT(6)
|
---|
118 | #define GUEST_PROC_CREATE_FLAG_UNQUOTED_ARGS RT_BIT(7)
|
---|
119 | /** @} */
|
---|
120 |
|
---|
121 | /** @name GUEST_PROC_OUT_H_XXX - Pipe handle IDs used internally for referencing
|
---|
122 | * to a certain pipe buffer.
|
---|
123 | * @{
|
---|
124 | */
|
---|
125 | #define GUEST_PROC_OUT_H_STDOUT_DEPRECATED 0 /**< Needed for VBox hosts < 4.1.0. */
|
---|
126 | #define GUEST_PROC_OUT_H_STDOUT 1
|
---|
127 | #define GUEST_PROC_OUT_H_STDERR 2
|
---|
128 | /** @} */
|
---|
129 |
|
---|
130 | /** @name PATHRENAME_FLAG_XXX - Guest path rename flags.
|
---|
131 | * Essentially using what IPRT's RTPATHRENAME_FLAGS_XXX have to offer.
|
---|
132 | * @{
|
---|
133 | */
|
---|
134 | /** Do not replace anything. */
|
---|
135 | #define PATHRENAME_FLAG_NO_REPLACE UINT32_C(0)
|
---|
136 | /** This will replace attempt any target which isn't a directory. */
|
---|
137 | #define PATHRENAME_FLAG_REPLACE RT_BIT(0)
|
---|
138 | /** Don't allow symbolic links as part of the path. */
|
---|
139 | #define PATHRENAME_FLAG_NO_SYMLINKS RT_BIT(1)
|
---|
140 | /** Mask of valid flags. */
|
---|
141 | #define PATHRENAME_FLAG_VALID_MASK UINT32_C(0x00000003)
|
---|
142 | /** @} */
|
---|
143 |
|
---|
144 | /** @name GUEST_SHUTDOWN_FLAG_XXX - Guest shutdown flags.
|
---|
145 | * Must match Main's GuestShutdownFlag_ definitions.
|
---|
146 | * @{
|
---|
147 | */
|
---|
148 | #define GUEST_SHUTDOWN_FLAG_NONE UINT32_C(0)
|
---|
149 | #define GUEST_SHUTDOWN_FLAG_POWER_OFF RT_BIT(0)
|
---|
150 | #define GUEST_SHUTDOWN_FLAG_REBOOT RT_BIT(1)
|
---|
151 | #define GUEST_SHUTDOWN_FLAG_FORCE RT_BIT(2)
|
---|
152 | /** @} */
|
---|
153 |
|
---|
154 | /** @name Defines for default (initial) guest process buffer lengths.
|
---|
155 | * Note: These defaults were the maximum values before; so be careful when raising those in order to
|
---|
156 | * not break running with older Guest Additions.
|
---|
157 | * @{
|
---|
158 | */
|
---|
159 | #define GUEST_PROC_DEF_CMD_LEN _1K
|
---|
160 | #define GUEST_PROC_DEF_ARGS_LEN _1K
|
---|
161 | #define GUEST_PROC_DEF_ENV_LEN _1K
|
---|
162 | #define GUEST_PROC_DEF_USER_LEN 128
|
---|
163 | #define GUEST_PROC_DEF_PASSWORD_LEN 128
|
---|
164 | #define GUEST_PROC_DEF_DOMAIN_LEN 256
|
---|
165 | /** @} */
|
---|
166 |
|
---|
167 | /** @name Defines for maximum guest process buffer lengths.
|
---|
168 | * @{
|
---|
169 | */
|
---|
170 | #define GUEST_PROC_MAX_CMD_LEN _1M
|
---|
171 | #define GUEST_PROC_MAX_ARGS_LEN _2M
|
---|
172 | #define GUEST_PROC_MAX_ENV_LEN _4M
|
---|
173 | #define GUEST_PROC_MAX_USER_LEN _64K
|
---|
174 | #define GUEST_PROC_MAX_PASSWORD_LEN _64K
|
---|
175 | #define GUEST_PROC_MAX_DOMAIN_LEN _64K
|
---|
176 | /** @} */
|
---|
177 |
|
---|
178 | /** @name Internal tools built into VBoxService which are used in order
|
---|
179 | * to accomplish tasks host<->guest.
|
---|
180 | * @{
|
---|
181 | */
|
---|
182 | #define VBOXSERVICE_TOOL_CAT "vbox_cat"
|
---|
183 | #define VBOXSERVICE_TOOL_LS "vbox_ls"
|
---|
184 | #define VBOXSERVICE_TOOL_RM "vbox_rm"
|
---|
185 | #define VBOXSERVICE_TOOL_MKDIR "vbox_mkdir"
|
---|
186 | #define VBOXSERVICE_TOOL_MKTEMP "vbox_mktemp"
|
---|
187 | #define VBOXSERVICE_TOOL_STAT "vbox_stat"
|
---|
188 | /** @} */
|
---|
189 |
|
---|
190 | /** Special process exit codes for "vbox_cat". */
|
---|
191 | typedef enum VBOXSERVICETOOLBOX_CAT_EXITCODE
|
---|
192 | {
|
---|
193 | VBOXSERVICETOOLBOX_CAT_EXITCODE_ACCESS_DENIED = RTEXITCODE_END,
|
---|
194 | VBOXSERVICETOOLBOX_CAT_EXITCODE_FILE_NOT_FOUND,
|
---|
195 | VBOXSERVICETOOLBOX_CAT_EXITCODE_PATH_NOT_FOUND,
|
---|
196 | VBOXSERVICETOOLBOX_CAT_EXITCODE_SHARING_VIOLATION,
|
---|
197 | VBOXSERVICETOOLBOX_CAT_EXITCODE_IS_A_DIRECTORY,
|
---|
198 | /** The usual 32-bit type hack. */
|
---|
199 | VBOXSERVICETOOLBOX_CAT_32BIT_HACK = 0x7fffffff
|
---|
200 | } VBOXSERVICETOOLBOX_CAT_EXITCODE;
|
---|
201 |
|
---|
202 | /** Special process exit codes for "vbox_stat". */
|
---|
203 | typedef enum VBOXSERVICETOOLBOX_STAT_EXITCODE
|
---|
204 | {
|
---|
205 | VBOXSERVICETOOLBOX_STAT_EXITCODE_ACCESS_DENIED = RTEXITCODE_END,
|
---|
206 | VBOXSERVICETOOLBOX_STAT_EXITCODE_FILE_NOT_FOUND,
|
---|
207 | VBOXSERVICETOOLBOX_STAT_EXITCODE_PATH_NOT_FOUND,
|
---|
208 | VBOXSERVICETOOLBOX_STAT_EXITCODE_NET_PATH_NOT_FOUND,
|
---|
209 | VBOXSERVICETOOLBOX_STAT_EXITCODE_INVALID_NAME,
|
---|
210 | /** The usual 32-bit type hack. */
|
---|
211 | VBOXSERVICETOOLBOX_STAT_32BIT_HACK = 0x7fffffff
|
---|
212 | } VBOXSERVICETOOLBOX_STAT_EXITCODE;
|
---|
213 |
|
---|
214 | /**
|
---|
215 | * Input status, reported by the client.
|
---|
216 | */
|
---|
217 | enum eInputStatus
|
---|
218 | {
|
---|
219 | /** Input is in an undefined state. */
|
---|
220 | INPUT_STS_UNDEFINED = 0,
|
---|
221 | /** Input was written (partially, see cbProcessed). */
|
---|
222 | INPUT_STS_WRITTEN = 1,
|
---|
223 | /** Input failed with an error (see flags for rc). */
|
---|
224 | INPUT_STS_ERROR = 20,
|
---|
225 | /** Process has abandoned / terminated input handling. */
|
---|
226 | INPUT_STS_TERMINATED = 21,
|
---|
227 | /** Too much input data. */
|
---|
228 | INPUT_STS_OVERFLOW = 30
|
---|
229 | };
|
---|
230 |
|
---|
231 |
|
---|
232 |
|
---|
233 | } /* namespace guestControl */
|
---|
234 |
|
---|
235 | #endif /* !VBOX_INCLUDED_GuestHost_GuestControl_h */
|
---|
236 |
|
---|