From: Katy Feng Date: Thu, 16 Nov 2023 17:21:20 +0000 (-0800) Subject: Changes to common source files not applicable to open-vm-tools. X-Git-Tag: stable-12.4.0~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1910ed7b5ac64c98d03b14532f8af7460fa0ebe0;p=thirdparty%2Fopen-vm-tools.git Changes to common source files not applicable to open-vm-tools. --- diff --git a/open-vm-tools/hgfsclient/hgfsclient.c b/open-vm-tools/hgfsclient/hgfsclient.c index 3bbe76340..e34541855 100644 --- a/open-vm-tools/hgfsclient/hgfsclient.c +++ b/open-vm-tools/hgfsclient/hgfsclient.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (c) 2006-2019,2021 VMware, Inc. All rights reserved. + * Copyright (c) 2006-2019,2021,2023 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -419,6 +419,9 @@ main(int argc, // IN { #ifdef _WIN32 WinUtil_EnableSafePathSearching(TRUE); +# if defined(VMX86_RELEASE) + WinUtil_VerifyExePathW(); +# endif #endif if (argc == 2 && (!strncmp(argv[1], "-h", 2) || diff --git a/open-vm-tools/lib/guestApp/guestApp.c b/open-vm-tools/lib/guestApp/guestApp.c index ddac5de6e..35fde3794 100644 --- a/open-vm-tools/lib/guestApp/guestApp.c +++ b/open-vm-tools/lib/guestApp/guestApp.c @@ -31,6 +31,7 @@ #include #include #include "productState.h" +#include "conf.h" // for tools install path regkey #include "winregistry.h" #include "windowsUtil.h" #endif @@ -133,9 +134,6 @@ GuestApp_GetDefaultScript(const char *confName) // IN LPWSTR GuestApp_GetInstallPathW(void) { - static LPCWSTR TOOLS_KEY_NAME = L"Software\\VMware, Inc.\\VMware Tools"; - static LPCWSTR INSTALLPATH_VALUE_NAME = L"InstallPath"; - HKEY key = NULL; LONG rc; DWORD cbData = 0; @@ -153,17 +151,20 @@ GuestApp_GetInstallPathW(void) #ifdef TOOLS_ARM64 samDesired |= KEY_WOW64_32KEY; #endif - rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE, TOOLS_KEY_NAME, 0, samDesired, &key); + rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE, CONF_VMWARE_TOOLS_REGKEY_W, 0, + samDesired, &key); if (ERROR_SUCCESS != rc) { - Debug("%s: Couldn't open key \"%S\".\n", __FUNCTION__, TOOLS_KEY_NAME); + Debug("%s: Couldn't open key \"%S\".\n", __FUNCTION__, + CONF_VMWARE_TOOLS_REGKEY_W); Debug("%s: RegOpenKeyExW error 0x%x.\n", __FUNCTION__, GetLastError()); goto exit; } - rc = RegQueryValueExW(key, INSTALLPATH_VALUE_NAME, 0, NULL, NULL, &cbData); + rc = RegQueryValueExW(key, CONF_VMWARE_TOOLS_INSTPATH_KEY_W, 0, NULL, NULL, + &cbData); if (ERROR_SUCCESS != rc) { Debug("%s: Couldn't get length of value \"%S\".\n", __FUNCTION__, - INSTALLPATH_VALUE_NAME); + CONF_VMWARE_TOOLS_INSTPATH_KEY_W); Debug("%s: RegQueryValueExW error 0x%x.\n", __FUNCTION__, GetLastError()); goto exit; } @@ -179,11 +180,11 @@ GuestApp_GetInstallPathW(void) } temp = cbData; - rc = RegQueryValueExW(key, INSTALLPATH_VALUE_NAME, 0, NULL, (LPBYTE) data, + rc = RegQueryValueExW(key, CONF_VMWARE_TOOLS_INSTPATH_KEY_W, 0, NULL, (LPBYTE) data, &temp); if (ERROR_SUCCESS != rc) { Debug("%s: Couldn't get data for value \"%S\".\n", __FUNCTION__, - INSTALLPATH_VALUE_NAME); + CONF_VMWARE_TOOLS_INSTPATH_KEY_W); Debug("%s: RegQueryValueExW error 0x%x.\n", __FUNCTION__, GetLastError()); goto exit; } @@ -228,7 +229,7 @@ GuestApp_GetInstallPath(void) if (WinReg_GetSZ(HKEY_LOCAL_MACHINE, CONF_VMWARE_TOOLS_REGKEY, - "InstallPath", + CONF_VMWARE_TOOLS_INSTPATH_KEY, &pathUtf8) != ERROR_SUCCESS) { Warning("%s: Unable to retrieve install path: %s\n", __FUNCTION__, Msg_ErrString()); diff --git a/open-vm-tools/namespacetool/namespacetool.c b/open-vm-tools/namespacetool/namespacetool.c index 915f149e5..fd842ed62 100644 --- a/open-vm-tools/namespacetool/namespacetool.c +++ b/open-vm-tools/namespacetool/namespacetool.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (c) 2016-2020,2022 VMware, Inc. All rights reserved. + * Copyright (c) 2016-2020,2022-2023 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -635,6 +635,9 @@ main(int argc, char *argv[]) #if defined(_WIN32) WinUtil_EnableSafePathSearching(TRUE); +#if defined(VMX86_RELEASE) + WinUtil_VerifyExePathW(); +#endif #endif gAppName = g_path_get_basename(argv[0]); diff --git a/open-vm-tools/rpctool/rpctool.c b/open-vm-tools/rpctool/rpctool.c index 6220a0a83..b343b7655 100644 --- a/open-vm-tools/rpctool/rpctool.c +++ b/open-vm-tools/rpctool/rpctool.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2002-2020 VMware, Inc. All rights reserved. + * Copyright (c) 2002-2020, 2023 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -146,6 +146,9 @@ main(int argc, char *argv[]) #ifdef _WIN32 WinUtil_EnableSafePathSearching(TRUE); +#if defined(VMX86_RELEASE) + WinUtil_VerifyExePathW(); +#endif #endif /* diff --git a/open-vm-tools/toolbox/toolbox-cmd.c b/open-vm-tools/toolbox/toolbox-cmd.c index 585073f33..ae9b209a3 100644 --- a/open-vm-tools/toolbox/toolbox-cmd.c +++ b/open-vm-tools/toolbox/toolbox-cmd.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (c) 2008-2021 VMware, Inc. All rights reserved. + * Copyright (c) 2008-2021,2023 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -462,6 +462,9 @@ main(int argc, // IN: length of command line arguments char **argv; WinUtil_EnableSafePathSearching(TRUE); +# if defined(VMX86_RELEASE) + WinUtil_VerifyExePathW(); +# endif Unicode_InitW(argc, wargv, NULL, &argv, NULL); #else diff --git a/open-vm-tools/vgauthImport/vgauthImport.c b/open-vm-tools/vgauthImport/vgauthImport.c index e96d19de7..3b2d14629 100644 --- a/open-vm-tools/vgauthImport/vgauthImport.c +++ b/open-vm-tools/vgauthImport/vgauthImport.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (c) 2012,2018-2021 VMware, Inc. All rights reserved. + * Copyright (c) 2012,2018-2021, 2023 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -522,8 +522,17 @@ main(int argc, char *argv[]) { NULL }, }; GOptionContext *optCtx; + +/* + * Using WinUtil_EnableSafePathSearching() and WinUtil_VerifyExePathW() from + * "vmware/tools/win32util.h" rather than the ones + * in vgauth/common/winUtil.h, since this app is generic toolbox apps. + */ #ifdef _WIN32 WinUtil_EnableSafePathSearching(TRUE); +#if defined(VMX86_RELEASE) + WinUtil_VerifyExePathW(); +#endif #endif /*