summaryrefslogtreecommitdiffstats
path: root/include/VBox/GuestHost/GuestControl.h
blob: 3ecbc0a3d5cc47f62e82d763d62db56eb60c71dd (plain)
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/* $Id: GuestControl.h $ */
/** @file
 * Guest Control - Common Guest and Host Code.
 *
 * @todo r=bird: Just merge this with GuestControlSvc.h!
 */

/*
 * Copyright (C) 2016-2022 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>.
 *
 * The contents of this file may alternatively be used under the terms
 * of the Common Development and Distribution License Version 1.0
 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
 * in the VirtualBox distribution, in which case the provisions of the
 * CDDL are applicable instead of those of the GPL.
 *
 * You may elect to license modified versions of this file under the
 * terms and conditions of either the GPL or the CDDL or both.
 *
 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
 */

#ifndef VBOX_INCLUDED_GuestHost_GuestControl_h
#define VBOX_INCLUDED_GuestHost_GuestControl_h
#ifndef RT_WITHOUT_PRAGMA_ONCE
# pragma once
#endif

#include <iprt/types.h>

/* Everything defined in this file lives in this namespace. */
namespace guestControl {

/**
 * Process status when executed in the guest.
 */
enum eProcessStatus
{
    /** Process is in an undefined state. */
    PROC_STS_UNDEFINED = 0,
    /** Process has been started. */
    PROC_STS_STARTED = 1,
    /** Process terminated normally. */
    PROC_STS_TEN = 2,
    /** Process terminated via signal. */
    PROC_STS_TES = 3,
    /** Process terminated abnormally. */
    PROC_STS_TEA = 4,
    /** Process timed out and was killed. */
    PROC_STS_TOK = 5,
    /** Process timed out and was not killed successfully. */
    PROC_STS_TOA = 6,
    /** Service/OS is stopping, process was killed. */
    PROC_STS_DWN = 7,
    /** Something went wrong (error code in flags). */
    PROC_STS_ERROR = 8
};

/**
 * Input flags, set by the host. This is needed for
 * handling flags on the guest side.
 * Note: Has to match Main's ProcessInputFlag_* flags!
 */
#define GUEST_PROC_IN_FLAG_NONE                     0x0
#define GUEST_PROC_IN_FLAG_EOF                      RT_BIT(0)

/**
 * Guest session creation flags.
 * Only handled internally at the moment.
 */
#define SESSIONCREATIONFLAG_NONE            0x0

/** @name DIRREMOVEREC_FLAG_XXX - Guest directory removement flags.
 * Essentially using what IPRT's RTDIRRMREC_F_
 * defines have to offer.
 * @{
 */
/** No remove flags specified. */
#define DIRREMOVEREC_FLAG_NONE                 UINT32_C(0x0)
/** Recursively deletes the directory contents. */
#define DIRREMOVEREC_FLAG_RECURSIVE            RT_BIT(0)
/** Delete the content of the directory and the directory itself. */
#define DIRREMOVEREC_FLAG_CONTENT_AND_DIR      RT_BIT(1)
/** Only delete the content of the directory, omit the directory it self. */
#define DIRREMOVEREC_FLAG_CONTENT_ONLY         RT_BIT(2)
/** Mask of valid flags. */
#define DIRREMOVEREC_FLAG_VALID_MASK           UINT32_C(0x00000007)
/** @}   */

/** @name GUEST_PROC_CREATE_FLAG_XXX - Guest process creation flags.
 * @note Has to match Main's ProcessCreateFlag_* flags!
 * @{
 */
#define GUEST_PROC_CREATE_FLAG_NONE             UINT32_C(0x0)
#define GUEST_PROC_CREATE_FLAG_WAIT_START       RT_BIT(0)
#define GUEST_PROC_CREATE_FLAG_IGNORE_ORPHANED  RT_BIT(1)
#define GUEST_PROC_CREATE_FLAG_HIDDEN           RT_BIT(2)
#define GUEST_PROC_CREATE_FLAG_PROFILE          RT_BIT(3)
#define GUEST_PROC_CREATE_FLAG_WAIT_STDOUT      RT_BIT(4)
#define GUEST_PROC_CREATE_FLAG_WAIT_STDERR      RT_BIT(5)
#define GUEST_PROC_CREATE_FLAG_EXPAND_ARGUMENTS RT_BIT(6)
#define GUEST_PROC_CREATE_FLAG_UNQUOTED_ARGS    RT_BIT(7)
/** @} */

/** @name GUEST_PROC_OUT_H_XXX - Pipe handle IDs used internally for referencing
 *        to a certain pipe buffer.
 * @{
 */
#define GUEST_PROC_OUT_H_STDOUT_DEPRECATED  0 /**< Needed for VBox hosts < 4.1.0. */
#define GUEST_PROC_OUT_H_STDOUT             1
#define GUEST_PROC_OUT_H_STDERR             2
/** @} */

/** @name PATHRENAME_FLAG_XXX - Guest path rename flags.
 * Essentially using what IPRT's RTPATHRENAME_FLAGS_XXX have to offer.
 * @{
 */
/** Do not replace anything. */
#define PATHRENAME_FLAG_NO_REPLACE          UINT32_C(0)
/** This will replace attempt any target which isn't a directory. */
#define PATHRENAME_FLAG_REPLACE             RT_BIT(0)
/** Don't allow symbolic links as part of the path. */
#define PATHRENAME_FLAG_NO_SYMLINKS         RT_BIT(1)
/** Mask of valid flags. */
#define PATHRENAME_FLAG_VALID_MASK          UINT32_C(0x00000003)
/** @} */

/** @name GUEST_SHUTDOWN_FLAG_XXX - Guest shutdown flags.
 * Must match Main's GuestShutdownFlag_ definitions.
 * @{
 */
#define GUEST_SHUTDOWN_FLAG_NONE            UINT32_C(0)
#define GUEST_SHUTDOWN_FLAG_POWER_OFF       RT_BIT(0)
#define GUEST_SHUTDOWN_FLAG_REBOOT          RT_BIT(1)
#define GUEST_SHUTDOWN_FLAG_FORCE           RT_BIT(2)
/** @} */

/** @name Defines for default (initial) guest process buffer lengths.
 * Note: These defaults were the maximum values before; so be careful when raising those in order to
 *       not break running with older Guest Additions.
 * @{
 */
#define GUEST_PROC_DEF_CMD_LEN        _1K
#define GUEST_PROC_DEF_ARGS_LEN       _1K
#define GUEST_PROC_DEF_ENV_LEN        _1K
#define GUEST_PROC_DEF_USER_LEN       128
#define GUEST_PROC_DEF_PASSWORD_LEN   128
#define GUEST_PROC_DEF_DOMAIN_LEN     256
/** @} */

/** @name Defines for maximum guest process buffer lengths.
 * @{
 */
#define GUEST_PROC_MAX_CMD_LEN            _1M
#define GUEST_PROC_MAX_ARGS_LEN           _2M
#define GUEST_PROC_MAX_ENV_LEN            _4M
#define GUEST_PROC_MAX_USER_LEN           _64K
#define GUEST_PROC_MAX_PASSWORD_LEN       _64K
#define GUEST_PROC_MAX_DOMAIN_LEN         _64K
/** @} */

/** @name Internal tools built into VBoxService which are used in order
 *        to accomplish tasks host<->guest.
 * @{
 */
#define VBOXSERVICE_TOOL_CAT        "vbox_cat"
#define VBOXSERVICE_TOOL_LS         "vbox_ls"
#define VBOXSERVICE_TOOL_RM         "vbox_rm"
#define VBOXSERVICE_TOOL_MKDIR      "vbox_mkdir"
#define VBOXSERVICE_TOOL_MKTEMP     "vbox_mktemp"
#define VBOXSERVICE_TOOL_STAT       "vbox_stat"
/** @} */

/** Special process exit codes for "vbox_cat". */
typedef enum VBOXSERVICETOOLBOX_CAT_EXITCODE
{
    VBOXSERVICETOOLBOX_CAT_EXITCODE_ACCESS_DENIED = RTEXITCODE_END,
    VBOXSERVICETOOLBOX_CAT_EXITCODE_FILE_NOT_FOUND,
    VBOXSERVICETOOLBOX_CAT_EXITCODE_PATH_NOT_FOUND,
    VBOXSERVICETOOLBOX_CAT_EXITCODE_SHARING_VIOLATION,
    VBOXSERVICETOOLBOX_CAT_EXITCODE_IS_A_DIRECTORY,
    /** The usual 32-bit type hack. */
    VBOXSERVICETOOLBOX_CAT_32BIT_HACK = 0x7fffffff
} VBOXSERVICETOOLBOX_CAT_EXITCODE;

/** Special process exit codes for "vbox_stat". */
typedef enum VBOXSERVICETOOLBOX_STAT_EXITCODE
{
    VBOXSERVICETOOLBOX_STAT_EXITCODE_ACCESS_DENIED = RTEXITCODE_END,
    VBOXSERVICETOOLBOX_STAT_EXITCODE_FILE_NOT_FOUND,
    VBOXSERVICETOOLBOX_STAT_EXITCODE_PATH_NOT_FOUND,
    VBOXSERVICETOOLBOX_STAT_EXITCODE_NET_PATH_NOT_FOUND,
    VBOXSERVICETOOLBOX_STAT_EXITCODE_INVALID_NAME,
    /** The usual 32-bit type hack. */
    VBOXSERVICETOOLBOX_STAT_32BIT_HACK = 0x7fffffff
} VBOXSERVICETOOLBOX_STAT_EXITCODE;

/**
 * Input status, reported by the client.
 */
enum eInputStatus
{
    /** Input is in an undefined state. */
    INPUT_STS_UNDEFINED = 0,
    /** Input was written (partially, see cbProcessed). */
    INPUT_STS_WRITTEN = 1,
    /** Input failed with an error (see flags for rc). */
    INPUT_STS_ERROR = 20,
    /** Process has abandoned / terminated input handling. */
    INPUT_STS_TERMINATED = 21,
    /** Too much input data. */
    INPUT_STS_OVERFLOW = 30
};



} /* namespace guestControl */

#endif /* !VBOX_INCLUDED_GuestHost_GuestControl_h */