1 | /* $Id: VBoxServiceVMInfo.cpp 55024 2015-03-31 10:35:51Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxService - Virtual Machine Information for the Host.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2009-2013 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 | /*******************************************************************************
|
---|
21 | * Header Files *
|
---|
22 | *******************************************************************************/
|
---|
23 | #ifdef RT_OS_WINDOWS
|
---|
24 | # ifdef TARGET_NT4 /* HACK ALERT! PMIB_IPSTATS undefined if 0x0400 with newer SDKs. */
|
---|
25 | # undef _WIN32_WINNT
|
---|
26 | # define _WIN32_WINNT 0x0500
|
---|
27 | # endif
|
---|
28 | # include <winsock2.h>
|
---|
29 | # include <iphlpapi.h>
|
---|
30 | # include <ws2tcpip.h>
|
---|
31 | # include <windows.h>
|
---|
32 | # include <Ntsecapi.h>
|
---|
33 | #else
|
---|
34 | # define __STDC_LIMIT_MACROS
|
---|
35 | # include <arpa/inet.h>
|
---|
36 | # include <errno.h>
|
---|
37 | # include <netinet/in.h>
|
---|
38 | # include <sys/ioctl.h>
|
---|
39 | # include <sys/socket.h>
|
---|
40 | # include <net/if.h>
|
---|
41 | # include <pwd.h> /* getpwuid */
|
---|
42 | # include <unistd.h>
|
---|
43 | # if !defined(RT_OS_OS2) && !defined(RT_OS_FREEBSD) && !defined(RT_OS_HAIKU)
|
---|
44 | # include <utmpx.h> /* @todo FreeBSD 9 should have this. */
|
---|
45 | # endif
|
---|
46 | # ifdef RT_OS_OS2
|
---|
47 | # include <net/if_dl.h>
|
---|
48 | # endif
|
---|
49 | # ifdef RT_OS_SOLARIS
|
---|
50 | # include <sys/sockio.h>
|
---|
51 | # include <net/if_arp.h>
|
---|
52 | # endif
|
---|
53 | # if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
|
---|
54 | # include <ifaddrs.h> /* getifaddrs, freeifaddrs */
|
---|
55 | # include <net/if_dl.h> /* LLADDR */
|
---|
56 | # include <netdb.h> /* getnameinfo */
|
---|
57 | # endif
|
---|
58 | # ifdef VBOX_WITH_DBUS
|
---|
59 | # include <VBox/dbus.h>
|
---|
60 | # endif
|
---|
61 | #endif
|
---|
62 |
|
---|
63 | #include <iprt/mem.h>
|
---|
64 | #include <iprt/thread.h>
|
---|
65 | #include <iprt/string.h>
|
---|
66 | #include <iprt/semaphore.h>
|
---|
67 | #include <iprt/system.h>
|
---|
68 | #include <iprt/time.h>
|
---|
69 | #include <iprt/assert.h>
|
---|
70 | #include <VBox/version.h>
|
---|
71 | #include <VBox/VBoxGuestLib.h>
|
---|
72 | #include "VBoxServiceInternal.h"
|
---|
73 | #include "VBoxServiceUtils.h"
|
---|
74 | #include "VBoxServicePropCache.h"
|
---|
75 |
|
---|
76 |
|
---|
77 | /** Structure containing information about a location awarness
|
---|
78 | * client provided by the host. */
|
---|
79 | /** @todo Move this (and functions) into VbglR3. */
|
---|
80 | typedef struct VBOXSERVICELACLIENTINFO
|
---|
81 | {
|
---|
82 | uint32_t uID;
|
---|
83 | char *pszName;
|
---|
84 | char *pszLocation;
|
---|
85 | char *pszDomain;
|
---|
86 | bool fAttached;
|
---|
87 | uint64_t uAttachedTS;
|
---|
88 | } VBOXSERVICELACLIENTINFO, *PVBOXSERVICELACLIENTINFO;
|
---|
89 |
|
---|
90 |
|
---|
91 | /*******************************************************************************
|
---|
92 | * Global Variables *
|
---|
93 | *******************************************************************************/
|
---|
94 | /** The vminfo interval (milliseconds). */
|
---|
95 | static uint32_t g_cMsVMInfoInterval = 0;
|
---|
96 | /** The semaphore we're blocking on. */
|
---|
97 | static RTSEMEVENTMULTI g_hVMInfoEvent = NIL_RTSEMEVENTMULTI;
|
---|
98 | /** The guest property service client ID. */
|
---|
99 | static uint32_t g_uVMInfoGuestPropSvcClientID = 0;
|
---|
100 | /** Number of currently logged in users in OS. */
|
---|
101 | static uint32_t g_cVMInfoLoggedInUsers = 0;
|
---|
102 | /** The guest property cache. */
|
---|
103 | static VBOXSERVICEVEPROPCACHE g_VMInfoPropCache;
|
---|
104 | static const char *g_pszPropCacheValLoggedInUsersList = "/VirtualBox/GuestInfo/OS/LoggedInUsersList";
|
---|
105 | static const char *g_pszPropCacheValLoggedInUsers = "/VirtualBox/GuestInfo/OS/LoggedInUsers";
|
---|
106 | static const char *g_pszPropCacheValNoLoggedInUsers = "/VirtualBox/GuestInfo/OS/NoLoggedInUsers";
|
---|
107 | static const char *g_pszPropCacheValNetCount = "/VirtualBox/GuestInfo/Net/Count";
|
---|
108 | /** A guest user's guest property root key. */
|
---|
109 | static const char *g_pszPropCacheValUser = "/VirtualBox/GuestInfo/User/";
|
---|
110 | /** The VM session ID. Changes whenever the VM is restored or reset. */
|
---|
111 | static uint64_t g_idVMInfoSession;
|
---|
112 | /** The last attached locartion awareness (LA) client timestamp. */
|
---|
113 | static uint64_t g_LAClientAttachedTS = 0;
|
---|
114 | /** The current LA client info. */
|
---|
115 | static VBOXSERVICELACLIENTINFO g_LAClientInfo;
|
---|
116 | /** User idle threshold (in ms). This specifies the minimum time a user is considered
|
---|
117 | * as being idle and then will be reported to the host. Default is 5s. */
|
---|
118 | uint32_t g_uVMInfoUserIdleThresholdMS = 5 * 1000;
|
---|
119 |
|
---|
120 |
|
---|
121 | /*******************************************************************************
|
---|
122 | * Defines *
|
---|
123 | *******************************************************************************/
|
---|
124 | static const char *g_pszLAActiveClient = "/VirtualBox/HostInfo/VRDP/ActiveClient";
|
---|
125 |
|
---|
126 | #ifdef VBOX_WITH_DBUS
|
---|
127 | /** ConsoleKit defines (taken from 0.4.5). */
|
---|
128 | #define CK_NAME "org.freedesktop.ConsoleKit"
|
---|
129 | #define CK_PATH "/org/freedesktop/ConsoleKit"
|
---|
130 | #define CK_INTERFACE "org.freedesktop.ConsoleKit"
|
---|
131 |
|
---|
132 | #define CK_MANAGER_PATH "/org/freedesktop/ConsoleKit/Manager"
|
---|
133 | #define CK_MANAGER_INTERFACE "org.freedesktop.ConsoleKit.Manager"
|
---|
134 | #define CK_SEAT_INTERFACE "org.freedesktop.ConsoleKit.Seat"
|
---|
135 | #define CK_SESSION_INTERFACE "org.freedesktop.ConsoleKit.Session"
|
---|
136 | #endif
|
---|
137 |
|
---|
138 |
|
---|
139 |
|
---|
140 | /**
|
---|
141 | * Signals the event so that a re-enumeration of VM-specific
|
---|
142 | * information (like logged in users) can happen.
|
---|
143 | *
|
---|
144 | * @return IPRT status code.
|
---|
145 | */
|
---|
146 | int VBoxServiceVMInfoSignal(void)
|
---|
147 | {
|
---|
148 | /* Trigger a re-enumeration of all logged-in users by unblocking
|
---|
149 | * the multi event semaphore of the VMInfo thread. */
|
---|
150 | if (g_hVMInfoEvent)
|
---|
151 | return RTSemEventMultiSignal(g_hVMInfoEvent);
|
---|
152 |
|
---|
153 | return VINF_SUCCESS;
|
---|
154 | }
|
---|
155 |
|
---|
156 |
|
---|
157 | /** @copydoc VBOXSERVICE::pfnPreInit */
|
---|
158 | static DECLCALLBACK(int) VBoxServiceVMInfoPreInit(void)
|
---|
159 | {
|
---|
160 | return VINF_SUCCESS;
|
---|
161 | }
|
---|
162 |
|
---|
163 |
|
---|
164 | /** @copydoc VBOXSERVICE::pfnOption */
|
---|
165 | static DECLCALLBACK(int) VBoxServiceVMInfoOption(const char **ppszShort, int argc, char **argv, int *pi)
|
---|
166 | {
|
---|
167 | /** @todo Use RTGetOpt here. */
|
---|
168 |
|
---|
169 | int rc = -1;
|
---|
170 | if (ppszShort)
|
---|
171 | /* no short options */;
|
---|
172 | else if (!strcmp(argv[*pi], "--vminfo-interval"))
|
---|
173 | rc = VBoxServiceArgUInt32(argc, argv, "", pi,
|
---|
174 | &g_cMsVMInfoInterval, 1, UINT32_MAX - 1);
|
---|
175 | else if (!strcmp(argv[*pi], "--vminfo-user-idle-threshold"))
|
---|
176 | rc = VBoxServiceArgUInt32(argc, argv, "", pi,
|
---|
177 | &g_uVMInfoUserIdleThresholdMS, 1, UINT32_MAX - 1);
|
---|
178 | return rc;
|
---|
179 | }
|
---|
180 |
|
---|
181 |
|
---|
182 | /** @copydoc VBOXSERVICE::pfnInit */
|
---|
183 | static DECLCALLBACK(int) VBoxServiceVMInfoInit(void)
|
---|
184 | {
|
---|
185 | /*
|
---|
186 | * If not specified, find the right interval default.
|
---|
187 | * Then create the event sem to block on.
|
---|
188 | */
|
---|
189 | if (!g_cMsVMInfoInterval)
|
---|
190 | g_cMsVMInfoInterval = g_DefaultInterval * 1000;
|
---|
191 | if (!g_cMsVMInfoInterval)
|
---|
192 | {
|
---|
193 | /* Set it to 5s by default for location awareness checks. */
|
---|
194 | g_cMsVMInfoInterval = 5 * 1000;
|
---|
195 | }
|
---|
196 |
|
---|
197 | int rc = RTSemEventMultiCreate(&g_hVMInfoEvent);
|
---|
198 | AssertRCReturn(rc, rc);
|
---|
199 |
|
---|
200 | VbglR3GetSessionId(&g_idVMInfoSession);
|
---|
201 | /* The status code is ignored as this information is not available with VBox < 3.2.10. */
|
---|
202 |
|
---|
203 | /* Initialize the LA client object. */
|
---|
204 | RT_ZERO(g_LAClientInfo);
|
---|
205 |
|
---|
206 | rc = VbglR3GuestPropConnect(&g_uVMInfoGuestPropSvcClientID);
|
---|
207 | if (RT_SUCCESS(rc))
|
---|
208 | VBoxServiceVerbose(3, "Property Service Client ID: %#x\n", g_uVMInfoGuestPropSvcClientID);
|
---|
209 | else
|
---|
210 | {
|
---|
211 | /* If the service was not found, we disable this service without
|
---|
212 | causing VBoxService to fail. */
|
---|
213 | if (rc == VERR_HGCM_SERVICE_NOT_FOUND) /* Host service is not available. */
|
---|
214 | {
|
---|
215 | VBoxServiceVerbose(0, "Guest property service is not available, disabling the service\n");
|
---|
216 | rc = VERR_SERVICE_DISABLED;
|
---|
217 | }
|
---|
218 | else
|
---|
219 | VBoxServiceError("Failed to connect to the guest property service! Error: %Rrc\n", rc);
|
---|
220 | RTSemEventMultiDestroy(g_hVMInfoEvent);
|
---|
221 | g_hVMInfoEvent = NIL_RTSEMEVENTMULTI;
|
---|
222 | }
|
---|
223 |
|
---|
224 | if (RT_SUCCESS(rc))
|
---|
225 | {
|
---|
226 | VBoxServicePropCacheCreate(&g_VMInfoPropCache, g_uVMInfoGuestPropSvcClientID);
|
---|
227 |
|
---|
228 | /*
|
---|
229 | * Declare some guest properties with flags and reset values.
|
---|
230 | */
|
---|
231 | int rc2 = VBoxServicePropCacheUpdateEntry(&g_VMInfoPropCache, g_pszPropCacheValLoggedInUsersList,
|
---|
232 | VBOXSERVICEPROPCACHEFLAG_TEMPORARY | VBOXSERVICEPROPCACHEFLAG_TRANSIENT, NULL /* Delete on exit */);
|
---|
233 | if (RT_FAILURE(rc2))
|
---|
234 | VBoxServiceError("Failed to init property cache value \"%s\", rc=%Rrc\n", g_pszPropCacheValLoggedInUsersList, rc2);
|
---|
235 |
|
---|
236 | rc2 = VBoxServicePropCacheUpdateEntry(&g_VMInfoPropCache, g_pszPropCacheValLoggedInUsers,
|
---|
237 | VBOXSERVICEPROPCACHEFLAG_TEMPORARY | VBOXSERVICEPROPCACHEFLAG_TRANSIENT, "0");
|
---|
238 | if (RT_FAILURE(rc2))
|
---|
239 | VBoxServiceError("Failed to init property cache value \"%s\", rc=%Rrc\n", g_pszPropCacheValLoggedInUsers, rc2);
|
---|
240 |
|
---|
241 | rc2 = VBoxServicePropCacheUpdateEntry(&g_VMInfoPropCache, g_pszPropCacheValNoLoggedInUsers,
|
---|
242 | VBOXSERVICEPROPCACHEFLAG_TEMPORARY | VBOXSERVICEPROPCACHEFLAG_TRANSIENT, "true");
|
---|
243 | if (RT_FAILURE(rc2))
|
---|
244 | VBoxServiceError("Failed to init property cache value \"%s\", rc=%Rrc\n", g_pszPropCacheValNoLoggedInUsers, rc2);
|
---|
245 |
|
---|
246 | rc2 = VBoxServicePropCacheUpdateEntry(&g_VMInfoPropCache, g_pszPropCacheValNetCount,
|
---|
247 | VBOXSERVICEPROPCACHEFLAG_TEMPORARY | VBOXSERVICEPROPCACHEFLAG_ALWAYS_UPDATE, NULL /* Delete on exit */);
|
---|
248 | if (RT_FAILURE(rc2))
|
---|
249 | VBoxServiceError("Failed to init property cache value \"%s\", rc=%Rrc\n", g_pszPropCacheValNetCount, rc2);
|
---|
250 |
|
---|
251 | /*
|
---|
252 | * Get configuration guest properties from the host.
|
---|
253 | * Note: All properties should have sensible defaults in case the lookup here fails.
|
---|
254 | */
|
---|
255 | char *pszValue;
|
---|
256 | rc2 = VBoxServiceReadHostProp(g_uVMInfoGuestPropSvcClientID, "/VirtualBox/GuestAdd/VBoxService/--vminfo-user-idle-threshold", true /* Read only */,
|
---|
257 | &pszValue, NULL /* Flags */, NULL /* Timestamp */);
|
---|
258 | if (RT_SUCCESS(rc2))
|
---|
259 | {
|
---|
260 | AssertPtr(pszValue);
|
---|
261 | g_uVMInfoUserIdleThresholdMS = RT_CLAMP(RTStrToUInt32(pszValue), 1000, UINT32_MAX - 1);
|
---|
262 | RTStrFree(pszValue);
|
---|
263 | }
|
---|
264 | }
|
---|
265 | return rc;
|
---|
266 | }
|
---|
267 |
|
---|
268 |
|
---|
269 | /**
|
---|
270 | * Retrieves a specifiy client LA property.
|
---|
271 | *
|
---|
272 | * @return IPRT status code.
|
---|
273 | * @param uClientID LA client ID to retrieve property for.
|
---|
274 | * @param pszProperty Property (without path) to retrieve.
|
---|
275 | * @param ppszValue Where to store value of property.
|
---|
276 | * @param puTimestamp Timestamp of property to retrieve. Optional.
|
---|
277 | */
|
---|
278 | static int vboxServiceGetLAClientValue(uint32_t uClientID, const char *pszProperty,
|
---|
279 | char **ppszValue, uint64_t *puTimestamp)
|
---|
280 | {
|
---|
281 | AssertReturn(uClientID, VERR_INVALID_PARAMETER);
|
---|
282 | AssertPtrReturn(pszProperty, VERR_INVALID_POINTER);
|
---|
283 |
|
---|
284 | int rc;
|
---|
285 |
|
---|
286 | char pszClientPath[255];
|
---|
287 | if (RTStrPrintf(pszClientPath, sizeof(pszClientPath),
|
---|
288 | "/VirtualBox/HostInfo/VRDP/Client/%RU32/%s", uClientID, pszProperty))
|
---|
289 | {
|
---|
290 | rc = VBoxServiceReadHostProp(g_uVMInfoGuestPropSvcClientID, pszClientPath, true /* Read only */,
|
---|
291 | ppszValue, NULL /* Flags */, puTimestamp);
|
---|
292 | }
|
---|
293 | else
|
---|
294 | rc = VERR_NO_MEMORY;
|
---|
295 |
|
---|
296 | return rc;
|
---|
297 | }
|
---|
298 |
|
---|
299 |
|
---|
300 | /**
|
---|
301 | * Retrieves LA client information. On success the returned structure will have allocated
|
---|
302 | * objects which need to be free'd with vboxServiceFreeLAClientInfo.
|
---|
303 | *
|
---|
304 | * @return IPRT status code.
|
---|
305 | * @param uClientID Client ID to retrieve information for.
|
---|
306 | * @param pClient Pointer where to store the client information.
|
---|
307 | */
|
---|
308 | static int vboxServiceGetLAClientInfo(uint32_t uClientID, PVBOXSERVICELACLIENTINFO pClient)
|
---|
309 | {
|
---|
310 | AssertReturn(uClientID, VERR_INVALID_PARAMETER);
|
---|
311 | AssertPtrReturn(pClient, VERR_INVALID_POINTER);
|
---|
312 |
|
---|
313 | int rc = vboxServiceGetLAClientValue(uClientID, "Name", &pClient->pszName,
|
---|
314 | NULL /* Timestamp */);
|
---|
315 | if (RT_SUCCESS(rc))
|
---|
316 | {
|
---|
317 | char *pszAttach;
|
---|
318 | rc = vboxServiceGetLAClientValue(uClientID, "Attach", &pszAttach,
|
---|
319 | &pClient->uAttachedTS);
|
---|
320 | if (RT_SUCCESS(rc))
|
---|
321 | {
|
---|
322 | AssertPtr(pszAttach);
|
---|
323 | pClient->fAttached = !RTStrICmp(pszAttach, "1") ? true : false;
|
---|
324 |
|
---|
325 | RTStrFree(pszAttach);
|
---|
326 | }
|
---|
327 | }
|
---|
328 | if (RT_SUCCESS(rc))
|
---|
329 | rc = vboxServiceGetLAClientValue(uClientID, "Location", &pClient->pszLocation,
|
---|
330 | NULL /* Timestamp */);
|
---|
331 | if (RT_SUCCESS(rc))
|
---|
332 | rc = vboxServiceGetLAClientValue(uClientID, "Domain", &pClient->pszDomain,
|
---|
333 | NULL /* Timestamp */);
|
---|
334 | if (RT_SUCCESS(rc))
|
---|
335 | pClient->uID = uClientID;
|
---|
336 |
|
---|
337 | return rc;
|
---|
338 | }
|
---|
339 |
|
---|
340 |
|
---|
341 | /**
|
---|
342 | * Frees all allocated LA client information of a structure.
|
---|
343 | *
|
---|
344 | * @param pClient Pointer to client information structure to free.
|
---|
345 | */
|
---|
346 | static void vboxServiceFreeLAClientInfo(PVBOXSERVICELACLIENTINFO pClient)
|
---|
347 | {
|
---|
348 | if (pClient)
|
---|
349 | {
|
---|
350 | if (pClient->pszName)
|
---|
351 | {
|
---|
352 | RTStrFree(pClient->pszName);
|
---|
353 | pClient->pszName = NULL;
|
---|
354 | }
|
---|
355 | if (pClient->pszLocation)
|
---|
356 | {
|
---|
357 | RTStrFree(pClient->pszLocation);
|
---|
358 | pClient->pszLocation = NULL;
|
---|
359 | }
|
---|
360 | if (pClient->pszDomain)
|
---|
361 | {
|
---|
362 | RTStrFree(pClient->pszDomain);
|
---|
363 | pClient->pszDomain = NULL;
|
---|
364 | }
|
---|
365 | }
|
---|
366 | }
|
---|
367 |
|
---|
368 |
|
---|
369 | /**
|
---|
370 | * Updates a per-guest user guest property inside the given property cache.
|
---|
371 | *
|
---|
372 | * @return IPRT status code.
|
---|
373 | * @param pCache Pointer to guest property cache to update user in.
|
---|
374 | * @param pszUser Name of guest user to update.
|
---|
375 | * @param pszDomain Domain of guest user to update. Optional.
|
---|
376 | * @param pszKey Key name of guest property to update.
|
---|
377 | * @param pszValueFormat Guest property value to set. Pass NULL for deleting
|
---|
378 | * the property.
|
---|
379 | */
|
---|
380 | int vboxServiceUserUpdateF(PVBOXSERVICEVEPROPCACHE pCache, const char *pszUser, const char *pszDomain,
|
---|
381 | const char *pszKey, const char *pszValueFormat, ...)
|
---|
382 | {
|
---|
383 | AssertPtrReturn(pCache, VERR_INVALID_POINTER);
|
---|
384 | AssertPtrReturn(pszUser, VERR_INVALID_POINTER);
|
---|
385 | /* pszDomain is optional. */
|
---|
386 | AssertPtrReturn(pszKey, VERR_INVALID_POINTER);
|
---|
387 | /* pszValueFormat is optional. */
|
---|
388 |
|
---|
389 | int rc = VINF_SUCCESS;
|
---|
390 |
|
---|
391 | char *pszName;
|
---|
392 | if (pszDomain)
|
---|
393 | {
|
---|
394 | if (!RTStrAPrintf(&pszName, "%s%s@%s/%s", g_pszPropCacheValUser, pszUser, pszDomain, pszKey))
|
---|
395 | rc = VERR_NO_MEMORY;
|
---|
396 | }
|
---|
397 | else
|
---|
398 | {
|
---|
399 | if (!RTStrAPrintf(&pszName, "%s%s/%s", g_pszPropCacheValUser, pszUser, pszKey))
|
---|
400 | rc = VERR_NO_MEMORY;
|
---|
401 | }
|
---|
402 |
|
---|
403 | char *pszValue = NULL;
|
---|
404 | if ( RT_SUCCESS(rc)
|
---|
405 | && pszValueFormat)
|
---|
406 | {
|
---|
407 | va_list va;
|
---|
408 | va_start(va, pszValueFormat);
|
---|
409 | if (RTStrAPrintfV(&pszValue, pszValueFormat, va) < 0)
|
---|
410 | rc = VERR_NO_MEMORY;
|
---|
411 | va_end(va);
|
---|
412 | if ( RT_SUCCESS(rc)
|
---|
413 | && !pszValue)
|
---|
414 | rc = VERR_NO_STR_MEMORY;
|
---|
415 | }
|
---|
416 |
|
---|
417 | if (RT_SUCCESS(rc))
|
---|
418 | rc = VBoxServicePropCacheUpdate(pCache, pszName, pszValue);
|
---|
419 | if (rc == VINF_SUCCESS) /* VBoxServicePropCacheUpdate will also return VINF_NO_CHANGE. */
|
---|
420 | {
|
---|
421 | /** @todo Combine updating flags w/ updating the actual value. */
|
---|
422 | rc = VBoxServicePropCacheUpdateEntry(pCache, pszName,
|
---|
423 | VBOXSERVICEPROPCACHEFLAG_TEMPORARY | VBOXSERVICEPROPCACHEFLAG_TRANSIENT,
|
---|
424 | NULL /* Delete on exit */);
|
---|
425 | }
|
---|
426 |
|
---|
427 | RTStrFree(pszValue);
|
---|
428 | RTStrFree(pszName);
|
---|
429 | return rc;
|
---|
430 | }
|
---|
431 |
|
---|
432 |
|
---|
433 | /**
|
---|
434 | * Writes the properties that won't change while the service is running.
|
---|
435 | *
|
---|
436 | * Errors are ignored.
|
---|
437 | */
|
---|
438 | static void vboxserviceVMInfoWriteFixedProperties(void)
|
---|
439 | {
|
---|
440 | /*
|
---|
441 | * First get OS information that won't change.
|
---|
442 | */
|
---|
443 | char szInfo[256];
|
---|
444 | int rc = RTSystemQueryOSInfo(RTSYSOSINFO_PRODUCT, szInfo, sizeof(szInfo));
|
---|
445 | VBoxServiceWritePropF(g_uVMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/Product",
|
---|
446 | "%s", RT_FAILURE(rc) ? "" : szInfo);
|
---|
447 |
|
---|
448 | rc = RTSystemQueryOSInfo(RTSYSOSINFO_RELEASE, szInfo, sizeof(szInfo));
|
---|
449 | VBoxServiceWritePropF(g_uVMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/Release",
|
---|
450 | "%s", RT_FAILURE(rc) ? "" : szInfo);
|
---|
451 |
|
---|
452 | rc = RTSystemQueryOSInfo(RTSYSOSINFO_VERSION, szInfo, sizeof(szInfo));
|
---|
453 | VBoxServiceWritePropF(g_uVMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/Version",
|
---|
454 | "%s", RT_FAILURE(rc) ? "" : szInfo);
|
---|
455 |
|
---|
456 | rc = RTSystemQueryOSInfo(RTSYSOSINFO_SERVICE_PACK, szInfo, sizeof(szInfo));
|
---|
457 | VBoxServiceWritePropF(g_uVMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/ServicePack",
|
---|
458 | "%s", RT_FAILURE(rc) ? "" : szInfo);
|
---|
459 |
|
---|
460 | /*
|
---|
461 | * Retrieve version information about Guest Additions and installed files (components).
|
---|
462 | */
|
---|
463 | char *pszAddVer;
|
---|
464 | char *pszAddVerExt;
|
---|
465 | char *pszAddRev;
|
---|
466 | rc = VbglR3GetAdditionsVersion(&pszAddVer, &pszAddVerExt, &pszAddRev);
|
---|
467 | VBoxServiceWritePropF(g_uVMInfoGuestPropSvcClientID, "/VirtualBox/GuestAdd/Version",
|
---|
468 | "%s", RT_FAILURE(rc) ? "" : pszAddVer);
|
---|
469 | VBoxServiceWritePropF(g_uVMInfoGuestPropSvcClientID, "/VirtualBox/GuestAdd/VersionExt",
|
---|
470 | "%s", RT_FAILURE(rc) ? "" : pszAddVerExt);
|
---|
471 | VBoxServiceWritePropF(g_uVMInfoGuestPropSvcClientID, "/VirtualBox/GuestAdd/Revision",
|
---|
472 | "%s", RT_FAILURE(rc) ? "" : pszAddRev);
|
---|
473 | if (RT_SUCCESS(rc))
|
---|
474 | {
|
---|
475 | RTStrFree(pszAddVer);
|
---|
476 | RTStrFree(pszAddVerExt);
|
---|
477 | RTStrFree(pszAddRev);
|
---|
478 | }
|
---|
479 |
|
---|
480 | #ifdef RT_OS_WINDOWS
|
---|
481 | /*
|
---|
482 | * Do windows specific properties.
|
---|
483 | */
|
---|
484 | char *pszInstDir;
|
---|
485 | rc = VbglR3GetAdditionsInstallationPath(&pszInstDir);
|
---|
486 | VBoxServiceWritePropF(g_uVMInfoGuestPropSvcClientID, "/VirtualBox/GuestAdd/InstallDir",
|
---|
487 | "%s", RT_FAILURE(rc) ? "" : pszInstDir);
|
---|
488 | if (RT_SUCCESS(rc))
|
---|
489 | RTStrFree(pszInstDir);
|
---|
490 |
|
---|
491 | VBoxServiceWinGetComponentVersions(g_uVMInfoGuestPropSvcClientID);
|
---|
492 | #endif
|
---|
493 | }
|
---|
494 |
|
---|
495 | #if defined(VBOX_WITH_DBUS) && defined(RT_OS_LINUX) /* Not yet for Solaris/FreeBSB. */
|
---|
496 | /*
|
---|
497 | * Simple wrapper to work around compiler-specific va_list madness.
|
---|
498 | */
|
---|
499 | static dbus_bool_t vboxService_dbus_message_get_args(DBusMessage *message,
|
---|
500 | DBusError *error,
|
---|
501 | int first_arg_type,
|
---|
502 | ...)
|
---|
503 | {
|
---|
504 | va_list va;
|
---|
505 | va_start(va, first_arg_type);
|
---|
506 | dbus_bool_t ret = dbus_message_get_args_valist(message, error,
|
---|
507 | first_arg_type, va);
|
---|
508 | va_end(va);
|
---|
509 | return ret;
|
---|
510 | }
|
---|
511 | #endif
|
---|
512 |
|
---|
513 | /**
|
---|
514 | * Provide information about active users.
|
---|
515 | */
|
---|
516 | static int vboxserviceVMInfoWriteUsers(void)
|
---|
517 | {
|
---|
518 | int rc = VINF_SUCCESS;
|
---|
519 | char *pszUserList = NULL;
|
---|
520 | uint32_t cUsersInList = 0;
|
---|
521 |
|
---|
522 | #ifdef RT_OS_WINDOWS
|
---|
523 | # ifndef TARGET_NT4
|
---|
524 | rc = VBoxServiceVMInfoWinWriteUsers(&g_VMInfoPropCache,
|
---|
525 | &pszUserList, &cUsersInList);
|
---|
526 | # else
|
---|
527 | rc = VERR_NOT_IMPLEMENTED;
|
---|
528 | # endif
|
---|
529 |
|
---|
530 | #elif defined(RT_OS_FREEBSD)
|
---|
531 | /** @todo FreeBSD: Port logged on user info retrieval.
|
---|
532 | * However, FreeBSD 9 supports utmpx, so we could use the code
|
---|
533 | * block below (?). */
|
---|
534 | rc = VERR_NOT_IMPLEMENTED;
|
---|
535 |
|
---|
536 | #elif defined(RT_OS_HAIKU)
|
---|
537 | /** @todo Haiku: Port logged on user info retrieval. */
|
---|
538 | rc = VERR_NOT_IMPLEMENTED;
|
---|
539 |
|
---|
540 | #elif defined(RT_OS_OS2)
|
---|
541 | /** @todo OS/2: Port logged on (LAN/local/whatever) user info retrieval. */
|
---|
542 | rc = VERR_NOT_IMPLEMENTED;
|
---|
543 |
|
---|
544 | #else
|
---|
545 | setutxent();
|
---|
546 | utmpx *ut_user;
|
---|
547 | uint32_t cListSize = 32;
|
---|
548 |
|
---|
549 | /* Allocate a first array to hold 32 users max. */
|
---|
550 | char **papszUsers = (char **)RTMemAllocZ(cListSize * sizeof(char *));
|
---|
551 | if (!papszUsers)
|
---|
552 | rc = VERR_NO_MEMORY;
|
---|
553 |
|
---|
554 | /* Process all entries in the utmp file.
|
---|
555 | * Note: This only handles */
|
---|
556 | while ( (ut_user = getutxent())
|
---|
557 | && RT_SUCCESS(rc))
|
---|
558 | {
|
---|
559 | # ifdef RT_OS_DARWIN /* No ut_user->ut_session on Darwin */
|
---|
560 | VBoxServiceVerbose(4, "Found entry \"%s\" (type: %d, PID: %RU32)\n",
|
---|
561 | ut_user->ut_user, ut_user->ut_type, ut_user->ut_pid);
|
---|
562 | # else
|
---|
563 | VBoxServiceVerbose(4, "Found entry \"%s\" (type: %d, PID: %RU32, session: %RU32)\n",
|
---|
564 | ut_user->ut_user, ut_user->ut_type, ut_user->ut_pid, ut_user->ut_session);
|
---|
565 | # endif
|
---|
566 | if (cUsersInList > cListSize)
|
---|
567 | {
|
---|
568 | cListSize += 32;
|
---|
569 | void *pvNew = RTMemRealloc(papszUsers, cListSize * sizeof(char*));
|
---|
570 | AssertBreakStmt(pvNew, cListSize -= 32);
|
---|
571 | papszUsers = (char **)pvNew;
|
---|
572 | }
|
---|
573 |
|
---|
574 | /* Make sure we don't add user names which are not
|
---|
575 | * part of type USER_PROCES. */
|
---|
576 | if (ut_user->ut_type == USER_PROCESS) /* Regular user process. */
|
---|
577 | {
|
---|
578 | bool fFound = false;
|
---|
579 | for (uint32_t i = 0; i < cUsersInList && !fFound; i++)
|
---|
580 | fFound = strcmp(papszUsers[i], ut_user->ut_user) == 0;
|
---|
581 |
|
---|
582 | if (!fFound)
|
---|
583 | {
|
---|
584 | VBoxServiceVerbose(4, "Adding user \"%s\" (type: %d) to list\n",
|
---|
585 | ut_user->ut_user, ut_user->ut_type);
|
---|
586 |
|
---|
587 | rc = RTStrDupEx(&papszUsers[cUsersInList], (const char *)ut_user->ut_user);
|
---|
588 | if (RT_FAILURE(rc))
|
---|
589 | break;
|
---|
590 | cUsersInList++;
|
---|
591 | }
|
---|
592 | }
|
---|
593 | }
|
---|
594 |
|
---|
595 | # ifdef VBOX_WITH_DBUS
|
---|
596 | # if defined(RT_OS_LINUX) /* Not yet for Solaris/FreeBSB. */
|
---|
597 | DBusError dbErr;
|
---|
598 | DBusConnection *pConnection = NULL;
|
---|
599 | int rc2 = RTDBusLoadLib();
|
---|
600 | bool fHaveLibDbus = false;
|
---|
601 | if (RT_SUCCESS(rc2))
|
---|
602 | {
|
---|
603 | /* Handle desktop sessions using ConsoleKit. */
|
---|
604 | VBoxServiceVerbose(4, "Checking ConsoleKit sessions ...\n");
|
---|
605 | fHaveLibDbus = true;
|
---|
606 | dbus_error_init(&dbErr);
|
---|
607 | pConnection = dbus_bus_get(DBUS_BUS_SYSTEM, &dbErr);
|
---|
608 | }
|
---|
609 |
|
---|
610 | if ( pConnection
|
---|
611 | && !dbus_error_is_set(&dbErr))
|
---|
612 | {
|
---|
613 | /* Get all available sessions. */
|
---|
614 | DBusMessage *pMsgSessions = dbus_message_new_method_call("org.freedesktop.ConsoleKit",
|
---|
615 | "/org/freedesktop/ConsoleKit/Manager",
|
---|
616 | "org.freedesktop.ConsoleKit.Manager",
|
---|
617 | "GetSessions");
|
---|
618 | if ( pMsgSessions
|
---|
619 | && (dbus_message_get_type(pMsgSessions) == DBUS_MESSAGE_TYPE_METHOD_CALL))
|
---|
620 | {
|
---|
621 | DBusMessage *pReplySessions = dbus_connection_send_with_reply_and_block(pConnection,
|
---|
622 | pMsgSessions, 30 * 1000 /* 30s timeout */,
|
---|
623 | &dbErr);
|
---|
624 | if ( pReplySessions
|
---|
625 | && !dbus_error_is_set(&dbErr))
|
---|
626 | {
|
---|
627 | char **ppszSessions; int cSessions;
|
---|
628 | if ( (dbus_message_get_type(pMsgSessions) == DBUS_MESSAGE_TYPE_METHOD_CALL)
|
---|
629 | && vboxService_dbus_message_get_args(pReplySessions, &dbErr, DBUS_TYPE_ARRAY,
|
---|
630 | DBUS_TYPE_OBJECT_PATH, &ppszSessions, &cSessions,
|
---|
631 | DBUS_TYPE_INVALID /* Termination */))
|
---|
632 | {
|
---|
633 | VBoxServiceVerbose(4, "ConsoleKit: retrieved %RU16 session(s)\n", cSessions);
|
---|
634 |
|
---|
635 | char **ppszCurSession = ppszSessions;
|
---|
636 | for (ppszCurSession;
|
---|
637 | ppszCurSession && *ppszCurSession; ppszCurSession++)
|
---|
638 | {
|
---|
639 | VBoxServiceVerbose(4, "ConsoleKit: processing session '%s' ...\n", *ppszCurSession);
|
---|
640 |
|
---|
641 | /* Only respect active sessions .*/
|
---|
642 | bool fActive = false;
|
---|
643 | DBusMessage *pMsgSessionActive = dbus_message_new_method_call("org.freedesktop.ConsoleKit",
|
---|
644 | *ppszCurSession,
|
---|
645 | "org.freedesktop.ConsoleKit.Session",
|
---|
646 | "IsActive");
|
---|
647 | if ( pMsgSessionActive
|
---|
648 | && dbus_message_get_type(pMsgSessionActive) == DBUS_MESSAGE_TYPE_METHOD_CALL)
|
---|
649 | {
|
---|
650 | DBusMessage *pReplySessionActive = dbus_connection_send_with_reply_and_block(pConnection,
|
---|
651 | pMsgSessionActive, 30 * 1000 /* 30s timeout */,
|
---|
652 | &dbErr);
|
---|
653 | if ( pReplySessionActive
|
---|
654 | && !dbus_error_is_set(&dbErr))
|
---|
655 | {
|
---|
656 | DBusMessageIter itMsg;
|
---|
657 | if ( dbus_message_iter_init(pReplySessionActive, &itMsg)
|
---|
658 | && dbus_message_iter_get_arg_type(&itMsg) == DBUS_TYPE_BOOLEAN)
|
---|
659 | {
|
---|
660 | /* Get uid from message. */
|
---|
661 | int val;
|
---|
662 | dbus_message_iter_get_basic(&itMsg, &val);
|
---|
663 | fActive = val >= 1;
|
---|
664 | }
|
---|
665 |
|
---|
666 | if (pReplySessionActive)
|
---|
667 | dbus_message_unref(pReplySessionActive);
|
---|
668 | }
|
---|
669 |
|
---|
670 | if (pMsgSessionActive)
|
---|
671 | dbus_message_unref(pMsgSessionActive);
|
---|
672 | }
|
---|
673 |
|
---|
674 | VBoxServiceVerbose(4, "ConsoleKit: session '%s' is %s\n",
|
---|
675 | *ppszCurSession, fActive ? "active" : "not active");
|
---|
676 |
|
---|
677 | /* *ppszCurSession now contains the object path
|
---|
678 | * (e.g. "/org/freedesktop/ConsoleKit/Session1"). */
|
---|
679 | DBusMessage *pMsgUnixUser = dbus_message_new_method_call("org.freedesktop.ConsoleKit",
|
---|
680 | *ppszCurSession,
|
---|
681 | "org.freedesktop.ConsoleKit.Session",
|
---|
682 | "GetUnixUser");
|
---|
683 | if ( fActive
|
---|
684 | && pMsgUnixUser
|
---|
685 | && dbus_message_get_type(pMsgUnixUser) == DBUS_MESSAGE_TYPE_METHOD_CALL)
|
---|
686 | {
|
---|
687 | DBusMessage *pReplyUnixUser = dbus_connection_send_with_reply_and_block(pConnection,
|
---|
688 | pMsgUnixUser, 30 * 1000 /* 30s timeout */,
|
---|
689 | &dbErr);
|
---|
690 | if ( pReplyUnixUser
|
---|
691 | && !dbus_error_is_set(&dbErr))
|
---|
692 | {
|
---|
693 | DBusMessageIter itMsg;
|
---|
694 | if ( dbus_message_iter_init(pReplyUnixUser, &itMsg)
|
---|
695 | && dbus_message_iter_get_arg_type(&itMsg) == DBUS_TYPE_UINT32)
|
---|
696 | {
|
---|
697 | /* Get uid from message. */
|
---|
698 | uint32_t uid;
|
---|
699 | dbus_message_iter_get_basic(&itMsg, &uid);
|
---|
700 |
|
---|
701 | /** @todo Add support for getting UID_MIN (/etc/login.defs on
|
---|
702 | * Debian). */
|
---|
703 | uint32_t uid_min = 1000;
|
---|
704 |
|
---|
705 | /* Look up user name (realname) from uid. */
|
---|
706 | setpwent();
|
---|
707 | struct passwd *ppwEntry = getpwuid(uid);
|
---|
708 | if ( ppwEntry
|
---|
709 | && ppwEntry->pw_name)
|
---|
710 | {
|
---|
711 | if (ppwEntry->pw_uid >= uid_min /* Only respect users, not daemons etc. */)
|
---|
712 | {
|
---|
713 | VBoxServiceVerbose(4, "ConsoleKit: session '%s' -> %s (uid: %RU32)\n",
|
---|
714 | *ppszCurSession, ppwEntry->pw_name, uid);
|
---|
715 |
|
---|
716 | bool fFound = false;
|
---|
717 | for (uint32_t i = 0; i < cUsersInList && !fFound; i++)
|
---|
718 | fFound = strcmp(papszUsers[i], ppwEntry->pw_name) == 0;
|
---|
719 |
|
---|
720 | if (!fFound)
|
---|
721 | {
|
---|
722 | VBoxServiceVerbose(4, "ConsoleKit: adding user \"%s\" to list\n",
|
---|
723 | ppwEntry->pw_name);
|
---|
724 |
|
---|
725 | rc = RTStrDupEx(&papszUsers[cUsersInList], (const char *)ppwEntry->pw_name);
|
---|
726 | if (RT_FAILURE(rc))
|
---|
727 | break;
|
---|
728 | cUsersInList++;
|
---|
729 | }
|
---|
730 | }
|
---|
731 | /* else silently ignore the user */
|
---|
732 | }
|
---|
733 | else
|
---|
734 | VBoxServiceError("ConsoleKit: unable to lookup user name for uid=%RU32\n", uid);
|
---|
735 | }
|
---|
736 | else
|
---|
737 | AssertMsgFailed(("ConsoleKit: GetUnixUser returned a wrong argument type\n"));
|
---|
738 | }
|
---|
739 |
|
---|
740 | if (pReplyUnixUser)
|
---|
741 | dbus_message_unref(pReplyUnixUser);
|
---|
742 | }
|
---|
743 | else if (fActive) /* don't bitch about inactive users */
|
---|
744 | {
|
---|
745 | static int s_iBitchedAboutConsoleKit = 0;
|
---|
746 | if (s_iBitchedAboutConsoleKit < 1)
|
---|
747 | {
|
---|
748 | s_iBitchedAboutConsoleKit++;
|
---|
749 | VBoxServiceError("ConsoleKit: unable to retrieve user for session '%s' (msg type=%d): %s\n",
|
---|
750 | *ppszCurSession, dbus_message_get_type(pMsgUnixUser),
|
---|
751 | dbus_error_is_set(&dbErr) ? dbErr.message : "No error information available");
|
---|
752 | }
|
---|
753 | }
|
---|
754 |
|
---|
755 | if (pMsgUnixUser)
|
---|
756 | dbus_message_unref(pMsgUnixUser);
|
---|
757 | }
|
---|
758 |
|
---|
759 | dbus_free_string_array(ppszSessions);
|
---|
760 | }
|
---|
761 | else
|
---|
762 | {
|
---|
763 | VBoxServiceError("ConsoleKit: unable to retrieve session parameters (msg type=%d): %s\n",
|
---|
764 | dbus_message_get_type(pMsgSessions),
|
---|
765 | dbus_error_is_set(&dbErr) ? dbErr.message : "No error information available");
|
---|
766 | }
|
---|
767 | dbus_message_unref(pReplySessions);
|
---|
768 | }
|
---|
769 |
|
---|
770 | if (pMsgSessions)
|
---|
771 | {
|
---|
772 | dbus_message_unref(pMsgSessions);
|
---|
773 | pMsgSessions = NULL;
|
---|
774 | }
|
---|
775 | }
|
---|
776 | else
|
---|
777 | {
|
---|
778 | static int s_iBitchedAboutConsoleKit = 0;
|
---|
779 | if (s_iBitchedAboutConsoleKit < 3)
|
---|
780 | {
|
---|
781 | s_iBitchedAboutConsoleKit++;
|
---|
782 | VBoxServiceError("Unable to invoke ConsoleKit (%d/3) -- maybe not installed / used? Error: %s\n",
|
---|
783 | s_iBitchedAboutConsoleKit,
|
---|
784 | dbus_error_is_set(&dbErr) ? dbErr.message : "No error information available");
|
---|
785 | }
|
---|
786 | }
|
---|
787 |
|
---|
788 | if (pMsgSessions)
|
---|
789 | dbus_message_unref(pMsgSessions);
|
---|
790 | }
|
---|
791 | else
|
---|
792 | {
|
---|
793 | static int s_iBitchedAboutDBus = 0;
|
---|
794 | if (s_iBitchedAboutDBus < 3)
|
---|
795 | {
|
---|
796 | s_iBitchedAboutDBus++;
|
---|
797 | VBoxServiceError("Unable to connect to system D-Bus (%d/3): %s\n", s_iBitchedAboutDBus,
|
---|
798 | fHaveLibDbus && dbus_error_is_set(&dbErr) ? dbErr.message : "D-Bus not installed");
|
---|
799 | }
|
---|
800 | }
|
---|
801 |
|
---|
802 | if ( fHaveLibDbus
|
---|
803 | && dbus_error_is_set(&dbErr))
|
---|
804 | dbus_error_free(&dbErr);
|
---|
805 | # endif /* RT_OS_LINUX */
|
---|
806 | # endif /* VBOX_WITH_DBUS */
|
---|
807 |
|
---|
808 | /** @todo Fedora/others: Handle systemd-loginctl. */
|
---|
809 |
|
---|
810 | /* Calc the string length. */
|
---|
811 | size_t cchUserList = 0;
|
---|
812 | if (RT_SUCCESS(rc))
|
---|
813 | {
|
---|
814 | for (uint32_t i = 0; i < cUsersInList; i++)
|
---|
815 | cchUserList += (i != 0) + strlen(papszUsers[i]);
|
---|
816 | }
|
---|
817 |
|
---|
818 | /* Build the user list. */
|
---|
819 | if (cchUserList > 0)
|
---|
820 | {
|
---|
821 | if (RT_SUCCESS(rc))
|
---|
822 | rc = RTStrAllocEx(&pszUserList, cchUserList + 1);
|
---|
823 | if (RT_SUCCESS(rc))
|
---|
824 | {
|
---|
825 | char *psz = pszUserList;
|
---|
826 | for (uint32_t i = 0; i < cUsersInList; i++)
|
---|
827 | {
|
---|
828 | if (i != 0)
|
---|
829 | *psz++ = ',';
|
---|
830 | size_t cch = strlen(papszUsers[i]);
|
---|
831 | memcpy(psz, papszUsers[i], cch);
|
---|
832 | psz += cch;
|
---|
833 | }
|
---|
834 | *psz = '\0';
|
---|
835 | }
|
---|
836 | }
|
---|
837 |
|
---|
838 | /* Cleanup. */
|
---|
839 | for (uint32_t i = 0; i < cUsersInList; i++)
|
---|
840 | RTStrFree(papszUsers[i]);
|
---|
841 | RTMemFree(papszUsers);
|
---|
842 |
|
---|
843 | endutxent(); /* Close utmpx file. */
|
---|
844 | #endif /* !RT_OS_WINDOWS && !RT_OS_FREEBSD && !RT_OS_HAIKU && !RT_OS_OS2 */
|
---|
845 |
|
---|
846 | Assert(RT_FAILURE(rc) || cUsersInList == 0 || (pszUserList && *pszUserList));
|
---|
847 |
|
---|
848 | /* If the user enumeration above failed, reset the user count to 0 except
|
---|
849 | * we didn't have enough memory anymore. In that case we want to preserve
|
---|
850 | * the previous user count in order to not confuse third party tools which
|
---|
851 | * rely on that count. */
|
---|
852 | if (RT_FAILURE(rc))
|
---|
853 | {
|
---|
854 | if (rc == VERR_NO_MEMORY)
|
---|
855 | {
|
---|
856 | static int s_iVMInfoBitchedOOM = 0;
|
---|
857 | if (s_iVMInfoBitchedOOM++ < 3)
|
---|
858 | VBoxServiceVerbose(0, "Warning: Not enough memory available to enumerate users! Keeping old value (%RU32)\n",
|
---|
859 | g_cVMInfoLoggedInUsers);
|
---|
860 | cUsersInList = g_cVMInfoLoggedInUsers;
|
---|
861 | }
|
---|
862 | else
|
---|
863 | cUsersInList = 0;
|
---|
864 | }
|
---|
865 | else /* Preserve logged in users count. */
|
---|
866 | g_cVMInfoLoggedInUsers = cUsersInList;
|
---|
867 |
|
---|
868 | VBoxServiceVerbose(4, "cUsersInList=%RU32, pszUserList=%s, rc=%Rrc\n",
|
---|
869 | cUsersInList, pszUserList ? pszUserList : "<NULL>", rc);
|
---|
870 |
|
---|
871 | if (pszUserList)
|
---|
872 | {
|
---|
873 | AssertMsg(cUsersInList, ("pszUserList contains users whereas cUsersInList is 0\n"));
|
---|
874 | rc = VBoxServicePropCacheUpdate(&g_VMInfoPropCache, g_pszPropCacheValLoggedInUsersList, "%s", pszUserList);
|
---|
875 | }
|
---|
876 | else
|
---|
877 | rc = VBoxServicePropCacheUpdate(&g_VMInfoPropCache, g_pszPropCacheValLoggedInUsersList, NULL);
|
---|
878 | if (RT_FAILURE(rc))
|
---|
879 | VBoxServiceError("Error writing logged in users list, rc=%Rrc\n", rc);
|
---|
880 |
|
---|
881 | rc = VBoxServicePropCacheUpdate(&g_VMInfoPropCache, g_pszPropCacheValLoggedInUsers, "%RU32", cUsersInList);
|
---|
882 | if (RT_FAILURE(rc))
|
---|
883 | VBoxServiceError("Error writing logged in users count, rc=%Rrc\n", rc);
|
---|
884 |
|
---|
885 | rc = VBoxServicePropCacheUpdate(&g_VMInfoPropCache, g_pszPropCacheValNoLoggedInUsers,
|
---|
886 | cUsersInList == 0 ? "true" : "false");
|
---|
887 | if (RT_FAILURE(rc))
|
---|
888 | VBoxServiceError("Error writing no logged in users beacon, rc=%Rrc\n", rc);
|
---|
889 |
|
---|
890 | if (pszUserList)
|
---|
891 | RTStrFree(pszUserList);
|
---|
892 |
|
---|
893 | VBoxServiceVerbose(4, "Writing users returned with rc=%Rrc\n", rc);
|
---|
894 | return rc;
|
---|
895 | }
|
---|
896 |
|
---|
897 |
|
---|
898 | /**
|
---|
899 | * Provide information about the guest network.
|
---|
900 | */
|
---|
901 | static int vboxserviceVMInfoWriteNetwork(void)
|
---|
902 | {
|
---|
903 | int rc = VINF_SUCCESS;
|
---|
904 | uint32_t cIfsReported = 0;
|
---|
905 | char szPropPath[256];
|
---|
906 |
|
---|
907 | #ifdef RT_OS_WINDOWS
|
---|
908 | IP_ADAPTER_INFO *pAdpInfo = NULL;
|
---|
909 |
|
---|
910 | # ifndef TARGET_NT4
|
---|
911 | ULONG cbAdpInfo = sizeof(*pAdpInfo);
|
---|
912 | pAdpInfo = (IP_ADAPTER_INFO *)RTMemAlloc(cbAdpInfo);
|
---|
913 | if (!pAdpInfo)
|
---|
914 | {
|
---|
915 | VBoxServiceError("VMInfo/Network: Failed to allocate IP_ADAPTER_INFO\n");
|
---|
916 | return VERR_NO_MEMORY;
|
---|
917 | }
|
---|
918 | DWORD dwRet = GetAdaptersInfo(pAdpInfo, &cbAdpInfo);
|
---|
919 | if (dwRet == ERROR_BUFFER_OVERFLOW)
|
---|
920 | {
|
---|
921 | IP_ADAPTER_INFO *pAdpInfoNew = (IP_ADAPTER_INFO*)RTMemRealloc(pAdpInfo, cbAdpInfo);
|
---|
922 | if (pAdpInfoNew)
|
---|
923 | {
|
---|
924 | pAdpInfo = pAdpInfoNew;
|
---|
925 | dwRet = GetAdaptersInfo(pAdpInfo, &cbAdpInfo);
|
---|
926 | }
|
---|
927 | }
|
---|
928 | else if (dwRet == ERROR_NO_DATA)
|
---|
929 | {
|
---|
930 | VBoxServiceVerbose(3, "VMInfo/Network: No network adapters available\n");
|
---|
931 |
|
---|
932 | /* If no network adapters available / present in the
|
---|
933 | * system we pretend success to not bail out too early. */
|
---|
934 | dwRet = ERROR_SUCCESS;
|
---|
935 | }
|
---|
936 |
|
---|
937 | if (dwRet != ERROR_SUCCESS)
|
---|
938 | {
|
---|
939 | if (pAdpInfo)
|
---|
940 | RTMemFree(pAdpInfo);
|
---|
941 | VBoxServiceError("VMInfo/Network: Failed to get adapter info: Error %d\n", dwRet);
|
---|
942 | return RTErrConvertFromWin32(dwRet);
|
---|
943 | }
|
---|
944 | # endif /* !TARGET_NT4 */
|
---|
945 |
|
---|
946 | SOCKET sd = WSASocket(AF_INET, SOCK_DGRAM, 0, 0, 0, 0);
|
---|
947 | if (sd == SOCKET_ERROR) /* Socket invalid. */
|
---|
948 | {
|
---|
949 | int wsaErr = WSAGetLastError();
|
---|
950 | /* Don't complain/bail out with an error if network stack is not up; can happen
|
---|
951 | * on NT4 due to start up when not connected shares dialogs pop up. */
|
---|
952 | if (WSAENETDOWN == wsaErr)
|
---|
953 | {
|
---|
954 | VBoxServiceVerbose(0, "VMInfo/Network: Network is not up yet.\n");
|
---|
955 | wsaErr = VINF_SUCCESS;
|
---|
956 | }
|
---|
957 | else
|
---|
958 | VBoxServiceError("VMInfo/Network: Failed to get a socket: Error %d\n", wsaErr);
|
---|
959 | if (pAdpInfo)
|
---|
960 | RTMemFree(pAdpInfo);
|
---|
961 | return RTErrConvertFromWin32(wsaErr);
|
---|
962 | }
|
---|
963 |
|
---|
964 | INTERFACE_INFO InterfaceList[20] = {0};
|
---|
965 | unsigned long nBytesReturned = 0;
|
---|
966 | if (WSAIoctl(sd,
|
---|
967 | SIO_GET_INTERFACE_LIST,
|
---|
968 | 0,
|
---|
969 | 0,
|
---|
970 | &InterfaceList,
|
---|
971 | sizeof(InterfaceList),
|
---|
972 | &nBytesReturned,
|
---|
973 | 0,
|
---|
974 | 0) == SOCKET_ERROR)
|
---|
975 | {
|
---|
976 | VBoxServiceError("VMInfo/Network: Failed to WSAIoctl() on socket: Error: %d\n", WSAGetLastError());
|
---|
977 | if (pAdpInfo)
|
---|
978 | RTMemFree(pAdpInfo);
|
---|
979 | return RTErrConvertFromWin32(WSAGetLastError());
|
---|
980 | }
|
---|
981 | int cIfacesSystem = nBytesReturned / sizeof(INTERFACE_INFO);
|
---|
982 |
|
---|
983 | /** @todo Use GetAdaptersInfo() and GetAdapterAddresses (IPv4 + IPv6) for more information. */
|
---|
984 | for (int i = 0; i < cIfacesSystem; ++i)
|
---|
985 | {
|
---|
986 | sockaddr_in *pAddress;
|
---|
987 | u_long nFlags = 0;
|
---|
988 | if (InterfaceList[i].iiFlags & IFF_LOOPBACK) /* Skip loopback device. */
|
---|
989 | continue;
|
---|
990 | nFlags = InterfaceList[i].iiFlags;
|
---|
991 | pAddress = (sockaddr_in *)&(InterfaceList[i].iiAddress);
|
---|
992 | Assert(pAddress);
|
---|
993 | char szIp[32];
|
---|
994 | RTStrPrintf(szIp, sizeof(szIp), "%s", inet_ntoa(pAddress->sin_addr));
|
---|
995 | RTStrPrintf(szPropPath, sizeof(szPropPath), "/VirtualBox/GuestInfo/Net/%RU32/V4/IP", cIfsReported);
|
---|
996 | VBoxServicePropCacheUpdate(&g_VMInfoPropCache, szPropPath, "%s", szIp);
|
---|
997 |
|
---|
998 | pAddress = (sockaddr_in *) & (InterfaceList[i].iiBroadcastAddress);
|
---|
999 | RTStrPrintf(szPropPath, sizeof(szPropPath), "/VirtualBox/GuestInfo/Net/%RU32/V4/Broadcast", cIfsReported);
|
---|
1000 | VBoxServicePropCacheUpdate(&g_VMInfoPropCache, szPropPath, "%s", inet_ntoa(pAddress->sin_addr));
|
---|
1001 |
|
---|
1002 | pAddress = (sockaddr_in *)&(InterfaceList[i].iiNetmask);
|
---|
1003 | RTStrPrintf(szPropPath, sizeof(szPropPath), "/VirtualBox/GuestInfo/Net/%RU32/V4/Netmask", cIfsReported);
|
---|
1004 | VBoxServicePropCacheUpdate(&g_VMInfoPropCache, szPropPath, "%s", inet_ntoa(pAddress->sin_addr));
|
---|
1005 |
|
---|
1006 | RTStrPrintf(szPropPath, sizeof(szPropPath), "/VirtualBox/GuestInfo/Net/%RU32/Status", cIfsReported);
|
---|
1007 | VBoxServicePropCacheUpdate(&g_VMInfoPropCache, szPropPath, nFlags & IFF_UP ? "Up" : "Down");
|
---|
1008 |
|
---|
1009 | # ifndef TARGET_NT4
|
---|
1010 | IP_ADAPTER_INFO *pAdp;
|
---|
1011 | for (pAdp = pAdpInfo; pAdp; pAdp = pAdp->Next)
|
---|
1012 | if (!strcmp(pAdp->IpAddressList.IpAddress.String, szIp))
|
---|
1013 | break;
|
---|
1014 |
|
---|
1015 | RTStrPrintf(szPropPath, sizeof(szPropPath), "/VirtualBox/GuestInfo/Net/%RU32/MAC", cIfsReported);
|
---|
1016 | if (pAdp)
|
---|
1017 | {
|
---|
1018 | char szMac[32];
|
---|
1019 | RTStrPrintf(szMac, sizeof(szMac), "%02X%02X%02X%02X%02X%02X",
|
---|
1020 | pAdp->Address[0], pAdp->Address[1], pAdp->Address[2],
|
---|
1021 | pAdp->Address[3], pAdp->Address[4], pAdp->Address[5]);
|
---|
1022 | VBoxServicePropCacheUpdate(&g_VMInfoPropCache, szPropPath, "%s", szMac);
|
---|
1023 | }
|
---|
1024 | else
|
---|
1025 | VBoxServicePropCacheUpdate(&g_VMInfoPropCache, szPropPath, NULL);
|
---|
1026 | # endif /* !TARGET_NT4 */
|
---|
1027 |
|
---|
1028 | cIfsReported++;
|
---|
1029 | }
|
---|
1030 | if (pAdpInfo)
|
---|
1031 | RTMemFree(pAdpInfo);
|
---|
1032 | if (sd >= 0)
|
---|
1033 | closesocket(sd);
|
---|
1034 |
|
---|
1035 | #elif defined(RT_OS_HAIKU)
|
---|
1036 | /** @todo Haiku: implement network info. retreival */
|
---|
1037 | return VERR_NOT_IMPLEMENTED;
|
---|
1038 |
|
---|
1039 | #elif defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
|
---|
1040 | struct ifaddrs *pIfHead = NULL;
|
---|
1041 |
|
---|
1042 | /* Get all available interfaces */
|
---|
1043 | rc = getifaddrs(&pIfHead);
|
---|
1044 | if (rc < 0)
|
---|
1045 | {
|
---|
1046 | rc = RTErrConvertFromErrno(errno);
|
---|
1047 | VBoxServiceError("VMInfo/Network: Failed to get all interfaces: Error %Rrc\n");
|
---|
1048 | return rc;
|
---|
1049 | }
|
---|
1050 |
|
---|
1051 | /* Loop through all interfaces and set the data. */
|
---|
1052 | for (struct ifaddrs *pIfCurr = pIfHead; pIfCurr; pIfCurr = pIfCurr->ifa_next)
|
---|
1053 | {
|
---|
1054 | /*
|
---|
1055 | * Only AF_INET and no loopback interfaces
|
---|
1056 | */
|
---|
1057 | /** @todo: IPv6 interfaces */
|
---|
1058 | if ( pIfCurr->ifa_addr->sa_family == AF_INET
|
---|
1059 | && !(pIfCurr->ifa_flags & IFF_LOOPBACK))
|
---|
1060 | {
|
---|
1061 | char szInetAddr[NI_MAXHOST];
|
---|
1062 |
|
---|
1063 | memset(szInetAddr, 0, NI_MAXHOST);
|
---|
1064 | getnameinfo(pIfCurr->ifa_addr, sizeof(struct sockaddr_in),
|
---|
1065 | szInetAddr, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
|
---|
1066 | RTStrPrintf(szPropPath, sizeof(szPropPath), "/VirtualBox/GuestInfo/Net/%RU32/V4/IP", cIfsReported);
|
---|
1067 | VBoxServicePropCacheUpdate(&g_VMInfoPropCache, szPropPath, "%s", szInetAddr);
|
---|
1068 |
|
---|
1069 | memset(szInetAddr, 0, NI_MAXHOST);
|
---|
1070 | getnameinfo(pIfCurr->ifa_broadaddr, sizeof(struct sockaddr_in),
|
---|
1071 | szInetAddr, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
|
---|
1072 | RTStrPrintf(szPropPath, sizeof(szPropPath), "/VirtualBox/GuestInfo/Net/%RU32/V4/Broadcast", cIfsReported);
|
---|
1073 | VBoxServicePropCacheUpdate(&g_VMInfoPropCache, szPropPath, "%s", szInetAddr);
|
---|
1074 |
|
---|
1075 | memset(szInetAddr, 0, NI_MAXHOST);
|
---|
1076 | getnameinfo(pIfCurr->ifa_netmask, sizeof(struct sockaddr_in),
|
---|
1077 | szInetAddr, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
|
---|
1078 | RTStrPrintf(szPropPath, sizeof(szPropPath), "/VirtualBox/GuestInfo/Net/%RU32/V4/Netmask", cIfsReported);
|
---|
1079 | VBoxServicePropCacheUpdate(&g_VMInfoPropCache, szPropPath, "%s", szInetAddr);
|
---|
1080 |
|
---|
1081 | /* Search for the AF_LINK interface of the current AF_INET one and get the mac. */
|
---|
1082 | for (struct ifaddrs *pIfLinkCurr = pIfHead; pIfLinkCurr; pIfLinkCurr = pIfLinkCurr->ifa_next)
|
---|
1083 | {
|
---|
1084 | if ( pIfLinkCurr->ifa_addr->sa_family == AF_LINK
|
---|
1085 | && !strcmp(pIfCurr->ifa_name, pIfLinkCurr->ifa_name))
|
---|
1086 | {
|
---|
1087 | char szMac[32];
|
---|
1088 | uint8_t *pu8Mac = NULL;
|
---|
1089 | struct sockaddr_dl *pLinkAddress = (struct sockaddr_dl *)pIfLinkCurr->ifa_addr;
|
---|
1090 |
|
---|
1091 | AssertPtr(pLinkAddress);
|
---|
1092 | pu8Mac = (uint8_t *)LLADDR(pLinkAddress);
|
---|
1093 | RTStrPrintf(szMac, sizeof(szMac), "%02X%02X%02X%02X%02X%02X",
|
---|
1094 | pu8Mac[0], pu8Mac[1], pu8Mac[2], pu8Mac[3], pu8Mac[4], pu8Mac[5]);
|
---|
1095 | RTStrPrintf(szPropPath, sizeof(szPropPath), "/VirtualBox/GuestInfo/Net/%RU32/MAC", cIfsReported);
|
---|
1096 | VBoxServicePropCacheUpdate(&g_VMInfoPropCache, szPropPath, "%s", szMac);
|
---|
1097 | break;
|
---|
1098 | }
|
---|
1099 | }
|
---|
1100 |
|
---|
1101 | RTStrPrintf(szPropPath, sizeof(szPropPath), "/VirtualBox/GuestInfo/Net/%RU32/Status", cIfsReported);
|
---|
1102 | VBoxServicePropCacheUpdate(&g_VMInfoPropCache, szPropPath, pIfCurr->ifa_flags & IFF_UP ? "Up" : "Down");
|
---|
1103 |
|
---|
1104 | cIfsReported++;
|
---|
1105 | }
|
---|
1106 | }
|
---|
1107 |
|
---|
1108 | /* Free allocated resources. */
|
---|
1109 | freeifaddrs(pIfHead);
|
---|
1110 |
|
---|
1111 | #else /* !RT_OS_WINDOWS && !RT_OS_FREEBSD */
|
---|
1112 | /*
|
---|
1113 | * Use SIOCGIFCONF to get a list of interface/protocol configurations.
|
---|
1114 | *
|
---|
1115 | * See "UNIX Network Programming Volume 1" by W. R. Stevens, section 17.6
|
---|
1116 | * for details on this ioctl.
|
---|
1117 | */
|
---|
1118 | int sd = socket(AF_INET, SOCK_DGRAM, 0);
|
---|
1119 | if (sd < 0)
|
---|
1120 | {
|
---|
1121 | rc = RTErrConvertFromErrno(errno);
|
---|
1122 | VBoxServiceError("VMInfo/Network: Failed to get a socket: Error %Rrc\n", rc);
|
---|
1123 | return rc;
|
---|
1124 | }
|
---|
1125 |
|
---|
1126 | /* Call SIOCGIFCONF with the right sized buffer (remember the size). */
|
---|
1127 | static int s_cbBuf = 256; // 1024
|
---|
1128 | int cbBuf = s_cbBuf;
|
---|
1129 | char *pchBuf;
|
---|
1130 | struct ifconf IfConf;
|
---|
1131 | rc = VINF_SUCCESS;
|
---|
1132 | for (;;)
|
---|
1133 | {
|
---|
1134 | pchBuf = (char *)RTMemTmpAllocZ(cbBuf);
|
---|
1135 | if (!pchBuf)
|
---|
1136 | {
|
---|
1137 | rc = VERR_NO_TMP_MEMORY;
|
---|
1138 | break;
|
---|
1139 | }
|
---|
1140 |
|
---|
1141 | IfConf.ifc_len = cbBuf;
|
---|
1142 | IfConf.ifc_buf = pchBuf;
|
---|
1143 | if (ioctl(sd, SIOCGIFCONF, &IfConf) >= 0)
|
---|
1144 | {
|
---|
1145 | /* Hard to anticipate how space an address might possibly take, so
|
---|
1146 | making some generous assumptions here to avoid performing the
|
---|
1147 | query twice with different buffer sizes. */
|
---|
1148 | if (IfConf.ifc_len + 128 < cbBuf)
|
---|
1149 | break;
|
---|
1150 | }
|
---|
1151 | else if (errno != EOVERFLOW)
|
---|
1152 | {
|
---|
1153 | rc = RTErrConvertFromErrno(errno);
|
---|
1154 | break;
|
---|
1155 | }
|
---|
1156 |
|
---|
1157 | /* grow the buffer */
|
---|
1158 | s_cbBuf = cbBuf *= 2;
|
---|
1159 | RTMemFree(pchBuf);
|
---|
1160 | }
|
---|
1161 | if (RT_FAILURE(rc))
|
---|
1162 | {
|
---|
1163 | close(sd);
|
---|
1164 | RTMemTmpFree(pchBuf);
|
---|
1165 | VBoxServiceError("VMInfo/Network: Error doing SIOCGIFCONF (cbBuf=%d): %Rrc\n", cbBuf, rc);
|
---|
1166 | return rc;
|
---|
1167 | }
|
---|
1168 |
|
---|
1169 | /*
|
---|
1170 | * Iterate the interface/protocol configurations.
|
---|
1171 | *
|
---|
1172 | * Note! The current code naively assumes one IPv4 address per interface.
|
---|
1173 | * This means that guest assigning more than one address to an
|
---|
1174 | * interface will get multiple entries for one physical interface.
|
---|
1175 | */
|
---|
1176 | # ifdef RT_OS_OS2
|
---|
1177 | struct ifreq *pPrevLinkAddr = NULL;
|
---|
1178 | # endif
|
---|
1179 | struct ifreq *pCur = IfConf.ifc_req;
|
---|
1180 | size_t cbLeft = IfConf.ifc_len;
|
---|
1181 | while (cbLeft >= sizeof(*pCur))
|
---|
1182 | {
|
---|
1183 | # if defined(RT_OS_SOLARIS) || defined(RT_OS_LINUX)
|
---|
1184 | /* These two do not provide the sa_len member but only support address
|
---|
1185 | * families which do not need extra bytes on the end. */
|
---|
1186 | # define SA_LEN(pAddr) sizeof(struct sockaddr)
|
---|
1187 | # elif !defined(SA_LEN)
|
---|
1188 | # define SA_LEN(pAddr) (pAddr)->sa_len
|
---|
1189 | # endif
|
---|
1190 | /* Figure the size of the current request. */
|
---|
1191 | size_t cbCur = RT_OFFSETOF(struct ifreq, ifr_addr)
|
---|
1192 | + SA_LEN(&pCur->ifr_addr);
|
---|
1193 | cbCur = RT_MAX(cbCur, sizeof(struct ifreq));
|
---|
1194 | # if defined(RT_OS_SOLARIS) || defined(RT_OS_LINUX)
|
---|
1195 | Assert(pCur->ifr_addr.sa_family == AF_INET);
|
---|
1196 | # endif
|
---|
1197 | AssertBreak(cbCur <= cbLeft);
|
---|
1198 |
|
---|
1199 | # ifdef RT_OS_OS2
|
---|
1200 | /* On OS/2 we get the MAC address in the AF_LINK that the BSD 4.4 stack
|
---|
1201 | emits. We boldly ASSUME these always comes first. */
|
---|
1202 | if ( pCur->ifr_addr.sa_family == AF_LINK
|
---|
1203 | && ((struct sockaddr_dl *)&pCur->ifr_addr)->sdl_alen == 6)
|
---|
1204 | pPrevLinkAddr = pCur;
|
---|
1205 | # endif
|
---|
1206 |
|
---|
1207 | /* Skip it if it's not the kind of address we're looking for. */
|
---|
1208 | struct ifreq IfReqTmp;
|
---|
1209 | bool fIfUp = false;
|
---|
1210 | bool fSkip = false;
|
---|
1211 | if (pCur->ifr_addr.sa_family != AF_INET)
|
---|
1212 | fSkip = true;
|
---|
1213 | else
|
---|
1214 | {
|
---|
1215 | /* Get the interface flags so we can detect loopback and check if it's up. */
|
---|
1216 | IfReqTmp = *pCur;
|
---|
1217 | if (ioctl(sd, SIOCGIFFLAGS, &IfReqTmp) < 0)
|
---|
1218 | {
|
---|
1219 | rc = RTErrConvertFromErrno(errno);
|
---|
1220 | VBoxServiceError("VMInfo/Network: Failed to ioctl(SIOCGIFFLAGS,%s) on socket: Error %Rrc\n", pCur->ifr_name, rc);
|
---|
1221 | break;
|
---|
1222 | }
|
---|
1223 | fIfUp = !!(IfReqTmp.ifr_flags & IFF_UP);
|
---|
1224 | if (IfReqTmp.ifr_flags & IFF_LOOPBACK) /* Skip the loopback device. */
|
---|
1225 | fSkip = true;
|
---|
1226 | }
|
---|
1227 | if (!fSkip)
|
---|
1228 | {
|
---|
1229 | size_t offSubProp = RTStrPrintf(szPropPath, sizeof(szPropPath), "/VirtualBox/GuestInfo/Net/%RU32", cIfsReported);
|
---|
1230 |
|
---|
1231 | sockaddr_in *pAddress = (sockaddr_in *)&pCur->ifr_addr;
|
---|
1232 | strcpy(&szPropPath[offSubProp], "/V4/IP");
|
---|
1233 | VBoxServicePropCacheUpdate(&g_VMInfoPropCache, szPropPath, "%s", inet_ntoa(pAddress->sin_addr));
|
---|
1234 |
|
---|
1235 | /* Get the broadcast address. */
|
---|
1236 | IfReqTmp = *pCur;
|
---|
1237 | if (ioctl(sd, SIOCGIFBRDADDR, &IfReqTmp) < 0)
|
---|
1238 | {
|
---|
1239 | rc = RTErrConvertFromErrno(errno);
|
---|
1240 | VBoxServiceError("VMInfo/Network: Failed to ioctl(SIOCGIFBRDADDR) on socket: Error %Rrc\n", rc);
|
---|
1241 | break;
|
---|
1242 | }
|
---|
1243 | pAddress = (sockaddr_in *)&IfReqTmp.ifr_broadaddr;
|
---|
1244 | strcpy(&szPropPath[offSubProp], "/V4/Broadcast");
|
---|
1245 | VBoxServicePropCacheUpdate(&g_VMInfoPropCache, szPropPath, "%s", inet_ntoa(pAddress->sin_addr));
|
---|
1246 |
|
---|
1247 | /* Get the net mask. */
|
---|
1248 | IfReqTmp = *pCur;
|
---|
1249 | if (ioctl(sd, SIOCGIFNETMASK, &IfReqTmp) < 0)
|
---|
1250 | {
|
---|
1251 | rc = RTErrConvertFromErrno(errno);
|
---|
1252 | VBoxServiceError("VMInfo/Network: Failed to ioctl(SIOCGIFNETMASK) on socket: Error %Rrc\n", rc);
|
---|
1253 | break;
|
---|
1254 | }
|
---|
1255 | # if defined(RT_OS_OS2) || defined(RT_OS_SOLARIS)
|
---|
1256 | pAddress = (sockaddr_in *)&IfReqTmp.ifr_addr;
|
---|
1257 | # else
|
---|
1258 | pAddress = (sockaddr_in *)&IfReqTmp.ifr_netmask;
|
---|
1259 | # endif
|
---|
1260 | strcpy(&szPropPath[offSubProp], "/V4/Netmask");
|
---|
1261 | VBoxServicePropCacheUpdate(&g_VMInfoPropCache, szPropPath, "%s", inet_ntoa(pAddress->sin_addr));
|
---|
1262 |
|
---|
1263 | # if defined(RT_OS_SOLARIS)
|
---|
1264 | /*
|
---|
1265 | * "ifreq" is obsolete on Solaris. We use the recommended "lifreq".
|
---|
1266 | * We might fail if the interface has not been assigned an IP address.
|
---|
1267 | * That doesn't matter; as long as it's plumbed we can pick it up.
|
---|
1268 | * But, if it has not acquired an IP address we cannot obtain it's MAC
|
---|
1269 | * address this way, so we just use all zeros there.
|
---|
1270 | */
|
---|
1271 | RTMAC IfMac;
|
---|
1272 | struct lifreq IfReq;
|
---|
1273 | RT_ZERO(IfReq);
|
---|
1274 | AssertCompile(sizeof(IfReq.lifr_name) >= sizeof(pCur->ifr_name));
|
---|
1275 | strncpy(IfReq.lifr_name, pCur->ifr_name, sizeof(pCur->ifr_name));
|
---|
1276 | if (ioctl(sd, SIOCGLIFADDR, &IfReq) >= 0)
|
---|
1277 | {
|
---|
1278 | struct arpreq ArpReq;
|
---|
1279 | RT_ZERO(ArpReq);
|
---|
1280 | memcpy(&ArpReq.arp_pa, &IfReq.lifr_addr, sizeof(struct sockaddr_in));
|
---|
1281 |
|
---|
1282 | if (ioctl(sd, SIOCGARP, &ArpReq) >= 0)
|
---|
1283 | memcpy(&IfMac, ArpReq.arp_ha.sa_data, sizeof(IfMac));
|
---|
1284 | else
|
---|
1285 | {
|
---|
1286 | rc = RTErrConvertFromErrno(errno);
|
---|
1287 | VBoxServiceError("VMInfo/Network: failed to ioctl(SIOCGARP) on socket: Error %Rrc\n", rc);
|
---|
1288 | break;
|
---|
1289 | }
|
---|
1290 | }
|
---|
1291 | else
|
---|
1292 | {
|
---|
1293 | VBoxServiceVerbose(2, "VMInfo/Network: Interface \"%s\" has no assigned IP address, skipping ...\n", pCur->ifr_name);
|
---|
1294 | continue;
|
---|
1295 | }
|
---|
1296 | # elif defined(RT_OS_OS2)
|
---|
1297 | RTMAC IfMac;
|
---|
1298 | if ( pPrevLinkAddr
|
---|
1299 | && strncmp(pCur->ifr_name, pPrevLinkAddr->ifr_name, sizeof(pCur->ifr_name)) == 0)
|
---|
1300 | {
|
---|
1301 | struct sockaddr_dl *pDlAddr = (struct sockaddr_dl *)&pPrevLinkAddr->ifr_addr;
|
---|
1302 | IfMac = *(PRTMAC)&pDlAddr->sdl_data[pDlAddr->sdl_nlen];
|
---|
1303 | }
|
---|
1304 | else
|
---|
1305 | RT_ZERO(IfMac);
|
---|
1306 | #else
|
---|
1307 | if (ioctl(sd, SIOCGIFHWADDR, &IfReqTmp) < 0)
|
---|
1308 | {
|
---|
1309 | rc = RTErrConvertFromErrno(errno);
|
---|
1310 | VBoxServiceError("VMInfo/Network: Failed to ioctl(SIOCGIFHWADDR) on socket: Error %Rrc\n", rc);
|
---|
1311 | break;
|
---|
1312 | }
|
---|
1313 | RTMAC IfMac = *(PRTMAC)&IfReqTmp.ifr_hwaddr.sa_data[0];
|
---|
1314 | # endif
|
---|
1315 | strcpy(&szPropPath[offSubProp], "/MAC");
|
---|
1316 | VBoxServicePropCacheUpdate(&g_VMInfoPropCache, szPropPath, "%02X%02X%02X%02X%02X%02X",
|
---|
1317 | IfMac.au8[0], IfMac.au8[1], IfMac.au8[2], IfMac.au8[3], IfMac.au8[4], IfMac.au8[5]);
|
---|
1318 |
|
---|
1319 | strcpy(&szPropPath[offSubProp], "/Status");
|
---|
1320 | VBoxServicePropCacheUpdate(&g_VMInfoPropCache, szPropPath, fIfUp ? "Up" : "Down");
|
---|
1321 |
|
---|
1322 | /* The name. */
|
---|
1323 | int rc2 = RTStrValidateEncodingEx(pCur->ifr_name, sizeof(pCur->ifr_name), 0);
|
---|
1324 | if (RT_SUCCESS(rc2))
|
---|
1325 | {
|
---|
1326 | strcpy(&szPropPath[offSubProp], "/Name");
|
---|
1327 | VBoxServicePropCacheUpdate(&g_VMInfoPropCache, szPropPath, "%.*s", sizeof(pCur->ifr_name), pCur->ifr_name);
|
---|
1328 | }
|
---|
1329 |
|
---|
1330 | cIfsReported++;
|
---|
1331 | }
|
---|
1332 |
|
---|
1333 | /*
|
---|
1334 | * Next interface/protocol configuration.
|
---|
1335 | */
|
---|
1336 | pCur = (struct ifreq *)((uintptr_t)pCur + cbCur);
|
---|
1337 | cbLeft -= cbCur;
|
---|
1338 | }
|
---|
1339 |
|
---|
1340 | RTMemTmpFree(pchBuf);
|
---|
1341 | close(sd);
|
---|
1342 | if (RT_FAILURE(rc))
|
---|
1343 | VBoxServiceError("VMInfo/Network: Network enumeration for interface %RU32 failed with error %Rrc\n", cIfsReported, rc);
|
---|
1344 |
|
---|
1345 | #endif /* !RT_OS_WINDOWS */
|
---|
1346 |
|
---|
1347 | #if 0 /* Zapping not enabled yet, needs more testing first. */
|
---|
1348 | /*
|
---|
1349 | * Zap all stale network interface data if the former (saved) network ifaces count
|
---|
1350 | * is bigger than the current one.
|
---|
1351 | */
|
---|
1352 |
|
---|
1353 | /* Get former count. */
|
---|
1354 | uint32_t cIfsReportedOld;
|
---|
1355 | rc = VBoxServiceReadPropUInt32(g_uVMInfoGuestPropSvcClientID, g_pszPropCacheValNetCount, &cIfsReportedOld,
|
---|
1356 | 0 /* Min */, UINT32_MAX /* Max */);
|
---|
1357 | if ( RT_SUCCESS(rc)
|
---|
1358 | && cIfsReportedOld > cIfsReported) /* Are some ifaces not around anymore? */
|
---|
1359 | {
|
---|
1360 | VBoxServiceVerbose(3, "VMInfo/Network: Stale interface data detected (%RU32 old vs. %RU32 current)\n",
|
---|
1361 | cIfsReportedOld, cIfsReported);
|
---|
1362 |
|
---|
1363 | uint32_t uIfaceDeleteIdx = cIfsReported;
|
---|
1364 | do
|
---|
1365 | {
|
---|
1366 | VBoxServiceVerbose(3, "VMInfo/Network: Deleting stale data of interface %d ...\n", uIfaceDeleteIdx);
|
---|
1367 | rc = VBoxServicePropCacheUpdateByPath(&g_VMInfoPropCache, NULL /* Value, delete */, 0 /* Flags */, "/VirtualBox/GuestInfo/Net/%RU32", uIfaceDeleteIdx++);
|
---|
1368 | } while (RT_SUCCESS(rc));
|
---|
1369 | }
|
---|
1370 | else if ( RT_FAILURE(rc)
|
---|
1371 | && rc != VERR_NOT_FOUND)
|
---|
1372 | {
|
---|
1373 | VBoxServiceError("VMInfo/Network: Failed retrieving old network interfaces count with error %Rrc\n", rc);
|
---|
1374 | }
|
---|
1375 | #endif
|
---|
1376 |
|
---|
1377 | /*
|
---|
1378 | * This property is a beacon which is _always_ written, even if the network configuration
|
---|
1379 | * does not change. If this property is missing, the host assumes that all other GuestInfo
|
---|
1380 | * properties are no longer valid.
|
---|
1381 | */
|
---|
1382 | VBoxServicePropCacheUpdate(&g_VMInfoPropCache, g_pszPropCacheValNetCount, "%RU32",
|
---|
1383 | cIfsReported);
|
---|
1384 |
|
---|
1385 | /* Don't fail here; just report everything we got. */
|
---|
1386 | return VINF_SUCCESS;
|
---|
1387 | }
|
---|
1388 |
|
---|
1389 |
|
---|
1390 | /** @copydoc VBOXSERVICE::pfnWorker */
|
---|
1391 | DECLCALLBACK(int) VBoxServiceVMInfoWorker(bool volatile *pfShutdown)
|
---|
1392 | {
|
---|
1393 | int rc;
|
---|
1394 |
|
---|
1395 | /*
|
---|
1396 | * Tell the control thread that it can continue
|
---|
1397 | * spawning services.
|
---|
1398 | */
|
---|
1399 | RTThreadUserSignal(RTThreadSelf());
|
---|
1400 |
|
---|
1401 | #ifdef RT_OS_WINDOWS
|
---|
1402 | /* Required for network information (must be called per thread). */
|
---|
1403 | WSADATA wsaData;
|
---|
1404 | if (WSAStartup(MAKEWORD(2, 2), &wsaData))
|
---|
1405 | VBoxServiceError("VMInfo/Network: WSAStartup failed! Error: %Rrc\n", RTErrConvertFromWin32(WSAGetLastError()));
|
---|
1406 | #endif /* RT_OS_WINDOWS */
|
---|
1407 |
|
---|
1408 | /*
|
---|
1409 | * Write the fixed properties first.
|
---|
1410 | */
|
---|
1411 | vboxserviceVMInfoWriteFixedProperties();
|
---|
1412 |
|
---|
1413 | /*
|
---|
1414 | * Now enter the loop retrieving runtime data continuously.
|
---|
1415 | */
|
---|
1416 | for (;;)
|
---|
1417 | {
|
---|
1418 | rc = vboxserviceVMInfoWriteUsers();
|
---|
1419 | if (RT_FAILURE(rc))
|
---|
1420 | break;
|
---|
1421 |
|
---|
1422 | rc = vboxserviceVMInfoWriteNetwork();
|
---|
1423 | if (RT_FAILURE(rc))
|
---|
1424 | break;
|
---|
1425 |
|
---|
1426 | /* Whether to wait for event semaphore or not. */
|
---|
1427 | bool fWait = true;
|
---|
1428 |
|
---|
1429 | /* Check for location awareness. This most likely only
|
---|
1430 | * works with VBox (latest) 4.1 and up. */
|
---|
1431 |
|
---|
1432 | /* Check for new connection. */
|
---|
1433 | char *pszLAClientID = NULL;
|
---|
1434 | int rc2 = VBoxServiceReadHostProp(g_uVMInfoGuestPropSvcClientID, g_pszLAActiveClient, true /* Read only */,
|
---|
1435 | &pszLAClientID, NULL /* Flags */, NULL /* Timestamp */);
|
---|
1436 | if (RT_SUCCESS(rc2))
|
---|
1437 | {
|
---|
1438 | AssertPtr(pszLAClientID);
|
---|
1439 | if (RTStrICmp(pszLAClientID, "0")) /* Is a client connected? */
|
---|
1440 | {
|
---|
1441 | uint32_t uLAClientID = RTStrToInt32(pszLAClientID);
|
---|
1442 | uint64_t uLAClientAttachedTS;
|
---|
1443 |
|
---|
1444 | /* Peek at "Attach" value to figure out if hotdesking happened. */
|
---|
1445 | char *pszAttach = NULL;
|
---|
1446 | rc2 = vboxServiceGetLAClientValue(uLAClientID, "Attach", &pszAttach,
|
---|
1447 | &uLAClientAttachedTS);
|
---|
1448 |
|
---|
1449 | if ( RT_SUCCESS(rc2)
|
---|
1450 | && ( !g_LAClientAttachedTS
|
---|
1451 | || (g_LAClientAttachedTS != uLAClientAttachedTS)))
|
---|
1452 | {
|
---|
1453 | vboxServiceFreeLAClientInfo(&g_LAClientInfo);
|
---|
1454 |
|
---|
1455 | /* Note: There is a race between setting the guest properties by the host and getting them by
|
---|
1456 | * the guest. */
|
---|
1457 | rc2 = vboxServiceGetLAClientInfo(uLAClientID, &g_LAClientInfo);
|
---|
1458 | if (RT_SUCCESS(rc2))
|
---|
1459 | {
|
---|
1460 | VBoxServiceVerbose(1, "VRDP: Hotdesk client %s with ID=%RU32, Name=%s, Domain=%s\n",
|
---|
1461 | /* If g_LAClientAttachedTS is 0 this means there already was an active
|
---|
1462 | * hotdesk session when VBoxService started. */
|
---|
1463 | !g_LAClientAttachedTS ? "already active" : g_LAClientInfo.fAttached ? "connected" : "disconnected",
|
---|
1464 | uLAClientID, g_LAClientInfo.pszName, g_LAClientInfo.pszDomain);
|
---|
1465 |
|
---|
1466 | g_LAClientAttachedTS = g_LAClientInfo.uAttachedTS;
|
---|
1467 |
|
---|
1468 | /* Don't wait for event semaphore below anymore because we now know that the client
|
---|
1469 | * changed. This means we need to iterate all VM information again immediately. */
|
---|
1470 | fWait = false;
|
---|
1471 | }
|
---|
1472 | else
|
---|
1473 | {
|
---|
1474 | static int s_iBitchedAboutLAClientInfo = 0;
|
---|
1475 | if (s_iBitchedAboutLAClientInfo < 10)
|
---|
1476 | {
|
---|
1477 | s_iBitchedAboutLAClientInfo++;
|
---|
1478 | VBoxServiceError("Error getting active location awareness client info, rc=%Rrc\n", rc2);
|
---|
1479 | }
|
---|
1480 | }
|
---|
1481 | }
|
---|
1482 | else if (RT_FAILURE(rc2))
|
---|
1483 | VBoxServiceError("Error getting attached value of location awareness client %RU32, rc=%Rrc\n",
|
---|
1484 | uLAClientID, rc2);
|
---|
1485 | if (pszAttach)
|
---|
1486 | RTStrFree(pszAttach);
|
---|
1487 | }
|
---|
1488 | else
|
---|
1489 | {
|
---|
1490 | VBoxServiceVerbose(1, "VRDP: UTTSC disconnected from VRDP server\n");
|
---|
1491 | vboxServiceFreeLAClientInfo(&g_LAClientInfo);
|
---|
1492 | }
|
---|
1493 |
|
---|
1494 | RTStrFree(pszLAClientID);
|
---|
1495 | }
|
---|
1496 | else
|
---|
1497 | {
|
---|
1498 | static int s_iBitchedAboutLAClient = 0;
|
---|
1499 | if ( (rc2 != VERR_NOT_FOUND) /* No location awareness installed, skip. */
|
---|
1500 | && s_iBitchedAboutLAClient < 3)
|
---|
1501 | {
|
---|
1502 | s_iBitchedAboutLAClient++;
|
---|
1503 | VBoxServiceError("VRDP: Querying connected location awareness client failed with rc=%Rrc\n", rc2);
|
---|
1504 | }
|
---|
1505 | }
|
---|
1506 |
|
---|
1507 | VBoxServiceVerbose(3, "VRDP: Handling location awareness done\n");
|
---|
1508 |
|
---|
1509 | /*
|
---|
1510 | * Flush all properties if we were restored.
|
---|
1511 | */
|
---|
1512 | uint64_t idNewSession = g_idVMInfoSession;
|
---|
1513 | VbglR3GetSessionId(&idNewSession);
|
---|
1514 | if (idNewSession != g_idVMInfoSession)
|
---|
1515 | {
|
---|
1516 | VBoxServiceVerbose(3, "The VM session ID changed, flushing all properties\n");
|
---|
1517 | vboxserviceVMInfoWriteFixedProperties();
|
---|
1518 | VBoxServicePropCacheFlush(&g_VMInfoPropCache);
|
---|
1519 | g_idVMInfoSession = idNewSession;
|
---|
1520 | }
|
---|
1521 |
|
---|
1522 | /*
|
---|
1523 | * Block for a while.
|
---|
1524 | *
|
---|
1525 | * The event semaphore takes care of ignoring interruptions and it
|
---|
1526 | * allows us to implement service wakeup later.
|
---|
1527 | */
|
---|
1528 | if (*pfShutdown)
|
---|
1529 | break;
|
---|
1530 | if (fWait)
|
---|
1531 | rc2 = RTSemEventMultiWait(g_hVMInfoEvent, g_cMsVMInfoInterval);
|
---|
1532 | if (*pfShutdown)
|
---|
1533 | break;
|
---|
1534 | if (rc2 != VERR_TIMEOUT && RT_FAILURE(rc2))
|
---|
1535 | {
|
---|
1536 | VBoxServiceError("RTSemEventMultiWait failed; rc2=%Rrc\n", rc2);
|
---|
1537 | rc = rc2;
|
---|
1538 | break;
|
---|
1539 | }
|
---|
1540 | else if (RT_LIKELY(RT_SUCCESS(rc2)))
|
---|
1541 | {
|
---|
1542 | /* Reset event semaphore if it got triggered. */
|
---|
1543 | rc2 = RTSemEventMultiReset(g_hVMInfoEvent);
|
---|
1544 | if (RT_FAILURE(rc2))
|
---|
1545 | rc2 = VBoxServiceError("RTSemEventMultiReset failed; rc2=%Rrc\n", rc2);
|
---|
1546 | }
|
---|
1547 | }
|
---|
1548 |
|
---|
1549 | #ifdef RT_OS_WINDOWS
|
---|
1550 | WSACleanup();
|
---|
1551 | #endif
|
---|
1552 |
|
---|
1553 | return rc;
|
---|
1554 | }
|
---|
1555 |
|
---|
1556 |
|
---|
1557 | /** @copydoc VBOXSERVICE::pfnStop */
|
---|
1558 | static DECLCALLBACK(void) VBoxServiceVMInfoStop(void)
|
---|
1559 | {
|
---|
1560 | RTSemEventMultiSignal(g_hVMInfoEvent);
|
---|
1561 | }
|
---|
1562 |
|
---|
1563 |
|
---|
1564 | /** @copydoc VBOXSERVICE::pfnTerm */
|
---|
1565 | static DECLCALLBACK(void) VBoxServiceVMInfoTerm(void)
|
---|
1566 | {
|
---|
1567 | if (g_hVMInfoEvent != NIL_RTSEMEVENTMULTI)
|
---|
1568 | {
|
---|
1569 | /** @todo temporary solution: Zap all values which are not valid
|
---|
1570 | * anymore when VM goes down (reboot/shutdown ). Needs to
|
---|
1571 | * be replaced with "temporary properties" later.
|
---|
1572 | *
|
---|
1573 | * One idea is to introduce a (HGCM-)session guest property
|
---|
1574 | * flag meaning that a guest property is only valid as long
|
---|
1575 | * as the HGCM session isn't closed (e.g. guest application
|
---|
1576 | * terminates). [don't remove till implemented]
|
---|
1577 | */
|
---|
1578 | /** @todo r=bird: Drop the VbglR3GuestPropDelSet call here and use the cache
|
---|
1579 | * since it remembers what we've written. */
|
---|
1580 | /* Delete the "../Net" branch. */
|
---|
1581 | const char *apszPat[1] = { "/VirtualBox/GuestInfo/Net/*" };
|
---|
1582 | int rc = VbglR3GuestPropDelSet(g_uVMInfoGuestPropSvcClientID, &apszPat[0], RT_ELEMENTS(apszPat));
|
---|
1583 |
|
---|
1584 | /* Destroy LA client info. */
|
---|
1585 | vboxServiceFreeLAClientInfo(&g_LAClientInfo);
|
---|
1586 |
|
---|
1587 | /* Destroy property cache. */
|
---|
1588 | VBoxServicePropCacheDestroy(&g_VMInfoPropCache);
|
---|
1589 |
|
---|
1590 | /* Disconnect from guest properties service. */
|
---|
1591 | rc = VbglR3GuestPropDisconnect(g_uVMInfoGuestPropSvcClientID);
|
---|
1592 | if (RT_FAILURE(rc))
|
---|
1593 | VBoxServiceError("Failed to disconnect from guest property service! Error: %Rrc\n", rc);
|
---|
1594 | g_uVMInfoGuestPropSvcClientID = 0;
|
---|
1595 |
|
---|
1596 | RTSemEventMultiDestroy(g_hVMInfoEvent);
|
---|
1597 | g_hVMInfoEvent = NIL_RTSEMEVENTMULTI;
|
---|
1598 | }
|
---|
1599 | }
|
---|
1600 |
|
---|
1601 |
|
---|
1602 | /**
|
---|
1603 | * The 'vminfo' service description.
|
---|
1604 | */
|
---|
1605 | VBOXSERVICE g_VMInfo =
|
---|
1606 | {
|
---|
1607 | /* pszName. */
|
---|
1608 | "vminfo",
|
---|
1609 | /* pszDescription. */
|
---|
1610 | "Virtual Machine Information",
|
---|
1611 | /* pszUsage. */
|
---|
1612 | " [--vminfo-interval <ms>] [--vminfo-user-idle-threshold <ms>]"
|
---|
1613 | ,
|
---|
1614 | /* pszOptions. */
|
---|
1615 | " --vminfo-interval Specifies the interval at which to retrieve the\n"
|
---|
1616 | " VM information. The default is 10000 ms.\n"
|
---|
1617 | " --vminfo-user-idle-threshold <ms>\n"
|
---|
1618 | " Specifies the user idle threshold (in ms) for\n"
|
---|
1619 | " considering a guest user as being idle. The default\n"
|
---|
1620 | " is 5000 (5 seconds).\n"
|
---|
1621 | ,
|
---|
1622 | /* methods */
|
---|
1623 | VBoxServiceVMInfoPreInit,
|
---|
1624 | VBoxServiceVMInfoOption,
|
---|
1625 | VBoxServiceVMInfoInit,
|
---|
1626 | VBoxServiceVMInfoWorker,
|
---|
1627 | VBoxServiceVMInfoStop,
|
---|
1628 | VBoxServiceVMInfoTerm
|
---|
1629 | };
|
---|
1630 |
|
---|