1 | /* $Id: hostversion.cpp 97732 2022-12-02 16:19:55Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * X11 guest client - Host version check.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2011-2022 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 | #include <stdio.h>
|
---|
28 | #include <iprt/assert.h>
|
---|
29 | #include <iprt/errcore.h>
|
---|
30 | #include <iprt/mem.h>
|
---|
31 | #include <iprt/ldr.h>
|
---|
32 | #include <iprt/string.h>
|
---|
33 | #include <iprt/thread.h>
|
---|
34 |
|
---|
35 | #include <VBox/log.h>
|
---|
36 | #include <VBox/VBoxGuestLib.h>
|
---|
37 | #ifdef VBOX_OSE
|
---|
38 | # include <VBox/version.h>
|
---|
39 | #endif
|
---|
40 |
|
---|
41 | #include "VBoxClient.h"
|
---|
42 |
|
---|
43 |
|
---|
44 | /**
|
---|
45 | * @interface_method_impl{VBCLSERVICE,pfnWorker}
|
---|
46 | */
|
---|
47 | static DECLCALLBACK(int) vbclHostVerWorker(bool volatile *pfShutdown)
|
---|
48 | {
|
---|
49 | /** @todo Move this part in VbglR3 and just provide a callback for the platform-specific
|
---|
50 | notification stuff, since this is very similar to the VBoxTray code. */
|
---|
51 |
|
---|
52 | RT_NOREF(pfShutdown);
|
---|
53 |
|
---|
54 | LogFlowFuncEnter();
|
---|
55 |
|
---|
56 | int rc;
|
---|
57 | #ifdef VBOX_WITH_GUEST_PROPS
|
---|
58 | uint32_t uGuestPropSvcClientID;
|
---|
59 | rc = VbglR3GuestPropConnect(&uGuestPropSvcClientID);
|
---|
60 | if (RT_FAILURE(rc))
|
---|
61 | {
|
---|
62 | VBClLogError("Cannot connect to guest property service while chcking for host version, rc = %Rrc\n", rc);
|
---|
63 | return rc;
|
---|
64 | }
|
---|
65 |
|
---|
66 | /* Let the main thread know that it can continue spawning services. */
|
---|
67 | RTThreadUserSignal(RTThreadSelf());
|
---|
68 |
|
---|
69 | /* Because we need desktop notifications to be displayed, wait
|
---|
70 | * some time to make the desktop environment load (as a work around). */
|
---|
71 | if (g_fDaemonized)
|
---|
72 | RTThreadSleep(RT_MS_30SEC);
|
---|
73 |
|
---|
74 | char *pszHostVersion;
|
---|
75 | char *pszGuestVersion;
|
---|
76 | bool fUpdate;
|
---|
77 |
|
---|
78 | rc = VbglR3HostVersionCheckForUpdate(uGuestPropSvcClientID, &fUpdate, &pszHostVersion, &pszGuestVersion);
|
---|
79 | if (RT_SUCCESS(rc))
|
---|
80 | {
|
---|
81 | if (fUpdate)
|
---|
82 | {
|
---|
83 | char szMsg[1024];
|
---|
84 | char szTitle[64];
|
---|
85 |
|
---|
86 | /** @todo add some translation macros here */
|
---|
87 | RTStrPrintf(szTitle, sizeof(szTitle), "VirtualBox Guest Additions update available!");
|
---|
88 | # ifndef VBOX_OSE
|
---|
89 | RTStrPrintf(szMsg, sizeof(szMsg), "Your guest is currently running the Guest Additions version %s. "
|
---|
90 | "We recommend updating to the latest version (%s) by choosing the "
|
---|
91 | "install option from the Devices menu.", pszGuestVersion, pszHostVersion);
|
---|
92 | # else
|
---|
93 | /* This is the message which appears for non-Oracle builds of the
|
---|
94 | * Guest Additions. Distributors are encouraged to customise this. */
|
---|
95 | RTStrPrintf(szMsg, sizeof(szMsg), "Your virtual machine is currently running the Guest Additions version %s. Since you are running a version of the Guest Additions provided by the operating system you installed in the virtual machine we recommend that you update it to at least version %s using that system's update features, or alternatively that you remove this version and then install the " VBOX_VENDOR_SHORT " Guest Additions package using the install option from the Devices menu. Please consult the documentation for the operating system you are running to find out how to update or remove the current Guest Additions package.", pszGuestVersion, pszHostVersion);
|
---|
96 | # endif /* VBOX_OSE */
|
---|
97 | rc = VBClShowNotify(szTitle, szMsg);
|
---|
98 | }
|
---|
99 |
|
---|
100 | /* Store host version to not notify again */
|
---|
101 | int rc2 = VbglR3HostVersionLastCheckedStore(uGuestPropSvcClientID, pszHostVersion);
|
---|
102 | if (RT_SUCCESS(rc))
|
---|
103 | rc = rc2;
|
---|
104 |
|
---|
105 | VbglR3GuestPropReadValueFree(pszHostVersion);
|
---|
106 | VbglR3GuestPropReadValueFree(pszGuestVersion);
|
---|
107 | }
|
---|
108 |
|
---|
109 | VbglR3GuestPropDisconnect(uGuestPropSvcClientID);
|
---|
110 | #else /* !VBOX_WITH_GUEST_PROPS */
|
---|
111 | rc = VERR_NOT_SUPPORTED;
|
---|
112 | #endif /* VBOX_WITH_GUEST_PROPS */
|
---|
113 |
|
---|
114 | return rc;
|
---|
115 | }
|
---|
116 |
|
---|
117 | VBCLSERVICE g_SvcHostVersion =
|
---|
118 | {
|
---|
119 | "hostversion", /* szName */
|
---|
120 | "VirtualBox host version check", /* pszDescription */
|
---|
121 | ".vboxclient-hostversion.pid", /* pszPidFilePath */
|
---|
122 | NULL, /* pszUsage */
|
---|
123 | NULL, /* pszOptions */
|
---|
124 | NULL, /* pfnOption */
|
---|
125 | NULL, /* pfnInit */
|
---|
126 | vbclHostVerWorker, /* pfnWorker */
|
---|
127 | NULL, /* pfnStop*/
|
---|
128 | NULL /* pfnTerm */
|
---|
129 | };
|
---|
130 |
|
---|