diff -Nru open-vm-tools-11.3.5/debian/changelog open-vm-tools-12.1.5/debian/changelog --- open-vm-tools-11.3.5/debian/changelog 2022-08-16 13:21:12.000000000 +0000 +++ open-vm-tools-12.1.5/debian/changelog 2023-07-25 04:09:02.000000000 +0000 @@ -1,33 +1,132 @@ -open-vm-tools (2:11.3.5-1ubuntu4.1) jammy-security; urgency=medium +open-vm-tools (2:12.1.5-3~ubuntu0.22.04.2) jammy-security; urgency=medium - * SECURITY UPDATE: local privilege escalation - - debian/patches/CVE-2022-31676.patch: check authorization on incoming - guestOps requests in open-vm-tools/vgauth/serviceImpl/proto.c. - - CVE-2022-31676 + * SECURITY UPDATE: authentication bypass vulnerability + - debian/patches/CVE-2023-20867.patch: Remove some dead code + - CVE-2023-20867 - -- Marc Deslauriers Tue, 16 Aug 2022 09:21:12 -0400 + -- Nishit Majithia Tue, 25 Jul 2023 09:39:02 +0530 -open-vm-tools (2:11.3.5-1ubuntu4) jammy; urgency=medium +open-vm-tools (2:12.1.5-3~ubuntu0.22.04.1) jammy; urgency=medium - * No-change rebuild to update maintainer scripts, see LP: 1959054 + * Backport recent open-vm-tools release v12.1.5 + (LP: #1998558) + * d/control: Add libabsl-dev as explicit build-dependency. + - (Closes #1032305) - -- Dave Jones Wed, 16 Feb 2022 17:15:58 +0000 + -- Bryce Harrington Thu, 16 Mar 2023 23:57:03 +0000 -open-vm-tools (2:11.3.5-1ubuntu3) jammy; urgency=medium +open-vm-tools (2:12.1.5-3) unstable; urgency=medium - * d/control, d/rules: other dependencies seem to be all ready, switch - to fuse3 again (LP 1956949 LP 1935665) - * d/p/libc-2.35-compat-FTBFS-fix.patch: fix FTBFS with glibc 2.35 - (LP: #1960224) + * [1e4d8a9] Remove libprocps-dev build-dep. (Closes: #1027271) - -- Christian Ehrhardt Tue, 01 Feb 2022 16:29:32 +0100 + -- Bernd Zeimetz Tue, 03 Jan 2023 12:19:05 +0100 -open-vm-tools (2:11.3.5-1ubuntu2) jammy; urgency=medium +open-vm-tools (2:12.1.5-2) unstable; urgency=medium - * d/control, d/rules: go back to fuse3 until all other - packages are ready (LP: #1956949) + * [f450cf8] Fix building with gRPC 1.51+ + Thanks to Laszlo Boszormenyi (GCS) (Closes: #1025491) - -- Christian Ehrhardt Mon, 10 Jan 2022 14:44:22 +0100 + -- Bernd Zeimetz Sat, 24 Dec 2022 16:52:48 +0100 + +open-vm-tools (2:12.1.5-1) unstable; urgency=medium + + * [d4a64a2] New upstream version 12.1.5 + * [adcd7a9] Remove accidentally added patch backup files + + -- Bernd Zeimetz Wed, 07 Dec 2022 17:30:35 +0100 + +open-vm-tools (2:12.1.0-2) unstable; urgency=medium + + [ Debian Janitor ] + * [2d8b9bb] Update lintian override info to new format on line 2. + Changes-By: lintian-brush + Fixes: lintian: mismatched-override + See-also: https://lintian.debian.org/tags/mismatched-override.html + + [ Bernd Zeimetz ] + * [fa63406] Move libguestStore.so, libgdp.so to open-vm-tools + (Closes: #1021611) (LP: #1992501) + + -- Bernd Zeimetz Mon, 14 Nov 2022 16:19:10 +0100 + +open-vm-tools (2:12.1.0-1~ubuntu0.22.04.1) jammy; urgency=medium + + * Backport recent open-vm-tools (LP: #1975767) + - Fixes issue with "udevadm trigger" affecting all devices + that can cause unwanted side-effects. + (LP: #1968354) + - Adds new binary open-vm-tools-containerinfo that installs the + vRealize Container Info plugin, which captures and publishes + information about running containers inside the guest. + - Adds new binary open-vm-tools-salt-minion that installs the Salt + Minion plugin for event driven IT automation, remote task execution, + and configuration management. + + -- Bryce Harrington Mon, 19 Sep 2022 17:52:55 +0000 + +open-vm-tools (2:12.1.0-1) unstable; urgency=high + + * [e704b2c] New upstream version 12.1.0 + Closes: #1018012 / CVE-2022-31676 + * [f9048c4] Remove patches applied upstream + + -- Bernd Zeimetz Wed, 24 Aug 2022 09:49:58 +0200 + +open-vm-tools (2:12.0.5-2) unstable; urgency=medium + + * Release 12.0.5 to unstable + - also (Closes: #1012814) + + -- Christian Ehrhardt Wed, 13 Jul 2022 11:30:52 +0200 + +open-vm-tools (2:12.0.5-1) experimental; urgency=medium + + [ Christian Ehrhardt ] + * [827c3e4] New upstream version 12.0.5 (LP: #1971253) (Closes: #1011633) + * [0d65b0785] d/copyright: fix whitespace damage + * [e831bdcce] d/control,d/rules: salt-minion is not supported or even built on + i386/arm64 + + [ Bryce Harrington ] + * [6a499a388] d/control: bump Standards-Version to 4.6.1 (no changes needed) + * [e0b695cf9] d/copyright: Update debian copyright to 2022 + * [11f2f331d] d/control: Improve plugin description + * [aa14fc72b] d/control, d/rules, d/*containerinfo*: add containerinfo plugin + * [441d7a31c] d/control, d/rules, d/*salt-minion*: Add salt-minion plugin + * [291c71b07] d/copyright: Add myself and Christian + + -- Christian Ehrhardt Mon, 11 Jul 2022 07:48:32 +0200 + +open-vm-tools (2:12.0.0-2) unstable; urgency=medium + + * [2eaee7c] Add dependencies for the containerinfo plugin. + * [c21ef1d] Fix building containerinfo on i386 + %ld is not a 64bit integer on i386. + * [5b23cd3] Use G_GINT64_FORMAT instead of lld + + -- Bernd Zeimetz Mon, 02 May 2022 19:06:08 +0200 + +open-vm-tools (2:12.0.0-1) unstable; urgency=medium + + [ Debian Janitor Bot ] + * [b8a7e72] Bump debhelper from old 12 to 13. + Rename debian/open-vm-tools-desktop.tmpfile to debian/open-vm-tools-desktop.tmpfiles. + Changes-By: lintian-brush + Fixes: lintian: package-uses-old-debhelper-compat-version + See-also: https://lintian.debian.org/tags/package-uses-old-debhelper-compat-version.html + * [db353fc] Update renamed lintian tag names in lintian overrides. + Changes-By: lintian-brush + Fixes: lintian: renamed-tag + See-also: https://lintian.debian.org/tags/renamed-tag.html + * [e836429] Set upstream metadata fields: Archive. + Changes-By: lintian-brush + + [ Bernd Zeimetz ] + * [c68b4a7] New upstream version 12.0.0 (Closes: #1006845) + * [5e498c2] Refresh patches + * [d1a0fb3] udevadm: trigger only for scsi devices on install. + Thanks to Benjamin Drung (Closes: #1009194) + + -- Bernd Zeimetz Wed, 27 Apr 2022 11:54:11 +0200 open-vm-tools (2:11.3.5-1) unstable; urgency=medium diff -Nru open-vm-tools-11.3.5/debian/control open-vm-tools-12.1.5/debian/control --- open-vm-tools-11.3.5/debian/control 2022-02-01 15:29:32.000000000 +0000 +++ open-vm-tools-12.1.5/debian/control 2023-03-16 23:57:03.000000000 +0000 @@ -5,9 +5,9 @@ XSBC-Original-Maintainer: Bernd Zeimetz Uploaders: Christian Ehrhardt Build-Depends: - debhelper-compat (= 12), doxygen, libcunit1-dev, + debhelper-compat (= 13), doxygen, libcunit1-dev, libfuse3-dev, libgtkmm-3.0-dev, libgtk-3-dev, - libicu-dev, libnotify-dev, libpam0g-dev, libprocps-dev, libx11-dev, + libicu-dev, libnotify-dev, libpam0g-dev, libx11-dev, libxinerama-dev, libxss-dev, libxtst-dev, libmspack-dev, libssl-dev, @@ -16,7 +16,14 @@ libdrm-dev, liblzma-dev, libgdk-pixbuf-xlib-2.0-dev, -Standards-Version: 4.5.1 + libcurl4-openssl-dev, + protobuf-compiler, + libprotobuf-dev, + protobuf-compiler-grpc, + libgrpc++-dev, libabsl-dev, + golang-github-containerd-containerd-dev, + golang-github-gogo-protobuf-dev, +Standards-Version: 4.6.1 Homepage: https://github.com/vmware/open-vm-tools Vcs-Git: https://salsa.debian.org/vmware-packaging-team/pkg-open-vm-tools.git Vcs-Browser: https://salsa.debian.org/vmware-packaging-team/pkg-open-vm-tools @@ -26,7 +33,10 @@ Pre-Depends: ${misc:Pre-Depends} Depends: ${misc:Depends}, ${shlibs:Depends}, pciutils, iproute2, lsb-release Recommends: ethtool, zerofree, fuse3 -Suggests: open-vm-tools-desktop, cloud-init +Breaks: open-vm-tools-sdmp (<< 2:12.1.0-2~) +Replaces: open-vm-tools-sdmp (<< 2:12.1.0-2~) +Suggests: open-vm-tools-desktop, cloud-init, + open-vm-tools-containerinfo, open-vm-tools-salt-minion [amd64] Description: Open VMware Tools for virtual machines hosted on VMware (CLI) The Open Virtual Machine Tools (open-vm-tools) project is an open source implementation of VMware Tools. It is a suite of virtualization utilities and @@ -65,8 +75,34 @@ drivers to improve the functionality, user experience and administration of VMware virtual machines. . - This package contains service discover plugin required to discover services - then used to build relationships between VMs in vRealiize. + This package contains the vRealize Operations Service Discovery + Management Pack (SDMP) plugin, which discovers services running in VMs + and builds relationships between them in vRealize. + +Package: open-vm-tools-containerinfo +Architecture: amd64 i386 arm64 +Depends: ${misc:Depends}, ${shlibs:Depends}, open-vm-tools (= ${binary:Version}) +Description: Open VMware Tools for VMs hosted on VMware (Service Discovery Plugin) + The Open Virtual Machine Tools (open-vm-tools) project is an open source + implementation of VMware Tools. It is a suite of virtualization utilities and + drivers to improve the functionality, user experience and administration of + VMware virtual machines. + . + This package contains the vRealize Container Info plugin, which + captures and publishes information about running containers inside the + guest. + +Package: open-vm-tools-salt-minion +Architecture: amd64 +Depends: ${misc:Depends}, ${shlibs:Depends}, open-vm-tools (= ${binary:Version}) +Description: Open VMware Tools for VMs hosted on VMware (Service Discovery Plugin) + The Open Virtual Machine Tools (open-vm-tools) project is an open source + implementation of VMware Tools. It is a suite of virtualization utilities and + drivers to improve the functionality, user experience and administration of + VMware virtual machines. + . + This package contains the Salt Minion plugin for event driven IT + automation, remote task execution, and configuration management. Package: open-vm-tools-dev Section: devel diff -Nru open-vm-tools-11.3.5/debian/copyright open-vm-tools-12.1.5/debian/copyright --- open-vm-tools-11.3.5/debian/copyright 2022-01-04 07:52:44.000000000 +0000 +++ open-vm-tools-12.1.5/debian/copyright 2023-03-16 21:15:40.000000000 +0000 @@ -29,7 +29,9 @@ Files: debian/* Copyright: 2007-2013 Daniel Baumann - 2014-2019 Bernd Zeimetz + 2014-2022 Bernd Zeimetz + 2017-2022 Christian Ehrhardt License: GPL-2+ License: BSD-3 diff -Nru open-vm-tools-11.3.5/debian/open-vm-tools-containerinfo.postinst open-vm-tools-12.1.5/debian/open-vm-tools-containerinfo.postinst --- open-vm-tools-11.3.5/debian/open-vm-tools-containerinfo.postinst 1970-01-01 00:00:00.000000000 +0000 +++ open-vm-tools-12.1.5/debian/open-vm-tools-containerinfo.postinst 2023-03-16 21:15:40.000000000 +0000 @@ -0,0 +1,42 @@ +#!/bin/sh +# postinst script for open-vm-tools-containerinfo +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see https://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + configure) + if deb-systemd-invoke -q is-active open-vm-tools.service; then + deb-systemd-invoke try-restart open-vm-tools + fi + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff -Nru open-vm-tools-11.3.5/debian/open-vm-tools-containerinfo.postrm open-vm-tools-12.1.5/debian/open-vm-tools-containerinfo.postrm --- open-vm-tools-11.3.5/debian/open-vm-tools-containerinfo.postrm 1970-01-01 00:00:00.000000000 +0000 +++ open-vm-tools-12.1.5/debian/open-vm-tools-containerinfo.postrm 2023-03-16 21:15:40.000000000 +0000 @@ -0,0 +1,43 @@ +#!/bin/sh +# postrm script for open-vm-tools-containerinfo +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `remove' +# * `purge' +# * `upgrade' +# * `failed-upgrade' +# * `abort-install' +# * `abort-install' +# * `abort-upgrade' +# * `disappear' +# +# for details, see https://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + purge|remove) + if deb-systemd-invoke -q is-active open-vm-tools.service; then + deb-systemd-invoke try-restart open-vm-tools + fi + ;; + + upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + ;; + + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff -Nru open-vm-tools-11.3.5/debian/open-vm-tools-desktop.lintian-overrides open-vm-tools-12.1.5/debian/open-vm-tools-desktop.lintian-overrides --- open-vm-tools-11.3.5/debian/open-vm-tools-desktop.lintian-overrides 2022-01-04 07:52:44.000000000 +0000 +++ open-vm-tools-12.1.5/debian/open-vm-tools-desktop.lintian-overrides 2023-03-16 22:05:54.000000000 +0000 @@ -1,5 +1,5 @@ # intentional setuid -open-vm-tools-desktop: setuid-binary usr/bin/vmware-user-suid-wrapper 4755 root/root +open-vm-tools-desktop: elevated-privileges 4755 root/root [usr/bin/vmware-user-suid-wrapper] # not existing - https://github.com/vmware/open-vm-tools/issues/526 open-vm-tools-desktop: no-manual-page usr/bin/vmware-user open-vm-tools-desktop: no-manual-page usr/bin/vmwgfxctrl diff -Nru open-vm-tools-11.3.5/debian/open-vm-tools-desktop.tmpfile open-vm-tools-12.1.5/debian/open-vm-tools-desktop.tmpfile --- open-vm-tools-11.3.5/debian/open-vm-tools-desktop.tmpfile 2022-01-04 07:52:44.000000000 +0000 +++ open-vm-tools-12.1.5/debian/open-vm-tools-desktop.tmpfile 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -d /tmp/VMwareDnD 1777 root root 10d diff -Nru open-vm-tools-11.3.5/debian/open-vm-tools-desktop.tmpfiles open-vm-tools-12.1.5/debian/open-vm-tools-desktop.tmpfiles --- open-vm-tools-11.3.5/debian/open-vm-tools-desktop.tmpfiles 1970-01-01 00:00:00.000000000 +0000 +++ open-vm-tools-12.1.5/debian/open-vm-tools-desktop.tmpfiles 2023-03-16 21:15:40.000000000 +0000 @@ -0,0 +1 @@ +d /tmp/VMwareDnD 1777 root root 10d diff -Nru open-vm-tools-11.3.5/debian/open-vm-tools.postinst open-vm-tools-12.1.5/debian/open-vm-tools.postinst --- open-vm-tools-11.3.5/debian/open-vm-tools.postinst 2022-01-04 07:52:44.000000000 +0000 +++ open-vm-tools-12.1.5/debian/open-vm-tools.postinst 2023-03-16 21:15:40.000000000 +0000 @@ -5,7 +5,7 @@ case "${1}" in configure) if which udevadm 1>/dev/null; then - udevadm trigger || true + udevadm trigger --type=devices --subsystem-match=scsi || true fi ;; diff -Nru open-vm-tools-11.3.5/debian/open-vm-tools-salt-minion.postinst open-vm-tools-12.1.5/debian/open-vm-tools-salt-minion.postinst --- open-vm-tools-11.3.5/debian/open-vm-tools-salt-minion.postinst 1970-01-01 00:00:00.000000000 +0000 +++ open-vm-tools-12.1.5/debian/open-vm-tools-salt-minion.postinst 2023-03-16 21:15:40.000000000 +0000 @@ -0,0 +1,42 @@ +#!/bin/sh +# postinst script for open-vm-tools-salt-minion +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see https://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + configure) + if deb-systemd-invoke -q is-active open-vm-tools.service; then + deb-systemd-invoke try-restart open-vm-tools + fi + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff -Nru open-vm-tools-11.3.5/debian/open-vm-tools-salt-minion.postrm open-vm-tools-12.1.5/debian/open-vm-tools-salt-minion.postrm --- open-vm-tools-11.3.5/debian/open-vm-tools-salt-minion.postrm 1970-01-01 00:00:00.000000000 +0000 +++ open-vm-tools-12.1.5/debian/open-vm-tools-salt-minion.postrm 2023-03-16 21:15:40.000000000 +0000 @@ -0,0 +1,43 @@ +#!/bin/sh +# postrm script for open-vm-tools-salt-minion +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `remove' +# * `purge' +# * `upgrade' +# * `failed-upgrade' +# * `abort-install' +# * `abort-install' +# * `abort-upgrade' +# * `disappear' +# +# for details, see https://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + purge|remove) + if deb-systemd-invoke -q is-active open-vm-tools.service; then + deb-systemd-invoke try-restart open-vm-tools + fi + ;; + + upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + ;; + + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff -Nru open-vm-tools-11.3.5/debian/patches/CVE-2022-31676.patch open-vm-tools-12.1.5/debian/patches/CVE-2022-31676.patch --- open-vm-tools-11.3.5/debian/patches/CVE-2022-31676.patch 2022-08-16 13:20:33.000000000 +0000 +++ open-vm-tools-12.1.5/debian/patches/CVE-2022-31676.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -From be635a7eaf7bd19177b7002aa2c793c78be77ecc Mon Sep 17 00:00:00 2001 -From: John Wolfe -Date: Wed, 10 Aug 2022 07:20:28 -0700 -Subject: [PATCH] Properly check authorization on incoming guestOps requests - -Fix public pipe request checks. Only a SessionRequest type should -be accepted on the public pipe. ---- - open-vm-tools/vgauth/serviceImpl/proto.c | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/open-vm-tools/vgauth/serviceImpl/proto.c b/open-vm-tools/vgauth/serviceImpl/proto.c -index db7159e..c4f85b0 100644 ---- a/open-vm-tools/vgauth/serviceImpl/proto.c -+++ b/open-vm-tools/vgauth/serviceImpl/proto.c -@@ -1,5 +1,5 @@ - /********************************************************* -- * Copyright (C) 2011-2016,2019-2021 VMware, Inc. All rights reserved. -+ * Copyright (c) 2011-2016,2019-2022 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 -@@ -1201,6 +1201,10 @@ Proto_SecurityCheckRequest(ServiceConnection *conn, - VGAuthError err; - gboolean isSecure = ServiceNetworkIsConnectionPrivateSuperUser(conn); - -+ if (conn->isPublic && req->reqType != PROTO_REQUEST_SESSION_REQ) { -+ return VGAUTH_E_PERMISSION_DENIED; -+ } -+ - switch (req->reqType) { - /* - * This comes over the public connection; alwsys let it through. --- -2.6.2 - diff -Nru open-vm-tools-11.3.5/debian/patches/CVE-2023-20867.patch open-vm-tools-12.1.5/debian/patches/CVE-2023-20867.patch --- open-vm-tools-11.3.5/debian/patches/CVE-2023-20867.patch 1970-01-01 00:00:00.000000000 +0000 +++ open-vm-tools-12.1.5/debian/patches/CVE-2023-20867.patch 2023-07-25 03:37:57.000000000 +0000 @@ -0,0 +1,151 @@ +From 3028cdd4c0b2461b904cbe5a5868c8e591aa0941 Mon Sep 17 00:00:00 2001 +From: John Wolfe +Date: Mon, 8 May 2023 19:04:57 -0700 +Subject: [PATCH] Remove some dead code. + +Address CVE-2023-20867. +Remove some authentication types which were deprecated long +ago and are no longer in use. These are dead code. +--- + open-vm-tools/services/plugins/vix/vixTools.c | 102 -------------------------- + 1 file changed, 102 deletions(-) + +--- open-vm-tools-12.1.5.orig/open-vm-tools/services/plugins/vix/vixTools.c ++++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/vix/vixTools.c +@@ -254,8 +254,6 @@ char *gImpersonatedUsername = NULL; + #define VIX_TOOLS_CONFIG_API_AUTHENTICATION "Authentication" + #define VIX_TOOLS_CONFIG_AUTHTYPE_AGENTS "InfrastructureAgents" + +-#define VIX_TOOLS_CONFIG_INFRA_AGENT_DISABLED_DEFAULT TRUE +- + /* + * The switch that controls all APIs + */ +@@ -730,9 +728,6 @@ VixError GuestAuthSAMLAuthenticateAndImp + + void GuestAuthUnimpersonate(); + +-static Bool VixToolsCheckIfAuthenticationTypeEnabled(GKeyFile *confDictRef, +- const char *typeName); +- + #if SUPPORT_VGAUTH + + VGAuthError TheVGAuthContext(VGAuthContext **ctx); +@@ -7913,29 +7908,6 @@ VixToolsImpersonateUser(VixCommandReques + userToken); + break; + } +- case VIX_USER_CREDENTIAL_ROOT: +- { +- if ((requestMsg->requestFlags & VIX_REQUESTMSG_HAS_HASHED_SHARED_SECRET) && +- !VixToolsCheckIfAuthenticationTypeEnabled(gConfDictRef, +- VIX_TOOLS_CONFIG_AUTHTYPE_AGENTS)) { +- /* +- * Don't accept hashed shared secret if disabled. +- */ +- g_message("%s: Requested authentication type has been disabled.\n", +- __FUNCTION__); +- err = VIX_E_GUEST_AUTHTYPE_DISABLED; +- goto done; +- } +- } +- // fall through +- +- case VIX_USER_CREDENTIAL_CONSOLE_USER: +- err = VixToolsImpersonateUserImplEx(NULL, +- credentialType, +- NULL, +- loadUserProfile, +- userToken); +- break; + case VIX_USER_CREDENTIAL_NAME_PASSWORD: + case VIX_USER_CREDENTIAL_NAME_PASSWORD_OBFUSCATED: + case VIX_USER_CREDENTIAL_NAMED_INTERACTIVE_USER: +@@ -8105,36 +8077,6 @@ VixToolsImpersonateUserImplEx(char const + } + + /* +- * If the VMX asks to be root, then we allow them. +- * The VMX will make sure that only it will pass this value in, +- * and only when the VM and host are configured to allow this. +- */ +- if ((VIX_USER_CREDENTIAL_ROOT == credentialType) +- && (thisProcessRunsAsRoot)) { +- *userToken = PROCESS_CREATOR_USER_TOKEN; +- +- gImpersonatedUsername = Util_SafeStrdup("_ROOT_"); +- err = VIX_OK; +- goto quit; +- } +- +- /* +- * If the VMX asks to be root, then we allow them. +- * The VMX will make sure that only it will pass this value in, +- * and only when the VM and host are configured to allow this. +- * +- * XXX This has been deprecated XXX +- */ +- if ((VIX_USER_CREDENTIAL_CONSOLE_USER == credentialType) +- && ((allowConsoleUserOps) || !(thisProcessRunsAsRoot))) { +- *userToken = PROCESS_CREATOR_USER_TOKEN; +- +- gImpersonatedUsername = Util_SafeStrdup("_CONSOLE_USER_NAME_"); +- err = VIX_OK; +- goto quit; +- } +- +- /* + * If the VMX asks us to run commands in the context of the current + * user, make sure that the user who requested the command is the + * same as the current user. +@@ -10814,50 +10756,6 @@ VixToolsCheckIfVixCommandEnabled(int opc + } + + +-/* +- *----------------------------------------------------------------------------- +- * +- * VixToolsCheckIfAuthenticationTypeEnabled -- +- * +- * Checks to see if a given authentication type has been +- * disabled via the tools configuration. +- * +- * Return value: +- * TRUE if enabled, FALSE otherwise. +- * +- * Side effects: +- * None +- * +- *----------------------------------------------------------------------------- +- */ +- +-static Bool +-VixToolsCheckIfAuthenticationTypeEnabled(GKeyFile *confDictRef, // IN +- const char *typeName) // IN +-{ +- char authnDisabledName[64]; // Authentication..disabled +- gboolean disabled; +- +- Str_Snprintf(authnDisabledName, sizeof(authnDisabledName), +- VIX_TOOLS_CONFIG_API_AUTHENTICATION ".%s.disabled", +- typeName); +- +- ASSERT(confDictRef != NULL); +- +- /* +- * XXX Skip doing the strcmp() to verify the auth type since we only +- * have the one typeName (VIX_TOOLS_CONFIG_AUTHTYPE_AGENTS), and default +- * it to VIX_TOOLS_CONFIG_INFRA_AGENT_DISABLED_DEFAULT. +- */ +- disabled = VMTools_ConfigGetBoolean(confDictRef, +- VIX_TOOLS_CONFIG_API_GROUPNAME, +- authnDisabledName, +- VIX_TOOLS_CONFIG_INFRA_AGENT_DISABLED_DEFAULT); +- +- return !disabled; +-} +- +- + /* + *----------------------------------------------------------------------------- + * diff -Nru open-vm-tools-11.3.5/debian/patches/debian/grpc_1.51 open-vm-tools-12.1.5/debian/patches/debian/grpc_1.51 --- open-vm-tools-11.3.5/debian/patches/debian/grpc_1.51 1970-01-01 00:00:00.000000000 +0000 +++ open-vm-tools-12.1.5/debian/patches/debian/grpc_1.51 2023-03-16 22:05:54.000000000 +0000 @@ -0,0 +1,13 @@ +Index: pkg-open-vm-tools/open-vm-tools/services/plugins/containerInfo/Makefile.am +=================================================================== +--- pkg-open-vm-tools.orig/open-vm-tools/services/plugins/containerInfo/Makefile.am ++++ pkg-open-vm-tools/open-vm-tools/services/plugins/containerInfo/Makefile.am +@@ -63,6 +63,8 @@ libcontainerInfo_la_SOURCES += container + libcontainerInfo_la_CPPFLAGS += @GRPC_CPPFLAGS@ + libcontainerInfo_la_LDFLAGS += -lprotobuf + libcontainerInfo_la_LDFLAGS += -lgrpc++ ++libcontainerInfo_la_LDFLAGS += -lgpr ++libcontainerInfo_la_LDFLAGS += -labsl_synchronization + + tasks.grpc.pb.cc containers.grpc.pb.cc: %.grpc.pb.cc : %.proto %.pb.cc + $(PROTOC) -I. -I$(GOGO_PROTOPATH) \ diff -Nru open-vm-tools-11.3.5/debian/patches/libc-2.35-compat-FTBFS-fix.patch open-vm-tools-12.1.5/debian/patches/libc-2.35-compat-FTBFS-fix.patch --- open-vm-tools-11.3.5/debian/patches/libc-2.35-compat-FTBFS-fix.patch 2022-02-01 15:29:32.000000000 +0000 +++ open-vm-tools-12.1.5/debian/patches/libc-2.35-compat-FTBFS-fix.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -Description: Avoid FTBFS with glibc 2.35 - Due to changes in libc6 a build that uses - 1. LTO: -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects - 2. Optimiziation with gcc: -O2 - 3. Gcc 11.2.0 - Will hit an build error as the linking step will now detect a potential - -Wstringop-overflow issue. - Reported to upstream and for now ignored in the Ubuntu build. -Forwarded: not-needed -X-Not-Forwarded-Reason: we'd want a real fix instead of just ignoring the error -Author: Christian Ehrhardt -Bug-Ubuntu: https://bugs.launchpad.net/bugs/1960224 -Bug-Upstream: https://github.com/vmware/open-vm-tools/issues/570 -Last-Update: 2022-02-07 - ---- - open-vm-tools/lib/asyncsocket/asyncsocket.c | 7 +++++++ - 1 file changed, 7 insertions(+) - -diff --git a/open-vm-tools/lib/asyncsocket/asyncsocket.c b/open-vm-tools/lib/asyncsocket/asyncsocket.c -index 05147d2e..546932ec 100644 ---- a/open-vm-tools/lib/asyncsocket/asyncsocket.c -+++ b/open-vm-tools/lib/asyncsocket/asyncsocket.c -@@ -2850,6 +2850,10 @@ AsyncTCPSocketPollWork(AsyncTCPSocket **asock, // IN: - pfd[i].events = read ? POLLIN : POLLOUT; - } - -+#if defined(__GNUC__) && (__GNUC__ >= 11) -+#pragma GCC diagnostic push -+#pragma GCC diagnostic ignored "-Wstringop-overflow" -+#endif - if (parentSock != NULL) { - AsyncTCPSocketUnlock(parentSock); - retval = poll(pfd, numSock, timeoutMS); -@@ -2863,6 +2867,9 @@ AsyncTCPSocketPollWork(AsyncTCPSocket **asock, // IN: - AsyncTCPSocketLock(asock[i]); - } - } -+#if defined(__GNUC__) && (__GNUC__ >= 11) -+#pragma GCC diagnostic pop -+#endif - #else - tv.tv_sec = timeoutMS / 1000; - tv.tv_usec = (timeoutMS % 1000) * 1000; --- -2.34.1 - diff -Nru open-vm-tools-11.3.5/debian/patches/series open-vm-tools-12.1.5/debian/patches/series --- open-vm-tools-11.3.5/debian/patches/series 2022-08-16 13:21:04.000000000 +0000 +++ open-vm-tools-12.1.5/debian/patches/series 2023-07-25 03:37:53.000000000 +0000 @@ -1,5 +1,4 @@ use-debian-pam debian/scsi-udev-rule -Update-open-vm-tools-to-build-with-either-Fuse-3-or-2.patch -libc-2.35-compat-FTBFS-fix.patch -CVE-2022-31676.patch +debian/grpc_1.51 +CVE-2023-20867.patch diff -Nru open-vm-tools-11.3.5/debian/patches/Update-open-vm-tools-to-build-with-either-Fuse-3-or-2.patch open-vm-tools-12.1.5/debian/patches/Update-open-vm-tools-to-build-with-either-Fuse-3-or-2.patch --- open-vm-tools-11.3.5/debian/patches/Update-open-vm-tools-to-build-with-either-Fuse-3-or-2.patch 2022-01-04 13:54:40.000000000 +0000 +++ open-vm-tools-12.1.5/debian/patches/Update-open-vm-tools-to-build-with-either-Fuse-3-or-2.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,785 +0,0 @@ -From 97917fce5828ef0efdae59d7bb6e4dd7f0caeae0 Mon Sep 17 00:00:00 2001 -From: John Wolfe -Date: Tue, 21 Dec 2021 12:48:50 -0800 -Subject: [PATCH] Update open-vm-tools to build with either Fuse 3 or Fuse 2 - -Vendors are requesting that open-vm-tools can be built with either -Fuse 2 or Fuse 3. While both Fuse 2 and Fuse 3 runtime can be -installed on a Linux system, vendors would prefer to switch from -Fuse 2 to Fuse 3 at the same time for all products to be available -with the base OS. - -Updating the configure.ac file to check for the presence of the Fuse 3 -or Fuse 2 development packages in the build environment. Providing -configure options to allow users to control the version of Fuse to be -used. - --without-fuse - vmblock-fuse and vmhgfs-fuse will be disabled. - --with-fuse=fuse3|3 - use Fuse 3.x - --with-fuse=fuse|2 - use Fuse 2.x - --with-fuse=auto - check for Fuse 3 or Fuse 2 availability; disable - vmblock-fuse and vmhgfs-fuse if unavailable. - --with-fuse - implicit "yes". - --with-fuse=yes - check for Fuse 3 or Fuse 2 availability; disable - vmblock-fuse and vmhgfs-fuse if unavailable. - -Pull request: https://github.com/vmware/open-vm-tools/pull/544 -Fixes issue: https://github.com/vmware/open-vm-tools/issues/314 - -The vmblock-fuse code is also used by WorkStation. Configure defines -are not available in internal builds. Reworked preprocessor tests to -use FUSE_MAJOR_VERSION from the fuse headers to determine API to be -used during compilation. - -Origin: upstream, https://github.com/vmware/open-vm-tools/commit/97917fce -Bug-Ubuntu: https://bugs.launchpad.net/bugs/1935665 -Last-Update: 2022-01-04 - ---- - open-vm-tools/AUTHORS | 3 + - open-vm-tools/configure.ac | 100 +++++++++++++++++--- - open-vm-tools/tests/testVmblock/Makefile.am | 14 ++- - open-vm-tools/vmblock-fuse/Makefile.am | 4 +- - open-vm-tools/vmblock-fuse/fsops.c | 50 ++++++++-- - open-vm-tools/vmblock-fuse/fsops.h | 19 +++- - open-vm-tools/vmblock-fuse/main.c | 6 +- - open-vm-tools/vmhgfs-fuse/Makefile.am | 4 +- - open-vm-tools/vmhgfs-fuse/config.c | 24 ++++- - open-vm-tools/vmhgfs-fuse/dir.c | 6 +- - open-vm-tools/vmhgfs-fuse/main.c | 78 +++++++++++---- - open-vm-tools/vmhgfs-fuse/module.h | 10 +- - 12 files changed, 262 insertions(+), 56 deletions(-) - -diff --git a/open-vm-tools/AUTHORS b/open-vm-tools/AUTHORS -index 262a99951..bb6d0c663 100644 ---- a/open-vm-tools/AUTHORS -+++ b/open-vm-tools/AUTHORS -@@ -76,3 +76,6 @@ Vincent Milum Jr Adding FreeBSD on ARM64 support to open-vm-tools. - - Miroslav Rezanina Fix issues using GCC 11 with gtk >= 3.20 and glib >=2.66.3 - - https://github.com/vmware/open-vm-tools/pull/505 -+ -+Marco Trevisan Update open-vm-tools to build with either Fuse 3 or Fuse 2 -+ - https://github.com/vmware/open-vm-tools/pull/544 -diff --git a/open-vm-tools/configure.ac b/open-vm-tools/configure.ac -index 1a7b70000..2c4f097f9 100644 ---- a/open-vm-tools/configure.ac -+++ b/open-vm-tools/configure.ac -@@ -540,16 +540,93 @@ fi - # - # Check for fuse. - # --AC_VMW_CHECK_LIB([fuse], -- [FUSE], -- [fuse], -- [], -- [], -- [fuse.h], -- [fuse_main], -- [have_fuse=yes], -- [have_fuse=no; -- AC_MSG_WARN([Fuse is missing, vmblock-fuse/vmhgfs-fuse will be disabled.])]) -+ -+AC_ARG_WITH([fuse], -+ [AS_HELP_STRING([--without-fuse], -+ [compiles without FUSE support (disables vmblock-fuse/vmhgfs-fuse).])], -+ [with_fuse="$withval"], -+ [with_fuse=auto]) -+ -+case "$with_fuse" in -+ fuse|2) -+ with_fuse="fuse" -+ ;; -+ fuse3|3) -+ with_fuse="fuse3" -+ ;; -+ auto) -+ ;; -+ yes) -+ ;; -+ no) -+ have_fuse3=no; -+ have_fuse=no; -+ ;; -+ *) -+ AC_MSG_FAILURE([--with-fuse was given with an unsupported paramter $with_fuse]) -+ ;; -+esac -+ -+ -+if test "$with_fuse" = "auto" || -+ test "$with_fuse" = "fuse3" || -+ test "$with_fuse" = "yes"; then -+ # -+ # Check for fuse3. -+ # -+ # FUSE_USE_VERSION sets the version of the FUSE API that will be exported. -+ AC_VMW_CHECK_LIB([fuse3], -+ [FUSE3], -+ [fuse3], -+ [], -+ [3.10.0], -+ [fuse3/fuse.h], -+ [fuse_main], -+ [have_fuse3=yes; -+ AC_DEFINE([HAVE_FUSE3], 1, [Define to 1 if using FUSE3.]) -+ AC_DEFINE([FUSE_USE_VERSION], 35, [FUSE API version to use.])], -+ [have_fuse3=no]) -+ -+ if test "$have_fuse3" = "no"; then -+ if test "$with_fuse" = "auto" || test "$with_fuse" = "yes"; then -+ AC_MSG_NOTICE([Fuse3 is missing, trying to use older Fuse library.]) -+ else -+ AC_MSG_FAILURE([Fuse3 was requested but unavailable on the system.]) -+ fi -+ fi -+fi -+ -+if test "$with_fuse" = "fuse" || -+ ( ( test "$with_fuse" = "auto" || test "$with_fuse" = "yes" ) && -+ test "$have_fuse3" = "no" ); then -+ # -+ # Check for fuse. -+ # -+ # FUSE_USE_VERSION sets the version of the FUSE API that will be exported. -+ AC_VMW_CHECK_LIB([fuse], -+ [FUSE], -+ [fuse], -+ [], -+ [], -+ [fuse.h], -+ [fuse_main], -+ [have_fuse=yes; -+ AC_DEFINE([HAVE_FUSE], 1, [Define to 1 if using FUSE.]) -+ AC_DEFINE([FUSE_USE_VERSION], 29, [FUSE API version to use.])], -+ [have_fuse=no]) -+ -+ if test "$have_fuse" = "no"; then -+ if test "$with_fuse" = "auto" || test "$with_fuse" = "yes"; then -+ AC_MSG_NOTICE([Fuse is missing, vmblock-fuse/vmhgfs-fuse will be disabled.]) -+ else -+ AC_MSG_FAILURE([Fuse2 was requested but unavailable on the system.]) -+ fi -+ fi -+fi -+ -+if test "$with_fuse" = "no"; then -+ AC_MSG_WARN([Fuse or Fuse3 is suppressed, vmblock-fuse/vmhgfs-fuse will be disabled.]) -+fi - - # - # Check for PAM. -@@ -1607,7 +1684,8 @@ AM_CONDITIONAL(HAVE_XCOMPOSITE, test "$have_xcomposite" = "yes") - AM_CONDITIONAL(ENABLE_TESTS, test "$have_cunit" = "yes") - AM_CONDITIONAL(WITH_ROOT_PRIVILEGES, test "$with_root_privileges" = "yes") - AM_CONDITIONAL(HAVE_DOXYGEN, test "$have_doxygen" = "yes") --AM_CONDITIONAL(HAVE_FUSE, test "$have_fuse" = "yes") -+AM_CONDITIONAL(HAVE_FUSE, test "$have_fuse" = "yes" || test "$have_fuse3" = "yes") -+AM_CONDITIONAL(HAVE_FUSE3, test "$have_fuse3" = "yes") - AM_CONDITIONAL(HAVE_GNU_LD, test "$with_gnu_ld" = "yes") - AM_CONDITIONAL(HAVE_GTKMM, test "$have_x" = "yes" -a \( "$with_gtkmm" = "yes" -o "$with_gtkmm3" = "yes" \) ) - AM_CONDITIONAL(HAVE_PAM, test "$with_pam" = "yes") -diff --git a/open-vm-tools/tests/testVmblock/Makefile.am b/open-vm-tools/tests/testVmblock/Makefile.am -index 3c44b4046..543b2f813 100644 ---- a/open-vm-tools/tests/testVmblock/Makefile.am -+++ b/open-vm-tools/tests/testVmblock/Makefile.am -@@ -15,12 +15,14 @@ - ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - ################################################################################ - -+ noinst_PROGRAMS = - if HAVE_FUSE -- noinst_PROGRAMS = vmware-testvmblock-fuse -+ noinst_PROGRAMS += vmware-testvmblock-fuse -+ noinst_PROGRAMS += vmware-testvmblock-manual-fuse -+endif -+if HAVE_FUSE3 -+ noinst_PROGRAMS += vmware-testvmblock-fuse - noinst_PROGRAMS += vmware-testvmblock-manual-fuse --else -- noinst_PROGRAMS = vmware-testvmblock-legacy -- noinst_PROGRAMS += vmware-testvmblock-manual-legacy - endif - - AM_CFLAGS = -@@ -30,10 +32,6 @@ AM_CFLAGS += -DVMX86_DEBUG - AM_LDFLAGS = - AM_LDFLAGS += -lpthread - --vmware_testvmblock_legacy_SOURCES = vmblocktest.c -- --vmware_testvmblock_manual_legacy_SOURCES = manual-blocker.c -- - vmware_testvmblock_fuse_CFLAGS = $(AM_CFLAGS) -Dvmblock_fuse - vmware_testvmblock_fuse_SOURCES = vmblocktest.c - -diff --git a/open-vm-tools/vmblock-fuse/Makefile.am b/open-vm-tools/vmblock-fuse/Makefile.am -index 9018096c4..81ff0acac 100644 ---- a/open-vm-tools/vmblock-fuse/Makefile.am -+++ b/open-vm-tools/vmblock-fuse/Makefile.am -@@ -1,5 +1,5 @@ - ################################################################################ --### Copyright (C) 2008-2016 VMware, Inc. All rights reserved. -+### Copyright (c) 2008-2016,2021 VMware, Inc. All rights reserved. - ### - ### This program is free software; you can redistribute it and/or modify - ### it under the terms of version 2 of the GNU General Public License as -@@ -29,12 +29,14 @@ AM_CFLAGS += -D_XOPEN_SOURCE=600 - AM_CFLAGS += -DUSERLEVEL - AM_CFLAGS += -D_FILE_OFFSET_BITS=64 - AM_CFLAGS += @FUSE_CPPFLAGS@ -+AM_CFLAGS += @FUSE3_CPPFLAGS@ - AM_CFLAGS += @GLIB2_CPPFLAGS@ - AM_CFLAGS += -I$(top_srcdir)/modules/shared/vmblock - AM_CFLAGS += -I$(srcdir) - - vmware_vmblock_fuse_LDADD = - vmware_vmblock_fuse_LDADD += @FUSE_LIBS@ -+vmware_vmblock_fuse_LDADD += @FUSE3_LIBS@ - vmware_vmblock_fuse_LDADD += @GLIB2_LIBS@ - - vmware_vmblock_fuse_SOURCES = -diff --git a/open-vm-tools/vmblock-fuse/fsops.c b/open-vm-tools/vmblock-fuse/fsops.c -index c14d78d47..cedcb7479 100644 ---- a/open-vm-tools/vmblock-fuse/fsops.c -+++ b/open-vm-tools/vmblock-fuse/fsops.c -@@ -65,6 +65,14 @@ static vmblockSpecialDirEntry symlinkDirEntry = - static vmblockSpecialDirEntry notifyDirEntry = - { NOTIFY_DIR "/*", S_IFREG | 0444, 1, 0 }; - -+#if FUSE_MAJOR_VERSION == 3 -+#define CALL_FUSE_FILLER(buf, name, stbuf, off, flags) \ -+ filler(buf, name, stbuf, off, flags) -+#else -+#define CALL_FUSE_FILLER(buf, name, stbuf, off, flags) \ -+ filler(buf, name, stbuf, off) -+#endif -+ - /* - *----------------------------------------------------------------------------- - * -@@ -248,9 +256,16 @@ SetTimesToNow(struct stat *statBuf) // OUT - *----------------------------------------------------------------------------- - */ - -+#if FUSE_MAJOR_VERSION == 3 -+int -+VMBlockGetAttr(const char *path, // IN: File to get attributes of. -+ struct stat *statBuf, // OUT: Where to put the attributes. -+ struct fuse_file_info *fi) // IN: Ignored -+#else - int - VMBlockGetAttr(const char *path, // IN: File to get attributes of. - struct stat *statBuf) // OUT: Where to put the attributes. -+#endif - { - vmblockSpecialDirEntry *dirEntry; - ASSERT(path != NULL); -@@ -362,7 +377,7 @@ ExternalReadDir(const char *blockPath, // IN: - errno = 0; - - while ((dentry = readdir(dir)) != NULL) { -- status = filler(buf, dentry->d_name, &statBuf, 0); -+ status = CALL_FUSE_FILLER(buf, dentry->d_name, &statBuf, 0, 0); - if (status == 1) { - break; - } -@@ -408,6 +423,17 @@ ExternalReadDir(const char *blockPath, // IN: - *----------------------------------------------------------------------------- - */ - -+#if FUSE_MAJOR_VERSION == 3 -+int -+VMBlockReadDir(const char *path, // IN: Directory to read. -+ void *buf, // OUT: Where to put directory -+ // listing. -+ fuse_fill_dir_t filler, // IN: Function to add an entry -+ // to buf. -+ off_t offset, // IN: Ignored. -+ struct fuse_file_info *fileInfo, // IN: Ignored. -+ enum fuse_readdir_flags flags) // IN: Ignored. -+#else - int - VMBlockReadDir(const char *path, // IN: Directory to read. - void *buf, // OUT: Where to put directory -@@ -416,6 +442,7 @@ VMBlockReadDir(const char *path, // IN: Directory to read. - // to buf. - off_t offset, // IN: Ignored. - struct fuse_file_info *fileInfo) // IN: Ignored. -+#endif - { - struct stat fileStat; - struct stat dirStat; -@@ -433,11 +460,11 @@ VMBlockReadDir(const char *path, // IN: Directory to read. - dirStat.st_mode = S_IFDIR; - - if (strcmp(path, "/") == 0) { -- (void)(filler(buf, ".", &dirStat, 0) || -- filler(buf, "..", &dirStat, 0) || -- filler(buf, VMBLOCK_DEVICE_NAME, &fileStat, 0) || -- filler(buf, REDIRECT_DIR_NAME, &dirStat, 0) || -- filler(buf, NOTIFY_DIR_NAME, &dirStat, 0)); -+ (void)(CALL_FUSE_FILLER(buf, ".", &dirStat, 0, 0) || -+ CALL_FUSE_FILLER(buf, "..", &dirStat, 0, 0) || -+ CALL_FUSE_FILLER(buf, VMBLOCK_DEVICE_NAME, &fileStat, 0, 0) || -+ CALL_FUSE_FILLER(buf, REDIRECT_DIR_NAME, &dirStat, 0, 0) || -+ CALL_FUSE_FILLER(buf, NOTIFY_DIR_NAME, &dirStat, 0, 0)); - return 0; - } else if ( (strcmp(path, REDIRECT_DIR) == 0) - || (strcmp(path, NOTIFY_DIR) == 0)) { -@@ -764,8 +791,19 @@ VMBlockRelease(const char *path, // IN: Must be control file. - *----------------------------------------------------------------------------- - */ - -+#if FUSE_MAJOR_VERSION == 3 -+void * -+VMBlockInit(struct fuse_conn_info *conn, -+ struct fuse_config *config) -+#else -+#if FUSE_USE_VERSION < 26 - void * - VMBlockInit(void) -+#else -+void * -+VMBlockInit(struct fuse_conn_info *conn) -+#endif -+#endif - { - BlockInit(); - return NULL; -diff --git a/open-vm-tools/vmblock-fuse/fsops.h b/open-vm-tools/vmblock-fuse/fsops.h -index 2f16c8bcd..a067abdf8 100644 ---- a/open-vm-tools/vmblock-fuse/fsops.h -+++ b/open-vm-tools/vmblock-fuse/fsops.h -@@ -1,5 +1,5 @@ - /********************************************************* -- * Copyright (C) 2008-2018 VMware, Inc. All rights reserved. -+ * Copyright (C) 2008-2018,2021 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 -@@ -30,13 +30,19 @@ - #ifndef _VMBLOCK_FUSE_H_ - #define _VMBLOCK_FUSE_H_ - -+/* -+ * FUSE_USE_VERSION must be set before the fuse or fuse3 headers are -+ * included. If undefined, fall back to previous default used. -+ */ -+#ifndef FUSE_USE_VERSION - /* - * FUSE_USE_VERSION sets the version of the FUSE API that will be exported. - * Version 25 is the newest version supported by the libfuse in our toolchain - * as of 2008-07. - */ -- - #define FUSE_USE_VERSION 25 -+#endif -+ - #include - - #include "vmblock.h" -@@ -55,9 +61,18 @@ - */ - - int VMBlockReadLink(const char *path, char *buf, size_t bufSize); -+ -+#if FUSE_MAJOR_VERSION == 3 -+int VMBlockGetAttr(const char *path, struct stat *statBuf, -+ struct fuse_file_info *fi); -+int VMBlockReadDir(const char *path, void *buf, fuse_fill_dir_t filler, -+ off_t offset, struct fuse_file_info *fileInfo, -+ enum fuse_readdir_flags); -+#else - int VMBlockGetAttr(const char *path, struct stat *statBuf); - int VMBlockReadDir(const char *path, void *buf, fuse_fill_dir_t filler, - off_t offset, struct fuse_file_info *fileInfo); -+#endif - int VMBlockOpen(const char *path, struct fuse_file_info *fileInfo); - int VMBlockWrite(const char *path, const char *buf, size_t size, off_t offset, - struct fuse_file_info *fileInfo); -diff --git a/open-vm-tools/vmblock-fuse/main.c b/open-vm-tools/vmblock-fuse/main.c -index bc07670a3..c9952473f 100644 ---- a/open-vm-tools/vmblock-fuse/main.c -+++ b/open-vm-tools/vmblock-fuse/main.c -@@ -1,5 +1,5 @@ - /********************************************************* -- * Copyright (C) 2008-2016 VMware, Inc. All rights reserved. -+ * Copyright (C) 2008-2016,2021 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 -@@ -66,5 +66,9 @@ main(int argc, // IN - LOGLEVEL_THRESHOLD = 4; - } - } -+#if FUSE_USE_VERSION < 26 - return fuse_main(argc, argv, &vmblockOperations); -+#else -+ return fuse_main(argc, argv, &vmblockOperations, NULL); -+#endif - } -diff --git a/open-vm-tools/vmhgfs-fuse/Makefile.am b/open-vm-tools/vmhgfs-fuse/Makefile.am -index 19089a08e..731431b74 100644 ---- a/open-vm-tools/vmhgfs-fuse/Makefile.am -+++ b/open-vm-tools/vmhgfs-fuse/Makefile.am -@@ -1,5 +1,5 @@ - ################################################################################ --### Copyright (C) 2015-2016 VMware, Inc. All rights reserved. -+### Copyright (c) 2015-2016,2021 VMware, Inc. All rights reserved. - ### - ### This program is free software; you can redistribute it and/or modify - ### it under the terms of version 2 of the GNU General Public License as -@@ -19,10 +19,12 @@ bin_PROGRAMS = vmhgfs-fuse - - AM_CFLAGS = - AM_CFLAGS += @FUSE_CPPFLAGS@ -+AM_CFLAGS += @FUSE3_CPPFLAGS@ - AM_CFLAGS += @GLIB2_CPPFLAGS@ - - vmhgfs_fuse_LDADD = - vmhgfs_fuse_LDADD += @FUSE_LIBS@ -+vmhgfs_fuse_LDADD += @FUSE3_LIBS@ - vmhgfs_fuse_LDADD += @GLIB2_LIBS@ - vmhgfs_fuse_LDADD += @VMTOOLS_LIBS@ - -diff --git a/open-vm-tools/vmhgfs-fuse/config.c b/open-vm-tools/vmhgfs-fuse/config.c -index c6125e9db..fe0cda9da 100644 ---- a/open-vm-tools/vmhgfs-fuse/config.c -+++ b/open-vm-tools/vmhgfs-fuse/config.c -@@ -1,5 +1,5 @@ - /********************************************************* -- * Copyright (C) 2015-2018 VMware, Inc. All rights reserved. -+ * Copyright (C) 2015-2018,2021 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 -@@ -22,6 +22,7 @@ - */ - - #include "module.h" -+#include - #include - - #ifdef VMX86_DEVEL -@@ -76,8 +77,10 @@ const struct fuse_opt vmhgfsOpts[] = { - VMHGFS_OPT("-l %i", logLevel, 4), - #endif - /* We will change the default value, unless it is specified explicitly. */ -+#if FUSE_MAJOR_VERSION != 3 - FUSE_OPT_KEY("big_writes", KEY_BIG_WRITES), - FUSE_OPT_KEY("nobig_writes", KEY_NO_BIG_WRITES), -+#endif - - FUSE_OPT_KEY("-V", KEY_VERSION), - FUSE_OPT_KEY("--version", KEY_VERSION), -@@ -131,8 +134,13 @@ Usage(char *prog_name) // IN - - #define LIB_MODULEPATH "/lib/modules" - #define MODULES_DEP "modules.dep" -+#if FUSE_MAJOR_VERSION == 3 -+#define FUSER_MOUNT_BIN "/bin/fusermount3" -+#define FUSER_MOUNT_USR_BIN "/usr/bin/fusermount3" -+#else - #define FUSER_MOUNT_BIN "/bin/fusermount" - #define FUSER_MOUNT_USR_BIN "/usr/bin/fusermount" -+#endif - #define PROC_FILESYSTEMS "/proc/filesystems" - #define FUSER_KERNEL_FS "fuse" - -@@ -406,7 +414,9 @@ vmhgfsOptProc(void *data, // IN - int key, // IN - struct fuse_args *outargs) // OUT - { -+#if FUSE_MAJOR_VERSION != 3 - struct vmhgfsConfig *config = data; -+#endif - - switch (key) { - case FUSE_OPT_KEY_NONOPT: -@@ -434,6 +444,7 @@ vmhgfsOptProc(void *data, // IN - } - return 1; - -+#if FUSE_MAJOR_VERSION != 3 - case KEY_BIG_WRITES: - config->addBigWrites = TRUE; - return 0; -@@ -441,11 +452,18 @@ vmhgfsOptProc(void *data, // IN - case KEY_NO_BIG_WRITES: - config->addBigWrites = FALSE; - return 0; -+#endif - - case KEY_HELP: - Usage(outargs->argv[0]); -+#if FUSE_MAJOR_VERSION != 3 - fuse_opt_add_arg(outargs, "-ho"); - fuse_main(outargs->argc, outargs->argv, NULL, NULL); -+#else -+ fprintf(stdout, "FUSE options:\n"); -+ fuse_cmdline_help(); -+ fuse_lib_help(outargs); -+#endif - exit(1); - - case KEY_ENABLED_FUSE: { -@@ -496,8 +514,8 @@ vmhgfsPreprocessArgs(struct fuse_args *outargs) // IN/OUT - #ifdef VMX86_DEVEL - config.logLevel = LOGLEVEL_THRESHOLD; - #endif --#ifdef __APPLE__ -- /* osxfuse does not have option 'big_writes'. */ -+#if defined(__APPLE__) || FUSE_MAJOR_VERSION == 3 -+ /* osxfuse and fuse3 does not have option 'big_writes'. */ - config.addBigWrites = FALSE; - #else - config.addBigWrites = TRUE; -diff --git a/open-vm-tools/vmhgfs-fuse/dir.c b/open-vm-tools/vmhgfs-fuse/dir.c -index d5fd1f8b5..b5dcc2945 100644 ---- a/open-vm-tools/vmhgfs-fuse/dir.c -+++ b/open-vm-tools/vmhgfs-fuse/dir.c -@@ -1,5 +1,5 @@ - /********************************************************* -- * Copyright (C) 2013,2019 VMware, Inc. All rights reserved. -+ * Copyright (C) 2013,2019,2021 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 -@@ -396,7 +396,11 @@ HgfsReadDirFromReply(uint32 *f_pos, // IN/OUT: Offset - st.st_size = attr.size; - st.st_ino = ino; - st.st_mode = d_type << 12; -+#if FUSE_MAJOR_VERSION == 3 -+ result = filldir(vfsDirent, escName, &st, 0, 0); -+#else - result = filldir(vfsDirent, escName, &st, 0); -+#endif - - if (result) { - /* -diff --git a/open-vm-tools/vmhgfs-fuse/main.c b/open-vm-tools/vmhgfs-fuse/main.c -index 1ce970b8b..e6d7812bb 100644 ---- a/open-vm-tools/vmhgfs-fuse/main.c -+++ b/open-vm-tools/vmhgfs-fuse/main.c -@@ -1,5 +1,5 @@ - /********************************************************* -- * Copyright (C) 2013 VMware, Inc. All rights reserved. -+ * Copyright (C) 2013,2021 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 -@@ -22,10 +22,6 @@ - * Main entry points for fuse file operations for HGFS - */ - --#if FUSE_USE_VERSION >= 26 --#define HAVE_UTIMENSAT 1 --#endif -- - #include "module.h" - #include "cache.h" - #include "filesystem.h" -@@ -119,9 +115,16 @@ freeAbsPath(char *abspath) // IN - *---------------------------------------------------------------------- - */ - -+#if FUSE_MAJOR_VERSION == 3 -+static int -+hgfs_getattr(const char *path, //IN: path of a file/directory -+ struct stat *stbuf, //IN/OUT: file/directoy attribute -+ struct fuse_file_info *fi) //IN/OUT: Unused -+#else - static int - hgfs_getattr(const char *path, //IN: path of a file/directory - struct stat *stbuf) //IN/OUT: file/directoy attribute -+#endif - { - HgfsHandle fileHandle = HGFS_INVALID_HANDLE; - HgfsAttrInfo newAttr = {0}; -@@ -365,12 +368,22 @@ exit: - *---------------------------------------------------------------------- - */ - -+#if FUSE_MAJOR_VERSION == 3 -+static int -+hgfs_readdir(const char *path, //IN: path to a directory -+ void *buf, //OUT: buffer to fill the dir entry -+ fuse_fill_dir_t filler, //IN: function pointer to fill buf -+ off_t offset, //IN: offset to read the dir -+ struct fuse_file_info *fi, //IN: file info set by open call -+ enum fuse_readdir_flags flags) //IN: unused -+#else - static int - hgfs_readdir(const char *path, //IN: path to a directory - void *buf, //OUT: buffer to fill the dir entry - fuse_fill_dir_t filler, //IN: function pointer to fill buf - off_t offset, //IN: offset to read the dir - struct fuse_file_info *fi) //IN: file info set by open call -+#endif - { - char *abspath = NULL; - int res = 0; -@@ -602,9 +615,16 @@ exit: - *---------------------------------------------------------------------- - */ - -+#if FUSE_MAJOR_VERSION == 3 -+static int -+hgfs_rename(const char *from, //IN: from path name -+ const char *to, //IN: to path name -+ unsigned int flags) //IN: unused -+#else - static int - hgfs_rename(const char *from, //IN: from path name - const char *to) //IN: to path name -+#endif - { - char *absfrom = NULL; - char *absto = NULL; -@@ -695,9 +715,16 @@ exit: - *---------------------------------------------------------------------- - */ - -+#if FUSE_MAJOR_VERSION == 3 -+static int -+hgfs_chmod(const char *path, //IN: path to a file -+ mode_t mode, //IN: mode to set -+ struct fuse_file_info *fi) //IN/OUT: unused -+#else - static int - hgfs_chmod(const char *path, //IN: path to a file - mode_t mode) //IN: mode to set -+#endif - { - char *abspath = NULL; - int res; -@@ -760,10 +787,18 @@ exit: - *---------------------------------------------------------------------- - */ - -+#if FUSE_MAJOR_VERSION == 3 -+static int -+hgfs_chown(const char *path, //IN: Path to a file -+ uid_t uid, //IN: User id -+ gid_t gid, //IN: Group id -+ struct fuse_file_info *fi) //IN/OUT: unused -+#else - static int - hgfs_chown(const char *path, //IN: Path to a file - uid_t uid, //IN: User id - gid_t gid) //IN: Group id -+#endif - { - HgfsHandle fileHandle = HGFS_INVALID_HANDLE; - HgfsAttrInfo newAttr = {0}; -@@ -823,9 +858,16 @@ exit: - *---------------------------------------------------------------------- - */ - -+#if FUSE_MAJOR_VERSION == 3 -+static int -+hgfs_truncate(const char *path, //IN: path to a file -+ off_t size, //IN: new size -+ struct fuse_file_info *fi) //IN/OUT: unused -+#else - static int - hgfs_truncate(const char *path, //IN: path to a file - off_t size) //IN: new size -+#endif - { - HgfsHandle fileHandle = HGFS_INVALID_HANDLE; - HgfsAttrInfo newAttr = {0}; -@@ -884,14 +926,15 @@ exit: - *---------------------------------------------------------------------- - */ - --#ifdef HAVE_UTIMENSAT -+#if FUSE_MAJOR_VERSION == 3 - static int - hgfs_utimens(const char *path, //IN: path to a file -- const struct timespec ts[2]) //IN: new time -+ const struct timespec ts[2], //IN: new time -+ struct fuse_file_info *fi) //IN/OUT: unused - #else - static int --hgfs_utime(const char *path, //IN: path to a file -- struct utimbuf *times) //IN: new time -+hgfs_utimens(const char *path, //IN: path to a file -+ const struct timespec ts[2]) //IN: new time - #endif - { - HgfsHandle fileHandle = HGFS_INVALID_HANDLE; -@@ -936,17 +979,10 @@ hgfs_utime(const char *path, //IN: path to a file - attr->mask = (HGFS_ATTR_VALID_WRITE_TIME | - HGFS_ATTR_VALID_ACCESS_TIME); - --#ifdef HAVE_UTIMENSAT - accessTimeSec = ts[0].tv_sec; - accessTimeNsec = ts[0].tv_nsec; - writeTimeSec = ts[1].tv_sec; - writeTimeNsec = ts[1].tv_nsec; --#else -- accessTimeSec = times->actime; -- accessTimeNsec = 0; -- writeTimeSec = times->modtime; -- writeTimeNsec = 0; --#endif - attr->accessTime = HgfsConvertToNtTime(accessTimeSec, accessTimeNsec); - attr->writeTime = HgfsConvertToNtTime(writeTimeSec, writeTimeNsec); - -@@ -1249,8 +1285,14 @@ exit: - *---------------------------------------------------------------------- - */ - -+#if FUSE_MAJOR_VERSION == 3 -+static void* -+hgfs_init(struct fuse_conn_info *conn, // IN: unused -+ struct fuse_config *cfg) // IN/OUT: unused -+#else - static void* - hgfs_init(struct fuse_conn_info *conn) // IN: unused -+#endif - { - pthread_t purgeCacheThread; - int dummy; -@@ -1335,11 +1377,7 @@ static struct fuse_operations vmhgfs_operations = { - .chmod = hgfs_chmod, - .chown = hgfs_chown, - .truncate = hgfs_truncate, --#ifdef HAVE_UTIMENSAT - .utimens = hgfs_utimens, --#else // HAVE_UTIMENSAT -- .utime = hgfs_utime, --#endif // defined HAVE_UTIMENSAT - .open = hgfs_open, - .read = hgfs_read, - .write = hgfs_write, -diff --git a/open-vm-tools/vmhgfs-fuse/module.h b/open-vm-tools/vmhgfs-fuse/module.h -index 7d0f1b01d..61f88e100 100644 ---- a/open-vm-tools/vmhgfs-fuse/module.h -+++ b/open-vm-tools/vmhgfs-fuse/module.h -@@ -1,5 +1,5 @@ - /********************************************************* -- * Copyright (C) 2013 VMware, Inc. All rights reserved. -+ * Copyright (C) 2013,2021 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 -@@ -25,7 +25,13 @@ - #ifndef _VMHGFS_FUSE_MODULE_H_ - #define _VMHGFS_FUSE_MODULE_H_ - --#define FUSE_USE_VERSION 29 -+/* -+ * FUSE_USE_VERSION must be set before the fuse or fuse3 headers are -+ * included. If undefined, fall back to previous default used. -+ */ -+#ifndef FUSE_USE_VERSION -+# define FUSE_USE_VERSION 29 -+#endif - - #include - #include "hgfsUtil.h" --- -2.34.1 - diff -Nru open-vm-tools-11.3.5/debian/patches/use-debian-pam open-vm-tools-12.1.5/debian/patches/use-debian-pam --- open-vm-tools-11.3.5/debian/patches/use-debian-pam 2022-01-04 07:52:44.000000000 +0000 +++ open-vm-tools-12.1.5/debian/patches/use-debian-pam 2023-03-16 21:15:40.000000000 +0000 @@ -2,7 +2,7 @@ =================================================================== --- pkg-open-vm-tools.orig/open-vm-tools/services/vmtoolsd/Makefile.am +++ pkg-open-vm-tools/open-vm-tools/services/vmtoolsd/Makefile.am -@@ -78,7 +78,7 @@ install-data-hook: +@@ -81,7 +81,7 @@ install-data-hook: install-exec-hook: $(INSTALL) -d $(DESTDIR)/etc/vmware-tools $(INSTALL) -d $(DESTDIR)/$(PAM_PREFIX)/pam.d/ diff -Nru open-vm-tools-11.3.5/debian/rules open-vm-tools-12.1.5/debian/rules --- open-vm-tools-11.3.5/debian/rules 2022-02-01 15:29:32.000000000 +0000 +++ open-vm-tools-12.1.5/debian/rules 2023-03-16 22:05:54.000000000 +0000 @@ -21,6 +21,7 @@ --enable-xmlsec1 \ --with-gtk3 \ --enable-servicediscovery \ + --enable-salt-minion \ --with-fuse=fuse3 \ CFLAGS="-fPIC -Wno-error=deprecated-declarations -Wno-error=address-of-packed-member -Wno-nonnull $(CFLAGS)" \ CUSTOM_PROCPS_NAME=procps @@ -76,13 +77,21 @@ mkdir -p debian/open-vm-tools-sdmp/usr/lib/$(DEB_HOST_MULTIARCH)/open-vm-tools/plugins/vmsvc/ mv debian/open-vm-tools/usr/lib/$(DEB_HOST_MULTIARCH)/open-vm-tools/plugins/vmsvc/libserviceDiscovery.so debian/open-vm-tools-sdmp/usr/lib/$(DEB_HOST_MULTIARCH)/open-vm-tools/plugins/vmsvc/ - mv debian/open-vm-tools/usr/lib/$(DEB_HOST_MULTIARCH)/open-vm-tools/plugins/vmsvc/libguestStore.so debian/open-vm-tools-sdmp/usr/lib/$(DEB_HOST_MULTIARCH)/open-vm-tools/plugins/vmsvc/ - mv debian/open-vm-tools/usr/lib/$(DEB_HOST_MULTIARCH)/open-vm-tools/plugins/vmsvc/libgdp.so debian/open-vm-tools-sdmp/usr/lib/$(DEB_HOST_MULTIARCH)/open-vm-tools/plugins/vmsvc/ mkdir -p debian/open-vm-tools-sdmp/usr/lib/$(DEB_HOST_MULTIARCH)/open-vm-tools/serviceDiscovery/scripts/ mv debian/open-vm-tools/usr/lib/$(DEB_HOST_MULTIARCH)/open-vm-tools/serviceDiscovery/scripts/* debian/open-vm-tools-sdmp/usr/lib/$(DEB_HOST_MULTIARCH)/open-vm-tools/serviceDiscovery/scripts/ rm -rf debian/open-vm-tools/usr/lib/$(DEB_HOST_MULTIARCH)/open-vm-tools/serviceDiscovery/ + # moving open-vm-tools-containerinfo files + mkdir -p debian/open-vm-tools-containerinfo/usr/lib/$(DEB_HOST_MULTIARCH)/open-vm-tools/plugins/containerinfo/ + mv debian/open-vm-tools/usr/lib/$(DEB_HOST_MULTIARCH)/open-vm-tools/plugins/vmsvc/libcontainerInfo.so debian/open-vm-tools-containerinfo/usr/lib/$(DEB_HOST_MULTIARCH)/open-vm-tools/plugins/containerinfo/ + +ifneq (,$(findstring $(DEB_HOST_ARCH), amd64)) + # moving open-vm-tools-salt-minion files + mkdir -p debian/open-vm-tools-salt-minion/usr/lib/$(DEB_HOST_MULTIARCH)/open-vm-tools/componentMgr/saltMinion/ + mv debian/open-vm-tools/usr/lib/$(DEB_HOST_MULTIARCH)/open-vm-tools/componentMgr/saltMinion/svtminion.sh debian/open-vm-tools-salt-minion/usr/lib/$(DEB_HOST_MULTIARCH)/open-vm-tools/componentMgr/saltMinion/ +endif + override_dh_gencontrol: if [ "${VENDOR}" = "UBUNTU" ]; \ then \ diff -Nru open-vm-tools-11.3.5/debian/upstream/metadata open-vm-tools-12.1.5/debian/upstream/metadata --- open-vm-tools-11.3.5/debian/upstream/metadata 2022-01-04 07:52:44.000000000 +0000 +++ open-vm-tools-12.1.5/debian/upstream/metadata 2023-03-16 21:15:40.000000000 +0000 @@ -1,3 +1,4 @@ +Archive: SourceForge Bug-Database: https://github.com/vmware/open-vm-tools/issues Bug-Submit: https://github.com/vmware/open-vm-tools/issues/new Repository: https://github.com/vmware/open-vm-tools.git diff -Nru open-vm-tools-11.3.5/open-vm-tools/AUTHORS open-vm-tools-12.1.5/open-vm-tools/AUTHORS --- open-vm-tools-11.3.5/open-vm-tools/AUTHORS 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/AUTHORS 2022-11-29 21:17:22.000000000 +0000 @@ -76,3 +76,12 @@ Miroslav Rezanina Fix issues using GCC 11 with gtk >= 3.20 and glib >=2.66.3 - https://github.com/vmware/open-vm-tools/pull/505 + +Marco Trevisan Update open-vm-tools to build with either Fuse 3 or Fuse 2 + - https://github.com/vmware/open-vm-tools/pull/544 + +Bartosz Brachaczek Make HgfsConvertFromNtTimeNsec aware of 64-bit time_t on i386 + - https://github.com/vmware/open-vm-tools/pull/387 + +Bernd Zeimetz Fix building containerinfo plugin on i386 + - https://github.com/vmware/open-vm-tools/pull/588 diff -Nru open-vm-tools-11.3.5/open-vm-tools/ChangeLog open-vm-tools-12.1.5/open-vm-tools/ChangeLog --- open-vm-tools-11.3.5/open-vm-tools/ChangeLog 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/ChangeLog 2022-11-29 21:17:22.000000000 +0000 @@ -1,27 +1,2092 @@ -commit 199592961abba672ebacfe19d1fa43caec6acb6c +commit 0c740b5ffaacd814f402aba924e55dc8ea033b62 Author: John Wolfe -Date: Thu Sep 23 17:48:02 2021 -0700 +Date: Tue Nov 29 13:11:04 2022 -0800 - Prepare to make the 11.3.5 OVT release announcement. + Update the ReleaseNotes.md for the 12.1.5 open-vm-tools release. + +commit 8958c3e0fa4b1f5ed4cb0ee98a967ddd73cd03ff +Author: John Wolfe +Date: Tue Nov 29 13:07:17 2022 -0800 + + Prepare for the open-vm-tools 12.1.5 release. + - Update the tools version in the configure.ac. Update the build numbers + buldNumber.h. + +commit 864ffc76c53e0523b08dad1d1a82a36f75e6f06c +Author: John Wolfe +Date: Thu Nov 10 12:10:55 2022 -0800 + + Update the ChangeLog file with the changes in the 12.1.5 open-vm-tools release. + - plus the ChangeLog update of Aug. 23, 2022 + +commit a205236af862e732c774a5c2b77b700ccfc73f25 +Author: John Wolfe +Date: Thu Nov 10 12:01:14 2022 -0800 + + Fix printf format type found by Coverity scan. + + printf format should be using %zu to print a size_t value. + +commit 0a5d9821a6a82ab773d41b7ae9afe9dc8cccff30 +Author: John Wolfe +Date: Thu Nov 10 12:01:14 2022 -0800 + + Avoid a vmtoolsd service error message if not on a VMware hypervisor. + + When open-vm-tools comes preinstalled in a base Linux release, the + vmtoolsd services are started automatically at system start + and desktop login. If running on physical hardware or in a non-VMware + hypervisor, the services will emit an error message to the systemd's + logging service before stopping. + + This change removes the unwanted error message. + +commit bb64ec6aa24c123bb25d1c48a4c126efa4fda5bf +Author: John Wolfe +Date: Thu Nov 10 12:01:14 2022 -0800 + + Add an example of a new deployPkg/wait-cloudinit-timeout setting to tools.conf. + +commit cd995a58b07a91d7804d9fdec5545a5fe11e9db9 +Author: John Wolfe +Date: Thu Nov 10 12:01:14 2022 -0800 + + Make Linux perl based customization work with the cloud-init workflow. + + To resolve issues seen where users want to set a vm's networking + and apply cloud-init userdata together before the vm is booted, the + deployPkg plugin has been modified to wait for cloud-init + execution to finish. This allows cloud-init to finish execution + completely before the customization process triggers a reboot + of the guest. + + This change is solely in the deployPkg plugin side, so a user can get + this change by upgrading their open-vm-tools in the guest/template. + Crossport of change 10318445 and 10330918 from main to vmtools-prod-cpd. + +commit f7009c53afdab9a9507257c77bfeb30d8baaac8c +Author: John Wolfe +Date: Thu Nov 10 12:01:14 2022 -0800 + + Add a null undo function to the vmbackup null provider. + + If a snapshot operation times out, vmbackup can attempt + to undo quiescing. Since no quiescing is done for the null + backup provider, no undo function was provided. If vmbackup + attempts to call the undo function, it dereferences a garbage + pointer resulting in a segfault. + + Rather than add null backup provider specific checks to vmbackup, + this change adds a null undo function to provide vmbackup with a + valid function pointer it can call. The new undo function updates + the vmbackup state machine state with a new currentOpName, but + has no other effect. currentOpName is set to the calling + function name, e.g. __FUNCTION__. + +commit db9cb277841ddd56e2665fd29e3ee8c6f37fe233 +Author: John Wolfe +Date: Thu Nov 10 12:01:14 2022 -0800 + + Prepare tools builds on vmtools-prod-cpd for the 12.1.5 update release. + + - Bump the tools version to 12.1.5. + +commit 6f5e4b13647b40a45c196dad76b1cb39cc6690b9 +Author: John Wolfe +Date: Tue Aug 23 14:59:44 2022 -0700 + + Update of the ChangeLog with the "open-vm-tools 12.1.0" release point marker. + +commit 196eee046dc54358275ee5130cd189cd686efb27 +Author: John Wolfe +Date: Tue Aug 23 14:52:28 2022 -0700 + + ================================================= + open-vm-tools 12.1.0 released at this point. + ================================================= + Update of the ChangeLog with the final changes in preparation for + the open-vm-tools 12.1.0 release. + +commit 296bffe04df602705d223d78633877ddd2f2cb9c +Author: John Wolfe +Date: Tue Aug 23 12:44:30 2022 -0700 + + Open-vm-tools 12.1.0 Release Notes + +commit 6914f15d59bd917dfa0dad04a6cc26632c03f5ba +Author: John Wolfe +Date: Mon Aug 22 09:16:36 2022 -0700 + + Preparing for the open-vm-tools 12.1.0 release. + + Syncing the tools version, build number and product build number with + the internal official build of VMware Tools / open-vm-tools 12.1.0. + +commit 8825496ceca35e28cc74721b9e25f094f1ae5f2b +Author: John Wolfe +Date: Sun Aug 21 13:16:01 2022 -0700 + + Update of the ChangeLog with granular push from the 12.1.0 tools product branch. + +commit 4a41aee3900ddec7d84b919e26e85e9a9b623cd5 +Author: John Wolfe +Date: Sun Aug 21 13:00:18 2022 -0700 + + VMTools 12.1.0 L10n drop. + +commit 732bb7a3287ebdb2be079f364da4b0ea6a4c08bd +Author: John Wolfe +Date: Sun Aug 21 12:42:12 2022 -0700 + + ChangeLog update of Aug. 21, 2020 + +commit 7fa57304ab41a26f1de972f4a024e7da3632df69 +Author: John Wolfe +Date: Sun Aug 21 09:37:23 2022 -0700 + + ==================================================================== + The "stable-12.1.x" branch was created from the "devel" branch here. + ==================================================================== + + Update ChangeLog with the granular push of Aug. 21, 2022. + - plus ChangeLog update of July 29, 2022. + +commit 70a74758bfe0042c27f15ce590fb21a2bc54d745 +Author: John Wolfe +Date: Sun Aug 21 07:56:49 2022 -0700 + + Properly check authorization on incoming guestOps requests. + + Fix public pipe request checks. Only a SessionRequest type should + be accepted on the public pipe. + +commit 08cac55b2a37fac30adfb090748ca2b96c3256db +Author: John Wolfe +Date: Sun Aug 21 07:56:49 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit a4f13c6a3427a2a9366945c817222c12c957f5af +Author: John Wolfe +Date: Sun Aug 21 07:56:49 2022 -0700 + + Address issues reported by Coverity. + +commit d2b1bb8fd315124de4cdcceb5b82b2e5b2882f30 +Author: John Wolfe +Date: Sun Aug 21 07:56:49 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 581091addcbb6484047587f6d12038a04f2cc14a +Author: John Wolfe +Date: Sun Aug 21 07:56:49 2022 -0700 + + Changes to common header files not directly applicable to open-vm-tools. + + ARM: native atomics + +commit 37aefc9db67398e04f4bd9017af69edd16670080 +Author: John Wolfe +Date: Sun Aug 21 07:56:49 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit ff29587e22711489207d020794b8f588058dfe52 +Author: John Wolfe +Date: Fri Jul 29 15:50:29 2022 -0700 + + Update ChangeLog with the granular push of July 28 & 29, 2022. + - plus ChangeLog update of July 12, 2022. + +commit d5b73e64a5857d40905acee1242edaaac7ce9494 +Author: John Wolfe +Date: Fri Jul 29 11:11:04 2022 -0700 + + Correct missed 2022 copyright update. + +commit 1bd202e0a819c520896c743b51f2c1365f7ae2b2 +Author: John Wolfe +Date: Thu Jul 28 20:03:43 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 306498ca0676354eb541b5817426191e615d0ef2 +Author: John Wolfe +Date: Thu Jul 28 20:03:43 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit b3f0be90d03a5da6d3bb695e9e1dd44f071814aa +Author: John Wolfe +Date: Thu Jul 28 20:03:43 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 5887bf59e95cba480568ad731f7b037894058fef +Author: John Wolfe +Date: Thu Jul 28 20:03:43 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 9982eee37884c819759aadcec987324d9fe5b41e +Author: John Wolfe +Date: Thu Jul 28 20:03:42 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit b5997ab6ecdbc6981a8a35b2349b3bd98c746a19 +Author: John Wolfe +Date: Thu Jul 28 20:03:42 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 24594a971f9807fbee2253ee7680846de6cd9a63 +Author: John Wolfe +Date: Thu Jul 28 20:03:42 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit bc9ab15472ed53a3071902ca5ec41d60e2f00d88 +Author: John Wolfe +Date: Thu Jul 28 20:03:42 2022 -0700 + + lib/misc/hostinfoPosix.c: iopl(3) is not avaiable on ARM. + +commit 6907610abb95f96c3e8a10389483bfe54efd3eee +Author: John Wolfe +Date: Thu Jul 28 20:03:42 2022 -0700 + + Changes to common source files not directly applicable to open-vm-tools. + +commit b76e3218ddb24e49a87ef35913f9bf1389166033 +Author: John Wolfe +Date: Thu Jul 28 20:03:42 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 155a8d440df8ae889d93c9aaee9d15bec9d7640d +Author: John Wolfe +Date: Thu Jul 28 20:03:42 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 7452011db95a49aaaa19c293fb1ff1ea0944d6db +Author: John Wolfe +Date: Thu Jul 28 20:03:42 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 386e493c3cd58723d183ecbd3f0594706778e423 +Author: John Wolfe +Date: Tue Jul 12 10:49:28 2022 -0700 + + Update ChangeLog with the granular push of July 12, 2022. + - plus ChangeLog update of June 7, 2022. + +commit eb48b7972c0c64735cb6fe7ca7ac3f505b80c7d4 +Author: John Wolfe +Date: Tue Jul 12 10:25:28 2022 -0700 + + Correct missed 2022 copyright update. + +commit ddfb569588d8b1a9cd31cb3bb5d33c58c72f7fbc +Author: John Wolfe +Date: Tue Jul 12 09:56:01 2022 -0700 + + Fix a bug in CodeSet_JsonEscape. + + Fix a bug introduced in an earlier change in which CodeSet_JsonEscape + erroneously tests the first character in the buffer when checking + whether to escape the character currently being processed. + +commit a816c2e149010bdca27a47006932aa10b686a895 +Author: John Wolfe +Date: Tue Jul 12 09:56:01 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 6aa2e661a35b88f0f69e744b4918340437cd6485 +Author: John Wolfe +Date: Tue Jul 12 09:56:01 2022 -0700 + + Fix a grammar error of c++11 scoped enumeration "enum class". + +commit e5e9a9ba31791d4f10e7dd75a8dbab179926511f +Author: John Wolfe +Date: Tue Jul 12 09:56:01 2022 -0700 + + Escape all control characters in JSON. + + Update CodeSet_JsonEscape to escape all control characters between + U+0000 and U+001F as required by the JSON standard. Delete + CodeSet_Utf8Escape as it is no longer used. Also update datasets + in-guest API tests accordingly. + +commit 47f47851a026cce6ee9738015759b45cf6931cc2 +Author: John Wolfe +Date: Tue Jul 12 09:56:01 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit bb2f24ed14f8d5102df6387253ba4ac4271bf4f5 +Author: John Wolfe +Date: Tue Jul 12 09:56:01 2022 -0700 + + Changes to common source files not applicable to open-vm-tools. + +commit f45b8f435f2d9b3536f283098ddaf69218ae7456 +Author: John Wolfe +Date: Tue Jul 12 09:56:01 2022 -0700 + + Add a comment with the bump of the Guest Msg Channels to 128. + +commit f272162cad49f13dc2d86eafb9aec7f0c2c7c8b4 +Author: John Wolfe +Date: Tue Jul 12 09:56:01 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 523df70f7f1b0ef760fe753404a0682b79b095b8 +Author: John Wolfe +Date: Tue Jul 12 09:56:01 2022 -0700 + + Bump up the Guest Msg Channels to 128. + +commit 9e371bd289f53585e67853a97328906c196af818 +Author: John Wolfe +Date: Tue Jul 12 09:56:01 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit d5b28c0380fb6687fd106e6ebd65570473940878 +Author: John Wolfe +Date: Tue Jul 12 09:56:01 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 42c136b5a3cddb077b5c39d933141e30d4c2c129 +Author: John Wolfe +Date: Tue Jul 12 09:56:01 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 091d43b06052d742e321d3f61c8620284d56b959 +Author: John Wolfe +Date: Tue Jul 12 09:56:01 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit df0099727e96292279398c3fbd7f3901f215e4f3 +Author: John Wolfe +Date: Tue Jul 12 09:56:01 2022 -0700 + + Common source file changes not directly applicable to open-vm-tools. + +commit 5317dfb778ee97c6fe83fbf23ee2e800fb608eaa +Author: John Wolfe +Date: Tue Jul 12 09:56:01 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 575f1ec1bee338c1a0ac6f14072429f926cf2f52 +Author: John Wolfe +Date: Tue Jun 7 10:07:23 2022 -0700 + + Update ChangeLog with the granular push of June 7, 2022. + - plus the sync of the README.md with the stable-12.0.x branch. + - plus ChangeLog update of May 17, 2022. + +commit 95956d193464f2aa0547e6dbd4f51bc2052d5f82 +Author: John Wolfe +Date: Tue Jun 7 09:52:42 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit dd2f50d4cc956d5d45638d31f68c449ba8afbca4 +Author: John Wolfe +Date: Tue Jun 7 09:52:42 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 9a38d3f49bad645826aad7f0cb778098ba6ca381 +Author: John Wolfe +Date: Tue Jun 7 09:52:42 2022 -0700 + + Common header file change not directly applicable to open-vm-tools. + +commit 0f78b84aeedab75e3614bfdda9fe5fd86268686e +Author: John Wolfe +Date: Tue Jun 7 09:52:42 2022 -0700 + + Log Facility: Improve wording of group level messages and filtering. + + Common header file change not directly applicable to open-vm-tools. + +commit 41509dbb7223fa7e8905718c357fbd6f243f06e3 +Author: John Wolfe +Date: Tue Jun 7 09:52:42 2022 -0700 + + Report consistent customization error status when custom script is disabled. + +commit f83c890a91e29febbe54a7be0ffe96c1e14f8057 +Author: John Wolfe +Date: Tue Jun 7 09:52:42 2022 -0700 + + Guest OS: Prepare for Linux 6 + + The basics are already there, update guest identification. + +commit 0b6597b97ce0d1607cb0602731b9c2d4ca0c5162 +Author: John Wolfe +Date: Tue Jun 7 09:52:42 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 9945bb6cc3aa6d811ef46d9ddf2c2ae462baa38d +Author: John Wolfe +Date: Tue Jun 7 09:52:41 2022 -0700 + + Common header file change not applicable to open-vm-tools at this time. + +commit d669d0263887a3da2242d55bae7eab224981e075 +Author: John Wolfe +Date: Tue Jun 7 09:52:41 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 7fa64a4e23e65224b1752e5037854fd6f9ea43cb +Author: John Wolfe +Date: Tue Jun 7 09:52:41 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit cff50b62e0db5f5978c14bb09b0e2fe7c1c89fc3 +Author: John Wolfe +Date: Tue Jun 7 09:52:41 2022 -0700 + + Log Facility: Enhance logging for grouped (named) log message. + + Common header file change not directly applicable to open-vm-tools. + +commit 939545b3e0445858cf7be038c978e7df2d8547ff +Author: John Wolfe +Date: Wed May 25 05:55:52 2022 -0700 + + Sync the README.md file with the version released with 12.0.5. + +commit 4c620fd78b6281ca8a045f3dffdf2180dd9c480f +Author: John Wolfe +Date: Tue May 17 18:47:08 2022 -0700 + + Update ChangeLog with the granular push of May 17, 2022. + - plus ChangeLog update of May 6, 2022. + +commit 29ba7eb2a1e6c62357ad46bc67daff94b0fc0dc4 +Author: John Wolfe +Date: Tue May 17 18:36:21 2022 -0700 + + Salt-minion plugin update: + + The Salt Minion installer script svtminion.sh has been updated. + - version 1.3 + - configurable download source + - requires the "wget" command + +commit e1a6796a1aecd22a7b76f5b4871d215b82277f18 +Author: John Wolfe +Date: Tue May 17 18:36:21 2022 -0700 + + Changes to common header files not applicable to open-vm-tools. + +commit b42ed315b7844660e9f9546c7bd85e1804938526 +Author: John Wolfe +Date: Tue May 17 18:36:21 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 074cd660a718e817e7db0df57f71252107d23490 +Author: John Wolfe +Date: Tue May 17 18:36:21 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit ce9459965a1900159b5f563c030385e554ba3e49 +Author: John Wolfe +Date: Tue May 17 18:36:21 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit bac24ee80957feea0336f7ac597630aedf13ec86 +Author: John Wolfe +Date: Tue May 17 18:36:21 2022 -0700 + + Changes to common source files not directly applicable to open-vm-tools. + +commit 784c520757e883c5e46e1d3a593e24d171cd280e +Author: John Wolfe +Date: Tue May 17 18:36:21 2022 -0700 + + Common header file change not applicable to open-vm-toole. + +commit 32db37a3cf437578efcb64d954aae9d5cca1ff83 +Author: John Wolfe +Date: Tue May 17 18:36:21 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 619f656f4444af598179345f8c35e056e3563de1 +Author: John Wolfe +Date: Tue May 17 18:36:21 2022 -0700 + + vm-support: Capture the locale configuration of the Linux guest. + + To aid in debugging issues related to locale configuration, the vm-support + command has been updated to collect the following: + + - The contents of the /etc/default/locale file if it exists. + - The contents of the /etc/locale.conf file if it exists. + - The output of the 'locale' command for the current environment. + - The output of the 'locale -a' command for a list of available locales. + +commit 0c675d3d53f9e859eaa396cabfbf68c85a9f5f72 +Author: John Wolfe +Date: Tue May 17 12:57:40 2022 -0700 + + Sync the README.md file with the version last released in the + stable-12.0.x and master branches. + +commit e7d6abcbd3134e01cd5a8602fe4edd01b9e60aec +Author: John Wolfe +Date: Fri May 6 14:40:22 2022 -0700 + + Update ChangeLog with the granular push of May 6, 2022. + - plus ChangeLog update of Apr. 19, 2022. + +commit 605c30a33f6dedc07ded8e24ce1491fba162ce82 +Author: John Wolfe +Date: Fri May 6 14:28:00 2022 -0700 + + Fix a compilation issue in the containerInfo plugin for i386 builds. + + The "gint64" type used for time values in the code is not a "long" on + i386. The fix using the glib "G_GINT64_FORMAT" macro was provided by + the Debian OVT maintainer. + + github PR: + https://github.com/vmware/open-vm-tools/pull/588 + +commit be5c99cbb69afc1586315195f40d0e31d4f742b1 +Author: John Wolfe +Date: Fri May 6 14:28:00 2022 -0700 + + Change to common header file not applicable to open-vm-tools. + +commit cf19772adf10706fa1da83aca21a9fc45977c387 +Author: John Wolfe +Date: Fri May 6 14:28:00 2022 -0700 + + Change to common header file not applicable to open-vm-tools. + +commit fde902600d26f8b38f13a7c535d094963f989697 +Author: John Wolfe +Date: Fri May 6 14:28:00 2022 -0700 + + Change to common header file not applicable to open-vm-tools. + +commit 0073b6ae4aed8466a2e657fe853cd993a60abd1b +Author: John Wolfe +Date: Fri May 6 14:28:00 2022 -0700 + + Changes to common source files not applicable to open-vm-tools. + +commit f9da69911d845d36515f8c45f6d5840f934a1189 +Author: John Wolfe +Date: Fri May 6 14:28:00 2022 -0700 + + Change to common header file not applicable to open-vm-tools. + +commit c613b3d554c49fe8bdc6103d90aa028e7bee854e +Author: John Wolfe +Date: Fri May 6 14:28:00 2022 -0700 + + Change to common header file not applicable to open-vm-tools. + +commit 9b9f221c486069d90ed6460edab72cb545ca0361 +Author: John Wolfe +Date: Fri May 6 14:28:00 2022 -0700 + + Change to common header file not applicable to open-vm-tools. + +commit 82e373eb02505791f34b0154a8c2762040034fd8 +Author: John Wolfe +Date: Fri May 6 14:28:00 2022 -0700 + + Change to common header file not applicable to open-vm-tools. + +commit 6df59bd95ec5a1a23be67483ef6a4c34cf849506 +Author: John Wolfe +Date: Fri May 6 14:27:59 2022 -0700 + + Change to common header file not applicable to open-vm-tools. + +commit 875d19750952f575f6f41b6ce4631ecdbe74b90a +Author: John Wolfe +Date: Fri May 6 14:27:59 2022 -0700 + + Service Discovery: Cassandra service version missed for a default Cassandra installation. + + Updated the get-versions.sh script to correctly report the version of the + Cassandra service running in the guest. + +commit 6452e34357b1dc258a038ea5137fd27d13f9f4ca +Author: John Wolfe +Date: Tue Apr 19 14:48:06 2022 -0700 + + Update ChangeLog with the granular push of Mar. 23, 2022. + - plus ChangeLog update of Apr. 4, 2022. + +commit f1e56311c8f245d6aba2a94d37e5df7220398ed5 +Author: John Wolfe +Date: Tue Apr 19 14:30:54 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 911b68fef82a3dfb083daa3bf0f61ed793e2961e +Author: John Wolfe +Date: Tue Apr 19 14:30:54 2022 -0700 + + Common header file change not directly applicable to open-vm-tools. + +commit c8f345b0cc50417665b0eff6bf19f0af2526ff74 +Author: John Wolfe +Date: Tue Apr 19 14:30:54 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit b3c2a0e00e3d40e979dacab1833a6711e0e5620a +Author: John Wolfe +Date: Tue Apr 19 14:30:54 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 19e2a77e0a2b29b77866876a5d45ec2df8f96d4f +Author: John Wolfe +Date: Tue Apr 19 14:30:54 2022 -0700 + + Changes to common header files not applicable to open-vm-tools. + +commit 93af2bbbe583e95598cfb46d042ac6025a6dcac8 +Author: John Wolfe +Date: Tue Apr 19 14:30:54 2022 -0700 + + Improve the "don't touch this" comments for Linux guest identification. + + Pull requests to add distro identification information are often submitted. + Open-vm-tools does not own the guest identification code. Such a change + requires coordinated changes throughout the VMware product stack. + + Improve the text to reduce pull requests for changes to common source + code that open-vm-tools does not own and cannot make. + +commit 36eea633611e678f3ea17a913c0990f319135c48 +Author: John Wolfe +Date: Tue Apr 19 14:30:54 2022 -0700 + + Make HgfsConvertFromNtTimeNsec aware of 64-bit time_t on i386. + + The change incorporates the support of 64 bit time epoch conversion + from Windows NT time to Unix Epoch time on i386. + + Addresses pull request: + https://github.com/vmware/open-vm-tools/pull/387 + +commit 472335e347018fbddfbbe45618193075e77fa836 +Author: John Wolfe +Date: Tue Apr 19 14:30:54 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit bb8a37981bfb76d9314d797c3ab1b394ce431d1d +Author: John Wolfe +Date: Tue Apr 19 14:30:54 2022 -0700 + + Changes to common header files not applicable to open-vm-tools. + +commit fb011741deec7e277f34974e32f88c60826e0db3 +Author: John Wolfe +Date: Tue Apr 19 14:30:54 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit d232afd908f22104a632e3060c9bf4170ac18018 +Author: John Wolfe +Date: Tue Apr 19 14:30:54 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 1b4db25a65153bd2c1c5a725303bf22a61ac931f +Author: John Wolfe +Date: Tue Apr 19 14:30:54 2022 -0700 + + Added the following miscellaneous checks for the deploypkg plugin. + + 1. Check if the plugin is running in a VMware VM. + 2. Check if the plugin is loaded by the main tools service. + 3. Check if the underlying hypervisor is ESXi. + +commit df63c64bf5e12a5f5bc0ba9bda4b786a4295ae5b +Author: John Wolfe +Date: Tue Apr 19 14:30:54 2022 -0700 + + Inclusive language - "kill" + + Address uses of the term "kill" in some files used by open-vm-tools. + +commit e057e41fc4d4e4e084cf46c9d16243fb05a7df19 +Author: John Wolfe +Date: Tue Apr 19 14:30:53 2022 -0700 + + Inclusive Language - "whitelist" + + Use allowlist instead of whitelist in some files used by open-vm-tools. + +commit 532cf9f3bb9dd3011239fb193f7458fc78ae921e +Author: John Wolfe +Date: Tue Apr 19 14:30:53 2022 -0700 + + ContainerInfo Plugin: correct compiler warnings in containerInfo_grpc.cc + + - The local variable "containersAdded" should be an 'unsigned int' since + it's compared with an 'unsigned int' parameter. + - Remove the unreferenced local variable "numContainers". + +commit 92a6422d03a932ab92f4b7c791673cf2f17bf3b9 +Author: John Wolfe +Date: Tue Apr 19 14:29:06 2022 -0700 + + Reverting previous bad patch erroneously comitted. + +commit 36b7f58392fbbb9e7bb336c0cf07202cba4d92cc +Author: John Wolfe +Date: Mon Apr 4 13:22:16 2022 -0700 + + Update ChangeLog with the granular push of Apr. 4, 2022. + - plus ChangeLog update of Mar. 23, 2022. + +commit 37f5400a44d1fbe4fdeef0fe048e8903af9f1907 +Author: John Wolfe +Date: Mon Apr 4 12:58:41 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 8665272146a9302faf16c98992f57d5cce6530bc +Author: John Wolfe +Date: Mon Apr 4 12:58:41 2022 -0700 + + Common header file change not directly related to open-vm-tools. + +commit 66644fb9b74bcad603a2e175e99be80b756bd6c8 +Author: John Wolfe +Date: Mon Apr 4 12:58:41 2022 -0700 + + VGAuth: Add secure VMX RPC support. + + - Added some error handling to work around VMX closing a + port that is being reused. + +commit eef3be312ad6f7ed5d96cafa15ffafc89bc43851 +Author: John Wolfe +Date: Mon Apr 4 12:58:41 2022 -0700 + + VGAuth: Update some error messages with certificate error text. + +commit b53ae31eaa20ec80f2d97f85ac6b9a295e21c287 +Author: John Wolfe +Date: Mon Apr 4 12:58:41 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit bd8be34a9a4e897d78297eb8ae970300e80253a0 +Author: John Wolfe +Date: Mon Apr 4 12:58:41 2022 -0700 + + DynBuf: Implement new function DynBuf_SafeInternalInsert(). + +commit d59878b05d57393770f1cf064141a17c9a8af3f4 +Author: John Wolfe +Date: Mon Apr 4 12:58:41 2022 -0700 + + DynBuf: Implement new function DynBuf_Insert. + + - DynBuf_Insert(): Insert data at a given offset within a dynamic buffer. + +commit 70509b63b728b65adfeb62afa40488782cc7f5f1 +Author: John Wolfe +Date: Mon Apr 4 12:58:41 2022 -0700 + + Record use of tools version 10.3.25. + + Adding version 10.3.25 to the list of releases or planned releases + of VMware Tools. + +commit 33b7eb9f3f3b8d58025f484a9c5fd30293f60622 +Author: John Wolfe +Date: Mon Apr 4 12:58:41 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit e7b3c7180fdf8f62b9852af90cdad725e69480da +Author: John Wolfe +Date: Mon Apr 4 12:58:41 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 936537f6234690f8ae1afba3ae8b0a6a89df6625 +Author: John Wolfe +Date: Mon Apr 4 12:58:41 2022 -0700 + + Generalize VMX RPC code in vgauthservice. + - Rework the code so that it can used for other RPCs in the future. + - Rework the code reading the RPC reply, since it can now be much larger. + - Also remove the attempt to use the "guest.log.text" RPC since the VMX + will just drop the logging on the floor with no error if the virtual + HW version is too old. A smart fail over is not possible. + +commit 2fe3cccfc1c36e946f46fb57813dd50c6c7f89dd +Author: John Wolfe +Date: Wed Mar 23 13:00:26 2022 -0700 + + Update ChangeLog with the granular push of Mar. 23, 2022. + - plus ChangeLog update of Mar. 10, 2022. + +commit 405c57fbcfe8772679fdaf594b368f5a68b31edf +Author: John Wolfe +Date: Wed Mar 23 12:04:31 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit b167d985e0632d6455334e09437905ab54fa1a60 +Author: John Wolfe +Date: Wed Mar 23 12:04:31 2022 -0700 + + Record the use of tools version 12.0.5. + +commit 577764a4adf5e6ff595e23fe54c30ccdce353977 +Author: John Wolfe +Date: Wed Mar 23 12:04:31 2022 -0700 + + Change to common header files not applicable to open-vm-tools. + +commit f0cb3eebe942fba3f5abca32303998985a756b90 +Author: John Wolfe +Date: Wed Mar 23 12:04:31 2022 -0700 + + Common header file change not applicable to open-vm-tools. + +commit b571bf4026b6f2dee31102a55dd7338c276646f9 +Author: John Wolfe +Date: Wed Mar 23 12:04:31 2022 -0700 + + VGAuth: Customize libxml2 to open local file with unescaped file name only. + +commit c0408788b07ec42f8c1bcf3e7373032d8b9784b3 +Author: John Wolfe +Date: Thu Mar 10 12:06:56 2022 -0800 + + Update ChangeLog with the granular push of Mar. 10, 2022. + - plus README.md updates related to 12.0.0 OVT release. + - plus ChangeLog update of Feb. 17, 2022. + +commit b47748c330f1fa495f099db0d6fcc300f9e82240 +Author: John Wolfe +Date: Thu Mar 10 11:36:24 2022 -0800 + + Common header file change not applicable to open-vm-tools. + +commit 6e16f34ac546f5cdf156cc484b29823b84603f76 +Author: John Wolfe +Date: Thu Mar 10 11:36:24 2022 -0800 + + Changes to common header files not directly related to open-vm-tools. + +commit e57a78d2fa4afe47b1a5d2d12d4e0a4a71db1073 +Author: John Wolfe +Date: Thu Mar 10 11:36:24 2022 -0800 + + Service Discovery: Script correction to collect the version of Cassandra. + +commit dfff48a686515a5046d8e33b8181f34f79fe6fa6 +Author: John Wolfe +Date: Thu Mar 10 11:36:23 2022 -0800 + + Common header file change not applicable to open-vm-tools. + +commit 092cc7135b6d0f5fc4dbbf8b14a3093dbee402d8 +Author: John Wolfe +Date: Thu Mar 10 11:36:23 2022 -0800 + + Common header file change not applicable to open-vm-tools. + +commit 68391545c1c7ac7804429f7dc73a158d74690b82 +Author: John Wolfe +Date: Thu Mar 10 11:36:23 2022 -0800 + + Common header file change not applicable to open-vm-tools. + +commit 69ce810007b0390a369425bc3561ab7befdb040c +Author: John Wolfe +Date: Thu Mar 10 11:36:23 2022 -0800 + + Common header file change not applicable to open-vm-tools. + +commit 97440ff3bc72428be0158cada3afc2513ead463a +Author: John Wolfe +Date: Wed Mar 2 16:49:49 2022 -0800 + + Update the README.md document. + - Adding configure and build information for new plugins and service(s) + added in the 12.0.0 tools release. + +commit 09ea13cfb0947137dd31cd1f278739e49aff95fc +Author: John Wolfe +Date: Tue Feb 22 16:52:02 2022 -0800 + + Update the list of operating system with open-vm-tools. Add: + * Flatcar Container Linux, all releases + * Rocky 8 and later releases + * AlmaLinux OS 8 and later releases + + Addresses: + https://github.com/vmware/open-vm-tools/pull/573 + https://github.com/vmware/open-vm-tools/pull/513 + +commit 43d17bd3f2e93566ee7b588494d29ab857c7a95f +Author: John Wolfe +Date: Thu Feb 17 15:10:47 2022 -0800 + + Update ChangeLog with the granular push of Feb. 17, 2022. + - plus ChangeLog update of Feb. 7, 2022. + +commit 2cf575e2fb0a6c83211e8e09339491889bdcc8fe +Author: John Wolfe +Date: Thu Feb 17 15:01:31 2022 -0800 + + Add missing 2022 copyright. + +commit 66b79830eccb5fd8c7b85f07b8090c763e12783c +Author: John Wolfe +Date: Thu Feb 17 14:51:25 2022 -0800 + + Common header file change not applicable to open-vm-tools. + +commit 27bd6b5a84370ad488227614df3740ad6c2014db +Author: John Wolfe +Date: Thu Feb 17 14:51:25 2022 -0800 + + Common header file change not applicable to open-vm-tools. + +commit bb597ad25dbf695b5d16ddea3c09080d1a715967 +Author: John Wolfe +Date: Thu Feb 17 14:51:25 2022 -0800 + + Backout previous changes to common header files not applicable to open-vm-tools. + +commit 92254389f42b0a09ea140427afb4d0352a56cb4b +Author: John Wolfe +Date: Thu Feb 17 14:51:25 2022 -0800 + + Adding configuration information for the GlobalConf feature. + + As part of the GlobalConf feature, a "globalconf" section is introduced + into tools.conf to provide custom configuration options for the feature. + The configuration parameters are as follows: + * enabled=false - Enable/disable the GlobalConf module. + * poll-interval=3600 - Poll interval for the GlobalConf feature. + * resource= - Defines the location of the tools.conf in the + GuestStore. There is a separate default for Windows + and Linux guests. + +commit 1b5114ab87e342af85eb340237ba2d747b49fdad +Author: John Wolfe +Date: Thu Feb 17 14:51:25 2022 -0800 + + Common header file change not applicable to open-vm-tools. + +commit f35987b39f2874f13b2f4facd1b1d3dde7ae2a63 +Author: John Wolfe +Date: Thu Feb 17 14:51:25 2022 -0800 + + Common header file change not applicable to open-vm-tools. + +commit de6d129476724668b8903e2a87654f50ba21b1b2 +Author: John Wolfe +Date: Thu Feb 17 14:51:25 2022 -0800 + + asyncsocket.c: Use size_t in place of int type for array size and indexing. + + Glibc 2.35 with GCC 11 and 12 produces additional warnings about strings + and array bounds. Switching from "int" to "size_t" type for variable + used for the array size and element indexing. + + GCC warned when an integer value is passed as the size of the + struct pollfd array to poll(). + + Fixes https://github.com/vmware/open-vm-tools/issues/570 + +commit 956fd221b6697242405bc3c1f8fe5c18236a9b68 +Author: John Wolfe +Date: Thu Feb 17 14:51:25 2022 -0800 + + Changes to common header files not applicable to open-vm-tools. + +commit 760d6ca22de590ffcce82c43926d8b91474cf101 +Author: John Wolfe +Date: Mon Feb 7 10:01:44 2022 -0800 + + Update ChangeLog with the granular push of Feb. 7, 2022. + - plus ChangeLog and late copyright update of Jan. 20, 2022. + +commit 8406802f4bf9269f02b6850b10741a7fce1635bc +Author: John Wolfe +Date: Mon Feb 7 09:52:43 2022 -0800 + + Correct missed 2022 copyright update. + +commit 4311a4a5d2952703cb808feb1f6372e28c2afc68 +Author: John Wolfe +Date: Mon Feb 7 09:40:01 2022 -0800 + + Common header file change not applicable to open-vm-tools. + +commit e9e485b9d6fd41acb5a777896b7c7efb32632722 +Author: John Wolfe +Date: Mon Feb 7 09:40:00 2022 -0800 + + Common header file change not applicable to open-vm-tools. + +commit a085da930a078f956192bb257de251a58e49a5f2 +Author: John Wolfe +Date: Mon Feb 7 09:40:00 2022 -0800 + + Common header file change not applicable to open-vm-tools. + +commit 5b0c9eada72482a7149a5188f11d470272e53087 +Author: John Wolfe +Date: Mon Feb 7 09:40:00 2022 -0800 + + Common header file change not applicable to open-vm-tools. + +commit 8692a2327c0bcd4608fd40d8f7539da5d82e6b28 +Author: John Wolfe +Date: Mon Feb 7 09:40:00 2022 -0800 + + Enable time step correction log in all builds. + + Enabled logging of the information in all builds of open-vm-tools. + This is useful for auditing and for debugging. + +commit 87389ed6975ed40bdc7883c64c2509da6650a435 +Author: John Wolfe +Date: Mon Feb 7 09:40:00 2022 -0800 + + Common header file change not applicable to open-vm-tools. + +commit 05943d86fbc47821c3036eaa3b11b7b7a1eb2780 +Author: John Wolfe +Date: Mon Feb 7 09:40:00 2022 -0800 + + Common header file change not applicable to open-vm-tools. + +commit d8ad6f5c0d2237ed6eb3230720be9701547e2ed9 +Author: John Wolfe +Date: Mon Feb 7 09:40:00 2022 -0800 + + Service Discovery script update. + + Updated the get-version.sh script to retrieve the vRLI version. + +commit a9e72b211bafb19ca0e674bf73351e1aa859d083 +Author: John Wolfe +Date: Mon Feb 7 09:40:00 2022 -0800 + + Common header file change not applicable to open-vm-tools. + +commit 5a040d4c25705565e8397b2135506e93e320bd54 +Author: John Wolfe +Date: Mon Feb 7 09:40:00 2022 -0800 + + Common header file cahnge not applicable to open-vm-tools. + +commit 627f748ab314c6bd2b6a5023d1f17684bd8eec0d +Author: John Wolfe +Date: Mon Feb 7 09:40:00 2022 -0800 + + Common source file change not applicable to open-vm-tools. + +commit 2290690693f0590bb5ffbd592ebd4b8062d57513 +Author: John Wolfe +Date: Mon Feb 7 09:40:00 2022 -0800 + + AppVisibility: Skip terminated/stopped containers. + + Added code to skip terminated/stopped containers. This is done + by using TaskStub to retrieve the pid for the running container. + If the pid cannot be retrieved, then that container is skipped. + + The previously suppressed "default" namespace has been restored. + + Fixed another minor issue with calculating the number of containers + that were added. + + Note: This changeset introduces a dependency on Tasks.proto, and + Tasks.proto depends on a few other proto files like mount, metrics, + descriptor and task. Modified the makefile to generate the necessary + C++ files from the proto files. + + Additional notes: + - .proto -> generates .pb.h, .pb.c and .grpc.pb.cc files. + - For compiling and building the library (.so file), the .grpc.pb.{h,cc} + and .pb.{h,cc} files are needed. + - The protoc compiler generates .pb.h and .pb.c files when the --cpp_out + option is specified. + - The protoc compiler generates .grpc.pb.* when the --grpc_out option is + specified. + +commit 5e79bc1414f31a07a9fb74c624b8b435546e0212 +Author: John Wolfe +Date: Mon Feb 7 09:40:00 2022 -0800 + + Common source file change not applicable to open-vm-tools. + +commit 75f3a3e2e6b4cfec157c02e8f06e5ac139ad98cc +Author: John Wolfe +Date: Mon Feb 7 09:40:00 2022 -0800 + + Common header file change not applicable to open-vm-tools. + +commit 192667e6e65ad7d7592798ef567278dbe15c293d +Author: John Wolfe +Date: Thu Jan 20 15:01:49 2022 -0800 + + Last minute 2022 copyright updates to several files. + +commit 99c00042476803def0d1aea4fc28cd59e271859d +Author: John Wolfe +Date: Thu Jan 20 11:50:29 2022 -0800 + + Update ChangeLog with the granular push of Jan. 20, 2022. + - plus ChangeLog update of Jan 2, 2022. + +commit bd0f9506e5ad3ee42c95cbd1aea0c9381e4abf59 +Author: John Wolfe +Date: Thu Jan 20 11:40:15 2022 -0800 + + Common header file change not applicable to open-vm-tools. + +commit ddd97d710b1b49a2d8b3679ac07c70feacb2aeb0 +Author: John Wolfe +Date: Thu Jan 20 11:40:15 2022 -0800 + + Common header file change not applicable to open-vm-tools. + +commit b4a4387294cc9dc3cb890093398abad4d0800bc2 +Author: John Wolfe +Date: Thu Jan 20 11:40:15 2022 -0800 + + Common header file change. + + Prepare to recognize macOS 14, Debian GNU/Linux 12, Rocky Linux, + and AlmaLinux. + +commit cbc229407f734a7b44aeecb9e3a6a51975ace35e +Author: John Wolfe +Date: Thu Jan 20 11:40:15 2022 -0800 + + open-vm-tools-12.0.0 L10n drop. + +commit e85e58885523f69b01fc8a49ee40732df6b6e2a6 +Author: John Wolfe +Date: Thu Jan 20 11:40:15 2022 -0800 + + ContainerInfo: Remove 'default' namespace from the default allowed namespace list. + +commit b9ebabe69f0d864bfaa28bf8773a4c8a51e29416 +Author: John Wolfe +Date: Thu Jan 20 11:40:15 2022 -0800 + + Changes to common source files not applicable to open-vm-tools. + +commit e2de0491601d6c14e5aa4b64467cced413ff28e6 +Author: John Wolfe +Date: Thu Jan 20 11:40:15 2022 -0800 + + Common header file change not applicable to open-vm-tools. + +commit 28dd7a83e35173ac7d1869906442ded5d1c632eb +Author: John Wolfe +Date: Thu Jan 20 11:40:15 2022 -0800 + + Common header file change not applicable to open-vm-tools. + +commit 750eed3fc4dc6d0265bc3e28b845e76ca3acf944 +Author: John Wolfe +Date: Thu Jan 20 11:40:15 2022 -0800 + + Common header file change not applicable to open-vm-tools. + +commit b59acd69c499825b1e0cc451f3c3798b1bb18d1c +Author: John Wolfe +Date: Thu Jan 20 11:40:15 2022 -0800 + + Common header file change not applicable to open-vm-tools. + +commit 0f084152e3e03d22dcaa5d80118f244dba3f1455 +Author: John Wolfe +Date: Thu Jan 20 11:40:15 2022 -0800 + + Set tools builds on the "devel" branch to version 12.1.0. + + Also, add back the definitions of TOOLS_VERSION_NEXT* inadvertently + removed in the previous change to vm_tools_version.h. + +commit f48b8797c14d43b3786fddae8bd38b890e48cd9d +Author: John Wolfe +Date: Thu Jan 20 11:40:15 2022 -0800 + + Common header file change not applicable to open-vm-tools. + +commit 87396d0925299645ce77491ca8ad30ad1cb01c85 +Author: John Wolfe +Date: Thu Jan 20 11:40:15 2022 -0800 + + Restrict Enable Salt Minion feature to x86_64 systems. + + Currently Salt Minion is available only for x86_64 systems. Update + configure.ac to exclude ENABLE_SALTMINION from ARM and 32-bit systems. + +commit 9c171d9aede372e9647fe05f09a0e127df6d1dbd +Author: John Wolfe +Date: Thu Jan 20 11:40:15 2022 -0800 + + Common header file change not applicable to open-vm-tools. + +commit bc9832a87009a1d41729ea6d07d1fae960026655 +Author: John Wolfe +Date: Sun Jan 2 02:20:56 2022 -0800 + + Update ChangeLog with the granular changes through 12/31/21. + - granular push of Jan. 2, 2022 + - plus ChangeLog update of Dec. 25. + +commit 34415b186a26a563690025d50b582cb7a73aef77 +Author: John Wolfe +Date: Sun Jan 2 02:10:04 2022 -0800 + + Set SABRE_SAW as the code name for the VMware Tools 12.0.0 release. + +commit e52bbb643aebf0a414d00c519cbe748a378d1570 +Author: John Wolfe +Date: Sun Jan 2 02:10:04 2022 -0800 + + The header added to the vmsvc log file is repeated at log file rotation. + + The log entry with the tools version, tools build number and guest OS + details added at the start of the vmsvc log file is repeated when log + file rotation occurs. + +commit c4220766355a623901f3d562ad03ddd3745729fd +Author: John Wolfe +Date: Sat Dec 25 10:10:54 2021 -0800 + + ==================================================================== + The "stable-12.0.x" branch was created from the "devel" branch here. + ==================================================================== + + Update ChangeLog with the granular push of Dec. 25, 2021. + - plus ChangeLog update of Dec. 21. + +commit f6d49e0acd81353d8022b639e231bc517a69b166 +Author: John Wolfe +Date: Sat Dec 25 09:51:13 2021 -0800 + + Common source file changes not directly applicable to open-vm-tools. + +commit ff6e8264fedfc3237ab66b91598d998bfa7eae39 +Author: John Wolfe +Date: Sat Dec 25 09:51:13 2021 -0800 + + Salt-minion and componentMgr plugin updates. + + Lastest version of the Salt Minion installer script. + The poll-interval of the componentMgr can be set to a minimum value of + five (5) seconds when compiled with -DVMX86_DEBUG. + +commit f0b616649db5cb3c7a5251cd981401bbf74039c7 +Author: John Wolfe +Date: Sat Dec 25 09:51:13 2021 -0800 + + Common header file change not applicable to open-vm-tools. + +commit 3c3cfcc9a9d16e79a9ef886f2831a7be28e9e596 +Author: John Wolfe +Date: Tue Dec 21 13:19:21 2021 -0800 + + Update ChangeLog with the granular push of Dec. 21, 2021. + - plus ChangeLog update of Dec. 4. + +commit 7987a3440f0d05b18faa77b9f9f67ae55d8a1cf1 +Author: John Wolfe +Date: Tue Dec 21 13:07:55 2021 -0800 + + Update missed 2021 copyright. + +commit 4c66981405127910285d182930e049c4fb496a7a +Author: John Wolfe +Date: Tue Dec 21 12:48:50 2021 -0800 + + Change to a common header file not applicable to open-vm-tools. + +commit cc72edfdd60497b86b8e7f20495c85ce414d6106 +Author: John Wolfe +Date: Tue Dec 21 12:48:50 2021 -0800 + + Changed the log domain of the containerInfo plugin to containerinfo. + + This will make both 'config group name' and 'logging domain' name the same. + Did some code-reorg. + +commit 97917fce5828ef0efdae59d7bb6e4dd7f0caeae0 +Author: John Wolfe +Date: Tue Dec 21 12:48:50 2021 -0800 + + Update open-vm-tools to build with either Fuse 3 or Fuse 2 + + Vendors are requesting that open-vm-tools can be built with either + Fuse 2 or Fuse 3. While both Fuse 2 and Fuse 3 runtime can be + installed on a Linux system, vendors would prefer to switch from + Fuse 2 to Fuse 3 at the same time for all products to be available + with the base OS. + + Updating the configure.ac file to check for the presence of the Fuse 3 + or Fuse 2 development packages in the build environment. Providing + configure options to allow users to control the version of Fuse to be + used. + --without-fuse - vmblock-fuse and vmhgfs-fuse will be disabled. + --with-fuse=fuse3|3 - use Fuse 3.x + --with-fuse=fuse|2 - use Fuse 2.x + --with-fuse=auto - check for Fuse 3 or Fuse 2 availability; disable + vmblock-fuse and vmhgfs-fuse if unavailable. + --with-fuse - implicit "yes". + --with-fuse=yes - check for Fuse 3 or Fuse 2 availability; disable + vmblock-fuse and vmhgfs-fuse if unavailable. + + Pull request: https://github.com/vmware/open-vm-tools/pull/544 + Fixes issue: https://github.com/vmware/open-vm-tools/issues/314 + + The vmblock-fuse code is also used by WorkStation. Configure defines + are not available in internal builds. Reworked preprocessor tests to + use FUSE_MAJOR_VERSION from the fuse headers to determine API to be + used during compilation. + +commit d0571b23fe1513c0ec83e8b57bd8e91edd5b86a3 +Author: John Wolfe +Date: Tue Dec 21 12:48:50 2021 -0800 + + Changes to common source files not applicable to open-vm-tools. + +commit 7776c845db0bc24c5103d80a8d8f76d73f79ec39 +Author: John Wolfe +Date: Tue Dec 21 12:48:50 2021 -0800 + + Change to a common header file not applicable to open-vm-tools. + +commit ec4040bfc25818e5979f8c681f13b4c0e3d9c38a +Author: John Wolfe +Date: Tue Dec 21 12:48:50 2021 -0800 + + Changes to a common source file not applicable to open-vm-tools. + +commit 3695f042018aedbca6d37751d3d1577bf1887aa1 +Author: John Wolfe +Date: Tue Dec 21 12:48:50 2021 -0800 + + Common source file change not applicable to open-vm-tools. + +commit 7cb1006b6f362a1e19b6dbaea5ae30bd727d4f5b +Author: John Wolfe +Date: Tue Dec 21 12:48:50 2021 -0800 + + Fix potential integer overflow when calling g_timeout_source_new() or + g_timeout_source_new_seconds(). + +commit c69332a9252413b265b4a146c072bcae8b16a3d3 +Author: John Wolfe +Date: Tue Dec 21 12:48:50 2021 -0800 + + Common header file change not applicable to open-vm-tools. + +commit 1c916a09107b2b6c901488587711db569ade9223 +Author: John Wolfe +Date: Tue Dec 21 12:48:50 2021 -0800 + + Changes to common header files not applicable to open-vm-tools. + +commit 8296854e348014441368af01edc41c728b80de86 +Author: John Wolfe +Date: Tue Dec 21 12:48:50 2021 -0800 + + Clean up of guest OS tables. + + Use official defines for Arm and guestOS strings. + +commit d5a3e4b02c5515cde9f10e351b67dade9c073d6e +Author: John Wolfe +Date: Tue Dec 21 12:48:50 2021 -0800 + + Remove the collection of GRUB files from the vm-support script + + GRUB configuration files have not been needed in the past. Therefore, as part + of this change, removing the code from vm-support script which collects any + grub configuration files. + +commit 63abb4f4b0fe73205888bedca91385faf3f53bf7 +Author: John Wolfe +Date: Tue Dec 21 12:48:50 2021 -0800 + + Adding Alma Linux and Rocky Linux to tools guest ID code. + +commit 89d3e8d9560708be308b0511bbacece903651790 +Author: John Wolfe +Date: Tue Dec 21 12:48:50 2021 -0800 + + Refactored the componentMgr plugin code following standard practices. + +commit d33c816998b8680b67b39a096f44e95d5019e1ab +Author: John Wolfe +Date: Tue Dec 21 12:48:50 2021 -0800 + + Adding Alma and Rocky Linux for x86 and Arm architectures. + +commit dce3b03c433e4ff77df5703e97519e3b32c9cf14 +Author: John Wolfe +Date: Tue Dec 21 12:48:50 2021 -0800 + + Common header file change not applicable to open-vm-tools. + +commit 32dd72b34033ba0f7eda8456a67bd45fee98c483 +Author: John Wolfe +Date: Tue Dec 21 12:48:50 2021 -0800 + + Common source file changes not directly applicable to open-vm-tools. + +commit 6b3e2e5ae06c77c122bc890a8ff8c3dede6368c9 +Author: John Wolfe +Date: Tue Dec 21 12:48:50 2021 -0800 + + Changes to common header files not applicable to open-vm-tools. + +commit ed84c0a175c0122555a6a7cc947590569d28becb +Author: John Wolfe +Date: Tue Dec 21 12:48:50 2021 -0800 + + containerInfo Plugin: list the Docker and Kubernetes containers in a guest VM. + + Added code for a new open-vm-tools plugin, containerInfo. + - Added a new configure option --disable-containerinfo to disable building + the containerinfo plugin. + --disable-containerinfo : Will not check for any dependent packages and + will not build the containerinfo plugin. + --enable-containerinfo=no : Same as --disable-containerinfo + --enable-containerinfo=auto : Checks for the dependent packages. If they + are available, then the containerinfo plugin + will be built. Otherwise, a warning is printeds + and the containerinfo plugin will be skipped. + --enable-containerinfo + --enable-containerinfo=yes : Checks for the dependent packages. If they are + available, then the containerinfo plugin will + be built. Otherwise, the configure will + terminate with an error. + + - Updated the sample tools.conf file with various settings related to + the containerinfo plugin. + - Due to an issue reported in https://github.com/protocolbuffers/protobuf/issues/9184, + implemented a workaround by changing 'import weak ' to 'import ' in the + .proto files while generating the header files. + + Build dependencies: (packages names may vary with Linux release). + - or - + - libcurl4-openssl-dev libcurl-devel + - protobuf-compiler protobuf-compiler + - libprotobuf-dev protobuf-devel + - protobuf-compiler-grpc grpc-plugins + - libgrpc++-dev grpc-devel + - golang-github-containerd-containerd-dev containerd-devel + - golang-github-gogo-protobuf-dev + + Runtime requirements: + + - curl, protobug and grpc-cpp + +commit b36b275bc8cd14c1e2e64f76e3b41307e24a165f +Author: John Wolfe +Date: Tue Dec 21 12:48:49 2021 -0800 + + Set the "svtminion.sh" script version to '1.0'. + +commit 53949064ee169cdba0925d99a1f9a75f63dbf39b +Author: John Wolfe +Date: Tue Dec 21 12:48:49 2021 -0800 + + Common header file change not applicable to open-vm-tools. + +commit b38a34acdf9ed3113e53f5e9f2c3cc0927df50eb +Author: John Wolfe +Date: Tue Dec 21 12:48:49 2021 -0800 + + Common header file change not applicable to open-vm-tools. + +commit 308259f3e5e3630cd30bd04aa0fd0d4c952d7ff2 +Author: John Wolfe +Date: Tue Dec 21 12:48:49 2021 -0800 + + Added the componentMgr plugin to the vmtoolsd vmsvc process. + + The new componentMgr plugin manages adding/removing of components + in the guest. + +commit db3a1dc6c9cc771bf4c4d8a268b6747f167bcad7 +Author: John Wolfe +Date: Tue Dec 21 12:48:49 2021 -0800 + + Salt Stack Script Integration for Linux. + + Added the "svtminion.sh" script which will be packaged for Linux to + support SaltStack integration and management from the componentMgr plugin. + +commit 50500199ac9e36ee67deffe51ccd714a6a90ef46 +Author: John Wolfe +Date: Tue Dec 21 12:48:49 2021 -0800 + + Activate the componentMgr plugin build and enablement of the Salt-Minion plugin. + +commit 67383c5669650766fbdb18962ce05afafb6d0dca +Author: John Wolfe +Date: Tue Dec 21 12:48:49 2021 -0800 + + Prepare to enable Mac OS 14 (Darwin 23) as a new guest. + +commit 3ca3a1d1ff4edb9ab6dbe5e30079167710ee5d06 +Author: John Wolfe +Date: Tue Dec 21 12:48:49 2021 -0800 + + filePosix.c: Increased the hash table size for better performance. + + Improved the performance of the functions File_ListDirectory() and + File_WalkDirectoryStart(). + +commit 011d680184caa26fd4d4d6fe77f77a862aee0adb +Author: John Wolfe +Date: Tue Dec 21 12:48:49 2021 -0800 + + Changes to common header files not applicable to open-vm-tools. + +commit be8ec133fb755dec100de90d6f5d42dd2a56cf6c +Author: John Wolfe +Date: Tue Dec 21 12:48:49 2021 -0800 + + Common header file change not applicable to open-vm-tools. + +commit 8b97e826ce53cbcd6ca5aa568906ffbe1b57f0d4 +Author: John Wolfe +Date: Tue Dec 21 12:48:49 2021 -0800 + + Common header file change not applicable to open-vm-tools. + +commit de920bf8398bcf7a017a4b012e84cf98d67babab +Author: John Wolfe +Date: Sat Dec 4 23:09:31 2021 -0800 + + Update ChangeLog with the granular push of Dec. 4, 2021. + - plus ChangeLog update of Nov. 19. + +commit 2cadef44dc8c156d8543111d62340212c501aa0d +Author: John Wolfe +Date: Sat Dec 4 22:55:11 2021 -0800 + + Common header file change not applicable to open-vm-tools. + +commit 5fc921074bbf7eba8ee1827de7f12417769e30ca +Author: John Wolfe +Date: Sat Dec 4 22:55:11 2021 -0800 + + Adding RHEL9_ARM and OTHERLINUX6_ARM to the ALLARM group. + +commit b3cb33a91bb97a17b575b77fa9a622b1a9a74a74 +Author: John Wolfe +Date: Sat Dec 4 22:55:11 2021 -0800 + + Changes to common header files not applicable to open-vm-tools. + +commit 8459c9bcda9b7901de0128d1cb594227b33eea1a +Author: John Wolfe +Date: Sat Dec 4 22:55:11 2021 -0800 + + Common header file change not applicable to open-vm-tools. + +commit 611dce7461466fbde66466b08efed436c3c9b3cb +Author: John Wolfe +Date: Sat Dec 4 22:55:11 2021 -0800 + + Common header file change not applicable to open-vm-tools. + +commit 9920a7e9141ae4910cc77b7891dd14607ee8a474 +Author: John Wolfe +Date: Fri Nov 19 12:52:20 2021 -0800 + + Update ChangeLog with the granular push of Nov. 19, 2021. + - plus ChangeLog update of Nov. 8. + +commit 28666842fb665b9039ea32a0de5602e6873ac442 +Author: John Wolfe +Date: Fri Nov 19 11:40:50 2021 -0800 + + [AsyncSocket] Avoid a potential NULL pointer dereference in a log message. + + A log message in AsyncTCPSocketListenerCreateImpl() accesses an error code + through an optional parameter. Introduce a local error variable to + capture any error code from called functions and have it available for the + log message. + +commit 342fd81a270bf36c79baec5bb928a9a979e95af2 +Author: John Wolfe +Date: Fri Nov 19 11:40:50 2021 -0800 + + Correct the guestFamily reported for RHEL 9. + + RHEL 9 had not been added to the ALLLINUX macro. This has been + corrected. + +commit 36514e38f5e31a74ef2e38cb13cebd054a52179d +Author: John Wolfe +Date: Fri Nov 19 11:40:50 2021 -0800 + + Common source file change not directly applicable to open-vm-tools. + +commit a91770b88b3d6f534944867f9c58f982b3f6c37a +Author: John Wolfe +Date: Fri Nov 19 11:40:50 2021 -0800 + + Change to common header file not applicable to open-vm-tools. + +commit 9997bb0c311e5d931d53f1a4328ced07ec911b77 +Author: John Wolfe +Date: Fri Nov 19 11:40:50 2021 -0800 + + Change to common header file not applicable to open-vm-tools. + +commit e4b6231aab74fcc51cf6a22848d9512605be8d28 +Author: John Wolfe +Date: Fri Nov 19 11:40:50 2021 -0800 + + Change to common header file not applicable to open-vm-tools. + +commit 44f883c59b11912eccfc67df5a9723a2848433b1 +Author: John Wolfe +Date: Mon Nov 8 14:03:23 2021 -0800 + + Update ChangeLog with the granular push of Nov. 8, 2021. + - plus ChangeLog update of Oct. 18. + +commit 819a20bd5fd2d4f84ae56183d2b2fa4fc88dd72b +Author: John Wolfe +Date: Mon Nov 8 13:33:58 2021 -0800 + + Common header file change not applicable to open-vm-tools. + +commit 53a3387f9bb7f15fd504d6a44c4d8608c1b6ef56 +Author: John Wolfe +Date: Mon Nov 8 13:33:58 2021 -0800 + + Code clean up. + - Fix assignments of pointer to constant data to a non-constant + pointer type. + - Remove code that has been commented out. + - Updated treatment of pointers as a boolean expression to be + a true boolean expression. + - Fixed some formatting issues. + +commit 04515ad7b6f3291af6236ef492de8bfb927d3151 +Author: John Wolfe +Date: Mon Nov 8 13:33:58 2021 -0800 + + Update open-vm-tools 12.0.0 to work with openssl 1.1.1 or 3.0.0. + +commit 0186a8af01f1dd09090cfcd1ddd5487d60c1026e +Author: John Wolfe +Date: Mon Nov 8 13:33:58 2021 -0800 + + AppInfo Enhancement: Remove duplicate applications. + + Update appinfo to remove duplicate applications from guestVar. + Add a "remove-duplicates" tools.conf key, which is enabled by default. + Setting "remove-duplicates=false" disables the functionality. + +commit 899063f29c498d1a0abd7ffce71ae05260a5555d +Author: John Wolfe +Date: Mon Nov 8 13:33:57 2021 -0800 + + Common header file change not applicable to open-vm-tools. + +commit aaaefaf7e0cc39bc7ec1c7f89069f5bf96baf5ca +Author: John Wolfe +Date: Mon Nov 8 13:33:57 2021 -0800 + + ServiceDiscovery: Enhance version scripts to discover vRLi and + Cassandra services versions. + +commit 8a4e38f66325092f84ba612e614f6fd16e135752 +Author: John Wolfe +Date: Mon Nov 8 13:33:57 2021 -0800 + + Common header file change not applicable to open-vm-tools. + +commit ffbbc2932e8fa348e7177f3cf91c1085641a295c +Author: John Wolfe +Date: Mon Nov 8 13:33:57 2021 -0800 + + Common header file change not applicable to open-vm-tools. + +commit e501f711f59b30ce4d402d5bbc2361cb5b29f541 +Author: John Wolfe +Date: Mon Nov 8 13:33:57 2021 -0800 + + Common header file change not applicable to open-vm-tools. + +commit df85d1e571414fdecabc98492da53fe2950a8e6b +Author: John Wolfe +Date: Mon Nov 8 13:33:57 2021 -0800 + + Changes to common source files not applicable to open-vm-tools. + +commit d40c8b6d3086f95980b41a1012639ae796e80fbc +Author: John Wolfe +Date: Mon Nov 8 13:33:57 2021 -0800 + + Common header file change not applicable to open-vm-tools. + +commit 16e24c8d789f8ff81a9fbb915858cb6af88f66a5 +Author: John Wolfe +Date: Mon Oct 18 07:44:47 2021 -0700 + + Update ChangeLog with the granular push of Oct. 18, 2021. + plus ChangeLog update of Oct. 6. + +commit d3158f108ec8119d270d08d613545b61f4a6d50b +Author: John Wolfe +Date: Mon Oct 18 07:31:44 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 8407406335a8f1bc25a23497cdb5b880fc2db6aa +Author: John Wolfe +Date: Mon Oct 18 07:31:44 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit e9907529c68df57dbf1baa5c5b0872098fb3bbeb +Author: John Wolfe +Date: Mon Oct 18 07:31:44 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 1ec43b3ef88719d8d3ad206e7a427c479c496e0d +Author: John Wolfe +Date: Mon Oct 18 07:31:44 2021 -0700 + + Remove characters from saml-schema-assertion-2.0.xsd. + + The file, created with Windows in 2011, has been changed + to Unix encoding. + +commit ae7d374ee335277a637ec99ada728df7545f2459 +Author: John Wolfe +Date: Mon Oct 18 07:31:44 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit f9bfc57babb4cc18e8fcada6f44c26d7dfca90ce +Author: John Wolfe +Date: Mon Oct 18 07:31:44 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit a45ded9333305f71eea2e0ab4cc144fc2efad74f +Author: John Wolfe +Date: Mon Oct 18 07:31:44 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 6ff8e802b6a2fdf1595d032a1ab94b9f83a2f61b +Author: John Wolfe +Date: Mon Oct 18 07:31:44 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 8f2a9bb928e5d41c308684e68ed68a742dfd8222 +Author: John Wolfe +Date: Mon Oct 18 07:31:44 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit c9639690ec6d7bce96a7c06d0a05546b811d6b1f +Author: John Wolfe +Date: Mon Oct 18 07:31:44 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit a1aa6abc127d872966415e5fd01a9e35db0f2ef5 +Author: John Wolfe +Date: Mon Oct 18 07:31:44 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 88de2de0f48cb0334cb8b57bca5ad016133d1674 +Author: John Wolfe +Date: Mon Oct 18 07:31:44 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit fe739dc30671ab0d6de67acd1dde374f88fe499c +Author: John Wolfe +Date: Mon Oct 18 07:31:43 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit c5bc4c37b8f948e3d9bf8d7e2f85196f5099d311 +Author: John Wolfe +Date: Wed Oct 6 23:52:03 2021 -0700 + + Update ChangeLog with the granular push of Oct. 6, 2021. + plus ChangeLog update of Sept. 20. + +commit 4aecc2978e09dddc1f7a0c9af7e9b8ffa57227e2 +Author: John Wolfe +Date: Wed Oct 6 23:40:31 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 02b9fea09af950780fdf6e93141edf97de9075de +Author: John Wolfe +Date: Wed Oct 6 23:40:31 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit d3147cbb1cec5b5ac41c1d1955f28a20d2bedf5a +Author: John Wolfe +Date: Wed Oct 6 23:40:31 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 8929bd9db5fc57a76491d3f1d8e314955c7b5823 +Author: John Wolfe +Date: Wed Oct 6 23:40:31 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit db093d15c263262632a854342b447c6b67e72394 +Author: John Wolfe +Date: Wed Oct 6 23:40:31 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 3b586cc541a0ead1bc60a6b11ec655e10e83c29c +Author: John Wolfe +Date: Wed Oct 6 23:40:31 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit daf6e0fb8ac80cc8bd718b6564b037fc9eb6b654 +Author: John Wolfe +Date: Mon Sep 20 08:51:19 2021 -0700 + + Update ChangeLog with the granular push of Sept. 20, 2021. + plus ChangeLog update of Sept. 7. + +commit fe059f34e4ab93f21c41b4598da6846eafd9bc20 +Author: John Wolfe +Date: Mon Sep 20 08:07:36 2021 -0700 + + Change to common header file not directly applicable to open-vm-tools. + +commit ffa5d491194412213882cdcc808d621b439ae2a6 +Author: John Wolfe +Date: Mon Sep 20 08:07:36 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 03b6ca66c23289da7b34d1e47f5769d063ee3ad9 +Author: John Wolfe +Date: Mon Sep 20 08:07:36 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit a3e4fd4e4692e36b5b66b5feb4044faa41d46f22 +Author: John Wolfe +Date: Mon Sep 20 08:07:36 2021 -0700 + + resolutionKMS: Add support for the svga3 device + + The resolution plugin was checking for only the svga2 device, which + does not exist on ARM. This makes the resolution plugin work on ARM. + +commit 21f193b21e3d2be122a6ee9755a45536671cf4e9 +Author: John Wolfe +Date: Mon Sep 20 08:07:36 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit fe8803ea205da66e8a5040f447835fd2292de89e +Author: John Wolfe +Date: Mon Sep 20 08:07:36 2021 -0700 + + Log the guest OS name and full name. - - ReleaseNotes.md - copy in the initial (final ?) 11.3.5 OVT release notes. - - configure.ac = set the tools version to 11.3.5. - - buildNumber.h - set the build and product number from the internal - release build. + Added a log message for the guest OS name and full name that is sent as + guestInfo. Messages are logged only when the guestInfo is successfully + updated to the VMX log. + +commit 7b58f891b283c4eb42602bba07f4713815a508da +Author: John Wolfe +Date: Tue Sep 7 06:49:29 2021 -0700 + + Update ChangeLog with the granular push of Sept. 7, 2021. + plus ChangeLog update of Aug. 23. + +commit 9a793fb5399b36cb473c57eb3a41570adfccc078 +Author: John Wolfe +Date: Tue Sep 7 06:39:53 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit d09c3d5247e21f0a881406a020e6cdf87ab0ee2d +Author: John Wolfe +Date: Tue Sep 7 06:39:53 2021 -0700 -commit 7f297dca6342350b1f01444c3636ffe39ab78c27 + Common header file change not applicable to open-vm-tools. + +commit b963fdd5363d1ecd347045408cf1b40e5ac27188 +Author: John Wolfe +Date: Tue Sep 7 06:39:53 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit ee2fe611e1c6f27d0e918a361a967f13da10ba08 +Author: John Wolfe +Date: Tue Sep 7 06:39:53 2021 -0700 + + Common header file change not directly applicable to open-vm-tools. + +commit e551b81709ee4f42e79f2f4aaa47d9443e24a2fa +Author: John Wolfe +Date: Tue Sep 7 06:39:53 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit adb9c0476a8dd9d15947857343b23c6ffe9b395c +Author: John Wolfe +Date: Tue Sep 7 06:39:53 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 6336dec45c73d60d8bd100ddc71f3b125a2a9cc9 +Author: John Wolfe +Date: Mon Aug 23 20:22:35 2021 -0700 + + Update ChangeLog with the granular push of Aug. 22, 2021. + plus ChangeLog update of Aug. 12. + +commit a6923583d4519019e25860abcd16c2205d8a3fde Author: John Wolfe -Date: Fri Aug 13 11:35:59 2021 -0700 +Date: Mon Aug 23 20:13:37 2021 -0700 - Remove the mount.vmhgfs from open-vm-tools. + Replace the use of appInfo's internal json escape function with + libmisc's CodeSet_JsonEscape(). + +commit c7a5a3e189494e44c16ed7c21ab0b4fac28b26b8 +Author: John Wolfe +Date: Mon Aug 23 20:13:37 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 3bae54175a7a72872920ba62842a5091a87ae11a +Author: John Wolfe +Date: Mon Aug 23 20:13:37 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 61331a189a0eeb76f014db28288b06c0323bc0b9 +Author: John Wolfe +Date: Mon Aug 23 20:13:36 2021 -0700 + + Removal of the hgfsmounter/mount.vmhgfs command from open-vm-tools. The hgfsmounter (mount.vmhgfs) command is no longer used in Linux - open-vm-tools. It has been replaced by hgfs-fuse. Therefore, removing + open-vm-tools. It has been replaced by hgfs-fuse. Remove all references to the hgfsmounter in Linux builds. -commit 07aa3359ea6c734afe9cb5907019f16e9fedc59e +commit f5fb3a9fb32ea465f965aa971bc40bdff8edc36f +Author: John Wolfe +Date: Mon Aug 23 20:13:36 2021 -0700 + + Further refinement of the toolsDeployPkg.log file. + + Modified the build info description with the module name instead of + "imgcust" or "sysimage". + +commit 1f971148e368b2df87cb20c74568494b7b543ced +Author: John Wolfe +Date: Thu Aug 12 12:57:20 2021 -0700 + + Update ChangeLog with the granular push of Aug. 12, 2021. + plus ChangeLog update of July 27. + +commit 38f8606a3f4faeb0b8ae1f9277c9c1b50ac19bbe Author: John Wolfe -Date: Fri Aug 13 11:35:58 2021 -0700 +Date: Thu Aug 12 12:46:05 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 574cbbe55abdc716a6af03a752260699c3e22784 +Author: John Wolfe +Date: Thu Aug 12 12:46:05 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 5003c79aaf398fbdc965c510c1b0be2350be7e64 +Author: John Wolfe +Date: Thu Aug 12 12:46:05 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit f254eef58523fc9539e3836d825056b999ff192b +Author: John Wolfe +Date: Thu Aug 12 12:46:05 2021 -0700 + + Reduce the scope of a local variable. + + The 'Codacy' tool reported that the scope of a local variable can be + reduced in the Debug() function of linuxDeployment.c. + +commit 63d9fd68f5513b683aae855d30a2da4d4e4f72a7 +Author: John Wolfe +Date: Thu Aug 12 12:46:05 2021 -0700 + + Common header file change not directly applicable to open-vm-tools. + +commit f39d4c1fe303d94a079f0d0e9ed098cde1cb0316 +Author: John Wolfe +Date: Thu Aug 12 12:46:05 2021 -0700 VmCheck_IsVirtualWorld(): assume VMware hypervisor if USE_VALGRIND is defined. @@ -32,9 +2097,145 @@ The "backdoor" touch test cannot be handled by Valgrind. -commit e4265556a1e60a0298c03cf06222d5106e77325f +commit 1c31dbfc3df970bd6f4e0ad297f8d79e105a2690 +Author: John Wolfe +Date: Thu Aug 12 12:46:05 2021 -0700 + + Update VMware Tools version to 12.0.0. + + The next major VMware Tools / open-vm-tools will be version 12.0.0. + +commit dd78c6abbb4f376afea1db423acaf483c4f56f32 +Author: John Wolfe +Date: Thu Aug 12 12:46:04 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit e76f136563a8e78676f9c1e069175dec835eaade +Author: John Wolfe +Date: Thu Aug 12 12:46:04 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit beee0873cbf0d0399d52cb762b2b3e85054c5774 +Author: John Wolfe +Date: Tue Jul 27 10:54:08 2021 -0700 + + Update ChangeLog with the granular push of July 27, 2021. + - plus ChangeLog update of July 8. + +commit 26e7c2f3b5198621c8234c4890431dc16698bcf3 +Author: John Wolfe +Date: Tue Jul 27 10:37:24 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit d78011e325c6275bc9199b102983544057dfc0bc +Author: John Wolfe +Date: Tue Jul 27 10:37:24 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 8db9ab140d15787064745c4ba0497fc7d162ab84 +Author: John Wolfe +Date: Tue Jul 27 10:37:24 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 4eb519b107745cd01018194aa059a5d0b39c3cf4 +Author: John Wolfe +Date: Tue Jul 27 10:37:24 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit c387b16795b4a78a53c89f607a8ca31580138e05 +Author: John Wolfe +Date: Tue Jul 27 10:37:24 2021 -0700 + + Changes to common source files not applicable to open-vm-tools. + +commit 8259e2e5238e7b90c7f1ddf396ec47fc9acabfe1 +Author: John Wolfe +Date: Tue Jul 27 10:37:24 2021 -0700 + + Add tools version and build info into the toolsDeployPkg.log file. + +commit 2fe6126e92f4bd4dc9eb683e59df84000b312398 +Author: John Wolfe +Date: Tue Jul 27 10:37:24 2021 -0700 + + Common header file change not directly applicable to open-vm-tools. + +commit 8c788af23d0855f1876e8e6de665d050a157c557 +Author: John Wolfe +Date: Tue Jul 27 10:37:24 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit cb8741edd1fe30dd423cf8533d63a4dc8bb39d8a +Author: John Wolfe +Date: Tue Jul 27 10:37:24 2021 -0700 + + Terminology cleanup in some comments. + +commit b873cda6c5bf0228b0442d1c3be402feafadf8c1 +Author: John Wolfe +Date: Tue Jul 27 10:37:24 2021 -0700 + + GuestOS: Support Fedora and Debian 10 for ARM + + Since we support Fedora, support ARM Fedora - 64 bit only. + + Remove VCPUHOTADD from ARM guests. There is no support for this. + +commit 3a599078d238c12c26d3ca3e39c743f7d9c65555 +Author: John Wolfe +Date: Tue Jul 27 10:37:24 2021 -0700 + + guest_os.h: A bit of clean up + + Arrange things in a nicer way. + +commit 61e3c68f029af528e61de5b22b215ef689870be2 +Author: John Wolfe +Date: Tue Jul 27 10:37:24 2021 -0700 + + Changes to common source files not applicable to open-vm-tools. + +commit 3226203c1c49e8d0fca9aa6a8557ac757c91c3a8 +Author: John Wolfe +Date: Thu Jul 8 20:35:44 2021 -0700 + + Update ChangeLog with the granular push of July 8, 2021. + - plus ChangeLog update of June 30. + +commit b033e5c2d77ee66e9426973005cf1f48a5b3cceb +Author: John Wolfe +Date: Thu Jul 8 20:10:23 2021 -0700 + + Common header file changes not applicable to open-vm-tools. + +commit c907662b1034bd783dab4728bec3af06892f6e4a +Author: John Wolfe +Date: Thu Jul 8 20:10:23 2021 -0700 + + Changes to common header files not directly applicable to open-vm-tools. + +commit e6ff175716602a91fa1385c30846961c57d089f2 +Author: John Wolfe +Date: Thu Jul 8 20:10:23 2021 -0700 + + Common header file change not directly applicable to open-vm-tools. + +commit d21b1402ac2e1f59851560ac08516ee8ddaa13b0 +Author: John Wolfe +Date: Thu Jul 8 20:10:23 2021 -0700 + + Changes to common header files not applicable to open-vm-tools. + +commit 35c78d66e0202a5ce217193d03bd48a50ce87c3c Author: John Wolfe -Date: Fri Aug 13 11:35:58 2021 -0700 +Date: Thu Jul 8 20:10:23 2021 -0700 Added a configurable logging capability to the network script. @@ -45,15 +2246,102 @@ is full or is not writeable. Added an example configuration in the tools.conf example file. -commit 56f88f3d8ddc708100faf0c6b4477fec7bcde13a +commit b484ab6727bbfd8691e8dd4f8d6ae297e06a8672 Author: John Wolfe -Date: Fri Aug 13 11:35:58 2021 -0700 +Date: Thu Jul 8 20:10:23 2021 -0700 - Changes to common source files not applicable to open-vm-tools. + Common header file change not applicable to open-vm-tools. + +commit 102714ebe1d0253a7a2afb373f5d73d9d25687fb +Author: John Wolfe +Date: Thu Jul 8 20:10:23 2021 -0700 + + Fixed the possible use of an uninitialized variable in Util_ExpandString. + + Additionally, several Boolean expressions were updated to be proper + Boolean values, for readability and consistency. + +commit 0ae179aa40ed68f3357faabbe6f101035206cd32 +Author: John Wolfe +Date: Thu Jul 8 20:10:23 2021 -0700 + + Changes to common header files not applicable to open-vm-tools. + + Prepared the basic infrastructure for adding Windows 11 guests. + +commit e1f850a1fa20a911abf9a3d7f2ca7ae6c2a44209 +Author: John Wolfe +Date: Thu Jul 8 20:10:23 2021 -0700 + + Record the use of VMware Tools version 11.3.5 in vm_tools_version.h + + Add TOOLS_VERSION_JIGSAW_UPDATE1 for version 11.3.5 in the header + file lib/include/vm_tools_version.h + +commit d5605d3861c1dd8a5cf968b627b7adad2da98308 +Author: John Wolfe +Date: Thu Jul 8 20:10:23 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 77196a4b4fe7edbdddab1adb402021979f224a0f +Author: John Wolfe +Date: Thu Jul 8 20:10:23 2021 -0700 + + Changes to common header files not applicable to open-vm-tools. + +commit 38777a57a1e9befbb5d858934e8c032923fb2242 +Author: John Wolfe +Date: Thu Jul 8 20:10:23 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 7caa442246e75e60e266f936538d68a0fa6045a8 +Author: John Wolfe +Date: Thu Jul 8 20:10:23 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 6e5c26b8bddbe7817d49b2f48dba6776e5d4f851 +Author: John Wolfe +Date: Thu Jul 8 20:10:23 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit c9bc765c083db8e3d4705eb14715792cdfba8d0c +Author: John Wolfe +Date: Wed Jun 30 11:53:41 2021 -0700 + + Update ChangeLog with the granular push of Jun 30, 2021. + - plus ChangeLog update of June 7. + +commit 4ac7706c44c4d29f38e8d1c7d2ac9cf45521cf4f +Author: John Wolfe +Date: Wed Jun 30 11:37:27 2021 -0700 + + Changes to a common header file not applicable to open-vm-tools. + +commit d5f0c71fd909527fcfd03f858d277abc9fae9569 +Author: John Wolfe +Date: Wed Jun 30 11:37:27 2021 -0700 + + Add page size defines for 64KB pages. + +commit c1457815c1c5e579a3d26c99fff3f6b9e6ed0d41 +Author: John Wolfe +Date: Wed Jun 30 11:37:27 2021 -0700 + + Changes to a common header file not applicable to open-vm-tools. + +commit 248830d868b7ade3ce199894fc0cb3c4771dd364 +Author: John Wolfe +Date: Wed Jun 30 11:37:27 2021 -0700 + + Changes to common source file not applicable to open-vm-tools. -commit 4a6491b17b2a7a71a60f94c8c9796b93cf914726 +commit bd5dede3536c30e2799fa8c788a9dc9b7f904d35 Author: John Wolfe -Date: Fri Aug 13 11:35:58 2021 -0700 +Date: Wed Jun 30 11:37:27 2021 -0700 Use os-release preferentially for guest identification. @@ -61,90 +2349,183 @@ the same as from the LSB score, use the os-release data. The os-release standard is well established and the LSB is deprecated. -commit 2500bd59ed76a4c376dad6da40345e9af9da1153 +commit 5fac74631a896e3e5b121a024a4293dcede5eaa1 Author: John Wolfe -Date: Fri Aug 13 11:35:58 2021 -0700 +Date: Wed Jun 30 11:37:27 2021 -0700 - Customization: Retry the Linux reboot if telinit is a soft link to systemctl. + Changes to a common header file not applicable to open-vm-tools. + +commit d9ff40dc4cf48b78cdebe9d05a393bd283429fa0 +Author: John Wolfe +Date: Wed Jun 30 11:37:27 2021 -0700 + + Changes to a common header file not applicable to open-vm-tools. + +commit 843e5851ac692c4bcaca1cfa262eda7e610417f0 +Author: John Wolfe +Date: Wed Jun 30 11:37:27 2021 -0700 + + Changes to a common header file not directly applicable to open-vm-tools. - Issues have been reported on some newer versions of Linux where the VM - failed to reboot at the end of a traditional customization. The command - '/sbin/telinit 6' exited abnormally due to SIGTERM sent by systemd and - where telinit is a symlink to systemctl. + This is part of a host-side fix for an intermittent DnD issue. + +commit 19c38e8ed9be5272dd45cd07d362345456d9c3ed +Author: John Wolfe +Date: Wed Jun 30 11:37:27 2021 -0700 + + Fix an issue of re-running scripts. - This fix checks if telinit is a soft link to systemctl and if yes, retries - a system reboot until the telinit command succeeds or the reboot literally - happens. + Fix an issue in the service discovery plugin where scripts can be re-run + while the previously started one is still active. -commit d09ffadb02deeae6f61157a6df23cc37d4a0d5d6 +commit 26b6e174f9a6ba780a052657cce3290f2174bcba Author: John Wolfe -Date: Fri Aug 13 11:35:58 2021 -0700 +Date: Wed Jun 30 11:37:27 2021 -0700 + + Changes to a common header file not applicable to open-vm-tools. - Set the tools version to 11.3.5 on the "stable-11.3.x" branch. +commit 03d3b6978b2c9d0e66d4b45b992724167ab14f03 +Author: John Wolfe +Date: Wed Jun 30 11:37:27 2021 -0700 -======================================================== + Changes to a common header file not applicable to open-vm-tools. - open-vm-tools 11.3.0 release +commit 59fe3b61458659b0bdcce7d8ac0e4ae9e4ae7b3d +Author: John Wolfe +Date: Wed Jun 30 11:37:27 2021 -0700 -======================================================== + Changes to a common header file not applicable to open-vm-tools. -commit 0456d11e57fc48104b413670511794c91f2e3673 +commit 81745623ae421c510fedba499ecfe0d916265a28 Author: John Wolfe -Date: Thu Jun 17 12:22:33 2021 -0700 +Date: Wed Jun 30 11:37:27 2021 -0700 - configure.ac: missed a version bump to 11.3.0. + Allow setting a custom poll interval in the service discovery plugin for debugging. -commit 7695514c2409afa85c69f0af38ddfa20780d47b9 +commit 08649561962e115cda98d6f1ef85a3559b12efe3 Author: John Wolfe -Date: Thu Jun 17 11:55:10 2021 -0700 +Date: Wed Jun 30 11:37:27 2021 -0700 - Update open-vm-tools/ChangeLog with final steps before release. + Change to common header file not applicable to open-vm-tools. -commit 7fd653a62d543dde25815ecd72067487a780f4b6 +commit 185952f4b8c85d0fb04eecd08be0673f9e800f70 Author: John Wolfe -Date: Thu Jun 17 11:47:50 2021 -0700 +Date: Wed Jun 30 11:37:27 2021 -0700 - Prepare to make the 11.3.0 OVT release announcement. - - - ReleaseNotes.md - copy in the iinitial (final ?) 11.3.0 OVT release notes. - - configure.ac = set the tools version to 11.3.0. - - buildNumber.h - set the build and product number from the internal - release build. + Add preliminary guest OS support of RHEL-9 for Arm. -commit 9ce90f4c64be0b382be65e0db0f63167dc16c786 +commit 176a0490fa001892e74237d1cf49607574bf8c4a Author: John Wolfe -Date: Tue Jun 15 07:58:27 2021 -0700 +Date: Wed Jun 30 11:37:27 2021 -0700 - Update ChangeLog with the ChangeLog update of June 7. + Throttle the "Nic limit reached" log message from the guestInfo plugin. + + Implement a wrapper API for throttling vmtools log messages. + Use the API to throttle the repetitive log message, "Nic limit reached", + from the guestInfo plugin. + + This change addresses the log spew reported in open-vm-tools issue: + https://github.com/vmware/open-vm-tools/issues/128 -commit 0eeda8e91370ac3d3af2e4efd7c6e413618aa839 +commit c3ad5e62cb9892e28486839aba19116aaadd76ef Author: John Wolfe -Date: Mon Jun 7 13:40:37 2021 -0700 +Date: Wed Jun 30 11:37:26 2021 -0700 - Update ChangeLog with the granular push to stable-11.3.x on June 7, 2021. - - plus ChangeLog update of May 20. + Add a header to the vmsvc log file. + + Add a log entry at the start of the vmsvc log file that includes the tools + version, build number, and guest OS details. -commit f8fd00cb7fbfbb9df62ba7723c472b84ffe495bf +commit 1d25adfe20a5da7a3ed37c970e72699d487f3cca Author: John Wolfe -Date: Mon Jun 7 13:36:32 2021 -0700 +Date: Mon Jun 7 10:53:14 2021 -0700 Adding missed 2021 copyright updates in granular pushes. -commit 008993082515aadfb3087ae22bec80ed5ac33684 +commit a01a33d95d511a1019c6f9ab7a525635c9a61c61 +Author: John Wolfe +Date: Mon Jun 7 08:25:09 2021 -0700 + + Enhanced the VMware Tools SDMP plugin to support GDP. + +commit 1751cd1e49edb5d88cb4d5175bdbb7ac5d86054c +Author: John Wolfe +Date: Mon Jun 7 08:25:09 2021 -0700 + + Add check that the packet size received is >= expected packet header size. + + DnD RpcV3: A corrupted packet received may result in an out of bounds (OOB) + memory access if the length of the message received is less than the size + of the expected packet header. + +commit e3de1afdd4d802596bffdbbb63ec6708fafcf51a +Author: John Wolfe +Date: Mon Jun 7 08:25:09 2021 -0700 + + GOS support: Add Linux 6.x support. + +commit bd151c59769f9bac14fc2df0d1076faa902734bf +Author: John Wolfe +Date: Mon Jun 7 08:25:09 2021 -0700 + + Change to a common source file not directly applicable to open-vm-tools. + + Adding a NULL pointer check. + +commit d5938385597f4c13b6e9d265a399a67258c47f41 +Author: John Wolfe +Date: Mon Jun 7 08:25:09 2021 -0700 + + Common header file change not applicable to open-vm-tools. + +commit 26b72e101e3d9a66e97e2179f142ce8961c7869f +Author: John Wolfe +Date: Mon Jun 7 08:25:09 2021 -0700 + + Update the tools version to 11.4.0 on the "devel" branch. + +commit 5c1025a2f29f199a65cf703b93c1ae5294ff0053 Author: John Wolfe -Date: Mon Jun 7 13:29:01 2021 -0700 +Date: Mon Jun 7 08:25:09 2021 -0700 Open-vm-tools 11.3.0 L10n updates. -commit e4c1a58df62e2b08fbef8e8e399dcba7654aefc5 +commit 40e473ea1378ab1874f4cdf8aa38d39e11299fe9 +Author: John Wolfe +Date: Mon Jun 7 08:25:08 2021 -0700 + + Customization: Retry the Linux reboot if telinit is a soft link to systemctl. + + Issues have been reported on some newer versions of Linux where the VM + failed to reboot at the end of a traditional customization. The command + '/sbin/telinit 6' exited abnormally due to SIGTERM sent by systemd and + where telinit is a symlink to systemctl. + + This fix checks if telinit is a soft link to systemctl and if yes, retries + a system reboot until the telinit command succeeds or the reboot literally + happens. + +commit f8eedf7070b0c11c73f86e1374c004a1bc0212e1 +Author: John Wolfe +Date: Mon Jun 7 08:25:08 2021 -0700 + + Change to common source file not directly applicable to open-vm-tools. + +commit 5acc2a69256aa351e38d7abe1914b7785de6d6b2 +Author: John Wolfe +Date: Mon Jun 7 08:25:08 2021 -0700 + + Changes to common source files not applicable to open-vm-tools. + +commit 9ff3c61c5d5ab58922c55db77704bab56bac75d6 Author: John Wolfe -Date: Mon Jun 7 13:29:01 2021 -0700 +Date: Mon Jun 7 08:25:08 2021 -0700 Common source file change not applicable to open-vm-tools. -commit 9fbd584aee962d6a3e18109eb408b01b273a19f4 +commit dc39fc8c67180b3e7213d01449868482c17b36f4 Author: John Wolfe -Date: Mon Jun 7 13:29:01 2021 -0700 +Date: Mon Jun 7 08:25:08 2021 -0700 Switch the current thread to "C" locale to parse /proc files. diff -Nru open-vm-tools-11.3.5/open-vm-tools/configure.ac open-vm-tools-12.1.5/open-vm-tools/configure.ac --- open-vm-tools-11.3.5/open-vm-tools/configure.ac 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/configure.ac 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ ################################################################################ -### Copyright (c) 2007-2021 VMware, Inc. All rights reserved. +### Copyright (c) 2007-2022 VMware, Inc. All rights reserved. ### ### Configure script for building the VMware OSS Tools. ### @@ -35,10 +35,10 @@ ### Initialization ### -TOOLS_VERSION="11.3.5" +TOOLS_VERSION="12.1.5" AC_INIT( [open-vm-tools], - [11.3.5], + [12.1.5], [open-vm-tools-devel@lists.sourceforge.net]) # In order to make this configure script auto-detect situations where @@ -467,6 +467,27 @@ fi fi +AC_ARG_ENABLE([salt-minion], + [AS_HELP_STRING([--enable-salt-minion], + [Install salt_minion related script files.])], + [ + enable_saltminion=$enableval + ], + [ + enable_saltminion=no + ]) + +# +# Check that salt_minion is enabled only on linux systems +# + +if test "$enable_saltminion" = "yes"; then + if test "$os" != "linux"; then + AC_MSG_ERROR([The salt_minion package is only supported for Linux + platforms. Try configure without --enable-salt-minion option.]) + fi +fi + # # Check for glib 2.34.0 or greater. # @@ -519,16 +540,93 @@ # # Check for fuse. # -AC_VMW_CHECK_LIB([fuse], - [FUSE], - [fuse], - [], - [], - [fuse.h], - [fuse_main], - [have_fuse=yes], - [have_fuse=no; - AC_MSG_WARN([Fuse is missing, vmblock-fuse/vmhgfs-fuse will be disabled.])]) + +AC_ARG_WITH([fuse], + [AS_HELP_STRING([--without-fuse], + [compiles without FUSE support (disables vmblock-fuse/vmhgfs-fuse).])], + [with_fuse="$withval"], + [with_fuse=auto]) + +case "$with_fuse" in + fuse|2) + with_fuse="fuse" + ;; + fuse3|3) + with_fuse="fuse3" + ;; + auto) + ;; + yes) + ;; + no) + have_fuse3=no; + have_fuse=no; + ;; + *) + AC_MSG_FAILURE([--with-fuse was given with an unsupported paramter $with_fuse]) + ;; +esac + + +if test "$with_fuse" = "auto" || + test "$with_fuse" = "fuse3" || + test "$with_fuse" = "yes"; then + # + # Check for fuse3. + # + # FUSE_USE_VERSION sets the version of the FUSE API that will be exported. + AC_VMW_CHECK_LIB([fuse3], + [FUSE3], + [fuse3], + [], + [3.10.0], + [fuse3/fuse.h], + [fuse_main], + [have_fuse3=yes; + AC_DEFINE([HAVE_FUSE3], 1, [Define to 1 if using FUSE3.]) + AC_DEFINE([FUSE_USE_VERSION], 35, [FUSE API version to use.])], + [have_fuse3=no]) + + if test "$have_fuse3" = "no"; then + if test "$with_fuse" = "auto" || test "$with_fuse" = "yes"; then + AC_MSG_NOTICE([Fuse3 is missing, trying to use older Fuse library.]) + else + AC_MSG_FAILURE([Fuse3 was requested but unavailable on the system.]) + fi + fi +fi + +if test "$with_fuse" = "fuse" || + ( ( test "$with_fuse" = "auto" || test "$with_fuse" = "yes" ) && + test "$have_fuse3" = "no" ); then + # + # Check for fuse. + # + # FUSE_USE_VERSION sets the version of the FUSE API that will be exported. + AC_VMW_CHECK_LIB([fuse], + [FUSE], + [fuse], + [], + [], + [fuse.h], + [fuse_main], + [have_fuse=yes; + AC_DEFINE([HAVE_FUSE], 1, [Define to 1 if using FUSE.]) + AC_DEFINE([FUSE_USE_VERSION], 29, [FUSE API version to use.])], + [have_fuse=no]) + + if test "$have_fuse" = "no"; then + if test "$with_fuse" = "auto" || test "$with_fuse" = "yes"; then + AC_MSG_NOTICE([Fuse is missing, vmblock-fuse/vmhgfs-fuse will be disabled.]) + else + AC_MSG_FAILURE([Fuse2 was requested but unavailable on the system.]) + fi + fi +fi + +if test "$with_fuse" = "no"; then + AC_MSG_WARN([Fuse or Fuse3 is suppressed, vmblock-fuse/vmhgfs-fuse will be disabled.]) +fi # # Check for PAM. @@ -552,6 +650,137 @@ [AC_VMW_LIB_ERROR([PAM], [pam])]) fi +AC_ARG_ENABLE([containerinfo], + [AS_HELP_STRING([--disable-containerinfo], + [do not build containerinfo plugin.])], + [ + enable_containerinfo=$enableval + ], + [ + if test "$os" = "linux"; then + enable_containerinfo=auto + else + enable_containerinfo=no + fi + ]) + +# +# Check that containerinfo plugin is enabled only on linux systems. +# +if test "$os" != "linux"; then + if test "$enable_containerinfo" = "yes"; then + AC_MSG_ERROR([The containerinfo plugin is only supported for Linux + platforms. Try configure with --disable-containerinfo option.]) + fi +fi + +if test "$enable_containerinfo" = "yes" || + test "$enable_containerinfo" = "auto"; then + +can_build_containerinfo=yes + +# +# AC_VMW_CONTAINERINFO_MSG(library) +# +# Wrapper around AC_MSG_WARN to print a standard message about missing libraries. +# +# library ($1): name of missing library / package. +# +AC_DEFUN([AC_VMW_CONTAINERINFO_MSG],[ + can_build_containerinfo=no + AC_MSG_WARN(["$1 is missing which is required for building containerinfo plugin."]) +]) + + AC_VMW_DEFAULT_FLAGS([CURL]) + AC_VMW_CHECK_LIB([curl], + [CURL], + [], + [], + [], + [curl/curl.h], + [curl_easy_init], + [CURL_CPPFLAGS="$CURL_CPPFLAGS"], + [AC_VMW_CONTAINERINFO_MSG([CURL])]) + + AC_VMW_CHECK_LIB([protobuf], + [PROTOBUF], + [protobuf], + [], + [3.0.0], + [], + [], + [], + [AC_VMW_CONTAINERINFO_MSG(["protobuf >= 3.0.0"])]) + + AC_VMW_DEFAULT_FLAGS([GRPC]) + AC_VMW_CHECK_LIBXX([grpc++], + [GRPC], + [grpc++], + [], + [1.3.2], + [grpc++/grpc++.h], + [], + [], + [AC_VMW_CONTAINERINFO_MSG(["grpc++ >= 1.3.2"])]) + +# +# proto files needed by containerd grpc client. +# + shared_prefix=/usr/share/gocode/src/github.com + AC_SUBST(TYPES_DIR, github.com/containerd/containerd/api/types) + AC_SUBST(TASKS_PROTOPATH, $shared_prefix/containerd/containerd/api/services/tasks/v1) + AC_SUBST(DEP_PROTOPATH, /usr/share/gocode/src) + AC_SUBST(CONTAINERD_PROTOPATH, $shared_prefix/containerd/containerd/api/services/containers/v1) + AC_SUBST(GOGO_PROTOPATH, $shared_prefix/gogo/protobuf) + AC_CHECK_FILE([${CONTAINERD_PROTOPATH}/containers.proto], + [], + [AC_VMW_CONTAINERINFO_MSG(["containerd package"])]) + AC_CHECK_FILE([${TASKS_PROTOPATH}/tasks.proto], + [], + [AC_VMW_CONTAINERINFO_MSG(["containerd package"])]) + AC_CHECK_FILE([${DEP_PROTOPATH}/${TYPES_DIR}/mount.proto], + [], + [AC_VMW_CONTAINERINFO_MSG(["containerd package"])]) + AC_CHECK_FILE([${DEP_PROTOPATH}/${TYPES_DIR}/metrics.proto], + [], + [AC_VMW_CONTAINERINFO_MSG(["containerd package"])]) + AC_CHECK_FILE([${DEP_PROTOPATH}/${TYPES_DIR}/descriptor.proto], + [], + [AC_VMW_CONTAINERINFO_MSG(["containerd package"])]) + AC_CHECK_FILE([${DEP_PROTOPATH}/${TYPES_DIR}/task/task.proto], + [], + [AC_VMW_CONTAINERINFO_MSG(["containerd package"])]) + AC_CHECK_FILE([${GOGO_PROTOPATH}/gogoproto/gogo.proto], + [], + [AC_VMW_CONTAINERINFO_MSG(["gogoproto package"])]) + +# +# Binaries needed to build for containerd grpc client. +# + AC_CHECK_PROG([GRPC_CPP], [grpc_cpp_plugin], [grpc_cpp_plugin], [not found]) + + if test "$GRPC_CPP" != "grpc_cpp_plugin" ; then + AC_VMW_CONTAINERINFO_MSG(["grpc_cpp_plugin binary"]) + fi + + AC_CHECK_PROG([PROTOC], [protoc], [protoc], [not found]) + + if test "$PROTOC" != "protoc" ; then + AC_VMW_CONTAINERINFO_MSG(["protoc binary"]) + fi + + if test "$can_build_containerinfo" = "no" ; then + if test "$enable_containerinfo" = "auto" ; then + enable_containerinfo=no + AC_MSG_WARN(["Cannot enable containerinfo plugin since one ore more required packages are missing."]) + else + AC_MSG_ERROR(["Cannot enable containerinfo plugin since one or more required packages are missing. Please configure without containerinfo (using --disable-containerinfo), or install the necessary libraries and devel package(s)."]) + fi + else + enable_containerinfo=yes + fi +fi + AC_ARG_ENABLE([vgauth], [AS_HELP_STRING([--disable-vgauth], [do not build vgauth.])], @@ -1473,11 +1702,13 @@ AM_CONDITIONAL(ENABLE_TESTS, test "$have_cunit" = "yes") AM_CONDITIONAL(WITH_ROOT_PRIVILEGES, test "$with_root_privileges" = "yes") AM_CONDITIONAL(HAVE_DOXYGEN, test "$have_doxygen" = "yes") -AM_CONDITIONAL(HAVE_FUSE, test "$have_fuse" = "yes") +AM_CONDITIONAL(HAVE_FUSE, test "$have_fuse" = "yes" || test "$have_fuse3" = "yes") +AM_CONDITIONAL(HAVE_FUSE3, test "$have_fuse3" = "yes") AM_CONDITIONAL(HAVE_GNU_LD, test "$with_gnu_ld" = "yes") AM_CONDITIONAL(HAVE_GTKMM, test "$have_x" = "yes" -a \( "$with_gtkmm" = "yes" -o "$with_gtkmm3" = "yes" \) ) AM_CONDITIONAL(HAVE_PAM, test "$with_pam" = "yes") AM_CONDITIONAL(USE_SLASH_PROC, test "$os" = "linux") +AM_CONDITIONAL(ENABLE_CONTAINERINFO, test "$enable_containerinfo" = "yes") AM_CONDITIONAL(ENABLE_DEPLOYPKG, test "$enable_deploypkg" = "yes") AM_CONDITIONAL(ENABLE_VGAUTH, test "$enable_vgauth" = "yes") AM_CONDITIONAL(USE_XMLSEC1, test "$use_xmlsec1" = "yes") @@ -1489,6 +1720,7 @@ AM_CONDITIONAL(VGAUTH_USE_CXX, test "$with_icu" = "yes" -o "$use_xmlsec1" != "yes") AM_CONDITIONAL(ENABLE_LIBAPPMONITOR, test "$enable_libappmonitor" = "yes") AM_CONDITIONAL(ENABLE_SDMP, test "$enable_servicediscovery" = "yes") +AM_CONDITIONAL(ENABLE_SALTMINION, test "$enable_saltminion" = "yes" -a \( "$arch" = "x64" \) ) if test "$have_xsm" != "yes"; then AC_DEFINE([NO_XSM], 1, []) @@ -1653,6 +1885,8 @@ services/plugins/Makefile \ services/plugins/gdp/Makefile \ services/plugins/appInfo/Makefile \ + services/plugins/componentMgr/Makefile \ + services/plugins/containerInfo/Makefile \ services/plugins/serviceDiscovery/Makefile \ services/plugins/desktopEvents/Makefile \ services/plugins/dndcp/Makefile \ diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/appUtil/appUtilX11.c open-vm-tools-12.1.5/open-vm-tools/lib/appUtil/appUtilX11.c --- open-vm-tools-11.3.5/open-vm-tools/lib/appUtil/appUtilX11.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/appUtil/appUtilX11.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2008-2019 VMware, Inc. All rights reserved. + * Copyright (C) 2008-2019,2022 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 @@ -174,6 +174,9 @@ */ iconSearchNameSize = strlen(iconName) + 1; iconSearchName = g_alloca(iconSearchNameSize); + + /* Ignore return, returns length of the source string */ + /* coverity[check_return] */ g_strlcpy(iconSearchName, iconName, iconSearchNameSize); myIconName = NULL; @@ -769,7 +772,7 @@ * Path, or NULL if not available * * Side effects: - * Allocated memory is returned + * Allocated memory is returned * *----------------------------------------------------------------------------- */ diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/asyncsocket/asyncsocket.c open-vm-tools-12.1.5/open-vm-tools/lib/asyncsocket/asyncsocket.c --- open-vm-tools-11.3.5/open-vm-tools/lib/asyncsocket/asyncsocket.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/asyncsocket/asyncsocket.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2003-2021 VMware, Inc. All rights reserved. + * Copyright (C) 2003-2022 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 @@ -370,7 +370,7 @@ static int AsyncTCPSocketSendBlocking(AsyncSocket *s, void *buf, int len, int *sent, int timeoutMS); static int AsyncTCPSocketDoOneMsg(AsyncSocket *s, Bool read, int timeoutMS); -static int AsyncTCPSocketWaitForReadMultiple(AsyncSocket **asock, int numSock, +static int AsyncTCPSocketWaitForReadMultiple(AsyncSocket **asock, size_t numSock, int timeoutMS, int *outIdx); static int AsyncTCPSocketSetOption(AsyncSocket *asyncSocket, AsyncSocketOpts_Layer layer, @@ -1007,6 +1007,7 @@ struct sockaddr_storage addr; socklen_t addrLen; char *ipString = NULL; + int tempError = ASOCKERR_SUCCESS; int getaddrinfoError = AsyncTCPSocketResolveAddr(addrStr, port, socketFamily, TRUE, &addr, &addrLen, &ipString); @@ -1014,7 +1015,7 @@ if (getaddrinfoError == 0) { asock = AsyncTCPSocketListenImpl(&addr, addrLen, connectFn, clientData, pollParams, - outError); + &tempError); if (asock) { TCPSOCKLG0(asock, @@ -1023,15 +1024,17 @@ "socket", ipString); } else { Log(ASOCKPREFIX "Could not create %s listener socket, error %d: %s\n", - addr.ss_family == AF_INET ? "IPv4" : "IPv6", *outError, - AsyncSocket_Err2String(*outError)); + addr.ss_family == AF_INET ? "IPv4" : "IPv6", tempError, + AsyncSocket_Err2String(tempError)); } free(ipString); } else { Log(ASOCKPREFIX "Could not resolve listener socket address.\n"); - if (outError) { - *outError = ASOCKERR_ADDRUNRESV; - } + tempError = ASOCKERR_ADDRUNRESV; + } + + if (outError) { + *outError = tempError; } return asock; @@ -1284,11 +1287,12 @@ AsyncSocketConnectFn connectFn, // IN void *clientData, // IN AsyncSocketPollParams *pollParams, // IN - int *outError) // OUT + int *outError) // OUT: optional { struct sockaddr_vm addr; AsyncTCPSocket *asock; int vsockDev = -1; + int tempError = ASOCKERR_SUCCESS; memset(&addr, 0, sizeof addr); addr.svm_family = VMCISock_GetAFValueFd(&vsockDev); @@ -1298,7 +1302,10 @@ asock = AsyncTCPSocketListenImpl((struct sockaddr_storage *)&addr, sizeof addr, connectFn, clientData, pollParams, - outError); + &tempError); + if (outError) { + *outError = tempError; + } VMCISock_ReleaseAFValueFd(vsockDev); return BaseSocket(asock); @@ -1519,7 +1526,6 @@ socklen_t addrLen, // IN int *outError) // OUT { - int error = ASOCKERR_BIND; int sysErr; unsigned int port; @@ -1602,7 +1608,7 @@ if (bind(asock->fd, (struct sockaddr *)addr, addrLen) != 0) { sysErr = ASOCK_LASTERROR(); if (sysErr == ASOCK_EADDRINUSE) { - error = ASOCKERR_BINDADDRINUSE; + *outError = ASOCKERR_BINDADDRINUSE; } Warning(ASOCKPREFIX "Could not bind socket, error %d: %s\n", sysErr, Err_Errno2String(sysErr)); @@ -1615,10 +1621,6 @@ SSL_Shutdown(asock->sslSock); free(asock); - if (outError) { - *outError = error; - } - return FALSE; } @@ -1646,14 +1648,13 @@ int *outError) // OUT { VMwareStatus pollStatus; - int error; ASSERT(NULL != asock); ASSERT(NULL != asock->sslSock); if (!connectFn) { Warning(ASOCKPREFIX "invalid arguments to listen!\n"); - error = ASOCKERR_INVAL; + *outError = ASOCKERR_INVAL; goto error; } @@ -1665,7 +1666,7 @@ int sysErr = ASOCK_LASTERROR(); Warning(ASOCKPREFIX "could not listen on socket, error %d: %s\n", sysErr, Err_Errno2String(sysErr)); - error = ASOCKERR_LISTEN; + *outError = ASOCKERR_LISTEN; goto error; } @@ -1681,7 +1682,7 @@ if (pollStatus != VMWARE_STATUS_SUCCESS) { TCPSOCKWARN(asock, "could not register accept callback!\n"); - error = ASOCKERR_POLL; + *outError = ASOCKERR_POLL; AsyncTCPSocketUnlock(asock); goto error; } @@ -1697,10 +1698,6 @@ SSL_Shutdown(asock->sslSock); free(asock); - if (outError) { - *outError = error; - } - return FALSE; } @@ -2661,8 +2658,8 @@ * * AsyncTCPSocketRecvPassedFd -- * - * See AsyncTCPSocketRecv. Besides that it allows for receiving one file - * descriptor... + * See AsyncTCPSocket_Recv. Besides that it allows for receiving one + * file descriptor... * * Results: * ASOCKERR_*. @@ -2810,7 +2807,7 @@ static int AsyncTCPSocketPollWork(AsyncTCPSocket **asock, // IN: - int numSock, // IN: + size_t numSock, // IN: void *p, // IN: Bool read, // IN: int timeoutMS, // IN: @@ -2830,11 +2827,11 @@ struct fd_set rwfds; struct fd_set exceptfds; #endif - int i; + size_t i; int retval; ASSERT(outAsock != NULL && *outAsock == NULL && asock != NULL && - numSock > 0); + numSock != 0); for (i = 0; i < numSock; i++) { if (read && SSL_Pending(asock[i]->sslSock)) { @@ -2855,7 +2852,7 @@ retval = poll(pfd, numSock, timeoutMS); AsyncTCPSocketLock(parentSock); } else { - for (i = numSock - 1; i >= 0; i--) { + for (i = numSock; i-- > 0; ) { AsyncTCPSocketUnlock(asock[i]); } retval = poll(pfd, numSock, timeoutMS); @@ -2881,7 +2878,7 @@ &exceptfds, timeoutMS >= 0 ? &tv : NULL); AsyncTCPSocketLock(parentSock); } else { - for (i = numSock - 1; i >= 0; i--) { + for (i = numSock; i-- > 0; ) { AsyncTCPSocketUnlock(asock[i]); } retval = select(1, read ? &rwfds : NULL, read ? NULL : &rwfds, @@ -3035,7 +3032,7 @@ #else void *p = NULL; #endif - int numSock = 0; + size_t numSock = 0; if (read && s->fd == -1) { if (!s->listenAsock4 && !s->listenAsock6) { @@ -3081,11 +3078,11 @@ static int AsyncTCPSocketWaitForReadMultiple(AsyncSocket **asock, // IN: - int numSock, // IN: + size_t numSock, // IN: int timeoutMS, // IN: int *outIdx) // OUT: { - int i; + size_t i; int err; AsyncTCPSocket *outAsock = NULL; #ifndef _WIN32 @@ -3099,7 +3096,7 @@ } err = AsyncTCPSocketPollWork((AsyncTCPSocket **)asock, numSock, p, TRUE, timeoutMS, NULL, &outAsock); - for (i = numSock - 1; i >= 0; i--) { + for (i = numSock; i-- > 0; ) { AsyncTCPSocket *tcpAsock = TCPSocket(asock[i]); if (outAsock == tcpAsock) { *outIdx = i; @@ -6633,10 +6630,11 @@ AsyncSocketConnectFn connectFn, // IN void *clientData, // IN AsyncSocketPollParams *pollParams, // IN - int *outError) // OUT + int *outError) // OUT: optional { struct sockaddr_un addr; AsyncTCPSocket *asock; + int tempError = ASOCKERR_SUCCESS; memset(&addr, 0, sizeof addr); addr.sun_family = AF_UNIX; @@ -6646,7 +6644,10 @@ asock = AsyncTCPSocketListenImpl((struct sockaddr_storage *)&addr, sizeof addr, connectFn, clientData, - pollParams, outError); + pollParams, &tempError); + if (outError) { + *outError = tempError; + } return BaseSocket(asock); } diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/asyncsocket/asyncSocketInterface.c open-vm-tools-12.1.5/open-vm-tools/lib/asyncsocket/asyncSocketInterface.c --- open-vm-tools-11.3.5/open-vm-tools/lib/asyncsocket/asyncSocketInterface.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/asyncsocket/asyncSocketInterface.c 2022-11-29 21:17:22.000000000 +0000 @@ -1513,12 +1513,11 @@ * * AsyncSocket_SetWebSocketCookie -- * - * Return the Cookie field value supplied during a WebSocket - * connection request. + * Insert Set-Cookie HTTP response header during WebSocket connection. * * Results: - * Cookie, if asock is WebSocket. - * NULL, if asock is not WebSocket. + * ASOCKERR_SUCCESS if we finished the operation, ASOCKERR_* error codes + * otherwise. * * Side effects: * None. diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/asyncsocket/asyncSocketVTable.h open-vm-tools-12.1.5/open-vm-tools/lib/asyncsocket/asyncSocketVTable.h --- open-vm-tools-11.3.5/open-vm-tools/lib/asyncsocket/asyncSocketVTable.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/asyncsocket/asyncSocketVTable.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2011,2014-2017,2019-2021 VMware, Inc. All rights reserved. + * Copyright (C) 2011,2014-2017,2019-2022 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 @@ -131,8 +131,8 @@ int timeoutMS); int (*doOneMsg)(AsyncSocket *s, Bool read, int timeoutMS); int (*waitForConnection)(AsyncSocket *s, int timeoutMS); - int (*waitForReadMultiple)(AsyncSocket **asock, int numSock, int timeoutMS, - int *outIdx); + int (*waitForReadMultiple)(AsyncSocket **asock, size_t numSock, + int timeoutMS, int *outIdx); int (*peek)(AsyncSocket *asock, void *buf, int len, void *cb, void *cbData); /* diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/file/fileInt.h open-vm-tools-12.1.5/open-vm-tools/lib/file/fileInt.h --- open-vm-tools-11.3.5/open-vm-tools/lib/file/fileInt.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/file/fileInt.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2007-2019 VMware, Inc. All rights reserved. + * Copyright (C) 2007-2019, 2021 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 @@ -197,7 +197,7 @@ { char *machineID; char *executionID; - char *lockType; + const char *lockType; char *locationChecksum; char *memberName; unsigned int lamportNumber; diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/file/fileIO.c open-vm-tools-12.1.5/open-vm-tools/lib/file/fileIO.c --- open-vm-tools-11.3.5/open-vm-tools/lib/file/fileIO.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/file/fileIO.c 2022-11-29 21:17:22.000000000 +0000 @@ -48,6 +48,7 @@ #include #endif #if defined(VMX86_SERVER) +#include "config.h" #include "fs_public.h" #endif @@ -1054,3 +1055,109 @@ { return FileIO_AtomicUpdateEx(newFD, currFD, TRUE) == 1; } + + +/* + *----------------------------------------------------------------------------- + * + * FileIOGetChoiceOnConfig -- + * + * Get the choice based on the "answer.msg.%s.file.open" in config file. + * If it's not set, will return the default 0x20. + * + * Results: + * The first character of the value or 0x20 by default. + * + * Side effects: + * None + * + *----------------------------------------------------------------------------- + */ + +static char +FileIOGetChoiceOnConfig(const char *device, // IN: device name + const char *pathName) // IN: file path +{ + char choice = 0x20; + +#if defined(VMX86_SERVER) + char *answer = Config_GetString(NULL, "answer.msg.%s.file.open", device); + + if (answer == NULL) { + Log("Appending %s output to %s. Use answer.msg.%s.file.open=\"replace\" " + "to replace file instead.", device, pathName, device); + } else { + const char *opt = answer; + + while (*opt == '_') { + opt++; + } + choice = *opt | 0x20; // tolower() for ascii + free(answer); + } +#endif + return choice; +} + + +/* + *----------------------------------------------------------------------------- + * + * FileIO_CreateDeviceFileNoPrompt -- + * + * If file does not exist, new file is created. If file does exist, + * configuration option answer.msg..file.open is consulted to + * decide whether to truncate file (replace), append data at the end of + * the file (append, the default), or fail open (cancel). + * + * Results: + * FileIOResult of call: FILEIO_SUCCESS or FILEIO_CANCELLED or other value. + * + * Side effects: + * None + * + *----------------------------------------------------------------------------- + */ + +FileIOResult +FileIO_CreateDeviceFileNoPrompt(FileIODescriptor *fd, // IN: file IO description + const char *pathName, // IN: file path + int openMode, // IN: + FileIOOpenAction action,// IN: + int perms, // IN: + const char *device) // IN: +{ + FileIOResult fret; + char choice = '\0'; + int time = 0; + + ASSERT(fd != NULL); + ASSERT(pathName != NULL); + ASSERT(device != NULL); + + while ((fret = FileIO_Create(fd, pathName, openMode, action, perms)) + == FILEIO_OPEN_ERROR_EXIST) { + if (choice == '\0') { + choice = FileIOGetChoiceOnConfig(device, pathName); + + switch (choice) { + case 'c': // Cancel + fret = FILEIO_CANCELLED; + break; + case 'r': // Replace + case 'o': // Overwrite + action = FILEIO_OPEN_CREATE_EMPTY; + break; + default: // Append, nothing, empty string + action = FILEIO_OPEN_CREATE; + break; + } + } + + if (fret == FILEIO_CANCELLED || time++ == 3) { + break; + } + } + + return fret; +} diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/file/fileIOPosix.c open-vm-tools-12.1.5/open-vm-tools/lib/file/fileIOPosix.c --- open-vm-tools-11.3.5/open-vm-tools/lib/file/fileIOPosix.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/file/fileIOPosix.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2021 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2022 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 @@ -102,6 +102,11 @@ #include #endif +#ifdef VMX86_SERVER +#include "fs_public.h" +#include +#endif + /* * fallocate() is only supported since the glibc-2.8 and * linux kernel-2.6.23. Presently the glibc in our toolchain is 2.3. @@ -2288,7 +2293,16 @@ FileIO_SupportsFileSize(const FileIODescriptor *fd, // IN: uint64 requestedSize) // IN: { -#if defined(__linux__) +#ifdef VMX86_SERVER + // PR 93215: Use VMkernel-specific logic. + uint64 maxFileSize; + if (ioctl(fd->posix, IOCTLCMD_VMFS_GET_MAX_FILE_SIZE, &maxFileSize) == -1) { + Log(LGPFX" %s: Could not get max file size for fd: %d, error: %s\n", + __func__, fd->posix, Err_Errno2String(errno)); + return FALSE; + } + return requestedSize <= maxFileSize; +#elif defined(__linux__) /* * Linux makes test on seek(), so we can do simple non-intrusive test. * Verified to work on 2.2.x, 2.4.x and 2.6.x, with ext2, ext3, smbfs, diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/file/fileLockPrimitive.c open-vm-tools-12.1.5/open-vm-tools/lib/file/fileLockPrimitive.c --- open-vm-tools-11.3.5/open-vm-tools/lib/file/fileLockPrimitive.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/file/fileLockPrimitive.c 2022-11-29 21:17:22.000000000 +0000 @@ -72,9 +72,9 @@ typedef struct parse_table { - int type; - char *name; - void *valuePtr; + int type; + const char *name; + void *valuePtr; } ParseTable; /* @@ -1282,27 +1282,22 @@ if (err == 0) { /* The name exists. Deal with it... */ - if (fileData.fileType == FILE_TYPE_REGULAR) { + if (fileData.fileType != FILE_TYPE_DIRECTORY) { /* - * It's a file. Assume this is an (active?) old style lock and - * err on the safe side - don't remove it (and automatically - * upgrade to a new style lock). + * Locks are implemented via directories. Ancient hosted locks and + * lock files imported alongsize an ESXi VM are implemented as + * files. It's safe to remove these. The ESXi lock files are + * meaningless and the ancient hosted lock files have been dead + * for over a decade (at the time of writing this comment). */ - Log(LGPFX" %s: '%s' exists; an old style lock file?\n", - __FUNCTION__, lockDir); - - err = EBUSY; - break; - } - - if (fileData.fileType != FILE_TYPE_DIRECTORY) { - /* Not a directory; attempt to remove the debris */ - if (FileDeletionRobust(lockDir, FALSE) != 0) { - Warning(LGPFX" %s: '%s' exists and is not a directory.\n", + err = FileDeletionRobust(lockDir, FALSE); + if (err == 0) { + Warning(LGPFX" %s: '%s' is not a directory. Removed.\n", __FUNCTION__, lockDir); - - err = ENOTDIR; + } else { + Warning(LGPFX" %s: an attempt to remove '%s' failed: %s\n", + __FUNCTION__, lockDir, Err_Errno2String(err)); break; } diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/file/filePosix.c open-vm-tools-12.1.5/open-vm-tools/lib/file/filePosix.c --- open-vm-tools-11.3.5/open-vm-tools/lib/file/filePosix.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/file/filePosix.c 2022-11-29 21:17:22.000000000 +0000 @@ -1234,9 +1234,9 @@ * Get the filesystem type number of the file system on which the * given file/directory resides. * - * Caller can specify either a pathname or an already opened fd of - * the file/dir whose filesystem he wants to determine. - * 'fd' takes precedence over 'pathName' so 'pathName' is used only + * Callers can specify either a pathname, or an already opened fd, + * of the file/dir whose filesystem they want to determine. + * 'fd' takes precedence over 'pathName', so 'pathName' is used only * if 'fd' is -1. * * Results: @@ -2996,7 +2996,7 @@ context = Util_SafeMalloc(sizeof *context); context->dirName = Util_SafeStrdup(dirName); - context->hash = HashTable_Alloc(256, HASH_STRING_KEY, NULL); + context->hash = HashTable_Alloc(2048, HASH_STRING_KEY, NULL); context->dir = Posix_OpenDir(dirName); if (context->dir == NULL) { diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/glibUtils/fileLogger.c open-vm-tools-12.1.5/open-vm-tools/lib/glibUtils/fileLogger.c --- open-vm-tools-11.3.5/open-vm-tools/lib/glibUtils/fileLogger.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/glibUtils/fileLogger.c 2022-11-29 21:17:22.000000000 +0000 @@ -392,6 +392,7 @@ g_io_channel_unref(logger->file); logger->append = FALSE; logger->file = FileLoggerOpen(logger); + logger->handler.logHeader = TRUE; } else { g_io_channel_flush(logger->file, NULL); } @@ -460,6 +461,7 @@ data->handler.shared = FALSE; data->handler.logfn = FileLoggerLog; data->handler.dtor = FileLoggerDestroy; + data->handler.logHeader = TRUE; data->path = g_filename_from_utf8(path, -1, NULL, NULL, NULL); if (data->path == NULL) { diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/globalConfig/globalConfig.c open-vm-tools-12.1.5/open-vm-tools/lib/globalConfig/globalConfig.c --- open-vm-tools-11.3.5/open-vm-tools/lib/globalConfig/globalConfig.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/globalConfig/globalConfig.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2020-2021 VMware, Inc. All rights reserved. + * Copyright (C) 2020-2022 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 @@ -50,7 +50,7 @@ /** * Default value for CONFNAME_GLOBALCONF_ENABLED setting in tools.conf. * - * FALSE will enable the module. + * TRUE will enable the module. GlobalConf module is disabled by default. */ #define GLOBALCONF_DEFAULT_ENABLED FALSE @@ -563,6 +563,9 @@ } cfg = g_key_file_new(); + + /* On error, 'err' will be set, null otherwise. */ + /* coverity[check_return] */ g_key_file_load_from_file(cfg, confPath, G_KEY_FILE_NONE, &err); if (err != NULL) { diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/hgfs/cpName.c open-vm-tools-12.1.5/open-vm-tools/lib/hgfs/cpName.c --- open-vm-tools-11.3.5/open-vm-tools/lib/hgfs/cpName.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/hgfs/cpName.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2016 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2016,2022 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 @@ -168,7 +168,14 @@ } /* Leaving space for the leading path separator, thus output to savedBufOut + 1. */ - *inSize = HgfsEscape_Do(*bufIn, *inSize, savedOutSize, savedBufOut + 1); + result = HgfsEscape_Do(*bufIn, *inSize, savedOutSize - 1, savedBufOut + 1); + if (result < 0) { + Log("%s: error: not enough room to perform escape: %d\n", + __FUNCTION__, result); + return -1; + } + *inSize = (size_t) result; + result = CPNameConvertFrom(&savedOutConst, inSize, outSize, bufOut, pathSep); *bufIn += *inSize; *inSize = 0; @@ -221,10 +228,10 @@ ASSERT(bufOut); in = *bufIn; + inEnd = in + *inSize; if (inPlaceConvertion) { in++; // Skip place for the leading path separator. } - inEnd = in + *inSize; myOutSize = *outSize; out = *bufOut; diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/hgfs/hgfsEscape.c open-vm-tools-12.1.5/open-vm-tools/lib/hgfs/hgfsEscape.c --- open-vm-tools-11.3.5/open-vm-tools/lib/hgfs/hgfsEscape.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/hgfs/hgfsEscape.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2008-2019 VMware, Inc. All rights reserved. + * Copyright (C) 2008-2019,2022 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 @@ -842,7 +842,6 @@ result += componentSize; if (unprocessedSize > 1) { currentComponent = currentComponent + componentSize; - componentSize = strlen(currentComponent) + 1; // Size of the next component } else { currentComponent = NULL; } diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/hgfs/hgfsUtil.c open-vm-tools-12.1.5/open-vm-tools/lib/hgfs/hgfsUtil.c --- open-vm-tools-11.3.5/open-vm-tools/lib/hgfs/hgfsUtil.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/hgfs/hgfsUtil.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2016 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2016,2022 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 @@ -109,24 +109,7 @@ HgfsConvertFromNtTimeNsec(struct timespec *unixTime, // OUT: Time in UNIX format uint64 ntTime) // IN: Time in Windows NT format { -#ifdef __i386__ - uint32 sec; - uint32 nsec; - - ASSERT(unixTime); - /* We assume that time_t is 32bit */ - ASSERT_ON_COMPILE(sizeof (unixTime->tv_sec) == 4); - - /* Cap NT time values that are outside of Unix time's range */ - - if (ntTime >= UNIX_S32_MAX) { - unixTime->tv_sec = 0x7FFFFFFF; - unixTime->tv_nsec = 0; - return 1; - } -#else ASSERT(unixTime); -#endif if (ntTime < UNIX_EPOCH) { unixTime->tv_sec = 0; @@ -135,13 +118,26 @@ } #ifdef __i386__ - Div643232(ntTime - UNIX_EPOCH, 10000000, &sec, &nsec); - unixTime->tv_sec = sec; - unixTime->tv_nsec = nsec * 100; -#else + if (sizeof unixTime->tv_sec == 4) { + uint32 sec,nsec; + + /* Cap NT time values that are outside of Unix time's range */ + if (ntTime >= UNIX_S32_MAX) { + unixTime->tv_sec = 0x7FFFFFFF; + unixTime->tv_nsec = 0; + return 1; + } + + Div643232(ntTime - UNIX_EPOCH, 10000000, &sec, &nsec); + unixTime->tv_sec = sec; + unixTime->tv_nsec = nsec * 100; + + return 0; + } +#endif + unixTime->tv_sec = (ntTime - UNIX_EPOCH) / 10000000; unixTime->tv_nsec = ((ntTime - UNIX_EPOCH) % 10000000) * 100; -#endif return 0; } diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/asyncsocket.h open-vm-tools-12.1.5/open-vm-tools/lib/include/asyncsocket.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/asyncsocket.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/asyncsocket.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2003-2021 VMware, Inc. All rights reserved. + * Copyright (C) 2003-2022 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 @@ -439,6 +439,10 @@ const char *httpRequest, char **httpResponse); +typedef int (*AsyncWebSocketHandoffSocketFn) (AsyncSocket *asock, void *cbData, + void *buf, uint32 bufLen, + uint32 currentPos); + /* * Listen on port and fire callback with new asock */ @@ -474,12 +478,22 @@ void *clientData, AsyncSocketPollParams *pollParams, void *sslCtx, - AsyncWebSocketHandleUpgradeRequestFn handleUpgradeRequestFn); + AsyncWebSocketHandleUpgradeRequestFn handleUpgradeRequestFn, + AsyncWebSocketHandoffSocketFn alpnCb, + const char* alpn); AsyncSocket *AsyncSocket_RegisterListenWebSocket(AsyncSocket *asock, const char *addrStr, unsigned int port, AsyncSocketPollParams *pollParams, int *outError); +AsyncSocket* AsyncSocket_UpgradeToWebSocket(AsyncSocket *asock, + const char *protocols[], + AsyncSocketConnectFn connectFn, + void *clientData, + Bool useSSL, + void *sslCtx, + AsyncWebSocketHandleUpgradeRequestFn handleUpgradeRequestFn, + int *outError); #ifndef _WIN32 AsyncSocket *AsyncSocket_ListenWebSocketUDS(const char *pipeName, @@ -561,6 +575,13 @@ AsyncSocket * AsyncSocket_AttachToNamedPipe(HANDLE handle, AsyncSocketPollParams *pollParams, int *outError); + +/* + * Obtain the client process id of the given named pipe + */ +Bool +AsyncSocket_GetNamedPipeClientProcessId(AsyncSocket* asock, + PULONG clientPid); #endif AsyncSocket * diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/backdoor_def.h open-vm-tools-12.1.5/open-vm-tools/lib/include/backdoor_def.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/backdoor_def.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/backdoor_def.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2021 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2022 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 @@ -174,9 +174,9 @@ #define BDOOR_CMD_SENDPSHAREHINTS 66 /* Not in use. Deprecated. */ #define BDOOR_CMD_ENABLE_USB_MOUSE 67 #define BDOOR_CMD_GET_VCPU_INFO 68 -# define BDOOR_CMD_VCPU_SLC64 0 +//#define BDOOR_CMD_VCPU_SLC64 0 /* BT-is-dead. Deprecated. */ # define BDOOR_CMD_VCPU_SYNC_VTSCS 1 -# define BDOOR_CMD_VCPU_HV_REPLAY_OK 2 +//#define BDOOR_CMD_VCPU_HV_REPLAY_OK 2 /* Replay-is-dead. Deprecated.*/ # define BDOOR_CMD_VCPU_LEGACY_X2APIC_OK 3 # define BDOOR_CMD_VCPU_MMIO_HONORS_PAT 4 # define BDOOR_CMD_VCPU_RESERVED 31 @@ -275,7 +275,8 @@ #define BDOOR_CMD_COREDUMP_UNSYNC 98 /* Devel only. For VMM cores */ #define BDOOR_CMD_APPLE_GPU_RES_SET 99 #define BDOOR_CMD_GETBUILDNUM 100 -#define BDOOR_CMD_MAX 101 +#define BDOOR_CMD_GETENTROPY 101 /* Configurable, off by default. */ +#define BDOOR_CMD_MAX 102 /* diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/buildNumber.h open-vm-tools-12.1.5/open-vm-tools/lib/include/buildNumber.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/buildNumber.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/buildNumber.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,12 +1,12 @@ #define BUILD_NUMBER \ - "build-18557794" + "build-20735119" #define BUILD_NUMBER_NUMERIC \ - 18557794 + 20735119 #define BUILD_NUMBER_NUMERIC_STRING \ - "18557794" + "20735119" #define PRODUCT_BUILD_NUMBER \ - "product-build-31214" + "product-build-39265" #define PRODUCT_BUILD_NUMBER_NUMERIC \ - 31214 + 39265 #define PRODUCT_BUILD_NUMBER_NUMERIC_STRING \ - "31214" + "39265" diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/codeset.h open-vm-tools-12.1.5/open-vm-tools/lib/include/codeset.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/codeset.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/codeset.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /* ********************************************************** - * Copyright (c) 2007-2021 VMware, Inc. All rights reserved. + * Copyright (c) 2007-2022 VMware, Inc. All rights reserved. * **********************************************************/ /* @@ -394,14 +394,6 @@ Bool CodeSet_IsValidUTF8String(const char *bufIn, // IN: size_t sizeIn); // IN: -typedef struct { - char c; - char *escape; -} CodeSetEscapeEntry; - -char *CodeSet_Utf8Escape(const char *utf8, // IN: - const CodeSetEscapeEntry *entries); // IN: - char *CodeSet_JsonEscape(const char *utf8); // IN: char *CodeSet_JsonUnescape(const char *utf8); // IN: diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/conf.h open-vm-tools-12.1.5/open-vm-tools/lib/include/conf.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/conf.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/conf.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2002-2021 VMware, Inc. All rights reserved. + * Copyright (C) 2002-2022 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 @@ -85,6 +85,14 @@ #define CONFNAME_APPINFO_DISABLED "disabled" /** + * Defines the configuration to remove duplicate applications. + * + * @param boolean Set to TRUE to remove duplicate apps. + * Set to FALSE to keep duplicate apps. + */ +#define CONFNAME_APPINFO_REMOVE_DUPLICATES "remove-duplicates" + +/** * Defines the configuration to use the WMI for getting the application * version information. * @@ -103,6 +111,82 @@ /* ****************************************************************************** + * BEGIN containerInfo goodies. + */ + +/** + * Defines the string used for the ContainerInfo config file group. + */ +#define CONFGROUPNAME_CONTAINERINFO "containerinfo" + +/** + * Define a custom ContainerInfo poll interval (in seconds). + * + * @note Illegal values result in a @c g_warning and fallback to the default + * poll interval. + * + * @param int User-defined poll interval. Set to 0 to disable polling. + */ +#define CONFNAME_CONTAINERINFO_POLLINTERVAL "poll-interval" + +/** + * Define the limit on the maximum number of containers to collect info from. + * If the number of running containers exceeds the limit, only the most recently + * created containers will be published. + * + * @note Illegal values result in a @c g_warning and fallback to the default + * max container limit. + * + * @param int User-defined max limit for # of containers queried. + */ +#define CONFNAME_CONTAINERINFO_LIMIT "max-containers" + +/** + * Defines the configuration to remove duplicate containers. + * + * @param boolean Set to TRUE to remove duplicate containers. + * Set to FALSE to keep duplicate containers. + */ +#define CONFNAME_CONTAINERINFO_REMOVE_DUPLICATES "remove-duplicates" + +/** + * Define the docker unix socket to use to communicate with the docker daemon. + * + * @note Illegal values result in a @c g_warning and fallback to docker's + * default unix socket. + * + * @param string absolute file path of the docker unix socket in use. + */ +#define CONFNAME_CONTAINERINFO_DOCKERSOCKET "docker-unix-socket" + +/** + * Define the containerd unix socket to connect with containerd gRPC server. + * This should be used to get containers. + * + * @note Illegal values result in a @c g_warning and fallback to the containerd + * default unix socket. + * + * @param string absolute file path of the containerd unix socket in use. + */ +#define CONFNAME_CONTAINERINFO_CONTAINERDSOCKET "containerd-unix-socket" + +/** + * Define the list of namespaces to be queried for the running containers. + * + * @note Illegal values result in a @c g_warning and fallback to the default + * list of namespaces. + * + * @param string Comma separated list of namespaces to be queried. + */ +#define CONFNAME_CONTAINERINFO_ALLOWED_NAMESPACES "allowed-namespaces" + +/* + * END containerInfo goodies. + ****************************************************************************** + */ + +/* + ****************************************************************************** * BEGIN ServiceDiscovery goodies. */ @@ -129,6 +213,34 @@ /* ****************************************************************************** + * BEGIN ComponentMgr goodies. + */ + +/** + * Defines the current poll interval (in seconds). + * This value is controlled by the componentMgr.poll-interval config file + * option. + */ +#define COMPONENTMGR_CONF_POLLINTERVAL "poll-interval" + +/** + * Name of section of configuration to be read from tools.conf. + */ +#define COMPONENTMGR_CONF_GROUPNAME "componentmgr" + +/** + * Defines the components managed by the componentMgr plugin. + * This value is controlled by the componentMgr.included config file option. + */ +#define COMPONENTMGR_CONF_INCLUDEDCOMPONENTS "included" + +/* + * END ComponentMgr goodies. + ****************************************************************************** + */ + +/* + ****************************************************************************** * BEGIN GuestStore upgrader goodies. ****************************************************************************** */ @@ -475,6 +587,12 @@ */ #define CONFNAME_DEPLOYPKG_ENABLE_CUST "enable-customization" +/** + * How long does guest customization wait until cloud-init execution done + * Valid value range: 0 ~ 1800 + */ +#define CONFNAME_DEPLOYPKG_WAIT_CLOUDINIT_TIMEOUT "wait-cloudinit-timeout" + /* * END deployPkg goodies. ****************************************************************************** @@ -497,6 +615,7 @@ #define CONFNAME_AUTOUPGRADE_ALLOW_UPGRADE "allow-upgrade" #define CONFNAME_AUTOUPGRADE_ALLOW_ADD_FEATURE "allow-add-feature" #define CONFNAME_AUTOUPGRADE_ALLOW_REMOVE_FEATURE "allow-remove-feature" +#define CONFNAME_AUTOUPGRADE_ALLOW_MSI_TRANSFORMS "allow-msi-transforms" /* * END upgrader goodies. diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/config.h open-vm-tools-12.1.5/open-vm-tools/lib/include/config.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/config.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/config.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2018 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2018,2021 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 @@ -41,6 +41,8 @@ void Config_SetAny(const char *value, const char *fmt, ...) PRINTF_DECL(2, 3); +void Config_SetAnySecure(const char *value, + const char *fmt, ...) PRINTF_DECL(2, 3); void Config_SetString(const char *value, const char *fmt, ...) PRINTF_DECL(2, 3); void Config_SetStringPlain(const char *value, @@ -113,7 +115,9 @@ Bool Config_Write(void); Bool Config_WriteNoMsg(void); -Bool Config_FileIsWritable(void); +Bool Config_FileIsWritable(void); + +Bool Config_IsIntegrityProtected(void); uint32 Config_GetMask(uint32 defaultMask, const char *optionName); uint64 Config_GetMask64(uint64 defaultMask, const char *optionName); diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/dbllnklst.h open-vm-tools-12.1.5/open-vm-tools/lib/include/dbllnklst.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/dbllnklst.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/dbllnklst.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2017,2020 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2017,2020,2022 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 @@ -69,6 +69,7 @@ #define INCLUDE_ALLOW_MODULE #define INCLUDE_ALLOW_USERLEVEL +#define INCLUDE_ALLOW_VMCORE #include "includeCheck.h" #include "vm_basic_types.h" diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/deployPkg/linuxDeployment.h open-vm-tools-12.1.5/open-vm-tools/lib/include/deployPkg/linuxDeployment.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/deployPkg/linuxDeployment.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/deployPkg/linuxDeployment.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2009-2019 VMware, Inc. All rights reserved. + * Copyright (C) 2009-2019, 2022 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 @@ -65,6 +65,25 @@ /* + *------------------------------------------------------------------------------ + * + * DeployPkg_SetWaitForCloudinitDoneTimeout + * + * Set the timeout value of customization process waits for cloud-init + * execution done before trigger reboot and after connect network adapters. + * + * @param timeout [in] + * timeout value to be used for waiting for cloud-init execution done + * + *------------------------------------------------------------------------------ + */ + +IMGCUST_API void +DeployPkg_SetWaitForCloudinitDoneTimeout(uint16 timeout); + + + +/* *------------------------------------------------------------------------------ * * DeployPkg_SetLogger -- diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/dynbuf.h open-vm-tools-12.1.5/open-vm-tools/lib/include/dynbuf.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/dynbuf.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/dynbuf.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2019 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2022 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 @@ -75,6 +75,12 @@ void const *data, // IN size_t size); // IN +MUST_CHECK_RETURN Bool +DynBuf_Insert(DynBuf *b, // IN/OUT + size_t offset, // IN + void const *data, // IN + size_t size); // IN + Bool DynBuf_Trim(DynBuf *b); // IN/OUT @@ -93,6 +99,17 @@ DynBuf_SafeInternalAppend(_buf, _data, _size, __FILE__, __LINE__) void +DynBuf_SafeInternalInsert(DynBuf *b, // IN/OUT + size_t offset, // IN + void const *data, // IN + size_t size, // IN + char const *file, // IN + unsigned int lineno); // IN + +#define DynBuf_SafeInsert(_buf, _offset, _data, _size) \ + DynBuf_SafeInternalInsert(_buf, _offset, _data, _size, __FILE__, __LINE__) + +void DynBuf_SafeInternalEnlarge(DynBuf *b, // IN/OUT size_t min_size, // IN char const *file, // IN diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/fileIO.h open-vm-tools-12.1.5/open-vm-tools/lib/include/fileIO.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/fileIO.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/fileIO.h 2022-11-29 21:17:22.000000000 +0000 @@ -493,6 +493,15 @@ const char *FileIO_Filename(FileIODescriptor *fd); +#ifdef VMX86_SERVER +FileIOResult FileIO_CreateDeviceFileNoPrompt(FileIODescriptor *fd, + const char *pathName, + int openMode, + FileIOOpenAction action, + int perms, + const char *device); +#endif + /* *------------------------------------------------------------------------- * diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/ghIntegrationCommon.h open-vm-tools-12.1.5/open-vm-tools/lib/include/ghIntegrationCommon.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/ghIntegrationCommon.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/ghIntegrationCommon.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2008-2021 VMware, Inc. All rights reserved. + * Copyright (C) 2008-2022 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 @@ -53,7 +53,10 @@ #define GHI_CHANNEL_VIEW_PROTOCOL 7 // Interactions with different protocols // in View RMKS #define GHI_CHANNEL_FCP 8 // FCP for View RMKS -#define GHI_CHANNEL_COUNT 9 +#define GHI_CHANNEL_VIEW_SDR 9 // Handled by View SDR +#define GHI_CHANNEL_VIEW_WHFB_REDIRECTION 10 // WhfbRedirectionMKSControl module in + // View RMKS +#define GHI_CHANNEL_COUNT 11 typedef uint32 GHIChannelType; @@ -186,6 +189,20 @@ #define GHI_HOST_VDP_COMMON_GET_GUEST_CAPS_CMD "ghi.mks.common.get.guest.caps" /* + * MKS->UI messages over GHI_CHANNEL_VIEW_WHFB_REDIRECTION + */ +#define GHI_CHANNEL_VIEW_WHFB_REDIRECTION_BITS \ + GHI_GUEST_CHANNEL_BITS(GHI_CHANNEL_VIEW_WHFB_REDIRECTION) +#define GHI_GUEST_WHFB_REDIRECTION_UNLOCK_REQUEST \ + (GHI_CHANNEL_VIEW_WHFB_REDIRECTION_BITS | 0x000001) + +/* + * UI->MKS messages over GHI_CHANNEL_VIEW_WHFB_REDIRECTION. + */ +#define GHI_WHFB_REDIRECTION_SET_SESSIONPIN_CMD "ghi.whfb.set.sessionpin" +#define GHI_WHFB_REDIRECTION_SET_USERVERIFICATIONRESULT_CMD "ghi.whfb.set.userverificationresult" + +/* * Capabilities for the message GHI_GUEST_VDP_COMMON_CAP_FEATURES */ typedef enum { @@ -193,4 +210,17 @@ VDP_COMMON_CAP_ITEM_COUNT } VDPCommonCapType; +/* + * UI->MKS messages over GHI_CHANNEL_VIEW_SDR + */ +#define GHI_VIEW_SDR_ADD_DRIVE "ghi.view.sdr.add.drive" +#define GHI_VIEW_SDR_REMOVE_DRIVE "ghi.view.sdr.remove.drive" + +/* + * MKS->UI messages over GHI_CHANNEL_VIEW_SDR. + */ +#define GHI_CHANNEL_VIEW_SDR_BITS GHI_GUEST_CHANNEL_BITS(GHI_CHANNEL_VIEW_SDR) +#define GHI_VIEW_SDR_VDP_CONNECTED (GHI_CHANNEL_VIEW_SDR_BITS | 0x000001) +#define GHI_VIEW_SDR_VDP_DISCONNECTED (GHI_CHANNEL_VIEW_SDR_BITS | 0x000002) + #endif // ifndef _GHINTEGRATIONCOMMON_H_ diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/glibUtils.h open-vm-tools-12.1.5/open-vm-tools/lib/include/glibUtils.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/glibUtils.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/glibUtils.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2011-2017 VMware, Inc. All rights reserved. + * Copyright (C) 2011-2017,2021 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 @@ -54,6 +54,7 @@ gboolean addsTimestamp; /**< Output adds timestamp automatically. */ GLogFunc logfn; /**< The function that writes to the output. */ GDestroyNotify dtor; /**< Destructor. */ + gboolean logHeader; /**< Header needs to be logged. */ } GlibLogger; diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/guest_msg_def.h open-vm-tools-12.1.5/open-vm-tools/lib/include/guest_msg_def.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/guest_msg_def.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/guest_msg_def.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2016 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2016,2022 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 @@ -90,8 +90,12 @@ * Max number of channels. * Unfortunately this has to be public because the monitor part * of the backdoor needs it for its trivial-case optimization. [greg] + * + * It would be nice to have as many as 1024 channels however, as we discovered + * in PR 2978984, it becomes particularly difficult to raise the number beyond + * 250. After much discussion, 128 was chosen. */ -#define GUESTMSG_MAX_CHANNEL 8 +#define GUESTMSG_MAX_CHANNEL 128 /* Flags to open a channel. --hpreg */ #define GUESTMSG_FLAG_COOKIE 0x80000000 diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/guest_os.h open-vm-tools-12.1.5/open-vm-tools/lib/include/guest_os.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/guest_os.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/guest_os.h 2022-11-29 21:17:22.000000000 +0000 @@ -88,10 +88,10 @@ BS(FREEBSD12), BS(FREEBSD13), \ BS(FREEBSD14) -#define ALLFREEBSD64 BS(FREEBSD_64), BS(FREEBSD11_64), \ - BS(FREEBSD12_64), BS(FREEBSD13_64), \ - BS(FREEBSD14_64), BS(ARM_FREEBSD13_64), \ - BS(ARM_FREEBSD14_64) +#define ALLFREEBSD64 BS(FREEBSD_64), \ + BS(FREEBSD11_64), BS(FREEBSD12_64), \ + BS(FREEBSD13_64), BS(FREEBSD13_ARM_64), \ + BS(FREEBSD14_64), BS(FREEBSD14_ARM_64) #define ALLFREEBSD ALLFREEBSD32, ALLFREEBSD64 @@ -110,52 +110,67 @@ #define ALLWIN2008R2_64 BS(WIN2008R2_64) #define ALLWIN2008R2 ALLWIN2008R2_64 -#define ALLWINSEVEN32 BS(WINSEVEN) -#define ALLWINSEVEN64 BS(WINSEVEN_64) +#define ALLWINSEVEN32 BS(WIN_7) +#define ALLWINSEVEN64 BS(WIN_7_64) #define ALLWINSEVEN ALLWINSEVEN32, ALLWINSEVEN64 -#define ALLWINEIGHTSERVER64 BS(WINEIGHTSERVER_64) +#define ALLWINEIGHTSERVER64 BS(WIN_8_SERVER_64) #define ALLWINEIGHTSERVER ALLWINEIGHTSERVER64 -#define ALLWINEIGHTCLIENT32 BS(WINEIGHT) -#define ALLWINEIGHTCLIENT64 BS(WINEIGHT_64) +#define ALLWINEIGHTCLIENT32 BS(WIN_8) +#define ALLWINEIGHTCLIENT64 BS(WIN_8_64) #define ALLWINEIGHTCLIENT ALLWINEIGHTCLIENT32, ALLWINEIGHTCLIENT64 #define ALLWINEIGHT ALLWINEIGHTSERVER, ALLWINEIGHTCLIENT -#define ALLWINTENSERVER64 BS(WIN_2016SRV_64), BS(WIN_2019SRV_64), \ - BS(WIN_2022SRV_64), BS(WIN_2025SRV_64) +#define ALLWIN_10_SERVER64 BS(WIN_2016SRV_64), BS(WIN_2019SRV_64) -#define ALLWINTENSERVER ALLWINTENSERVER64 +#define ALLWIN_10_SERVER ALLWIN_10_SERVER64 -#define ALLWINTENCLIENT32 BS(WINTEN) -#define ALLWINTENCLIENT64 BS(WINTEN_64), BS(ARM_WINTEN_64) -#define ALLWINTENCLIENT ALLWINTENCLIENT32, ALLWINTENCLIENT64 - -#define ALLWINTEN32 ALLWINTENCLIENT32 -#define ALLWINTEN64 ALLWINTENCLIENT64, ALLWINTENSERVER -#define ALLWINTEN ALLWINTENCLIENT, ALLWINTENSERVER +#define ALLWIN_10_CLIENT32 BS(WIN_10) +#define ALLWIN_10_CLIENT64 BS(WIN_10_64), BS(WIN_10_ARM_64) +#define ALLWIN_10_CLIENT ALLWIN_10_CLIENT32, ALLWIN_10_CLIENT64 + +#define ALLWIN_10_32 ALLWIN_10_CLIENT32 +#define ALLWIN_10_64 ALLWIN_10_CLIENT64, ALLWIN_10_SERVER +#define ALLWIN_10 ALLWIN_10_CLIENT, ALLWIN_10_SERVER + +#define ALLWIN_11_SERVER64 BS(WIN_2022SRV_64), BS(WIN_2025SRV_64) +#define ALLWIN_11_SERVER ALLWIN_11_SERVER64 + +#define ALLWIN_11_CLIENT64 BS(WIN_11_64), BS(WIN_11_ARM_64) +#define ALLWIN_11_CLIENT ALLWIN_11_CLIENT64 + +#define ALLWIN_11_64 ALLWIN_11_CLIENT64, ALLWIN_11_SERVER +#define ALLWIN_11 ALLWIN_11_CLIENT64, ALLWIN_11_SERVER + +#define ALLWIN_12_CLIENT64 BS(WIN_12_64), BS(WIN_12_ARM_64) +#define ALLWIN_12_CLIENT ALLWIN_12_CLIENT64 + +#define ALLWIN_12 ALLWIN_12_CLIENT64 #define ALLHYPER_V BS(HYPER_V) -#define ALLWINVISTA_OR_HIGHER ALLWINVISTA, ALLWINLONGHORN, \ - ALLWIN2008R2, ALLWINSEVEN, \ - ALLWINEIGHTSERVER, ALLWINEIGHTCLIENT, \ - ALLWINTENSERVER, ALLWINTENCLIENT, \ - ALLHYPER_V \ +#define ALLWINVISTA_OR_HIGHER ALLWINVISTA, ALLWINLONGHORN, \ + ALLWIN2008R2, ALLWINSEVEN, \ + ALLWINEIGHTSERVER, ALLWINEIGHTCLIENT, \ + ALLWIN_10_SERVER, ALLWIN_10_CLIENT, \ + ALLWIN_11_SERVER, ALLWIN_11_CLIENT, \ + ALLWIN_12_CLIENT, ALLHYPER_V #define ALLWINNT32 BS(WINNT), ALLWIN2000, \ ALLWINXP32, ALLWINNET32, \ ALLWINVISTA32, ALLWINLONGHORN32, \ ALLWINSEVEN32, ALLWINEIGHTCLIENT32, \ - ALLWINTENCLIENT32 + ALLWIN_10_CLIENT32 -#define ALLWINNT64 ALLWINXP64, ALLWINNET64, \ - ALLWINVISTA64, ALLWINLONGHORN64, \ - ALLWINSEVEN64, ALLWIN2008R2_64, \ - ALLWINEIGHTCLIENT64, ALLWINEIGHTSERVER, \ - ALLWINTENCLIENT64, ALLWINTENSERVER, \ - ALLHYPER_V +#define ALLWINNT64 ALLWINXP64, ALLWINNET64, \ + ALLWINVISTA64, ALLWINLONGHORN64, \ + ALLWINSEVEN64, ALLWIN2008R2_64, \ + ALLWINEIGHTCLIENT64, ALLWINEIGHTSERVER, \ + ALLWIN_10_CLIENT64, ALLWIN_10_SERVER, \ + ALLWIN_11_CLIENT64, ALLWIN_11_SERVER, \ + ALLWIN_12_CLIENT64, ALLHYPER_V #define ALLWINNT ALLWINNT32, ALLWINNT64 @@ -172,14 +187,14 @@ BS(SOLARIS10), BS(SOLARIS10_64), \ ALLSOLARIS11_OR_HIGHER -#define ALLSOLARIS BS(SOLARIS_6_AND_7), \ - BS(SOLARIS8), \ - BS(SOLARIS9), \ +#define ALLSOLARIS BS(SOLARIS_6_AND_7), \ + BS(SOLARIS8), \ + BS(SOLARIS9), \ ALLSOLARIS10_OR_HIGHER #define ALLNETWARE BS(NETWARE4), BS(NETWARE5), BS(NETWARE6) -#define ALLPHOTON BS(PHOTON_64), BS(ARM_PHOTON_64) +#define ALLPHOTON BS(PHOTON_64), BS(PHOTON_ARM_64) #define ALL26XLINUX32 BS(DEBIAN), BS(RHEL), \ BS(UBUNTU), BS(CENTOS), \ @@ -206,21 +221,30 @@ #define ALL5XLINUX32 BS(OTHER5XLINUX) -#define ALL5XLINUX64 BS(OTHER5XLINUX_64), BS(ARM_OTHER5XLINUX_64), \ - BS(ARM_DEBIAN_64), BS(ARM_UBUNTU_64) - -#define ALLVMKERNEL BS(VMKERNEL), BS(VMKERNEL5), BS(VMKERNEL6), \ - BS(VMKERNEL65), BS(VMKERNEL7), BS(ARM_VMKERNEL7) - -#define ALLLINUX32 BS(VMKERNEL), BS(OTHERLINUX), \ - BS(OTHER24XLINUX), \ - ALL26XLINUX32, ALL3XLINUX32, ALL4XLINUX32, \ - ALL5XLINUX32 +#define ALL5XLINUX64 BS(OTHER5XLINUX_64), BS(OTHER5XLINUX_ARM_64), \ + BS(DEBIAN_ARM_64), BS(UBUNTU_ARM_64), \ + BS(RHEL9_64), BS(RHEL9_ARM_64), \ + BS(ROCKY_LINUX_64), BS(ROCKY_LINUX_ARM_64), \ + BS(ALMA_LINUX_64), BS(ALMA_LINUX_ARM_64) + +#define ALL6XLINUX32 BS(OTHER6XLINUX) + +#define ALL6XLINUX64 BS(OTHER6XLINUX_64), BS(OTHER6XLINUX_ARM_64) + +#define ALLVMKERNEL BS(VMKERNEL), BS(VMKERNEL5), \ + BS(VMKERNEL6), BS(VMKERNEL65), \ + BS(VMKERNEL7), BS(VMKERNEL7_ARM), \ + BS(VMKERNEL8), BS(VMKERNEL8_ARM) + +#define ALLLINUX32 BS(VMKERNEL), BS(OTHERLINUX), \ + BS(OTHER24XLINUX), ALL26XLINUX32, \ + ALL3XLINUX32, ALL4XLINUX32, \ + ALL5XLINUX32, ALL6XLINUX32 #define ALLLINUX64 BS(OTHERLINUX_64), BS(OTHER24XLINUX_64), \ ALL26XLINUX64, ALL3XLINUX64, \ ALL4XLINUX64, ALL5XLINUX64, \ - ALLPHOTON + ALL6XLINUX64, ALLPHOTON #define ALLLINUX ALLLINUX32, ALLLINUX64 @@ -232,7 +256,8 @@ BS(DARWIN15_64), BS(DARWIN16_64), \ BS(DARWIN17_64), BS(DARWIN18_64), \ BS(DARWIN19_64), BS(DARWIN20_64), \ - BS(DARWIN21_64), BS(DARWIN22_64) + BS(DARWIN21_64), BS(DARWIN22_64), \ + BS(DARWIN23_64) #define ALLDARWIN ALLDARWIN32, ALLDARWIN64 @@ -240,7 +265,7 @@ ALLFREEBSD64, ALLDARWIN64, \ ALLPHOTON, ALLVMKERNEL, \ BS(SOLARIS10_64), BS(SOLARIS11_64), \ - BS(OTHER_64), BS(ARM_OTHER_64) + BS(OTHER_64), BS(OTHER_ARM_64) #define ALLECOMSTATION BS(ECOMSTATION), BS(ECOMSTATION2) @@ -248,22 +273,27 @@ #define ALLCRX BS(CRXSYS1_64), BS(CRXPOD1_64) -#define ALLARM BS(ARM_WINTEN_64), BS(ARM_UBUNTU_64), \ - BS(ARM_PHOTON_64), BS(ARM_VMKERNEL7), \ - BS(ARM_OTHER_64), BS(ARM_OTHER5XLINUX_64), \ - BS(ARM_DEBIAN_64), BS(ARM_FREEBSD13_64), \ - BS(ARM_FREEBSD14_64) +#define ALLARM BS(WIN_10_ARM_64), BS(WIN_11_ARM_64), \ + BS(WIN_12_ARM_64), BS(RHEL9_ARM_64), \ + BS(UBUNTU_ARM_64), BS(PHOTON_ARM_64), \ + BS(VMKERNEL7_ARM), BS(VMKERNEL8_ARM), \ + BS(OTHER_ARM_64), BS(OTHER5XLINUX_ARM_64), \ + BS(OTHER6XLINUX_ARM_64), BS(DEBIAN_ARM_64), \ + BS(FREEBSD13_ARM_64), BS(FREEBSD14_ARM_64), \ + BS(ALMA_LINUX_ARM_64), BS(ROCKY_LINUX_ARM_64) /* - * These constants are generated by GuestInfoGetOSName which is in - * the bora-vmsoft subtree. + * Architecture prefixes. No prefix implies the X86 architecture. */ +#define STR_OS_ARM_PREFIX "arm-" +#define STR_OS_RISCV_PREFIX "riscv-" + /* vmkernel (ESX) */ #define STR_OS_VMKERNEL "vmkernel" -#define STR_OS_ARM_VMKERNEL "arm-vmkernel" /* Linux */ +#define STR_OS_ALMA_LINUX "almaLinux" #define STR_OS_AMAZON_LINUX "amazonlinux" #define STR_OS_ANNVIX "Annvix" #define STR_OS_ARCH "Arch" @@ -277,7 +307,6 @@ #define STR_OS_COBALT "Cobalt" #define STR_OS_CONECTIVA "Conectiva" #define STR_OS_DEBIAN "debian" -#define STR_OS_ARM_DEBIAN "arm-debian" #define STR_OS_FEDORA "Fedora" #define STR_OS_FLATCAR "flatcar" #define STR_OS_GENTOO "Gentoo" @@ -291,15 +320,13 @@ #define STR_OS_MANDRAKE_FULL "Mandrake Linux" #define STR_OS_MANDRIVA "mandriva" #define STR_OS_MKLINUX "MkLinux" -#define STR_OS_NOVELL "nld9" +#define STR_OS_NOVELL "nld" #define STR_OS_NOVELL_FULL "Novell Linux Desktop 9" #define STR_OS_ORACLE "oraclelinux" #define STR_OS_OTHER_LINUX "otherlinux" #define STR_OS_OTHER_LINUX_FULL "Other Linux" #define STR_OS_OTHER "other" #define STR_OS_OTHER_FULL "Other OSes" -#define STR_OS_ARM_OTHER "arm-other" -#define STR_OS_ARM_OTHER_FULL "Other OSes Arm" #define STR_OS_OTHER_LINUX "otherlinux" #define STR_OS_OTHER_LINUXFULL "Other Linux" #define STR_OS_OTHER_24 "other24xlinux" @@ -309,18 +336,18 @@ #define STR_OS_OTHER_3X "other3xlinux" #define STR_OS_OTHER_3X_FULL "Other Linux 3.x kernel" #define STR_OS_OTHER_4X "other4xlinux" -#define STR_OS_OTHER_4X_FULL "Other Linux 4.x" +#define STR_OS_OTHER_4X_FULL "Other Linux 4.x kernel" #define STR_OS_OTHER_5X "other5xlinux" -#define STR_OS_OTHER_5X_FULL "Other Linux 5.x and later kernel" -#define STR_OS_ARM_OTHER_5X "arm-other5xlinux" -#define STR_OS_ARM_OTHER_5X_FULL "Other Linux 5.x and later kernel Arm" +#define STR_OS_OTHER_5X_FULL "Other Linux 5.x kernel" +#define STR_OS_OTHER_6X "other6xlinux" +#define STR_OS_OTHER_6X_FULL "Other Linux 6.x and later kernel" #define STR_OS_PHOTON "vmware-photon" -#define STR_OS_ARM_PHOTON "arm-vmware-photon" #define STR_OS_PHOTON_FULL "VMware Photon OS" #define STR_OS_PLD "PLD" #define STR_OS_RED_HAT "redhat" #define STR_OS_RED_HAT_EN "rhel" #define STR_OS_RED_HAT_FULL "Red Hat Linux" +#define STR_OS_ROCKY_LINUX "rockyLinux" #define STR_OS_SLACKWARE "Slackware" #define STR_OS_SLES "sles" #define STR_OS_SUSE "suse" @@ -333,7 +360,6 @@ #define STR_OS_TURBO "turbolinux" #define STR_OS_TURBO_FULL "Turbolinux" #define STR_OS_UBUNTU "ubuntu" -#define STR_OS_ARM_UBUNTU "arm-ubuntu" #define STR_OS_ULTRAPENGUIN "UltraPenguin" #define STR_OS_UNITEDLINUX "UnitedLinux" #define STR_OS_VALINUX "VALinux" @@ -370,14 +396,14 @@ #define STR_OS_WIN_NET_ST "winNetStandard" #define STR_OS_WIN_NET_ST_FULL "Windows Server 2003 Standard Edition" #define STR_OS_WIN_NET_EN "winNetEnterprise" -#define STR_OS_WIN_NET_EN_FULL "Windows Server 2003 Enterprise Edition" +#define STR_OS_WIN_NET_EN_FULL "Windows Server 2003 Enterprise Edition" #define STR_OS_WIN_NET_BUS "winNetBusiness" #define STR_OS_WIN_NET_BUS_FULL "Windows Server 2003 Small Business" #define STR_OS_WIN_NET_COMPCLUSTER "winNetComputeCluster" #define STR_OS_WIN_NET_COMPCLUSTER_FULL "Windows Server 2003 Compute Cluster Edition" #define STR_OS_WIN_NET_STORAGESERVER "winNetStorageSvr" #define STR_OS_WIN_NET_STORAGESERVER_FULL "Windows Storage Server 2003" -#define STR_OS_WIN_NET_DC_FULL "Windows Server 2003 Datacenter Edition" +#define STR_OS_WIN_NET_DC_FULL "Windows Server 2003 Datacenter Edition" #define STR_OS_WIN_NET_DC "winNetDatacenter" #define STR_OS_WIN_LONG "longhorn" #define STR_OS_WIN_VISTA "winVista" @@ -397,7 +423,7 @@ #define STR_OS_WIN_VISTA_STARTER "winVistaStarter-32" #define STR_OS_WIN_VISTA_STARTER_FULL "Windows Vista Starter Edition" #define STR_OS_WIN_2008_CLUSTER "winServer2008Cluster-32" -#define STR_OS_WIN_2008_CLUSTER_FULL "Windows Server 2008 Cluster Server Edition" +#define STR_OS_WIN_2008_CLUSTER_FULL "Windows Server 2008 Cluster Server Edition" #define STR_OS_WIN_2008_DATACENTER "winServer2008Datacenter-32" #define STR_OS_WIN_2008_DATACENTER_FULL "Windows Server 2008 Datacenter Edition" #define STR_OS_WIN_2008_DATACENTER_CORE "winServer2008DatacenterCore-32" @@ -416,24 +442,24 @@ #define STR_OS_WIN_2008_MEDIUM_SECURITY_FULL "Windows Essential Business Server Security Server" #define STR_OS_WIN_2008_SERVER_FOR_SMALLBUSINESS "winServer2008ForSmallBusiness-32" #define STR_OS_WIN_2008_SERVER_FOR_SMALLBUSINESS_FULL "Windows Server 2008 for Windows Essential Server Solutions" -#define STR_OS_WIN_2008_SMALL_BUSINESS "winServer2008SmallBusiness-32" +#define STR_OS_WIN_2008_SMALL_BUSINESS "winServer2008SmallBusiness-32" #define STR_OS_WIN_2008_SMALL_BUSINESS_FULL "Windows Server 2008 Small Business Server" #define STR_OS_WIN_2008_SMALL_BUSINESS_PREMIUM "winServer2008SmallBusinessPremium-32" #define STR_OS_WIN_2008_SMALL_BUSINESS_PREMIUM_FULL "Windows Server 2008 Small Business Server Premium Edition" -#define STR_OS_WIN_2008_STANDARD "winServer2008Standard-32" -#define STR_OS_WIN_2008_STANDARD_FULL "Windows Server 2008 Standard Edition" -#define STR_OS_WIN_2008_STANDARD_CORE "winServer2008StandardCore-32" +#define STR_OS_WIN_2008_STANDARD "winServer2008Standard-32" +#define STR_OS_WIN_2008_STANDARD_FULL "Windows Server 2008 Standard Edition" +#define STR_OS_WIN_2008_STANDARD_CORE "winServer2008StandardCore-32" #define STR_OS_WIN_2008_STANDARD_CORE_FULL "Windows Server 2008 Standard Edition (core installation)" #define STR_OS_WIN_2008_STORAGE_ENTERPRISE "winServer2008StorageEnterprise-32" #define STR_OS_WIN_2008_STORAGE_ENTERPRISE_FULL "Windows Server 2008 Storage Server Enterprise" -#define STR_OS_WIN_2008_STORAGE_EXPRESS "winServer2008StorageExpress-32" +#define STR_OS_WIN_2008_STORAGE_EXPRESS "winServer2008StorageExpress-32" #define STR_OS_WIN_2008_STORAGE_EXPRESS_FULL "Windows Server 2008 Storage Server Express" #define STR_OS_WIN_2008_STORAGE_STANDARD "winServer2008StorageStandard-32" #define STR_OS_WIN_2008_STORAGE_STANDARD_FULL "Windows Server 2008 Storage Server Standard" #define STR_OS_WIN_2008_STORAGE_WORKGROUP "winServer2008StorageWorkgroup-32" #define STR_OS_WIN_2008_STORAGE_WORKGROUP_FULL "Windows Server 2008 Storage Server Workgroup" -#define STR_OS_WIN_2008_WEB_SERVER "winServer2008Web-32" -#define STR_OS_WIN_2008_WEB_SERVER_FULL "Windows Server 2008 Web Server Edition" +#define STR_OS_WIN_2008_WEB_SERVER "winServer2008Web-32" +#define STR_OS_WIN_2008_WEB_SERVER_FULL "Windows Server 2008 Web Server Edition" /* Windows 64-bit */ #define STR_OS_WIN_VISTA_ULTIMATE_X64 "winVistaUltimate-64" @@ -442,12 +468,12 @@ #define STR_OS_WIN_VISTA_ENTERPRISE_X64 "winVistaEnterprise-64" #define STR_OS_WIN_VISTA_BUSINESS_X64 "winVistaBusiness-64" #define STR_OS_WIN_VISTA_STARTER_X64 "winVistaStarter-64" + #define STR_OS_WIN_2008_CLUSTER_X64 "winServer2008Cluster-64" #define STR_OS_WIN_2008_DATACENTER_X64 "winServer2008Datacenter-64" #define STR_OS_WIN_2008_DATACENTER_CORE_X64 "winServer2008DatacenterCore-64" #define STR_OS_WIN_2008_ENTERPRISE_X64 "winServer2008Enterprise-64" #define STR_OS_WIN_2008_ENTERPRISE_CORE_X64 "winServer2008EnterpriseCore-64" -#define STR_OS_WIN_2008_ENTERPRISE_ITANIUM_X64 "winServer2008EnterpriseItanium-64" #define STR_OS_WIN_2008_MEDIUM_MANAGEMENT_X64 "winServer2008MediumManagement-64" #define STR_OS_WIN_2008_MEDIUM_MESSAGING_X64 "winServer2008MediumMessaging-64" #define STR_OS_WIN_2008_MEDIUM_SECURITY_X64 "winServer2008MediumSecurity-64" @@ -462,10 +488,17 @@ #define STR_OS_WIN_2008_STORAGE_WORKGROUP_X64 "winServer2008StorageWorkgroup-64" #define STR_OS_WIN_2008_WEB_SERVER_X64 "winServer2008Web-64" +/* All */ +#define STR_OS_64BIT_SUFFIX "-64" +#define STR_OS_64BIT_SUFFIX_FULL " (64 bit)" +#define STR_OS_EMPTY "" + /* Windows 7 */ -#define STR_OS_WIN_SEVEN "windows7" -#define STR_OS_WIN_SEVEN_X64 "windows7-64" +#define STR_OS_WINDOWS "windows" + +#define STR_OS_WIN_SEVEN STR_OS_WINDOWS "7" +#define STR_OS_WIN_SEVEN_X64 STR_OS_WIN_SEVEN STR_OS_64BIT_SUFFIX #define STR_OS_WIN_SEVEN_GENERIC "Windows 7" #define STR_OS_WIN_SEVEN_STARTER_FULL "Windows 7 Starter" @@ -477,7 +510,7 @@ /* Windows Server 2008 R2 (based on Windows 7) */ -#define STR_OS_WIN_2008R2_X64 "windows7srv-64" +#define STR_OS_WIN_2008R2_X64 STR_OS_WINDOWS "7srv" STR_OS_64BIT_SUFFIX #define STR_OS_WIN_2008R2_FOUNDATION_FULL "Windows Server 2008 R2 Foundation Edition" #define STR_OS_WIN_2008R2_STANDARD_FULL "Windows Server 2008 R2 Standard Edition" @@ -487,8 +520,8 @@ /* Windows 8 */ -#define STR_OS_WIN_EIGHT "windows8" -#define STR_OS_WIN_EIGHT_X64 "windows8-64" +#define STR_OS_WIN_EIGHT STR_OS_WINDOWS "8" +#define STR_OS_WIN_EIGHT_X64 STR_OS_WIN_EIGHT STR_OS_64BIT_SUFFIX #define STR_OS_WIN_EIGHT_GENERIC_FULL "Windows 8%s" #define STR_OS_WIN_EIGHTSERVER_GENERIC_FULL "Windows Server%s 2012" @@ -499,7 +532,7 @@ /* Windows Server 2012 */ -#define STR_OS_WIN_EIGHTSERVER_X64 "windows8srv-64" +#define STR_OS_WIN_EIGHTSERVER_X64 STR_OS_WINDOWS "8srv" STR_OS_64BIT_SUFFIX #define STR_OS_WIN_2012_FOUNDATION_FULL "Windows Server 2012%s Foundation Edition" #define STR_OS_WIN_2012_ESSENTIALS_FULL "Windows Server 2012%s Essentials Edition" @@ -513,6 +546,12 @@ /* + * Windows on Arm + * + * Window on Arm support starts with Windows 10. + */ + +/* * Windows 10 * * Microsoft renamed Windows 9 to Windows 10 at the last minute; Windows 9 was @@ -520,11 +559,10 @@ * Windows 10 to ensure that things continue to work. */ -#define STR_OS_WINTEN "windows9" -#define STR_OS_WINTEN_X64 "windows9-64" -#define STR_OS_ARM_WIN "arm-windows" +#define STR_OS_WIN_10 STR_OS_WINDOWS "9" +#define STR_OS_WIN_10_X64 STR_OS_WIN_10 STR_OS_64BIT_SUFFIX -#define STR_OS_WIN_TEN_GENERIC_FULL "Windows 10" +#define STR_OS_WIN_10_GENERIC_FULL "Windows 10" #define STR_OS_WIN_10_HOME_FULL "Windows 10 Home" #define STR_OS_WIN_10_EDUCATION_FULL "Windows 10 Education" #define STR_OS_WIN_10_ENTERPRISE_FULL "Windows 10 Enterprise" @@ -532,28 +570,52 @@ #define STR_OS_WIN_10_PRO_FULL "Windows 10 Pro" #define STR_OS_WIN_10_IOTCORE_FULL "Windows 10 IoT Core" +/* + * Windows 11 + */ + +#define STR_OS_WIN_11 STR_OS_WINDOWS "11" +#define STR_OS_WIN_11_X64 STR_OS_WIN_11 STR_OS_64BIT_SUFFIX + +#define STR_OS_WIN_11_GENERIC_FULL "Windows 11" +#define STR_OS_WIN_11_HOME_FULL "Windows 11 Home" +#define STR_OS_WIN_11_EDUCATION_FULL "Windows 11 Education" +#define STR_OS_WIN_11_ENTERPRISE_FULL "Windows 11 Enterprise" +#define STR_OS_WIN_11_PRO_WORKSTATION_FULL "Windows 11 Pro for Workstations" +#define STR_OS_WIN_11_PRO_FULL "Windows 11 Pro" +#define STR_OS_WIN_11_IOTCORE_FULL "Windows 11 IoT Core" + +/* + * Windows 12 + */ + +#define STR_OS_WIN_12 STR_OS_WINDOWS "12" +#define STR_OS_WIN_12_X64 STR_OS_WIN_12 STR_OS_64BIT_SUFFIX + +/* No full names known yet */ + /* Windows Server 2016 */ -#define STR_OS_WIN_2016SRV_X64 "windows9srv-64" +#define STR_OS_WIN_2016SRV_X64 STR_OS_WINDOWS "9srv" STR_OS_64BIT_SUFFIX /* Windows Server 2019 */ -#define STR_OS_WIN_2019SRV_X64 "windows2019srv-64" +#define STR_OS_WIN_2019SRV_X64 STR_OS_WINDOWS "2019srv" STR_OS_64BIT_SUFFIX /* Windows Server 2022 */ -#define STR_OS_WIN_2022SRV_X64 "windows2019srvNext-64" +#define STR_OS_WIN_2022SRV_X64 STR_OS_WINDOWS "2019srvNext" STR_OS_64BIT_SUFFIX /* Windows Server 2025 */ -#define STR_OS_WIN_2025SRV_X64 "windows2022srvNext-64" +#define STR_OS_WIN_2025SRV_X64 STR_OS_WINDOWS "2022srvNext" STR_OS_64BIT_SUFFIX -/* THIS SPACE FOR RENT (Windows 10 official server variant names) */ +/* THIS SPACE FOR RENT (Windows 10 and later official server variant names) */ -#define STR_OS_WIN_TENSERVER_2016_GENERIC_FULL "Windows Server 2016" -#define STR_OS_WIN_TENSERVER_2019_GENERIC_FULL "Windows Server 2019" -#define STR_OS_WIN_TENSERVER_2022_GENERIC_FULL "Windows Server 2022" -#define STR_OS_WIN_TENSERVER_2025_GENERIC_FULL "Windows Server 2025" +#define STR_OS_WIN_10_SERVER_2016_GENERIC_FULL "Windows Server 2016" +#define STR_OS_WIN_10_SERVER_2019_GENERIC_FULL "Windows Server 2019" +#define STR_OS_WIN_11_SERVER_2022_GENERIC_FULL "Windows Server 2022" +#define STR_OS_WIN_11_SERVER_2025_GENERIC_FULL "Windows Server 2025" /* Microsoft Hyper-V */ #define STR_OS_HYPER_V "winHyperV" @@ -562,7 +624,7 @@ /* Windows Future/Unknown */ #define STR_OS_WIN_UNKNOWN "windowsUnknown" -#define STR_OS_WIN_UNKNOWN_X64 "windowsUnknown-64" +#define STR_OS_WIN_UNKNOWN_X64 STR_OS_WIN_UNKNOWN STR_OS_64BIT_SUFFIX #define STR_OS_WIN_UNKNOWN_GENERIC "Windows Unknown" /* Modifiers for Windows Vista, Windows Server 2008, and later. */ @@ -570,8 +632,7 @@ #define STR_OS_WIN_64_BIT_EXTENSION ", 64-bit" /* FreeBSD */ -#define STR_OS_FREEBSD "freeBSD" -#define STR_OS_ARM_FREEBSD "arm-freeBSD" +#define STR_OS_FREEBSD "freeBSD" /* Solaris */ #define STR_OS_SOLARIS "solaris" @@ -582,11 +643,6 @@ /* Mac OS */ #define STR_OS_MACOS "darwin" -/* All */ -#define STR_OS_64BIT_SUFFIX "-64" -#define STR_OS_64BIT_SUFFIX_FULL " (64 bit)" -#define STR_OS_EMPTY "" - #if defined(__cplusplus) } // extern "C" #endif diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/guest_os_tables.h open-vm-tools-12.1.5/open-vm-tools/lib/include/guest_os_tables.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/guest_os_tables.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/guest_os_tables.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2021 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2022 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 @@ -50,15 +50,19 @@ GOT(GUEST_OS_LONGHORN_64) \ GOT(GUEST_OS_WINVISTA) \ GOT(GUEST_OS_WINVISTA_64) \ - GOT(GUEST_OS_WINSEVEN) /* Windows 7 32-bit */ \ - GOT(GUEST_OS_WINSEVEN_64) /* Windows 7 64-bit */ \ + GOT(GUEST_OS_WIN_7) /* Windows 7 32-bit */ \ + GOT(GUEST_OS_WIN_7_64) /* Windows 7 64-bit */ \ + GOT(GUEST_OS_WIN_8) /* Windows 8 32-bit */ \ + GOT(GUEST_OS_WIN_8_64) /* Windows 8 64-bit */ \ + GOT(GUEST_OS_WIN_10) /* Windows 10 32-bit */ \ + GOT(GUEST_OS_WIN_10_64) /* Windows 10 64-bit */ \ + GOT(GUEST_OS_WIN_10_ARM_64) /* Windows 10 Arm 64-bit */ \ + GOT(GUEST_OS_WIN_11_64) /* Windows 11 64-bit */ \ + GOT(GUEST_OS_WIN_11_ARM_64) /* Windows 11 Arm 64-bit */ \ + GOT(GUEST_OS_WIN_12_64) /* Windows 12 64-bit */ \ + GOT(GUEST_OS_WIN_12_ARM_64) /* Windows 12 Arm 64-bit */ \ GOT(GUEST_OS_WIN2008R2_64) /* Server 2008 R2 64-bit */ \ - GOT(GUEST_OS_WINEIGHT) /* Windows 8 32-bit */ \ - GOT(GUEST_OS_WINEIGHT_64) /* Windows 8 64-bit */ \ - GOT(GUEST_OS_WINEIGHTSERVER_64) /* Windows 8 Server 64-bit */ \ - GOT(GUEST_OS_WINTEN) /* Windows 10 32-bit */ \ - GOT(GUEST_OS_WINTEN_64) /* Windows 10 64-bit */ \ - GOT(GUEST_OS_ARM_WINTEN_64) /* Windows 10 Arm 64-bit */ \ + GOT(GUEST_OS_WIN_8_SERVER_64) /* Windows 8 Server 64-bit */ \ GOT(GUEST_OS_WIN_2016SRV_64) /* Windows Server 2016 64-bit */ \ GOT(GUEST_OS_WIN_2019SRV_64) /* Windows Server 2019 64-bit */ \ GOT(GUEST_OS_WIN_2022SRV_64) /* Windows Server 2022 64-bit */ \ @@ -77,21 +81,25 @@ GOT(GUEST_OS_OTHER3XLINUX_64) /* Linux 3.x 64-bit */ \ GOT(GUEST_OS_OTHER4XLINUX) /* Linux 4.x 32-bit */ \ GOT(GUEST_OS_OTHER4XLINUX_64) /* Linux 4.x 64-bit */ \ - GOT(GUEST_OS_OTHER5XLINUX) /* Linux 5.x and later 32-bit */ \ - GOT(GUEST_OS_OTHER5XLINUX_64) /* Linux 5.x and later 64-bit */ \ - GOT(GUEST_OS_ARM_OTHER5XLINUX_64) /* Linux 5.x and later Arm 64-bit */ \ - GOT(GUEST_OS_OTHER) \ + GOT(GUEST_OS_OTHER5XLINUX) /* Linux 5.x 32-bit */ \ + GOT(GUEST_OS_OTHER5XLINUX_64) /* Linux 5.x 64-bit */ \ + GOT(GUEST_OS_OTHER5XLINUX_ARM_64) /* Linux 5.x Arm 64-bit */ \ + GOT(GUEST_OS_OTHER6XLINUX) /* Linux 6.x and later 32-bit */ \ + GOT(GUEST_OS_OTHER6XLINUX_64) /* Linux 6.x and later 64-bit */ \ + GOT(GUEST_OS_OTHER6XLINUX_ARM_64) /* Linux 6.x and later Arm 64-bit */ \ + GOT(GUEST_OS_OTHER) /* Other 32-bit */ \ GOT(GUEST_OS_OTHER_64) /* Other 64-bit */ \ - GOT(GUEST_OS_ARM_OTHER_64) /* Other Arm 64-bit */ \ + GOT(GUEST_OS_OTHER_ARM_64) /* Other Arm 64-bit */ \ GOT(GUEST_OS_UBUNTU) \ GOT(GUEST_OS_UBUNTU_64) \ - GOT(GUEST_OS_ARM_UBUNTU_64) \ + GOT(GUEST_OS_UBUNTU_ARM_64) \ GOT(GUEST_OS_DEBIAN) \ GOT(GUEST_OS_DEBIAN_64) \ - GOT(GUEST_OS_ARM_DEBIAN_64) \ + GOT(GUEST_OS_DEBIAN_ARM_64) \ GOT(GUEST_OS_RHEL) \ GOT(GUEST_OS_RHEL_64) \ GOT(GUEST_OS_RHEL9_64) \ + GOT(GUEST_OS_RHEL9_ARM_64) \ GOT(GUEST_OS_FREEBSD) \ GOT(GUEST_OS_FREEBSD_64) \ GOT(GUEST_OS_FREEBSD11) \ @@ -100,10 +108,10 @@ GOT(GUEST_OS_FREEBSD12_64) \ GOT(GUEST_OS_FREEBSD13) \ GOT(GUEST_OS_FREEBSD13_64) \ + GOT(GUEST_OS_FREEBSD13_ARM_64) \ GOT(GUEST_OS_FREEBSD14) \ GOT(GUEST_OS_FREEBSD14_64) \ - GOT(GUEST_OS_ARM_FREEBSD13_64) \ - GOT(GUEST_OS_ARM_FREEBSD14_64) \ + GOT(GUEST_OS_FREEBSD14_ARM_64) \ GOT(GUEST_OS_SOLARIS_6_AND_7) \ GOT(GUEST_OS_SOLARIS8) \ GOT(GUEST_OS_SOLARIS9) \ @@ -127,6 +135,7 @@ GOT(GUEST_OS_DARWIN20_64) /* Mac OS 11 */ \ GOT(GUEST_OS_DARWIN21_64) /* Mac OS 12 */ \ GOT(GUEST_OS_DARWIN22_64) /* Mac OS 13 */ \ + GOT(GUEST_OS_DARWIN23_64) /* Mac OS 14 */ \ GOT(GUEST_OS_OPENSERVER_5_AND_6) \ GOT(GUEST_OS_UNIXWARE7) \ GOT(GUEST_OS_NETWARE4) \ @@ -136,10 +145,12 @@ GOT(GUEST_OS_VMKERNEL5) /* ESX 5.x 64-bit */ \ GOT(GUEST_OS_VMKERNEL6) /* ESX 6 64-bit */ \ GOT(GUEST_OS_VMKERNEL65) /* ESX 6.5 and 6.7 64-bit */ \ - GOT(GUEST_OS_VMKERNEL7) /* ESX 7 and later 64-bit */ \ - GOT(GUEST_OS_ARM_VMKERNEL7) /* ESX 7 and later Arm 64-bit */ \ + GOT(GUEST_OS_VMKERNEL7) /* ESX 7 64-bit */ \ + GOT(GUEST_OS_VMKERNEL7_ARM) /* ESX 7 Arm 64-bit */ \ + GOT(GUEST_OS_VMKERNEL8) /* ESX 8 and later 64-bit */ \ + GOT(GUEST_OS_VMKERNEL8_ARM) /* ESX 8 and later Arm 64-bit */ \ GOT(GUEST_OS_PHOTON_64) /* VMware Photon 64-bit */ \ - GOT(GUEST_OS_ARM_PHOTON_64) /* VMware Photon Arm 64-bit */ \ + GOT(GUEST_OS_PHOTON_ARM_64) /* VMware Photon Arm 64-bit */ \ GOT(GUEST_OS_ORACLE) \ GOT(GUEST_OS_ORACLE_64) \ GOT(GUEST_OS_ORACLE6) \ @@ -158,7 +169,11 @@ GOT(GUEST_OS_AMAZONLINUX3_64) \ GOT(GUEST_OS_CRXSYS1_64) /* VMware CRX system VM 1.0 64-bit */ \ GOT(GUEST_OS_CRXPOD1_64) /* VMware CRX pod VM 1.0 64-bit */ \ - GOT(GUEST_OS_LINUX_MINT_64) + GOT(GUEST_OS_LINUX_MINT_64) \ + GOT(GUEST_OS_ROCKY_LINUX_64) \ + GOT(GUEST_OS_ROCKY_LINUX_ARM_64) \ + GOT(GUEST_OS_ALMA_LINUX_64) \ + GOT(GUEST_OS_ALMA_LINUX_ARM_64) /* @@ -202,6 +217,8 @@ GOKM("windows8srv-64", windows8Server64Guest, TRUE) \ GOKM("windows9", windows9Guest, TRUE) \ GOKM("windows9-64", windows9_64Guest, TRUE) \ + GOKM("windows11-64", windows11_64Guest, TRUE) \ + GOKM("windows12-64", windows12_64Guest, TRUE) \ GOKM("windows9srv-64", windows9Server64Guest, TRUE) \ GOKM("windows2019srv-64", windows2019srv_64Guest, TRUE) \ GOKM("windows2019srvNext-64", windows2019srvNext_64Guest, TRUE) \ @@ -324,6 +341,8 @@ GOKM("debian10-64", debian10_64Guest, TRUE) \ GOKM("debian11", debian11Guest, TRUE) \ GOKM("debian11-64", debian11_64Guest, TRUE) \ + GOKM("debian12", debian12Guest, TRUE) \ + GOKM("debian12-64", debian12_64Guest, TRUE) \ GOKM("asianux3", asianux3Guest, TRUE) \ GOKM("asianux3-64", asianux3_64Guest, TRUE) \ GOKM("asianux4", asianux4Guest, TRUE) \ @@ -351,12 +370,16 @@ GOKM("other4xlinux-64", other4xLinux64Guest, TRUE) \ GOKM("other5xlinux", other5xLinuxGuest, TRUE) \ GOKM("other5xlinux-64", other5xLinux64Guest, TRUE) \ + GOKM("other6xlinux", other6xLinuxGuest, TRUE) \ + GOKM("other6xlinux-64", other6xLinux64Guest, TRUE) \ GOKM("linux", otherLinuxGuest, FALSE) \ GOKM("otherlinux", otherLinuxGuest, TRUE) \ GOKM("otherlinux-64", otherLinux64Guest, TRUE) \ GOKM("genericlinux", genericLinuxGuest, TRUE) \ GOKM("amazonlinux2-64", amazonlinux2_64Guest, TRUE) \ GOKM("amazonlinux3-64", amazonlinux3_64Guest, TRUE) \ + GOKM("almalinux-64", almalinux_64Guest, TRUE) \ + GOKM("rockylinux-64", rockylinux_64Guest, TRUE) \ GOKM("CRXPod1-64", crxPod1Guest, TRUE) \ /* Netware guests */ \ GOKM("netware4", netware4Guest, TRUE) \ @@ -388,12 +411,14 @@ GOKM("darwin20-64", darwin20_64Guest, TRUE) \ GOKM("darwin21-64", darwin21_64Guest, TRUE) \ GOKM("darwin22-64", darwin22_64Guest, TRUE) \ + GOKM("darwin23-64", darwin23_64Guest, TRUE) \ /* ESX guests */ \ GOKM("vmkernel", vmkernelGuest, TRUE) \ GOKM("vmkernel5", vmkernel5Guest, TRUE) \ GOKM("vmkernel6", vmkernel6Guest, TRUE) \ GOKM("vmkernel65", vmkernel65Guest, TRUE) \ GOKM("vmkernel7", vmkernel7Guest, TRUE) \ + GOKM("vmkernel8", vmkernel8Guest, TRUE) \ /* Other guests */ \ GOKM("dos", dosGuest, TRUE) \ GOKM("os2", os2Guest, TRUE) \ @@ -408,6 +433,8 @@ GOKM("freeBSD12-64", freebsd12_64Guest, TRUE) \ GOKM("freeBSD13", freebsd13Guest, TRUE) \ GOKM("freeBSD13-64", freebsd13_64Guest, TRUE) \ + GOKM("freeBSD14", freebsd14Guest, TRUE) \ + GOKM("freeBSD14-64", freebsd14_64Guest, TRUE) \ GOKM("openserver5", openServer5Guest, TRUE) \ GOKM("openserver6", openServer6Guest, TRUE) \ GOKM("unixware7", unixWare7Guest, TRUE) \ diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/hostinfo.h open-vm-tools-12.1.5/open-vm-tools/lib/include/hostinfo.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/hostinfo.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/hostinfo.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2021 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2022 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 @@ -48,6 +48,14 @@ HOSTINFO_PROCESS_QUERY_UNKNOWN // Process existence cannot be determined } HostinfoProcessQuery; +typedef struct HostinfoProcessSnapshot HostinfoProcessSnapshot; + +HostinfoProcessSnapshot *Hostinfo_AcquireProcessSnapshot(void); +void Hostinfo_ReleaseProcessSnapshot(HostinfoProcessSnapshot *s); + +HostinfoProcessQuery Hostinfo_QueryProcessSnapshot(HostinfoProcessSnapshot *s, + int pid); + HostinfoProcessQuery Hostinfo_QueryProcessExistence(int pid); /* This macro defines the current version of the structured header. */ @@ -156,7 +164,6 @@ Bool Hostinfo_NestingSupported(void); Bool Hostinfo_VCPUInfoBackdoor(unsigned bit); Bool Hostinfo_SynchronizedVTSCs(void); -Bool Hostinfo_NestedHVReplaySupported(void); Bool Hostinfo_TouchBackDoor(void); Bool Hostinfo_TouchVirtualPC(void); Bool Hostinfo_TouchXen(void); @@ -212,6 +219,7 @@ OS_WINSEVEN = 9, OS_WIN8 = 10, OS_WIN10 = 11, + OS_WIN11 = 12, OS_UNKNOWN = 99999 // last, highest value } OS_TYPE; @@ -241,6 +249,8 @@ OS_DETAIL_WIN8SERVER = 23, OS_DETAIL_WIN10 = 24, OS_DETAIL_WIN10SERVER = 25, + OS_DETAIL_WIN11 = 26, + OS_DETAIL_WIN11SERVER = 27, OS_DETAIL_UNKNOWN = 99999 // last, highest value } OS_DETAIL_TYPE; diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/includeCheck.h open-vm-tools-12.1.5/open-vm-tools/lib/include/includeCheck.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/includeCheck.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/includeCheck.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2019 VMware, Inc. All rights reserved. + * Copyright (c) 1998-2019, 2021-2022 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 @@ -79,11 +79,12 @@ * that this is acceptable. */ +#if defined VMM && defined ULM +#error "VMM and ULM cannot be defined at the same time." +#endif -#if defined VMCORE && \ - !(defined VMX86_VMX || defined VMM || defined ULM || \ - defined MONITOR_APP || defined VMMON) -#error "VMCORE without VMX86_VMX, VMM, ULM, MONITOR_APP, or VMMON." +#if defined ULM && !defined USERLEVEL +#error "All ULM code must be compiled with USERLEVEL set." #endif #if defined VMCORE && !defined INCLUDE_ALLOW_VMCORE @@ -100,7 +101,7 @@ #if defined USERLEVEL && !defined VMX86_VMX && !defined VMCORE && \ !defined ULM && !defined INCLUDE_ALLOW_USERLEVEL && \ - !defined INCLUDE_ALLOW_MKS + !defined INCLUDE_ALLOW_MKS && !defined VSAN_USERLEVEL #error "The surrounding include file is not allowed at userlevel." #endif #undef INCLUDE_ALLOW_USERLEVEL diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/log.h open-vm-tools-12.1.5/open-vm-tools/lib/include/log.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/log.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/log.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2021 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2022 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 @@ -37,6 +37,7 @@ /** * Log Facility + * ------------ * * The Log Facility exists to record events of program execution for purposes * of auditing, debugging, and monitoring. Any non-trivial program should use @@ -52,13 +53,14 @@ * use the source, Luke -- starting at lib/log/logFacility.c * * The events are explicitly annotated by the developer (i.e. you) - * with a level, an optional module, and a message. + * with a level, an optional group, and a message. * * Notes: * - Log() is defined as Log_Info() * - Warning() is defined as Log_Warning() * * Log Level + * --------- * * The Log Level indicates the (in)significance of the event, with larger * numbers indicating lesser significance. The level, whether explicit @@ -67,67 +69,57 @@ * "warning" or "error" is almost certainly mis-routed. * * The following rules of thumb provide a rough guide to choice of level. + * * * VMW_LOG_AUDIT -- always logged, for auditing purposes * + change to authorization * + change to configuration + * * * VMW_LOG_PANIC -- system broken; cannot exit gracefully * + wild pointer; corrupt arena * + error during error exit + * * * VMW_LOG_ERROR -- system broken; must exit * + required resource inaccessible (memory; storage; network) * + incorrigible internal inconsistency + * * * VMW_LOG_WARNING -- unexpected condition; may require immediate attention * + inconsistency corrected or ignored * + timeout or slow operation + * * * VMW_LOG_NOTICE -- unexpected condition; may require eventual attention * + missing config; default used * + lower level error ignored + * * * VMW_LOG_INFO -- expected condition * + non-standard configuration * + alternate path taken (e.g. on lower level error) + * * * VMW_LOG_VERBOSE -- normal operation; potentially useful information * + system health observation, for monitoring * + unexpected non-error state + * * * VMW_LOG_TRIVIA -- normal operation; excess information * + vaguely interesting note * + anything else the developer thinks might be useful + * * * VMW_LOG_DEBUG_* -- flow and logic tracing * + routine entry, with parameters; routine exit, with return value * + intermediate values or decisions * - * Log Module + * Log Facility Message Groups + * --------------------------- * - * The Log routines accept an explicit level (see below) - * as well as an optional module parameter. - * This affords another degree of freedom in filtering. - * - * To use the module parameter: - * - * (0) The module identifier must already exist, or be invented and defined, - * in public/loglevel_userVars.h - * - * (1) Define LOGLEVEL_MODULE before the include of "log.h". - * The value must be a valid module identifier (see above). - * It is a good idea to see if "log.h" is included more than once, - * and if so, to remove any extra inclusions. - * - * If all uses of LOG() are converted to use Log_ variants, - * remember to remove "loglevel_user.h". - * - * (2) Pass the module information to the Log Facility. - * LOGLEVEL_MODULE is actually encoded in the level parameter by - * the LOG_ROUTING_BITS(level) macro. - * - * Use - * Log_LevelModule(level, ...); - * OR - * LogV_Module(level, ...); - * OR - * Log_Level(LOG_ROUTING_BITS(level), ...); - * OR - * Log_V(LOG_ROUTING_BITS(level), ...); + * For information about Log Facility Message Groups visit + * lib/log/logFacility.c. * - * Log Message + * Log Facility Message Filtering + * ------------------------------ + * + * For information about Log Facility message filtering visit + * lib/log/logFacility.c. + * + * Log Message Guidelines + * ---------------------- * * Every Log message should be unique, unambiguously describing the event * being logged, and should include all relevant data, in human-readable form. @@ -139,31 +131,6 @@ * + format disk size or offset in hex; specify units if not bytes * + quote string arguments (e.g. pathnames) which can contain spaces * - * Log Filter - * - * The Log Facility filters events as they arrive, by level and by module, - * discarding events above the configured filter level. - * This is similar to how syslog and the vmacore logger handle levels. - * - * There is a global filter and assorted module filters. - * The global filter is used for all entries to the Log Facility - * UNLESS a module is specified. - * - * Module filters are limited to a module (name specific) context; - * they do not fall within the global context. This allows entries to be - * controlled by module AND level. This is similar to LOG(), for those - * familiar with it ... except that module filters are available in - * all build types. - * - * Each module is a separate configuration namespace, with module-specific - * filter levels. The default module filter level is none (VMW_LOG_AUDIT) - * i.e. module filters by default discard all events (just like LOG()). - * - * Regardless of what level of filtering is specified, the VMW_LOG_AUDIT - * level is used to log something that requires an audit at a later date. - * It is *ALWAYS* logged and *NEVER* outputs to the "standard error". - */ -/* * Level Value Comments *--------------------------------------------------------------------------- */ @@ -202,7 +169,7 @@ #define LOG_FILTER_DEFAULT_LEVEL VMW_LOG_INFO #endif -#ifdef VMX86_SERVER +#if defined(VMX86_SERVER) /* WORLD_MAX_OPID_STRING_SIZE */ #define LOG_MAX_OPID_LENGTH 128 #else @@ -210,9 +177,27 @@ #define LOG_MAX_OPID_LENGTH 32 #endif +#define LOG_NO_KEEPOLD 0 // Keep no old log files +#define LOG_NO_ROTATION_SIZE 0 // Do not rotate based on file size +#define LOG_NO_THROTTLE_THRESHOLD 0 // No threshold before throttling +#define LOG_NO_BPS_LIMIT 0xFFFFFFFF // unlimited input rate + +/* + * The defaults for how many older log files to kept around, and what to do + * with rotation-by-size. + */ + +#if defined(VMX86_SERVER) +#define LOG_DEFAULT_KEEPOLD 10 +#define LOG_DEFAULT_ROTATION_SIZE 2048000 +#else +#define LOG_DEFAULT_KEEPOLD 3 +#define LOG_DEFAULT_ROTATION_SIZE LOG_NO_ROTATION_SIZE +#endif + /* * The "routing" parameter contains the level in the low order bits; - * the higher order bits specify the module of the log call. + * the higher order bits specify the group of the log call. */ #define VMW_LOG_LEVEL_BITS 5 // Log level bits (32 levels max) @@ -333,9 +318,9 @@ #if !defined(VMM) typedef struct { - int32 legalLevelValue; - char *legalName; - char *levelIdStr; + int32 legalLevelValue; + const char *legalName; + const char *levelIdStr; } LogLevelData; const LogLevelData * @@ -354,21 +339,21 @@ Log_CfgInterface(void); int32 -Log_SetStderrLevel(uint32 module, +Log_SetStderrLevel(uint32 group, int32 level); int32 -Log_GetStderrLevel(uint32 module); +Log_GetStderrLevel(uint32 group); int32 -Log_SetLogLevel(uint32 module, +Log_SetLogLevel(uint32 group, int32 level); int32 -Log_GetLogLevel(uint32 module); +Log_GetLogLevel(uint32 group); uint32 -Log_LookupModuleNumber(const char *moduleName); +Log_LookupGroupNumber(const char *groupName); LogOutput * Log_NewStdioOutput(const char *appPrefix, @@ -387,6 +372,25 @@ struct Dictionary *params, struct CfgInterface *cfgIf); +typedef struct { + uint32 keepOld; + uint32 rotateSize; + uint32 throttleThreshold; + uint32 throttleBPS; + Bool useTimeStamp; + Bool useMilliseconds; + Bool useThreadName; + Bool useLevelDesignator; + Bool useOpID; + Bool append; + Bool syncAfterWrite; + Bool fastRotation; +} LogFileParameters; + +Bool +Log_GetFileParameters(const LogOutput *output, + LogFileParameters *parms); + typedef void (LogCustomMsgFunc)(int level, const char *msg); @@ -607,12 +611,13 @@ char *buf, size_t max); -typedef Bool (LogOwnerFunc)(void *userData, - const char *fileName); +typedef Bool (LogMayDeleteFunc)(void *userData, + const char *fileName, + uint32 *pid); Bool Log_BoundNumFiles(const LogOutput *output, - LogOwnerFunc *func, + LogMayDeleteFunc *mayDeleteFunc, void *userData); typedef struct { @@ -627,18 +632,6 @@ Log_GetFileObject(const LogOutput *output, LogFileObject *result); -#if defined(VMX86_SERVER) -#define LOG_KEEPOLD 6 // Old log files to keep around; ESX value -#else -#define LOG_KEEPOLD 3 // Old log files to keep around; non-ESX value -#endif - -#define LOG_NO_KEEPOLD 0 // Keep no old log files -#define LOG_NO_ROTATION_SIZE 0 // Do not rotate based on file size -#define LOG_NO_THROTTLE_THRESHOLD 0 // No threshold before throttling -#define LOG_NO_BPS_LIMIT 0xFFFFFFFF // unlimited input rate - - /* * Assemble a line. */ @@ -691,12 +684,39 @@ Log_RegisterOpIdFunction(GetOpId *getOpIdFunc); void -Log_LoadModuleFilters(const char *appPrefix, - struct CfgInterface *cfgIf); +Log_LoadGroupFilters(const char *appPrefix, + struct CfgInterface *cfgIf); long Log_OffsetUtc(void); +/* + * log throttling: + * + * throttleThreshold = start log throttling only after this many bytes have + * been logged (allows initial vmx startup spew). + * + * throttleBPS = start throttling if more than this many bytes per second are + * logged. Continue throttling until rate drops below this value. + * + * bytesLogged = total bytes logged. + * + * logging rate = (bytesLogged - lastBytesSample)/(curTime - lastSampleTime) + */ + +typedef struct { + uint64 throttleThreshold; + uint64 bytesLogged; + uint64 lastBytesSample; + VmTimeType lastTimeSample; + uint32 throttleBPS; + Bool throttled; +} LogThrottleInfo; + +Bool +Log_IsThrottled(LogThrottleInfo *info, + size_t msgLen); + #endif /* !VMM */ #if defined(__cplusplus) @@ -706,73 +726,49 @@ #endif /* VMWARE_LOG_H */ /* - * To use the Log Facility Module Specific Filters: - * - * 1) Modify the file (C/C++) slightly. - * - * Define LOGLEVEL_MODULE before the include of "log.h". It's a good - * idea to see if "log.h" is included more than once and, if so, to - * remove any extra inclusions. - * - * If all uses of LOG are converted to use the module-specific filters, - * remember to remove "loglevel_user.h". - * - * 2) Pass the LOGLEVEL_MODULE information to the Log Facility. - * - * Use LogV_Module and/or Log_LevelModule. - * - * OR - * - * Use the LOG_ROUTING_BITS macro as part of a call to LogV and/or - * Log_Level. + * Log Facility Message Group macros */ -#if !defined(VMW_LOG_MODULE_LEVELS) +#if !defined(VMW_LOG_GROUP_LEVELS) #include "vm_basic_defs.h" #include "loglevel_userVars.h" - #define LOGFACILITY_MODULEVAR(mod) XCONC(_logFacilityModule_, mod) + #define LOGFACILITY_GROUPVAR(group) XCONC(_logFacilityGroup_, group) - enum LogFacilityModuleValue { - LOGLEVEL_USER(LOGFACILITY_MODULEVAR) + enum LogFacilityGroupValue { + LOGLEVEL_USER(LOGFACILITY_GROUPVAR) }; - #define VMW_LOG_MODULE_LEVELS + #define VMW_LOG_GROUP_LEVELS #endif -#if defined(LOG_ROUTING_BITS) - #undef LOG_ROUTING_BITS +/* + * Legacy VMW_LOG_ROUTING macro + * + * Group name is "inherited" from the LOGLEVEL_MODULE define. + */ + +#if defined(VMW_LOG_ROUTING) + #undef VMW_LOG_ROUTING #endif #if defined(LOGLEVEL_MODULE) - /* Module bits of zero (0) indicate no module has been specified */ - #define LOG_ROUTING_BITS(level) \ - (((LOGFACILITY_MODULEVAR(LOGLEVEL_MODULE) + 1) << VMW_LOG_LEVEL_BITS) | level) + #define VMW_LOG_ROUTING(level) \ + (((LOGFACILITY_GROUPVAR(LOGLEVEL_MODULE) + 1) << VMW_LOG_LEVEL_BITS) | (level)) #else - #define LOG_ROUTING_BITS(level) (level) + #define VMW_LOG_ROUTING(level) (level) #endif /* - * Helper functions for module level filters. + * VMW_LOG_ROUTING_EX macro + * + * Group name is specified in the macro. */ -#if defined(Log_LevelModule) - #undef Log_LevelModule -#endif - -#define Log_LevelModule(level, ...) \ - Log_Level(LOG_ROUTING_BITS(level), __VA_ARGS__) - -#if defined(LogV_Module) - #undef LogV_Module +#if defined(VMW_LOG_ROUTING_EX) + #undef VMW_LOG_ROUTING_EX #endif -#define LogV_Module(level, ...) \ - LogV(LOG_ROUTING_BITS(level), __VA_ARGS__) - -#if defined(Log_IsEnabledModule) - #undef Log_IsEnabledModule -#endif +#define VMW_LOG_ROUTING_EX(name, level) \ + (((LOGFACILITY_GROUPVAR(name) + 1) << VMW_LOG_LEVEL_BITS) | (level)) -#define Log_IsEnabledModule(level) \ - Log_IsEnabled(LOG_ROUTING_BITS(level)) diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/loglevel_userVars.h open-vm-tools-12.1.5/open-vm-tools/lib/include/loglevel_userVars.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/loglevel_userVars.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/loglevel_userVars.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2021 VMware, Inc. All rights reserved. + * Copyright (c) 1998-2022 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 @@ -105,7 +105,7 @@ LOGLEVEL_VAR(ftConfig), /*lib/ftConfig */ \ LOGLEVEL_VAR(ftcpt), \ LOGLEVEL_VAR(gmm), \ - LOGLEVEL_VAR(gpumgmt), \ + LOGLEVEL_VAR(gpuManager), \ LOGLEVEL_VAR(grainTrack), \ LOGLEVEL_VAR(grm), \ LOGLEVEL_VAR(guestAppMonitor), \ @@ -164,6 +164,7 @@ LOGLEVEL_VAR(mksDX11Basic), \ LOGLEVEL_VAR(mksDX11ResourceView), \ LOGLEVEL_VAR(mksDX11ShimOps), \ + LOGLEVEL_VAR(mksDX12Renderer), \ LOGLEVEL_VAR(mksFrame), \ LOGLEVEL_VAR(mksGLBasic), \ LOGLEVEL_VAR(mksGLContextMux), \ @@ -188,6 +189,7 @@ LOGLEVEL_VAR(mksWinBSOD), \ LOGLEVEL_VAR(mor), \ LOGLEVEL_VAR(mstat), \ + LOGLEVEL_VAR(msvga), \ LOGLEVEL_VAR(mvnc), \ LOGLEVEL_VAR(namespaceDb), \ LOGLEVEL_VAR(namespaceMgr), \ @@ -313,6 +315,7 @@ LOGLEVEL_VAR(vncBlit), \ LOGLEVEL_VAR(vncDecode), \ LOGLEVEL_VAR(vncEncode), \ + LOGLEVEL_VAR(vncRegEnc), \ LOGLEVEL_VAR(vncServer), \ LOGLEVEL_VAR(vncServerOS), \ LOGLEVEL_VAR(vnet), \ diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/poll.h open-vm-tools-12.1.5/open-vm-tools/lib/include/poll.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/poll.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/poll.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2020 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2021 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 @@ -254,6 +254,7 @@ void Poll_InitGtk(void); // On top of glib for Linux void Poll_InitCF(void); // On top of CoreFoundation for OSX +Bool Poll_IsInitialized(void); /* * Functions diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/sha1.h open-vm-tools-12.1.5/open-vm-tools/lib/include/sha1.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/sha1.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/sha1.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2019 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2022 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 @@ -82,7 +82,6 @@ #define SHA1Init VMW_SHA1Init #define SHA1Update VMW_SHA1Update #define SHA1Final VMW_SHA1Final -#define SHA1RawBufferHash VMW_SHA1RawBufferHash #endif /* !VMKERNEL */ @@ -113,29 +112,19 @@ unsigned char buffer[64]; } SHA1_CTX; +#if defined VMKBOOT || defined VMKERNEL +/* New SHA1 uses are not allowed. Old uses are going away. SHA1 isn't secure. */ +void SHA1Init_Legacy(SHA1_CTX* context); +void SHA1Update_Legacy(SHA1_CTX* context, + const unsigned char *data, + size_t len); +void SHA1Final_Legacy(unsigned char digest[SHA1_HASH_LEN], SHA1_CTX* context); +#else void SHA1Init(SHA1_CTX* context); void SHA1Update(SHA1_CTX* context, const unsigned char *data, size_t len); void SHA1Final(unsigned char digest[SHA1_HASH_LEN], SHA1_CTX* context); - -#if defined VMKBOOT || defined VMKERNEL -void SHA1RawBufferHash(const void *data, - uint32 size, - uint32 result[5]); -void SHA1RawTransformBlocks(uint32 state[5], - const unsigned char *buffer, - uint32 numBlocks); -void SHA1RawInit(uint32 state[5]); - -#define SHA1_MULTI_MAX_BUFFERS 8 - -void SHA1MultiBuffer(uint32 numBuffers, - uint32 len, - const void *salt, - uint32 saltLen, - const void *data[], - unsigned char *digests[]); #endif #endif // defined __APPLE__ && defined USERLEVEL diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/sigc++2to3.h open-vm-tools-12.1.5/open-vm-tools/lib/include/sigc++2to3.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/sigc++2to3.h 1970-01-01 00:00:00.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/sigc++2to3.h 2022-11-29 21:17:22.000000000 +0000 @@ -0,0 +1,143 @@ +/********************************************************* + * Copyright (C) 2022 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 + * by the Free Software Foundation version 2.1 and no later version. + * + * 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 Lesser GNU General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + *********************************************************/ + +/* + * sigc++2to3.h -- + * + * A header file that contain definations that will allow some sigc++2 APIs + * to work when builing with sigc++3. + */ + +#pragma once + + +#include +#include +#include + + +#if SIGCXX_MAJOR_VERSION >= 3 + +namespace sigc { + + +// Bridge slot syntax change +template +class slot : public slot { +private: + using _true_slot = slot; +public: + inline slot() = default; + inline slot(const _true_slot& src) : _true_slot(src) {} + template + inline slot(const T_functor& func) : _true_slot(func) {} +}; + +template +using slot0 = slot; +template +using slot1 = slot; +template +using slot2 = slot; +template +using slot3 = slot; +template +using slot4 = slot; +template +using slot5 = slot; +template +using slot6 = slot; +template +using slot7 = slot; + + +// Bridge signal syntax change +template +class signal : public signal, public trackable { +public: + signal() = default; + + decltype(auto) make_slot() const { + return mem_fun(*this, &signal::emit); + } +}; + +template +using signal0 = signal; +template +using signal1 = signal; +template +using signal2 = signal; +template +using signal3 = signal; +template +using signal4 = signal; +template +using signal5 = signal; +template +using signal6 = signal; +template +using signal7 = signal; + + +//Bridge bound_mem_functor +template +using bound_mem_functor0 = bound_mem_functor; +template +using bound_mem_functor1 = bound_mem_functor; +template +using bound_mem_functor2 = bound_mem_functor; +template +using bound_mem_functor3 = bound_mem_functor; +template +using bound_mem_functor4 = bound_mem_functor; +template +using bound_mem_functor5 = bound_mem_functor; +template +using bound_mem_functor6 = bound_mem_functor; +template +using bound_mem_functor7 = bound_mem_functor; + + + +// Add old mem_fun API for pointer +template +inline decltype(auto) +mem_fun(T_obj *obj, T_return (T_obj::*func)(T_arg...)) +{ + return bound_mem_functor(*obj, func); +} + +template +inline decltype(auto) +mem_fun(const T_obj *obj, T_return (T_obj::*func)(T_arg...) const) +{ + return bound_mem_functor(*obj, func); +} + + +// Stub sigc::ref impl +template +inline decltype(auto) ref(T& t) { return std::ref(t); } +template +inline decltype(auto) ref(const T& t) { return std::cref(t); } + + +} //namespace sigc + +#endif // SIGCXX_MAJOR_VERSION >= 3 diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/sigPosixRegs.h open-vm-tools-12.1.5/open-vm-tools/lib/include/sigPosixRegs.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/sigPosixRegs.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/sigPosixRegs.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2009-2017,2020-2021 VMware, Inc. All rights reserved. + * Copyright (C) 2009-2017,2020-2022 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 @@ -145,6 +145,7 @@ #define SC_PC(uc) ((unsigned long) (uc)->uc_mcontext->__ss.__pc) #elif defined(__aarch64__) #define SC_X(uc,n) ((unsigned long) (uc)->uc_mcontext->__ss.__x[n]) +#define SC_FP(uc) ((unsigned long) (uc)->uc_mcontext->__ss.__x[29]) #define SC_SP(uc) ((unsigned long) (uc)->uc_mcontext->__ss.__sp) #define SC_PC(uc) ((unsigned long) (uc)->uc_mcontext->__ss.__pc) #define SC_PSR(uc) ((unsigned long) (uc)->uc_mcontext->__ss.__cpsr) @@ -280,6 +281,7 @@ #define SC_PC(uc) ((unsigned long) (uc)->uc_mcontext.arm_pc) #elif defined(__aarch64__) #define SC_X(uc,n) ((unsigned long) (uc)->uc_mcontext.regs[n]) +#define SC_FP(uc) ((unsigned long) (uc)->uc_mcontext.regs[29]) #define SC_SP(uc) ((unsigned long) (uc)->uc_mcontext.sp) #define SC_PC(uc) ((unsigned long) (uc)->uc_mcontext.pc) #define SC_PSR(uc) ((unsigned long) (uc)->uc_mcontext.pstate) diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/strutil.h open-vm-tools-12.1.5/open-vm-tools/lib/include/strutil.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/strutil.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/strutil.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2018, 2021 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2018, 2021-2022 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 @@ -66,6 +66,7 @@ Bool StrUtil_CaselessStartsWith(const char *s, const char *prefix); Bool StrUtil_EndsWith(const char *s, const char *suffix); Bool StrUtil_CaselessEndsWith(const char *s, const char *suffix); +const char * StrUtil_CaselessStrstr(const char *str, const char *strSearch); Bool StrUtil_IsASCII(const char *s); Bool StrUtil_VDynBufPrintf(struct DynBuf *b, const char *fmt, va_list args); diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_assert.h open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_assert.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_assert.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_assert.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2021 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2022 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 @@ -79,7 +79,11 @@ // XXX not necessary except some places include vm_assert.h improperly #include "vm_basic_types.h" + +/* No stdarg.h on Linux kernels 5.15+ */ +#ifndef KBUILD_MODNAME #include +#endif #ifdef __cplusplus extern "C" { @@ -101,7 +105,10 @@ * so it uses generic functions. */ -#if !defined VMM || defined MONITOR_APP // { +#if !defined VMM || \ + defined BINARY_CHECKER || defined COREQUERY || defined DECODER || \ + defined DIS16 || defined FROBOS || defined TRAPAPI_APP || \ + defined VMM_LINKER || defined VMSS2CORE # if defined (VMKPANIC) # include "vmk_assert.h" @@ -115,8 +122,7 @@ # define _ASSERT_PANIC_BUG_NORETURN(bug, name) \ Panic(_##name##Fmt " bugNr=%d\n", __FILE__, __LINE__, bug) # endif /* VMKPANIC */ - -#endif // } +#endif // These strings don't have newline so that a bug can be tacked on. @@ -346,22 +352,21 @@ * compilation options will lead to different control-flow-derived * errors, causing some make targets to fail while others succeed. * - * VC++ has the __assume() built-in function which we don't trust - * (see bug 43485); gcc has no such construct; we just panic in - * userlevel code. The monitor doesn't want to pay the size penalty - * (measured at 212 bytes for the release vmm for a minimal infinite - * loop; panic would cost even more) so it does without and lives - * with the inconsistency. + * VC++ has the __assume() built-in function which we don't trust (see + * bug 43485). However, __assume() is used in the Windows ULM + * implementation, because the newer compiler used for that project + * generates correct code. * + * With gcc, the __builtin_unreachable() extension is used when the + * compiler is known to support it. */ -# if defined VMKPANIC || defined VMM +# if defined VMKPANIC || defined VMM || defined ULM_ESX +# undef NOT_REACHED +# define NOT_REACHED() __builtin_unreachable() +# elif defined ULM_WIN # undef NOT_REACHED -# if defined __GNUC__ && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 5) -# define NOT_REACHED() (__builtin_unreachable()) -# else -# define NOT_REACHED() ((void)0) -# endif +# define NOT_REACHED() __assume(0) # else // keep debug definition # endif diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_atomic_arm64_begin.h open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_atomic_arm64_begin.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_atomic_arm64_begin.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_atomic_arm64_begin.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2017-2018 VMware, Inc. All rights reserved. + * Copyright (C) 2017-2018,2022 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 @@ -30,6 +30,40 @@ #include "vm_basic_asm_arm64.h" +/* + * Today these are defines, but long-term these will be patchable globals + * for ESXi kernel-mode code (and something similar for ESXi userspace code). + * + * Atomic_HaveLSE should be set to 1 for CPUs that have the LSE extenstion + * and where the atomic instructions are known to have a performance benefit. + * Seemingly, on some low-end chips (CA55) there may not be a benefit. + * + * Not every operation can be performed using a single-instruction atomic - + * LSE doesn't cover all kinds of logical/arithmetic operations. For example, + * there's an ldeor instruction, but not an ldorr. For cases, where there is no + * combined instruction that atomically performs the load/store and the ALU + * operation, we fall back to CAS or to LL/SC. On some uarches - e.g. Neoverse + * N1 - CAS shows better behavior during heavy contention than LL/SC. LL/SC, + * though, remains the safest option. Atomic_PreferCasForOps controls this. + */ + +#ifdef VMK_ARM_LSE +#define Atomic_HaveLSE 1 +#else +#define Atomic_HaveLSE 0 +#endif +#define Atomic_PreferCasForOps 1 + +#define _VMATOM_LSE_HAVE(x) _VMATOM_LSE_HAVE_##x +#define _VMATOM_LSE_HAVE_add 1 +#define _VMATOM_LSE_HAVE_sub 0 +#define _VMATOM_LSE_HAVE_eor 1 +#define _VMATOM_LSE_HAVE_orr 0 +#define _VMATOM_LSE_HAVE_and 0 + +#define Atomic_PreferLSE(op) (Atomic_HaveLSE && \ + (_VMATOM_LSE_HAVE(op) || Atomic_PreferCasForOps)) + /* bit size, instruction suffix, register prefix, extend suffix */ #define _VMATOM_SIZE_8 8, b, w, b #define _VMATOM_SIZE_16 16, h, w, h @@ -121,41 +155,99 @@ /* Read (not returned), op with modval, write. */ #define _VMATOM_SNIPPET_OP(bs, is, rp, es, fenced, atm, op, modval) ({ \ - uint32 _failed; \ - uint##bs _sample; \ + uint##bs _newval; \ \ _VMATOM_FENCE(fenced); \ - __asm__ __volatile__( \ - "1: ldxr"#is" %"#rp"0, %2 \n\t"\ - " "#op" %"#rp"0, %"#rp"0, %"#rp"3 \n\t"\ - " stxr"#is" %w1 , %"#rp"0, %2 \n\t"\ - " cbnz %w1 , 1b \n\t"\ - : "=&r" (_sample), \ - "=&r" (_failed), \ - "+Q" (*atm) \ - : "r" (modval) \ - ); \ + if (Atomic_PreferLSE(op)) { \ + if (_VMATOM_LSE_HAVE(op)) { \ + __asm__ __volatile__( \ + ".arch armv8.2-a \n\t"\ + "st" #op #is" %"#rp"1, %0 \n\t"\ + : "+Q" (*atm) \ + : "r" (modval) \ + ); \ + } else { \ + uint##bs _oldval; \ + uint##bs _clobberedval; \ + __asm__ __volatile__( \ + ".arch armv8.2-a \n\t"\ + " ldr"#is" %"#rp"1, %3 \n\t"\ + "1: mov %"#rp"0, %"#rp"1 \n\t"\ + " "#op" %"#rp"2, %"#rp"0, %"#rp"4 \n\t"\ + " cas"#is" %"#rp"1, %"#rp"2, %3 \n\t"\ + " cmp %"#rp"0, %"#rp"1, uxt"#es" \n\t"\ + " b.ne 1b \n\t"\ + : "=&r" (_oldval), \ + "=&r" (_clobberedval), \ + "=&r" (_newval), \ + "+Q" (*atm) \ + : "r" (modval) \ + : "cc" \ + ); \ + } \ + } else { \ + uint32 _failed; \ + __asm__ __volatile__( \ + "1: ldxr"#is" %"#rp"0, %2 \n\t"\ + " "#op" %"#rp"0, %"#rp"0, %"#rp"3 \n\t"\ + " stxr"#is" %w1 , %"#rp"0, %2 \n\t"\ + " cbnz %w1 , 1b \n\t"\ + : "=&r" (_newval), \ + "=&r" (_failed), \ + "+Q" (*atm) \ + : "r" (modval) \ + ); \ + } \ _VMATOM_FENCE(fenced); \ }) /* Read (returned), op with modval, write. */ #define _VMATOM_SNIPPET_ROP(bs, is, rp, es, fenced, atm, op, modval) ({ \ - uint32 _failed; \ uint##bs _newval; \ uint##bs _oldval; \ \ _VMATOM_FENCE(fenced); \ - __asm__ __volatile__( \ - "1: ldxr"#is" %"#rp"0, %3 \n\t"\ - " "#op" %"#rp"1, %"#rp"0, %"#rp"4 \n\t"\ - " stxr"#is" %w2 , %"#rp"1, %3 \n\t"\ - " cbnz %w2 , 1b \n\t"\ - : "=&r" (_oldval), \ - "=&r" (_newval), \ - "=&r" (_failed), \ - "+Q" (*atm) \ - : "r" (modval) \ - ); \ + if (Atomic_PreferLSE(op)) { \ + if (_VMATOM_LSE_HAVE(op)) { \ + __asm__ __volatile__( \ + ".arch armv8.2-a \n\t"\ + "ld" #op #is" %"#rp"2, %"#rp"0, %1 \n\t"\ + : "=r" (_oldval), \ + "+Q" (*atm) \ + : "r" (modval) \ + ); \ + } else { \ + uint##bs _clobberedval; \ + __asm__ __volatile__( \ + ".arch armv8.2-a \n\t"\ + " ldr"#is" %"#rp"1, %3 \n\t"\ + "1: mov %"#rp"0, %"#rp"1 \n\t"\ + " "#op" %"#rp"2, %"#rp"0, %"#rp"4 \n\t"\ + " cas"#is" %"#rp"1, %"#rp"2, %3 \n\t"\ + " cmp %"#rp"0, %"#rp"1, uxt"#es" \n\t"\ + " b.ne 1b \n\t"\ + : "=&r" (_oldval), \ + "=&r" (_clobberedval), \ + "=&r" (_newval), \ + "+Q" (*atm) \ + : "r" (modval) \ + : "cc" \ + ); \ + } \ + } else { \ + uint32 _failed; \ + __asm__ __volatile__( \ + "1: ldxr"#is" %"#rp"0, %3 \n\t"\ + " "#op" %"#rp"1, %"#rp"0, %"#rp"4 \n\t"\ + " stxr"#is" %w2 , %"#rp"1, %3 \n\t"\ + " cbnz %w2 , 1b \n\t"\ + : "=&r" (_oldval), \ + "=&r" (_newval), \ + "=&r" (_failed), \ + "+Q" (*atm) \ + : "r" (modval) \ + ); \ + } \ _VMATOM_FENCE(fenced); \ \ _oldval; \ @@ -163,19 +255,29 @@ /* Read (returned), write. */ #define _VMATOM_SNIPPET_RW(bs, is, rp, es, fenced, atm, val) ({ \ - uint32 _failed; \ uint##bs _oldval; \ \ _VMATOM_FENCE(fenced); \ - __asm__ __volatile__( \ - "1: ldxr"#is" %"#rp"0, %2 \n\t"\ - " stxr"#is" %w1 , %"#rp"3, %2 \n\t"\ - " cbnz %w1 , 1b \n\t"\ - : "=&r" (_oldval), \ - "=&r" (_failed), \ - "+Q" (*atm) \ - : "r" (val) \ - ); \ + if (Atomic_HaveLSE) { \ + __asm__ __volatile__( \ + ".arch armv8.2-a \n\t"\ + "swp"#is" %"#rp"2, %"#rp"0, %1 \n\t"\ + : "=r" (_oldval), \ + "+Q" (*atm) \ + : "r" (val) \ + ); \ + } else { \ + uint32 _failed; \ + __asm__ __volatile__( \ + "1: ldxr"#is" %"#rp"0, %2 \n\t"\ + " stxr"#is" %w1 , %"#rp"3, %2 \n\t"\ + " cbnz %w1 , 1b \n\t"\ + : "=&r" (_oldval), \ + "=&r" (_failed), \ + "+Q" (*atm) \ + : "r" (val) \ + ); \ + } \ _VMATOM_FENCE(fenced); \ \ _oldval; \ @@ -183,24 +285,34 @@ /* Read (returned), if equal to old then write new. */ #define _VMATOM_SNIPPET_RIFEQW(bs, is, rp, es, fenced, atm, old, new) ({ \ - uint32 _failed; \ uint##bs _oldval; \ \ _VMATOM_FENCE(fenced); \ - __asm__ __volatile__( \ - "1: ldxr"#is" %"#rp"0, %2 \n\t"\ - " cmp %"#rp"0, %"#rp"3, uxt"#es" \n\t"\ - " b.ne 2f \n\t"\ - " stxr"#is" %w1 , %"#rp"4, %2 \n\t"\ - " cbnz %w1 , 1b \n\t"\ - "2: \n\t"\ - : "=&r" (_oldval), \ - "=&r" (_failed), \ - "+Q" (*atm) \ - : "r" (old), \ - "r" (new) \ - : "cc" \ - ); \ + if (Atomic_HaveLSE) { \ + __asm__ __volatile__( \ + ".arch armv8.2-a \n\t"\ + "cas"#is" %"#rp"0, %"#rp"2, %1 \n\t"\ + : "=r" (_oldval), \ + "+Q" (*atm) \ + : "r" (new), "0" (old) \ + ); \ + } else { \ + uint32 _failed; \ + __asm__ __volatile__( \ + "1: ldxr"#is" %"#rp"0, %2 \n\t"\ + " cmp %"#rp"0, %"#rp"3, uxt"#es" \n\t"\ + " b.ne 2f \n\t"\ + " stxr"#is" %w1 , %"#rp"4, %2 \n\t"\ + " cbnz %w1 , 1b \n\t"\ + "2: \n\t"\ + : "=&r" (_oldval), \ + "=&r" (_failed), \ + "+Q" (*atm) \ + : "r" (old), \ + "r" (new) \ + : "cc" \ + ); \ + } \ _VMATOM_FENCE(fenced); \ \ _oldval; \ diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_atomic_arm64_end.h open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_atomic_arm64_end.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_atomic_arm64_end.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_atomic_arm64_end.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2017 VMware, Inc. All rights reserved. + * Copyright (C) 2017,2022 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 @@ -27,6 +27,12 @@ #endif /* Undefine all the private macros we previously defined. */ +#undef _VMATOM_LSE_HAVE +#undef _VMATOM_LSE_HAVE_add +#undef _VMATOM_LSE_HAVE_sub +#undef _VMATOM_LSE_HAVE_eor +#undef _VMATOM_LSE_HAVE_orr +#undef _VMATOM_LSE_HAVE_and #undef _VMATOM_SIZE_8 #undef _VMATOM_SIZE_16 #undef _VMATOM_SIZE_32 diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_atomic.h open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_atomic.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_atomic.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_atomic.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2021 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2022 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 @@ -229,40 +229,59 @@ uint128 oldVal, // IN uint128 newVal) // IN { -#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 +#if defined VM_ARM_64 + /* + * Don't use __sync_val_compare_and_swap, as this cannot magically + * use the right (LL/SC vs LSE) atomics without -moutline-atomics. + */ +#if __GNUC__ >= 9 + if (Atomic_HaveLSE) { + SMP_RW_BARRIER_RW(); + __asm__ __volatile__( + ".arch armv8.2-a \n\t" + "casp %0, %H0, %2, %H2, %1 \n\t" + : "+r" (oldVal), + "+Q" (ptr->value) + : "r" (newVal) + ); + SMP_RW_BARRIER_RW(); + return oldVal; + } else +#endif /* __GNUC__ */ + { + union { + uint128 raw; + struct { + uint64 lo; + uint64 hi; + }; + } res, _old = { oldVal }, _new = { newVal }; + uint32 failed; + + SMP_RW_BARRIER_RW(); + __asm__ __volatile__( + "1: ldxp %x0, %x1, %3 \n\t" + " cmp %x0, %x4 \n\t" + " ccmp %x1, %x5, #0, eq \n\t" + " b.ne 2f \n\t" + " stxp %w2, %x6, %x7, %3 \n\t" + " cbnz %w2, 1b \n\t" + "2: \n\t" + : "=&r" (res.lo), + "=&r" (res.hi), + "=&r" (failed), + "+Q" (ptr->value) + : "r" (_old.lo), + "r" (_old.hi), + "r" (_new.lo), + "r" (_new.hi) + : "cc" + ); + SMP_RW_BARRIER_RW(); + return res.raw; + } +#elif __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 return __sync_val_compare_and_swap(&ptr->value, oldVal, newVal); -#elif defined VM_ARM_64 - union { - uint128 raw; - struct { - uint64 lo; - uint64 hi; - }; - } res, _old = { oldVal }, _new = { newVal }; - uint32 failed; - - SMP_RW_BARRIER_RW(); - __asm__ __volatile__( - "1: ldxp %x0, %x1, %3 \n\t" - " cmp %x0, %x4 \n\t" - " ccmp %x1, %x5, #0, eq \n\t" - " b.ne 2f \n\t" - " stxp %w2, %x6, %x7, %3 \n\t" - " cbnz %w2, 1b \n\t" - "2: \n\t" - : "=&r" (res.lo), - "=&r" (res.hi), - "=&r" (failed), - "+Q" (ptr->value) - : "r" (_old.lo), - "r" (_old.hi), - "r" (_new.lo), - "r" (_new.hi) - : "cc" - ); - SMP_RW_BARRIER_RW(); - - return res.raw; #endif } #endif @@ -1502,7 +1521,21 @@ ); #endif /* VM_X86_ANY */ #elif defined _MSC_VER - _InterlockedExchangeAdd((long *)&var->value, -(long)val); + /* + * Microsoft warning C4146, enabled by the /sdl option for + * additional security checks, objects to `-val' when val is + * unsigned, even though that is always well-defined by C and has + * exactly the semantics we want, namely negation modulo 2^32. + * (The signed version, in contrast, has undefined behaviour at + * some inputs.) + * + * https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-2-c4146?view=msvc-170 + * https://docs.microsoft.com/en-us/cpp/build/reference/sdl-enable-additional-security-checks?view=msvc-170 + */ +# pragma warning(push) +# pragma warning(disable: 4146) + _InterlockedExchangeAdd((long *)&var->value, (long)-val); +# pragma warning(pop) #else #error No compiler defined for Atomic_Sub #endif @@ -2194,9 +2227,6 @@ * * Atomically subtracts a 64-bit integer from another. * - * Note: It is expected that val <= var. If untrue, the result - * cannot be represented in an unsigned type. - * * Results: * Returns the old value just prior to the subtraction * @@ -2213,7 +2243,25 @@ #if defined __GNUC__ && defined VM_ARM_64 return _VMATOM_X(ROP, 64, TRUE, &var->value, sub, val); #else - return Atomic_ReadAdd64(var, (uint64)-(int64)val); +# ifdef _MSC_VER + /* + * Microsoft warning C4146, enabled by the /sdl option for + * additional security checks, objects to `-val' when val is + * unsigned, even though that is always well-defined by C and has + * exactly the semantics we want, namely negation modulo 2^64. + * (The signed version, in contrast, has undefined behaviour at + * some inputs.) + * + * https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-2-c4146?view=msvc-170 + * https://docs.microsoft.com/en-us/cpp/build/reference/sdl-enable-additional-security-checks?view=msvc-170 + */ +# pragma warning(push) +# pragma warning(disable: 4146) +# endif + return Atomic_ReadAdd64(var, -val); +# ifdef _MSC_VER +# pragma warning(pop) +# endif #endif } diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_basic_asm_arm64.h open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_basic_asm_arm64.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_basic_asm_arm64.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_basic_asm_arm64.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2013-2021 VMware, Inc. All rights reserved. + * Copyright (C) 2013-2022 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 @@ -144,6 +144,48 @@ /* + *---------------------------------------------------------------------- + * + * ESB -- + * + * Error synchronization barrier. + * + * Error synchronization event as per Arm ARM. NOP if ARMv8.2 + * RAS extensions are not implemented. + * + * Results: + * None + * + * Side effects: + * SError exception or DISR/VDISR getting updated. + * + *---------------------------------------------------------------------- + */ + +#if defined __GNUC__ +static INLINE void +ESB(void) +{ + /* + * The assembler of gcc 9.3 with -march=armv8-a errors out with + * "Error: selected processor does not support `esb'" + * There is no way to cleanly temporarily push/pop -march=armv8.2-a or the + * ras extension. The error does not occur with gcc versions >= 10.2. + */ +# if __GNUC__ > 10 || __GNUC__ == 10 && __GNUC_MINOR__ >= 2 + asm volatile("esb" ::: "memory"); +# else + asm volatile( + ".arch armv8.2-a" "\n\t" + "esb" "\n\t" + ".arch " XSTR(VMW_ARCH) + ::: "memory" + ); +# endif +} +#endif + +/* * Memory Barriers * =============== * @@ -154,45 +196,54 @@ * accesses accross the barrier. It is not a CPU instruction, it is a compiler * directive (i.e. it does not emit any code). * + * => A compiler memory barrier on its own is useful for coordinating + * with an interrupt handler (or preemption logic in the scheduler) + * on the same CPU, so that the order of read and write + * instructions in code that might be interrupted is consistent + * with the barriers. But when there are other CPUs involved, or + * other types of devices like memory-mapped I/O and DMA + * controllers, a compiler memory barrier is not enough. + * * A CPU memory barrier prevents the CPU from re-ordering memory accesses * accross the barrier. It is a CPU instruction. * + * => On its own the CPU instruction isn't useful because the compiler + * may reorder loads and stores around the CPU instruction. It is + * useful only when combined with a compiler memory barrier. + * * A memory barrier is the union of a compiler memory barrier and a CPU memory - * barrier. A compiler memory barrier is a useless construct by itself. It is - * only useful when combined with a CPU memory barrier, to implement a memory * barrier. * * Semantics * --------- * - * At the time COMPILER_*_BARRIER were created (and references to them were + * At the time COMPILER_MEM_BARRIER was created (and references to it were * added to the code), the code was only targetting x86. The intent of the code * was really to use a memory barrier, but because x86 uses a strongly ordered - * memory model, the CPU would not re-order memory accesses, and the code could - * get away with using just a compiler memory barrier. So COMPILER_*_BARRIER - * were born and were implemented as compiler memory barriers _on x86_. But - * make no mistake, _the semantics that the code expects from - * COMPILER_*_BARRIER are that of a memory barrier_! + * memory model, the CPU would not re-order most memory accesses (store-load + * ordering still requires MFENCE even on x86), and the code could get away + * with using just a compiler memory barrier. So COMPILER_MEM_BARRIER was born + * and was implemented as a compiler memory barrier _on x86_. But make no + * mistake, _the semantics that the code expects from COMPILER_MEM_BARRIER is + * that of a memory barrier_! * * DO NOT USE! * ----------- * - * On at least one non-x86 architecture, COMPILER_*_BARRIER are - * 1) Misnomers + * On at least one non-x86 architecture, COMPILER_MEM_BARRIER is + * 1) A misnomer * 2) Not fine-grained enough to provide the best performance. - * For the above two reasons, usage of COMPILER_*_BARRIER is now deprecated. - * _Do not add new references to COMPILER_*_BARRIER._ Instead, precisely + * For the above two reasons, usage of COMPILER_MEM_BARRIER is now deprecated. + * _Do not add new references to COMPILER_MEM_BARRIER._ Instead, precisely * document the intent of your code by using * __BARRIER_. - * Existing references to COMPILER_*_BARRIER are being slowly but surely - * converted, and when no references are left, COMPILER_*_BARRIER will be + * Existing references to COMPILER_MEM_BARRIER are being slowly but surely + * converted, and when no references are left, COMPILER_MEM_BARRIER will be * retired. * * Thanks for pasting this whole comment into every architecture header. */ -#define COMPILER_READ_BARRIER() SMP_R_BARRIER_R() -#define COMPILER_WRITE_BARRIER() SMP_W_BARRIER_W() #define COMPILER_MEM_BARRIER() SMP_RW_BARRIER_RW() /* @@ -201,7 +252,7 @@ * __BARRIER_ * * where: - * is either SMP, DMA, or MMIO. + * is either INTR, SMP, DMA, or MMIO. * <*_access type> is either R(load), W(store) or RW(any). * * Above every use of these memory barriers in the code, there _must_ be a diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_basic_asm.h open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_basic_asm.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_basic_asm.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_basic_asm.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2003-2021 VMware, Inc. All rights reserved. + * Copyright (c) 2003-2022 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 @@ -787,7 +787,7 @@ * bora/lib/vprobe/arm64/vp_emit_tc.c::VpEmit_BuiltinRDTSCWork() * bora/modules/vmkernel/tests/core/xmapTest/xmapTest_arm64.c::XMapTest_SetupLoopCode() */ -#if (defined(VMKERNEL) || defined(VMM)) && !defined(VMK_ARM_EL1) +#if (defined(VMKERNEL) || defined(VMM)) && !defined(VMK_ARM_EL1_OR_VHE) return MRS(CNTPCT_EL0); #else return MRS(CNTVCT_EL0); @@ -844,9 +844,10 @@ /* *----------------------------------------------------------------------------- * - * {Clear,Set,Test}Bit{32,64} -- + * {Clear, Set, Test, Toggle}Bit{32, 64} -- * - * Sets tests or clears a specified single bit in the provided variable. + * Sets tests clears or toggles a specified single bit in the provided + * variable. * * The index input value specifies which bit to modify and is 0-based. * Index is truncated by hardware to a 5-bit or 6-bit offset for the @@ -872,6 +873,12 @@ } static INLINE void +ToggleBit32(uint32 *var, unsigned index) +{ + *var ^= 1 << index; +} + +static INLINE void SetBit64(uint64 *var, unsigned index) { *var |= CONST64U(1) << index; @@ -883,6 +890,12 @@ *var &= ~(CONST64U(1) << index); } +static INLINE void +ToggleBit64(uint64 *var, unsigned index) +{ + *var ^= (CONST64U(1) << index); +} + static INLINE Bool TestBit32(const uint32 *var, unsigned index) { @@ -910,18 +923,27 @@ *----------------------------------------------------------------------------- */ +#if defined __GCC_ASM_FLAG_OUTPUTS__ +/* + * See https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html + * 6.47.2.4 Flag Output Operands + * + * This expands to 0 or 1 instructions followed by the output operand string. + */ +#define GCC_ASM_BT_EPILOG : "=@ccc" +#else +#define GCC_ASM_BT_EPILOG "\n\tsetc\t%0" : "=qQm" +#endif + static INLINE Bool SetBitVector(void *var, int32 index) { #if defined(__GNUC__) && defined(VM_X86_ANY) Bool bit; - __asm__ ( - "bts %2, %1;" - "setc %0" - : "=qQm" (bit), "+m" (*(uint32 *)var) - : "rI" (index) - : "memory", "cc" - ); + __asm__("bts\t%2, %1" + GCC_ASM_BT_EPILOG (bit), "+m" (*(uint32 *)var) + : "rI" (index) + : "memory", "cc"); return bit; #elif defined(_MSC_VER) return _bittestandset((long *)var, index) != 0; @@ -937,13 +959,10 @@ { #if defined(__GNUC__) && defined(VM_X86_ANY) Bool bit; - __asm__ ( - "btr %2, %1;" - "setc %0" - : "=qQm" (bit), "+m" (*(uint32 *)var) - : "rI" (index) - : "memory", "cc" - ); + __asm__("btr\t%2, %1" + GCC_ASM_BT_EPILOG (bit), "+m" (*(uint32 *)var) + : "rI" (index) + : "memory", "cc"); return bit; #elif defined(_MSC_VER) return _bittestandreset((long *)var, index) != 0; @@ -959,13 +978,10 @@ { #if defined(__GNUC__) && defined(VM_X86_ANY) Bool bit; - __asm__ ( - "btc %2, %1;" - "setc %0" - : "=qQm" (bit), "+m" (*(uint32 *)var) - : "rI" (index) - : "memory", "cc" - ); + __asm__("btc\t%2, %1" + GCC_ASM_BT_EPILOG (bit), "+m" (*(uint32 *)var) + : "rI" (index) + : "memory", "cc"); return bit; #elif defined(_MSC_VER) return _bittestandcomplement((long *)var, index) != 0; @@ -981,13 +997,10 @@ { #if defined(__GNUC__) && defined(VM_X86_ANY) Bool bit; - __asm__ ( - "bt %2, %1;" - "setc %0" - : "=qQm" (bit) - : "m" (*(const uint32 *)var), "rI" (index) - : "cc" - ); + __asm__("bt\t%2, %1" + GCC_ASM_BT_EPILOG (bit) + : "m" (*(const uint32 *)var), "rI" (index) + : "cc"); return bit; #elif defined _MSC_VER return _bittest((long *)var, index) != 0; @@ -996,6 +1009,7 @@ #endif } +#undef GCC_ASM_BT_EPILOG /* *----------------------------------------------------------------------------- @@ -1259,6 +1273,79 @@ } +/* + *----------------------------------------------------------------------------- + * + * INTR_R_BARRIER_R -- + * INTR_R_BARRIER_W -- + * INTR_R_BARRIER_RW -- + * INTR_W_BARRIER_R -- + * INTR_W_BARRIER_W -- + * INTR_W_BARRIER_RW -- + * INTR_RW_BARRIER_R -- + * INTR_RW_BARRIER_W -- + * INTR_RW_BARRIER_RW -- + * + * Enforce ordering on memory operations witnessed by and + * affected by interrupt handlers. + * + * This should be used to replace the legacy COMPILER_MEM_BARRIER + * for code that has been audited to determine it only needs + * ordering with respect to interrupt handlers, and not to other + * CPUs (SMP_*), memory-mapped I/O (MMIO_*), or DMA (DMA_*). + * + *----------------------------------------------------------------------------- + */ + +#ifdef __GNUC__ + +static INLINE void +INTR_RW_BARRIER_RW(void) +{ + __asm__ __volatile__("" ::: "memory"); +} + +#define INTR_R_BARRIER_R INTR_RW_BARRIER_RW +#define INTR_R_BARRIER_W INTR_RW_BARRIER_RW +#define INTR_R_BARRIER_RW INTR_RW_BARRIER_RW +#define INTR_W_BARRIER_R INTR_RW_BARRIER_RW +#define INTR_W_BARRIER_W INTR_RW_BARRIER_RW +#define INTR_W_BARRIER_RW INTR_RW_BARRIER_RW +#define INTR_RW_BARRIER_R INTR_RW_BARRIER_RW +#define INTR_RW_BARRIER_W INTR_RW_BARRIER_RW + +#elif defined _MSC_VER + +static INLINE void +INTR_R_BARRIER_R(void) +{ + _ReadBarrier(); +} + +static INLINE void +INTR_W_BARRIER_W(void) +{ + _WriteBarrier(); +} + +static INLINE void +INTR_RW_BARRIER_RW(void) +{ + _ReadWriteBarrier(); +} + +#define INTR_R_BARRIER_W INTR_RW_BARRIER_RW +#define INTR_R_BARRIER_RW INTR_RW_BARRIER_RW +#define INTR_W_BARRIER_R INTR_RW_BARRIER_RW +#define INTR_W_BARRIER_RW INTR_RW_BARRIER_RW +#define INTR_RW_BARRIER_R INTR_RW_BARRIER_RW +#define INTR_RW_BARRIER_W INTR_RW_BARRIER_RW + +#else +#error No compiler defined for INTR_*_BARRIER_* +#endif + + #if defined __cplusplus } // extern "C" #endif diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_basic_asm_x86_64.h open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_basic_asm_x86_64.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_basic_asm_x86_64.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_basic_asm_x86_64.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2020 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2021 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 @@ -303,6 +303,37 @@ } #endif /* __GNUC__ */ + +/* + * XSAVES/XRSTORS + * saves/restores processor state components + * + * The pointer passed in must be 64-byte aligned. + */ + +#if defined(__GNUC__) +static INLINE void +XSAVES(const void *save, uint64 mask) +{ + __asm__ __volatile__ ( + "xsaves %0 \n" + : "=m" (*(uint8 *)save) + : "a" ((uint32)mask), "d" ((uint32)(mask >> 32)) + : "memory"); +} + +static INLINE void +XRSTORS(const void *load, uint64 mask) +{ + __asm__ __volatile__ ( + "xrstors %0 \n" + : + : "m" (*(const uint8 *)load), + "a" ((uint32)mask), "d" ((uint32)(mask >> 32)) + : "memory"); +} + +#endif /* __GNUC__ */ #endif /* VMM || VMKERNEL || FROBOS || ULM */ /* diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_basic_asm_x86_common.h open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_basic_asm_x86_common.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_basic_asm_x86_common.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_basic_asm_x86_common.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2013-2020 VMware, Inc. All rights reserved. + * Copyright (C) 2013-2022 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 @@ -167,6 +167,37 @@ /* *----------------------------------------------------------------------------- * + * CLFLUSH -- + * + * Wrapper around the CLFLUSH instruction. + * + * Results: + * None. + * + * Side effects: + * See CLFLUSH instruction in Intel SDM or AMD Programmer's Manual. + * + *----------------------------------------------------------------------------- + */ + +static INLINE void +CLFLUSH(const void *addr) +{ +#ifdef __GNUC__ + __asm__ __volatile__( + "clflush %0" + :: "m" (*(uint8 *)addr)); +#elif defined _MSC_VER + _mm_clflush(addr); +#else +#error No compiler defined for CLFLUSH +#endif +} + + +/* + *----------------------------------------------------------------------------- + * * MFENCE -- * * Wrapper around the MFENCE instruction. @@ -379,50 +410,57 @@ * accesses accross the barrier. It is not a CPU instruction, it is a compiler * directive (i.e. it does not emit any code). * + * => A compiler memory barrier on its own is useful for coordinating + * with an interrupt handler (or preemption logic in the scheduler) + * on the same CPU, so that the order of read and write + * instructions in code that might be interrupted is consistent + * with the barriers. But when there are other CPUs involved, or + * other types of devices like memory-mapped I/O and DMA + * controllers, a compiler memory barrier is not enough. + * * A CPU memory barrier prevents the CPU from re-ordering memory accesses * accross the barrier. It is a CPU instruction. * + * => On its own the CPU instruction isn't useful because the compiler + * may reorder loads and stores around the CPU instruction. It is + * useful only when combined with a compiler memory barrier. + * * A memory barrier is the union of a compiler memory barrier and a CPU memory - * barrier. A compiler memory barrier is a useless construct by itself. It is - * only useful when combined with a CPU memory barrier, to implement a memory * barrier. * * Semantics * --------- * - * At the time COMPILER_*_BARRIER were created (and references to them were + * At the time COMPILER_MEM_BARRIER was created (and references to it were * added to the code), the code was only targetting x86. The intent of the code * was really to use a memory barrier, but because x86 uses a strongly ordered - * memory model, the CPU would not re-order memory accesses, and the code could - * get away with using just a compiler memory barrier. So COMPILER_*_BARRIER - * were born and were implemented as compiler memory barriers _on x86_. But - * make no mistake, _the semantics that the code expects from - * COMPILER_*_BARRIER are that of a memory barrier_! + * memory model, the CPU would not re-order most memory accesses (store-load + * ordering still requires MFENCE even on x86), and the code could get away + * with using just a compiler memory barrier. So COMPILER_MEM_BARRIER was born + * and was implemented as a compiler memory barrier _on x86_. But make no + * mistake, _the semantics that the code expects from COMPILER_MEM_BARRIER is + * that of a memory barrier_! * * DO NOT USE! * ----------- * - * On at least one non-x86 architecture, COMPILER_*_BARRIER are - * 1) Misnomers + * On at least one non-x86 architecture, COMPILER_MEM_BARRIER is + * 1) A misnomer * 2) Not fine-grained enough to provide the best performance. - * For the above two reasons, usage of COMPILER_*_BARRIER is now deprecated. - * _Do not add new references to COMPILER_*_BARRIER._ Instead, precisely + * For the above two reasons, usage of COMPILER_MEM_BARRIER is now deprecated. + * _Do not add new references to COMPILER_MEM_BARRIER._ Instead, precisely * document the intent of your code by using * __BARRIER_. - * Existing references to COMPILER_*_BARRIER are being slowly but surely - * converted, and when no references are left, COMPILER_*_BARRIER will be + * Existing references to COMPILER_MEM_BARRIER are being slowly but surely + * converted, and when no references are left, COMPILER_MEM_BARRIER will be * retired. * * Thanks for pasting this whole comment into every architecture header. */ #if defined __GNUC__ -# define COMPILER_READ_BARRIER() COMPILER_MEM_BARRIER() -# define COMPILER_WRITE_BARRIER() COMPILER_MEM_BARRIER() # define COMPILER_MEM_BARRIER() __asm__ __volatile__("" ::: "memory") #elif defined _MSC_VER -# define COMPILER_READ_BARRIER() _ReadBarrier() -# define COMPILER_WRITE_BARRIER() _WriteBarrier() # define COMPILER_MEM_BARRIER() _ReadWriteBarrier() #endif @@ -432,12 +470,11 @@ * __BARRIER_ * * where: - * is either SMP, DMA, or MMIO. + * is either INTR, SMP, DMA, or MMIO. * <*_access type> is either R(load), W(store) or RW(any). * * Above every use of these memory barriers in the code, there _must_ be a * comment to justify the use, i.e. a comment which: - * * 1) Precisely identifies which memory accesses must not be re-ordered across * the memory barrier. * 2) Explains why it is important that the memory accesses not be re-ordered. @@ -488,7 +525,7 @@ * i.e. WB using above terminology), so we only need to worry about store-load * reordering. In other cases a compiler barrier is sufficient. SMP store-load * reordering is handled with a locked XOR (instead of a proper MFENCE - * instructon) for performance reasons. See PR 1674199 for more details. + * instruction) for performance reasons. See PR 1674199 for more details. * * DMA barriers are equivalent to SMP barriers on x86. * @@ -498,14 +535,14 @@ * not guarding non-temporal/WC accesses. */ -#define SMP_R_BARRIER_R() COMPILER_READ_BARRIER() -#define SMP_R_BARRIER_W() COMPILER_MEM_BARRIER() -#define SMP_R_BARRIER_RW() COMPILER_MEM_BARRIER() +#define SMP_R_BARRIER_R() INTR_R_BARRIER_R() +#define SMP_R_BARRIER_W() INTR_R_BARRIER_W() +#define SMP_R_BARRIER_RW() INTR_R_BARRIER_RW() #define SMP_W_BARRIER_R() LOCKED_INSN_BARRIER() -#define SMP_W_BARRIER_W() COMPILER_WRITE_BARRIER() +#define SMP_W_BARRIER_W() INTR_W_BARRIER_W() #define SMP_W_BARRIER_RW() LOCKED_INSN_BARRIER() #define SMP_RW_BARRIER_R() LOCKED_INSN_BARRIER() -#define SMP_RW_BARRIER_W() COMPILER_MEM_BARRIER() +#define SMP_RW_BARRIER_W() INTR_RW_BARRIER_W() #define SMP_RW_BARRIER_RW() LOCKED_INSN_BARRIER() /* diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_basic_defs.h open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_basic_defs.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_basic_defs.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_basic_defs.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2003-2021 VMware, Inc. All rights reserved. + * Copyright (C) 2003-2022 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 @@ -89,7 +89,10 @@ * References: * C90 7.17, C99 7.19, C11 7.19 */ -#if !defined(VMKERNEL) +/* Use linux/stddef.h when building Linux kernel modules. */ +#ifdef KBUILD_MODNAME +# include +#elif !defined(VMKERNEL) # include #else /* @@ -181,12 +184,10 @@ #if defined __APPLE__ #include #undef MASK - #if defined VM_ARM_ANY - #include - #undef PAGE_SHIFT - #undef PAGE_SIZE - #undef PAGE_MASK - #endif +#include +#undef PAGE_SHIFT +#undef PAGE_SIZE +#undef PAGE_MASK #endif /* @@ -250,6 +251,7 @@ #define PAGE_SHIFT_4KB 12 #define PAGE_SHIFT_16KB 14 +#define PAGE_SHIFT_64KB 16 #ifndef PAGE_SHIFT // { #if defined __x86_64__ || defined __i386__ @@ -271,6 +273,7 @@ #define PAGE_SIZE_4KB (1 << PAGE_SHIFT_4KB) #define PAGE_SIZE_16KB (1 << PAGE_SHIFT_16KB) +#define PAGE_SIZE_64KB (1 << PAGE_SHIFT_64KB) #ifndef PAGE_SIZE #define PAGE_SIZE (1 << PAGE_SHIFT) @@ -278,6 +281,7 @@ #define PAGE_MASK_4KB (PAGE_SIZE_4KB - 1) #define PAGE_MASK_16KB (PAGE_SIZE_16KB - 1) +#define PAGE_MASK_64KB (PAGE_SIZE_64KB - 1) #ifndef PAGE_MASK #define PAGE_MASK (PAGE_SIZE - 1) @@ -285,6 +289,7 @@ #define PAGE_OFFSET_4KB(_addr) ((uintptr_t)(_addr) & (PAGE_SIZE_4KB - 1)) #define PAGE_OFFSET_16KB(_addr) ((uintptr_t)(_addr) & (PAGE_SIZE_16KB - 1)) +#define PAGE_OFFSET_64KB(_addr) ((uintptr_t)(_addr) & (PAGE_SIZE_64KB - 1)) #ifndef PAGE_OFFSET #define PAGE_OFFSET(_addr) ((uintptr_t)(_addr) & (PAGE_SIZE - 1)) @@ -307,6 +312,10 @@ #define BYTES_2_PAGES(_nbytes) ((_nbytes) >> PAGE_SHIFT) #endif +#ifndef BYTES_2_PAGES_4KB +#define BYTES_2_PAGES_4KB(_nbytes) ((_nbytes) >> PAGE_SHIFT_4KB) +#endif + #ifndef PAGES_2_BYTES #define PAGES_2_BYTES(_npages) (((uint64)(_npages)) << PAGE_SHIFT) #endif @@ -319,9 +328,23 @@ #define MBYTES_SHIFT 20 #endif +#ifndef GBYTES_SHIFT +#define GBYTES_SHIFT 30 +#endif + +#ifndef KBYTES_2_PAGES +#define KBYTES_2_PAGES(_nkbytes) \ + ((uint64)(_nkbytes) >> (PAGE_SHIFT - KBYTES_SHIFT)) +#endif + #ifndef MBYTES_2_PAGES -#define MBYTES_2_PAGES(_nbytes) \ - ((uint64)(_nbytes) << (MBYTES_SHIFT - PAGE_SHIFT)) +#define MBYTES_2_PAGES(_nMbytes) \ + ((uint64)(_nMbytes) << (MBYTES_SHIFT - PAGE_SHIFT)) +#endif + +#ifndef MBYTES_2_PAGES_4KB +#define MBYTES_2_PAGES_4KB(_nMbytes) \ + ((uint64)(_nMbytes) << (MBYTES_SHIFT - PAGE_SHIFT_4KB)) #endif #ifndef PAGES_2_KBYTES @@ -343,11 +366,12 @@ #endif #ifndef GBYTES_2_PAGES -#define GBYTES_2_PAGES(_nbytes) ((uint64)(_nbytes) << (30 - PAGE_SHIFT)) +#define GBYTES_2_PAGES(_nGbytes) \ + ((uint64)(_nGbytes) << (GBYTES_SHIFT - PAGE_SHIFT)) #endif #ifndef PAGES_2_GBYTES -#define PAGES_2_GBYTES(_npages) ((_npages) >> (30 - PAGE_SHIFT)) +#define PAGES_2_GBYTES(_npages) ((_npages) >> (GBYTES_SHIFT - PAGE_SHIFT)) #endif #ifndef BYTES_2_KBYTES @@ -355,7 +379,7 @@ #endif #ifndef KBYTES_2_BYTES -#define KBYTES_2_BYTES(_nbytes) ((uint64)(_nbytes) << KBYTES_SHIFT) +#define KBYTES_2_BYTES(_nkbytes) ((uint64)(_nkbytes) << KBYTES_SHIFT) #endif #ifndef BYTES_2_MBYTES @@ -363,15 +387,15 @@ #endif #ifndef MBYTES_2_BYTES -#define MBYTES_2_BYTES(_nbytes) ((uint64)(_nbytes) << MBYTES_SHIFT) +#define MBYTES_2_BYTES(_nMbytes) ((uint64)(_nMbytes) << MBYTES_SHIFT) #endif #ifndef BYTES_2_GBYTES -#define BYTES_2_GBYTES(_nbytes) ((_nbytes) >> 30) +#define BYTES_2_GBYTES(_nbytes) ((_nbytes) >> GBYTES_SHIFT) #endif #ifndef GBYTES_2_BYTES -#define GBYTES_2_BYTES(_nbytes) ((uint64)(_nbytes) << 30) +#define GBYTES_2_BYTES(_nGbytes) ((uint64)(_nGbytes) << GBYTES_SHIFT) #endif #ifndef VM_PAE_LARGE_PAGE_SHIFT @@ -591,6 +615,13 @@ #define DEBUG_ONLY(...) #endif +#if defined(VMX86_DEBUG) || defined(VMX86_ENABLE_SPLOCK_STATS) +#define LOCK_STATS_ON +#define LOCK_STATS_ONLY(...) __VA_ARGS__ +#else +#define LOCK_STATS_ONLY(...) +#endif + #ifdef VMX86_STATS #define vmx86_stats 1 #define STATS_ONLY(x) x @@ -655,6 +686,13 @@ #define VMKERNEL_ONLY(x) #endif +/* + * In MSVC, _WIN32 is defined as 1 when the compilation target is + * 32-bit ARM, 64-bit ARM, x86, or x64 (which implies _WIN64). This + * is documented in C/C++ preprocessor section of the Microsoft C++, + * C, and Assembler documentation (https://via.vmw.com/EchK). + */ + #ifdef _WIN32 #define WIN32_ONLY(x) x #define POSIX_ONLY(x) @@ -727,12 +765,6 @@ #define ULM_ONLY(x) #endif -#ifdef ULM_ESX_VMX -#define ulm_esx_vmx 1 -#else -#define ulm_esx_vmx 0 -#endif - #if defined(VMM) || defined(ULM) #define MONITOR_ONLY(x) x #else @@ -852,6 +884,11 @@ * wasted. On x86, GCC 6.3.0 behaves sub-optimally when variables are declared * on the stack using the aligned attribute, so this pattern is preferred. * See PRs 1795155, 1819963. + * + * GCC9 has been shown to exhibit aliasing issues when using + * '-fstrict-aliasing=2' that did not happen under GCC6 with this + * construct. + * See @9503890, PR 2906490. */ #define WITH_PTR_TO_ALIGNED_VAR(_type, _align, _var) \ do { \ @@ -888,4 +925,17 @@ #define VMW_CLANG_ANALYZER_NORETURN() ((void)0) #endif +/* VMW_FALLTHROUGH + * + * Instructs GCC 9 and above to not warn when a case label of a + * 'switch' statement falls through to the next label. + * + * If not GCC 9 or above, expands to nothing. + */ +#if __GNUC__ >= 9 +#define VMW_FALLTHROUGH() __attribute__((fallthrough)) +#else +#define VMW_FALLTHROUGH() +#endif + #endif // ifndef _VM_BASIC_DEFS_H_ diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_basic_types.h open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_basic_types.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_basic_types.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_basic_types.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2021 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2022 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 @@ -512,14 +512,7 @@ typedef uint64 PhysMemSize; typedef uint64 BA; -#ifdef VMKERNEL -typedef void *BPN; -#else typedef uint64 BPN; -#endif - -#define UINT64_2_BPN(u) ((BPN)(u)) -#define BPN_2_UINT64(b) ((uint64)(b)) typedef uint64 PageCnt; typedef uint64 PageNum; @@ -546,9 +539,6 @@ typedef User_CartelID User_CartelGroupID; #define INVALID_CARTELGROUP_ID INVALID_CARTEL_ID -typedef uint32 Worldlet_ID; -#define INVALID_WORLDLET_ID ((Worldlet_ID)-1) - typedef int8 Reg8; typedef int16 Reg16; typedef int32 Reg32; @@ -566,7 +556,7 @@ #if (defined(VMM) || defined(COREQUERY) || defined(EXTDECODER) || \ defined (VMKERNEL) || defined (VMKBOOT) || defined (ULM)) && \ - !defined (FROBOS) + !defined (FROBOS) || defined (VSAN_USERLEVEL) typedef Reg64 Reg; typedef UReg64 UReg; #endif @@ -669,12 +659,12 @@ #define MAX_MPN ((MPN)MPN38_MASK - 3) /* 50 bits of address space */ #define INVALID_IOPN ((IOPN)-1) -#define MAX_IOPN (INVALID_IOPN - 1) +#define MAX_IOPN (IOA_2_IOPN((IOA)-1)) #define INVALID_LPN ((LPN)-1) #define INVALID_VPN ((VPN)-1) #define INVALID_LPN64 ((LPN64)-1) -#define INVALID_PAGENUM ((PageNum)0x000000ffffffffffull) +#define INVALID_PAGENUM ((PageNum)0x0000003fffffffffull) #define INVALID_PAGENUM32 ((uint32)-1) /* @@ -775,11 +765,11 @@ #endif /* - * Similarly, we require a compiler that is at least vs2012. + * Similarly, we require a compiler that is at least vs2015. * Enforce this here. */ -#if defined _MSC_VER && _MSC_VER < 1700 -#error "cl.exe version is too old, need vs2012 or better" +#if defined _MSC_VER && _MSC_VER < 1900 +#error "cl.exe version is too old, need vs2015 or better" #endif diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/vmci_defs.h open-vm-tools-12.1.5/open-vm-tools/lib/include/vmci_defs.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/vmci_defs.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/vmci_defs.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2005-2019 VMware, Inc. All rights reserved. + * Copyright (C) 2005-2019,2021 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 @@ -39,15 +39,20 @@ #endif /* Register offsets. */ -#define VMCI_STATUS_ADDR 0x00 -#define VMCI_CONTROL_ADDR 0x04 -#define VMCI_ICR_ADDR 0x08 -#define VMCI_IMR_ADDR 0x0c -#define VMCI_DATA_OUT_ADDR 0x10 -#define VMCI_DATA_IN_ADDR 0x14 -#define VMCI_CAPS_ADDR 0x18 -#define VMCI_RESULT_LOW_ADDR 0x1c -#define VMCI_RESULT_HIGH_ADDR 0x20 +#define VMCI_STATUS_ADDR 0x00 +#define VMCI_CONTROL_ADDR 0x04 +#define VMCI_ICR_ADDR 0x08 +#define VMCI_IMR_ADDR 0x0c +#define VMCI_DATA_OUT_ADDR 0x10 +#define VMCI_DATA_IN_ADDR 0x14 +#define VMCI_CAPS_ADDR 0x18 +#define VMCI_RESULT_LOW_ADDR 0x1c +#define VMCI_RESULT_HIGH_ADDR 0x20 +#define VMCI_DATA_OUT_LOW_ADDR 0x24 +#define VMCI_DATA_OUT_HIGH_ADDR 0x28 +#define VMCI_DATA_IN_LOW_ADDR 0x2c +#define VMCI_DATA_IN_HIGH_ADDR 0x30 +#define VMCI_PAGE_SHIFT_ADDR 0x34 /* Max number of devices. */ #define VMCI_MAX_DEVICES 1 @@ -66,6 +71,7 @@ #define VMCI_CAPS_DATAGRAM 0x4 #define VMCI_CAPS_NOTIFICATIONS 0x8 #define VMCI_CAPS_PPN64 0x10 +#define VMCI_CAPS_DMA_DATAGRAM 0x20 #define VMCI_CAPS_CLEAR_TO_ACK (0x1 << 31) #define VMCI_CAPS_NOT_ACKED (VMCI_CAPS_HYPERCALL | VMCI_CAPS_GUESTCALL | \ @@ -74,10 +80,12 @@ /* Interrupt Cause register bits. */ #define VMCI_ICR_DATAGRAM 0x1 #define VMCI_ICR_NOTIFICATION 0x2 +#define VMCI_ICR_INOUT 0x4 /* Interrupt Mask register bits. */ #define VMCI_IMR_DATAGRAM 0x1 #define VMCI_IMR_NOTIFICATION 0x2 +#define VMCI_IMR_INOUT 0x4 /* Interrupt type. */ typedef enum VMCIIntrType { @@ -89,7 +97,9 @@ /* * Maximum MSI/MSI-X interrupt vectors in the device. */ -#define VMCI_MAX_INTRS 2 +#define VMCI_MAX_INTRS_NOTIFICATION 2 +#define VMCI_MAX_INTRS_INOUT 3 +#define VMCI_MAX_INTRS VMCI_MAX_INTRS_INOUT /* * Supported interrupt vectors. There is one for each ICR value above, @@ -97,6 +107,7 @@ */ #define VMCI_INTR_DATAGRAM 0 #define VMCI_INTR_NOTIFICATION 1 +#define VMCI_INTR_INOUT 2 /* @@ -465,7 +476,7 @@ * a line in a store, for example, you walk up to the tail. * * consumerHead: the point in the queue from which the next element is - * dequeued. In other words, who is next in line is he who is at the + * dequeued. In other words, the next in line is the one at the * head of the line. * * Also, producerTail points to an empty byte in the Queue, whereas @@ -931,6 +942,48 @@ typedef VMCIFilterList VMCIProtoFilters[VMCI_FP_MAX]; typedef VMCIProtoFilters VMCIFilters[VMCI_FD_MAX]; + +/* + * Common header for describing a buffer used for VMCI datagram + * send/receive using DMA. The header is placed in a single + * page buffer, and the address is presented to the device through + * the VMCI_DATA_OUT_LOW_ADDR/VMCI_DATA_OUT_HIGH_ADDR registers + * for send, and VMCI_DATA_IN_LOW_ADDR/VMCI_DATA_IN_HIGH_ADDR for + * receives. If opcode is 0, the header is followed immediately by + * the data area of the specified size in contiguous physical + * addresses. If opcode is 1, the header is followed by a series + * of scatter gather array elements (formatted as VMCISgElem) + * each describing contiguous physical buffers. The scatter gather + * array elements must all fit within the same page as the header. + * On send, the busy flag will be set by the guest when the buffer + * is ready for sending, and cleared by the device when the send + * is complete. On receive, the busy flag is cleared by the guest + * when the buffer is ready to receive new datagrams, and set by + * the device when the incoming datagrams have been copied to the + * buffer and are ready for guest consumption. + */ + +#define VMCI_DATA_IN_OUT_DATA_INLINE 0 +#define VMCI_DATA_IN_OUT_DATA_SG_ARRAY 1 + +typedef struct { + uint32 busy; + uint32 opcode; // 0: data follows header, 1: sg array follows header + uint32 size; // size of data or number of sg elements + uint32 rsvd; + uint64 result; // Result of a send datagram operation +} VMCIDataInOutHeader; + +/* + * Format of the the scatter gather element used by SG arrays following + * VMCIDataInOutHeader. + */ + +typedef struct { + uint64 addr; // guest physical address + uint64 size; // length of data +} VMCISgElem; + #if defined __cplusplus } // extern "C" #endif diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_device_version.h open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_device_version.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_device_version.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_device_version.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998,2005-2012,2014-2021 VMware, Inc. All rights reserved. + * Copyright (C) 1998,2005-2012,2014-2022 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 @@ -56,6 +56,7 @@ */ #define PCI_VENDOR_ID_VMWARE 0x15AD #define PCI_DEVICE_ID_VMWARE_SBX 0x0420 +#define PCI_DEVICE_ID_VMWARE_SVGA_EFI 0x0407 #define PCI_DEVICE_ID_VMWARE_SVGA3 0x0406 #define PCI_DEVICE_ID_VMWARE_SVGA2 0x0405 #define PCI_DEVICE_ID_VMWARE_SVGA 0x0710 @@ -255,10 +256,13 @@ /************* NVME implementation limits ********************************/ #define NVME_MAX_CONTROLLERS 4 #define NVME_MIN_NAMESPACES 1 -#define NVME_MAX_NAMESPACES 15 /* We support only 15 namespaces same - * as SCSI devices. +#define NVME_MAX_NAMESPACES 64 /* We support 64 namespaces same + * as PVSCSI controller. */ - +#define NVME_HW19_MAX_NAMESPACES 15 // HWv19 and before supports 15 namespaces +#define NVME_FUTURE_MAX_NAMESPACES 256 /* To support NVME to the possible 256 + * disks per controller in future. + */ /************* SCSI implementation limits ********************************/ #define SCSI_MAX_CONTROLLERS 4 // Need more than 1 for MSCS clustering #define SCSI_MAX_DEVICES 16 // BT-958 emulates only 16 @@ -275,26 +279,11 @@ #define AHCI_MAX_PORTS SATA_MAX_DEVICES /* - * Publicly supported maximum number of disks per VM. - */ -#define MAX_NUM_DISKS \ - ((SATA_MAX_CONTROLLERS * SATA_MAX_DEVICES) + \ - (SCSI_MAX_CONTROLLERS * SCSI_MAX_DEVICES) + \ - (NVME_MAX_CONTROLLERS * NVME_MAX_NAMESPACES) + \ - (IDE_NUM_INTERFACES * IDE_DRIVES_PER_IF)) - -/* - * Maximum number of supported disks in a VM from HWV14 or later, using PVSCSI updated max - * devices. The note above still holds true, but instead of publicly supporting - * all devices, HWv14 simply extends the maximum support to 256 devices, - * instead ~244 calculated above. - * - * PVSCSI_HW_MAX_DEVICES is 65 - allowing 64 disks + controller (at ID 7) - * 4 * 64 = 256 devices. - * + * Official limit for supported number of disks is 440 per VM. + * VM can have more disks (up to 636 as of now), but such VM is not + * supported (main reason being too long downtime during (s)vmotion). */ -#define MAX_NUM_DISKS_HWV14 MAX(MAX_NUM_DISKS, \ - (SCSI_MAX_CONTROLLERS * PVSCSI_MAX_NUM_DISKS)) +#define MAX_NUM_DISKS_SUPPORTED 440 /* * VSCSI_BV_INTS is the number of uint32's needed for a bit vector @@ -338,10 +327,10 @@ #define MAX_FLOPPY_DRIVES 2 /************* PCI Passthrough implementation limits ********************/ -#define MAX_PCI_PASSTHRU_DEVICES 16 +#define MAX_PCI_PASSTHRU_DEVICES 128 /************* Test device implementation limits ********************/ -#define MAX_PCI_TEST_DEVICES 16 +#define MAX_PCI_TEST_DEVICES 128 /************* VDTI PCI Device implementation limits ********************/ #define MAX_VDTI_PCI_DEVICES 16 diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_legal.h open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_legal.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_legal.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_legal.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2006-2020 VMware, Inc. All rights reserved. + * Copyright (C) 2006-2022 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 @@ -37,7 +37,7 @@ * Updating them therefore may require updating translations and vmsg * auditing files in bora/messages/ to avoid breaking the build. */ -#define COPYRIGHT_YEARS "1998-2021" /* See the note above when changing. */ +#define COPYRIGHT_YEARS "1998-2022" /* See the note above when changing. */ #define COPYRIGHT_STRING "Copyright (C) " COPYRIGHT_YEARS " " COMPANY_NAME #define RIGHT_RESERVED "All rights reserved." diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_product.h open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_product.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_product.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_product.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2006-2021 VMware, Inc. All rights reserved. + * Copyright (c) 2006-2022 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 @@ -196,6 +196,7 @@ #if !( defined(VMX86_ESXIO) \ || defined(VMX86_SERVER) \ + || defined(VMKBOOT) \ || defined(VMX86_DESKTOP) \ || defined(VMX86_HORIZON_VIEW) \ || defined(VMX86_VPX) \ @@ -227,6 +228,8 @@ # define PRODUCT_SHORT_NAME PRODUCT_ESXIO_NAME #elif defined(VMX86_SERVER) # define PRODUCT_SHORT_NAME PRODUCT_ESXI_NAME +#elif defined(VMKBOOT) +# define PRODUCT_SHORT_NAME PRODUCT_ESXI_NAME #elif defined(VMX86_VMRC) /* check VMX86_VMRC before VMX86_DESKTOP */ # define PRODUCT_SHORT_NAME PRODUCT_VMRC_NAME #elif defined(VMX86_TOOLS) diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_product_versions.h open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_product_versions.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_product_versions.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_product_versions.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2021 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2022 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 @@ -19,6 +19,42 @@ #define VM_PRODUCT_VERSIONS_H /* + * + * This file contains sections delineated by marker tags like MARKER_XXX_... + * These tags are used to generate vm_product_versions_fast.h, which is a + * version header that enables faster compiles. + * + * When BUILD_NUMBER and similar macros are defined as numbers, builds become + * slow as the consumer can't be cached (the crypto-hash for the C compiler's + * inputs changes each build). For cases where that is still necessary, + * vm_product_versions_slow.h can be used. Note: the fast headers require + * linking to bora/lib/version. + * + * to avoid multiple copy of similar header, xx_fast.h code is generated from + * this file using these marker tag. + * + */ + +//MARKER_FAST_UNCOMMENT_START +//#ifdef __cplusplus +//extern "C" { +//#endif +// +//extern unsigned int gProductVersion[]; +//extern unsigned int gVieFileVersion[]; +//extern unsigned int gVpxVersionNumeric[]; +//extern unsigned int gNetdumpFileVersion[]; +//extern unsigned int gFoundryFileVersion[]; +// +//extern unsigned int gOvftoolFileVersion[]; +//extern const char gEsxReleaseVersionString[]; +// +//#ifdef __cplusplus +//} +//#endif +//MARKER_FAST_UNCOMMENT_END + +/* * NOTE: Some of the macro expansions in this file require information * from the generated file, 'buildNumber.h'. For those * expansions, and for those expansions only, you must include @@ -33,6 +69,8 @@ * version. Otherwise we use a hard-coded value for Workstation and a different * hard-coded value for every other product. */ + +//MARKER_FAST_REMOVE_START #if defined(VMX86_VMRC) /* check VMX86_VMRC before VMX86_DESKTOP */ #define PRODUCT_VERSION 12,1,0,PRODUCT_BUILD_NUMBER_NUMERIC /* VMRC_VERSION_NUMBER below has to match this */ #elif defined(VMX86_FLEX) /* check VMX86_FLEX before VMX86_DESKTOP */ @@ -43,9 +81,9 @@ #define PRODUCT_VERSION 1,1,5,PRODUCT_BUILD_NUMBER_NUMERIC #elif defined(VMX86_VPX) /* this should be kept in sync with the corresponding vpx branch. */ - #define PRODUCT_VERSION 7,0,3,PRODUCT_BUILD_NUMBER_NUMERIC + #define PRODUCT_VERSION 8,0,0,PRODUCT_BUILD_NUMBER_NUMERIC #elif defined(VMX86_HORIZON_VIEW) - #define PRODUCT_VERSION 8,4,0,PRODUCT_BUILD_NUMBER_NUMERIC + #define PRODUCT_VERSION 8,7,0,PRODUCT_BUILD_NUMBER_NUMERIC // VMX86_DESKTOP must be last because it is the default and is always defined. #elif defined(VMX86_DESKTOP) // WORKSTATION_VERSION_NUMBER below has to match this @@ -58,6 +96,10 @@ /* Generic catch-all. */ #define PRODUCT_VERSION 0,0,0,PRODUCT_BUILD_NUMBER_NUMERIC #endif +//MARKER_FAST_REMOVE_END +//MARKER_FAST_UNCOMMENT_START +//#define PRODUCT_VERSION gProductVersion +//MARKER_FAST_UNCOMMENT_END /* * The VIE components are shared by different products and may be updated by newer @@ -83,7 +125,12 @@ * VMI 2.0 : 3.1.0 * P2VA 3.0 : 3.?.? */ +//MARKER_FAST_REMOVE_START #define VIE_FILEVERSION 6,5,0,PRODUCT_BUILD_NUMBER_NUMERIC +//MARKER_FAST_REMOVE_END +//MARKER_FAST_UNCOMMENT_START +//#define VIE_FILEVERSION gVieFileVersion +//MARKER_FAST_UNCOMMENT_END /* * This string can be a little more "free form". The license @@ -135,9 +182,9 @@ * 7.0.1-3.4: Patch 3 / quarterly release 3 * 7.0.2-5.5: Update 2 / quarterly release 5 */ -#define ESX_VERSION_MAJOR "7" +#define ESX_VERSION_MAJOR "8" #define ESX_VERSION_MINOR "0" -#define ESX_VERSION_MAINT "3" // 0 = Pre-release/GA, 1 = Update 1 +#define ESX_VERSION_MAINT "0" // 0 = Pre-release/GA, 1 = Update 1 #define ESX_VERSION_UPDATE ESX_VERSION_MAINT // ESX's own update level #define ESX_VERSION ESX_VERSION_MAJOR "." ESX_VERSION_MINOR "." \ @@ -145,11 +192,21 @@ #define ESX_VERSION_THIRD_PARTY ESX_VERSION_MAJOR ESX_VERSION_MINOR \ ESX_VERSION_UPDATE -#define ESX_RELEASE_UPDATE "0" // Quarterly release +#define ESX_RELEASE_UPDATE "1" // Quarterly release #define ESX_RELEASE_PATCH "0" // 0 = experimental #define ESX_RELEASE_QUARTERLY ESX_RELEASE_UPDATE // ESX's own quarterly release #define ESX_RELEASE ESX_RELEASE_QUARTERLY "." ESX_RELEASE_PATCH +// ESX release versioning string - +// ..-.. +//MARKER_FAST_REMOVE_START +#define ESX_RELEASE_VERSION_STR ESX_VERSION "-" ESX_RELEASE "." \ + XSTR(BUILD_NUMBER_NUMERIC) +//MARKER_FAST_REMOVE_END +//MARKER_FAST_UNCOMMENT_START +//#define ESX_RELEASE_VERSION_STR gEsxReleaseVersionString +//MARKER_FAST_UNCOMMENT_END + #define WORKSTATION_RELEASE_DESCRIPTION "" #define P2V_VERSION "e.x.p" #define P2V_FILE_VERSION 3,0,0,0 @@ -157,8 +214,6 @@ /* * HEADS UP: Don't merge patch version bumps (e.g. x.y.0 -> x.y.1) to CBS * branches (*-main), 'cuz it breaks stuff in VIX land. See bug 939456. - * - * Whenever WORKSTATION_VERSION_NUMBER and PLAYER_VERSION_NUMBER are changed, * necessary VIX changes also need to be done. See bug 939456. * * ALSO, leave FOO_VERSION at e.x.p on all EXCEPT release branches. @@ -184,7 +239,7 @@ */ #define FUSION_VERSION "e.x.p" -#define VIM_VERSION "7.0.3" +#define VIM_VERSION "8.0.0" /* *For smooth version bump up for quaterly releases, we need to have a fallback *mechanism to previous version in all those components which perform version @@ -214,28 +269,33 @@ 6.0.0,\ 6.5.0" // Put VPX_VERSION first, because vpx/make/defs.mk doesn't check for suffix. -#define VPX_VERSION "7.0.3" -#define VPX_VERSION_MAJOR "7" +#define VPX_VERSION "8.0.0" +#define VPX_VERSION_MAJOR "8" #define VPX_VERSION_MINOR "0" -#define VPX_VERSION_MAINT "3" -#define VPX_VERSION_PATCH "00000" +#define VPX_VERSION_MAINT "0" +#define VPX_VERSION_PATCH "10000" #define VPX_VERSION_THIRD_PARTY VPX_VERSION_MAJOR VPX_VERSION_MINOR \ VPX_VERSION_MAINT -#define VPX_VERSION_NUMERIC 7,0,3,PRODUCT_BUILD_NUMBER_NUMERIC +//MARKER_FAST_REMOVE_START +#define VPX_VERSION_NUMERIC 8,0,0,PRODUCT_BUILD_NUMBER_NUMERIC +//MARKER_FAST_REMOVE_END +//MARKER_FAST_UNCOMMENT_START +//#define VPX_VERSION_NUMERIC gVpxVersionNumeric +//MARKER_FAST_UNCOMMENT_END // Last supported ESX version by VC. -#define VPX_MIN_HOST_VERSION "6.5.0" +#define VPX_MIN_HOST_VERSION "6.7.0" #define MAX_SUPPORTED_VI_VERSION "6.6" //from ovfTool/src/supportedVersions.h -#define VCDB_CURRENT_SCHEMA_VERSION 703 // from PitCADatabase.h +#define VCDB_CURRENT_SCHEMA_VERSION 800 // from PitCADatabase.h #define VPX_RELEASE_UPDATE "0" /* 0 = Pre-release/GA, 1 = Update 1 */ #define VPX_RELEASE_PATCH "0" /* 0 = experimental */ #define VPX_RELEASE VPX_RELEASE_UPDATE "." VPX_RELEASE_PATCH /* expected database version for current release */ -#define VPXD_VDB_DB_VERSION_ID 703 -#define VPXD_VDB_DB_VERSION_VALUE "VirtualCenter Database 7.0" +#define VPXD_VDB_DB_VERSION_ID 800 +#define VPXD_VDB_DB_VERSION_VALUE "VirtualCenter Database 8.0" /* * OSM Release Version for OSS/TP usage tracking and ticket filing @@ -249,31 +309,59 @@ // Changing the version is required when CPD releases an update. #define VA_PATCH_VERSION "5100" -#define HORIZONOSOT_VERSION "1.3.0" +#define HORIZONOSOT_VERSION "1.1.2204" #define HORIZONVMDS_VERSION "1.0.0" -#define INTEGRITY_VERSION "7.0.3" /* Should use VPX_VERSION? */ +#define INTEGRITY_VERSION "8.0.0" /* Should use VPX_VERSION? */ #define SVA_VERSION "1.0.0" #define SSO_VERSION "1.0.0" #define SDK_VERSION "4.1.0" #define FOUNDRY_VERSION "1.17.0" + +//MARKER_FAST_REMOVE_START #define FOUNDRY_FILE_VERSION 1,17,0,PRODUCT_BUILD_NUMBER_NUMERIC +//MARKER_FAST_REMOVE_END +//MARKER_FAST_UNCOMMENT_START +//#define FOUNDRY_FILE_VERSION gFoundryFileVersion +//MARKER_FAST_UNCOMMENT_END + #define VLICENSE_VERSION "1.1.5" #define DDK_VERSION "e.x.p" #define VIPERL_VERSION "7.0.0" #define RCLI_VERSION "7.0.0" #define VDM_VERSION "e.x.p" #define NETDUMP_VERSION "5.1.0" + +//MARKER_FAST_REMOVE_START #define NETDUMP_FILE_VERSION 5,1,0,PRODUCT_BUILD_NUMBER_NUMERIC -#define VDDK_VERSION "7.0.3" -#define VDDK_VERSION_MAJOR 7 +//MARKER_FAST_REMOVE_END +//MARKER_FAST_UNCOMMENT_START +//#define NETDUMP_FILE_VERSION gNetdumpFileVersion +//MARKER_FAST_UNCOMMENT_END + +#define VDDK_VERSION "8.0.0" +#define VDDK_VERSION_MAJOR 8 #define VDDK_VERSION_MINOR 0 -#define VDDK_VERSION_MAINT 3 +#define VDDK_VERSION_MAINT 0 + +//MARKER_FAST_REMOVE_START #define VDDK_FILE_VERSION VDDK_VERSION_MAJOR,VDDK_VERSION_MINOR,\ VDDK_VERSION_MAINT,PRODUCT_BUILD_NUMBER_NUMERIC -#define OVFTOOL_VERSION "4.4.2" +//MARKER_FAST_REMOVE_END +//MARKER_FAST_UNCOMMENT_START +//#define VDDK_FILE_VERSION gVddkFileVersion +//MARKER_FAST_UNCOMMENT_END + +#define OVFTOOL_VERSION "4.5.0" #define VCSA_INSTALLER_VERSION "1.0.0" -#define OVFTOOL_FILE_VERSION 4,4,1,PRODUCT_BUILD_NUMBER_NUMERIC + +//MARKER_FAST_REMOVE_START +#define OVFTOOL_FILE_VERSION 4,5,0,PRODUCT_BUILD_NUMBER_NUMERIC +//MARKER_FAST_REMOVE_END +//MARKER_FAST_UNCOMMENT_START +//#define OVFTOOL_FILE_VERSION gOvftoolFileVersion +//MARKER_FAST_UNCOMMENT_END + #define VGAUTH_VERSION "1.0.0" #define COMMON_AGENT_VERSION "e.x.p" #define VIEWY_VERSION "e.x.p" @@ -284,7 +372,7 @@ #define PRECHECK_VERSION "e.x.p" #define VHSESDK_VERSION "1.0.0" #define VIEWVC_VERSION "14.0.2" -#define WCP_VERSION "0.0.10" +#define WCP_VERSION "0.0.17" #define VSTATS_VERSION "0.0.1" #define XVP_VERSION "1.0.0" /* @@ -293,24 +381,27 @@ * SCons parsing code requires that each line have a version string, so we * can't just do something like #define RDESDK_VERSION VIEW_VERSION" */ -#define VIEW_CLIENT_VERSION "8.4.0" +#define VIEW_CLIENT_VERSION "8.7.0" #define VIEW_CLIENT_VERSION_NUMBER VIEW_CLIENT_VERSION -#define VIEW_VERSION "8.4.0" -#define RDE_RFT_ALL_VERSION "8.4.0" -#define RDE_RFT_REL_VERSION "8.4.0" -#define RDESDKREL_VERSION "8.4.0" -#define MKSVCHANDEV_VERSION "15.4.0" -#define TSMMRDEV_VERSION "8.4.0" -#define RDF_VERSION "8.4.0" -#define HORIZON_DAAS_AGENT_VERSION "21.3.0" -#define HORIZON_USB_AGENT_VERSION "11.4.0" -#define MFW_VERSION "16.4.0" +#define VIEW_VERSION "8.7.0" +#define RDE_RFT_ALL_VERSION "8.7.0" +#define RDE_RFT_REL_VERSION "8.7.0" +#define RDESDKREL_VERSION "8.7.0" +#define MKSVCHANDEV_VERSION "15.7.0" +#define TSMMRDEV_VERSION "8.7.0" +#define RDF_VERSION "8.7.0" +#define HORIZON_DAAS_AGENT_VERSION "22.3.0" +#define HORIZON_USB_AGENT_VERSION "11.7.0" +#define HORIZON_UPDATETOOL_VERSION "2.0.7" +#define MFW_VERSION "16.7.0" +#define INPUTDEVTAP_VERSION "16.7.0" + /* * This is the Horizon Marketing version which is shared between * Horizon Client, Agent and Server. It is set in the format of * YYMM of the targeted release date. */ -#define HORIZON_YYMM_VERSION "2109" +#define HORIZON_YYMM_VERSION "2209" #ifndef MAKESTR #define MAKESTR(x) #x @@ -391,8 +482,19 @@ * not needed in the string. */ +//MARKER_FAST_REMOVE_START #define PRODUCT_VERSION_STRING PRODUCT_VERSION_NUMBER " " BUILD_NUMBER - +//MARKER_FAST_REMOVE_END +//MARKER_FAST_UNCOMMENT_START +//#ifdef __cplusplus +//extern "C" { +//#endif +//extern const char gProductVersionString[]; +//#ifdef __cplusplus +//} +//#endif +//#define PRODUCT_VERSION_STRING gProductVersionString +//MARKER_FAST_UNCOMMENT_END /* * The license manager requires that PRODUCT_VERSION_STRING matches the * following pattern: [.][.]. @@ -419,14 +521,14 @@ # define PRODUCT_LICENSE_VERSION "0.0" #else # if defined(VMX86_SERVER) -# define PRODUCT_LICENSE_VERSION "7.0" +# define PRODUCT_LICENSE_VERSION "8.0" # elif defined(VMX86_VMRC) /* check VMX86_VMRC before VMX86_DESKTOP */ # define PRODUCT_LICENSE_VERSION PRODUCT_VMRC_VERSION_STRING_FOR_LICENSE # elif defined(VMX86_FLEX) /* check VMX86_FLEX before VMX86_DESKTOP */ # define PRODUCT_LICENSE_VERSION PRODUCT_FLEX_VERSION_STRING_FOR_LICENSE # elif defined(VMX86_VPX) -# define PRODUCT_LICENSE_VERSION "7.0" -# define PRODUCT_LICENSE_FILE_VERSION "7.0.5.0" +# define PRODUCT_LICENSE_VERSION "8.0" +# define PRODUCT_LICENSE_FILE_VERSION "8.0.1.1" # elif defined(VMX86_SDK) # define PRODUCT_LICENSE_VERSION "1.0" # elif defined(VMX86_P2V) @@ -443,8 +545,8 @@ # endif # define PRODUCT_VERSION_STRING_FOR_LICENSE PRODUCT_LICENSE_VERSION #endif -#define PRODUCT_ESX_LICENSE_VERSION "7.0" -#define PRODUCT_ESX_LICENSE_FILE_VERSION "7.0.5.0" +#define PRODUCT_ESX_LICENSE_VERSION "8.0" +#define PRODUCT_ESX_LICENSE_FILE_VERSION "8.0.1.1" /* * The configuration file version string should be changed @@ -517,6 +619,7 @@ #define PRODUCT_VERSION_WORKSTATION_140 PRODUCT_WORKSTATION_BRIEF_NAME " 14.x" #define PRODUCT_VERSION_WORKSTATION_150 PRODUCT_WORKSTATION_BRIEF_NAME " 15.x" #define PRODUCT_VERSION_WORKSTATION_160 PRODUCT_WORKSTATION_BRIEF_NAME " 16.x" +#define PRODUCT_VERSION_WORKSTATION_162 PRODUCT_WORKSTATION_BRIEF_NAME " 16.2.x" #define PRODUCT_VERSION_PLAYER_1 PRODUCT_PLAYER_BRIEF_NAME " 1.x" #define PRODUCT_VERSION_MAC_DESKTOP_1 PRODUCT_MAC_DESKTOP_BRIEF_NAME " 1.1" #define PRODUCT_VERSION_MAC_DESKTOP_2 PRODUCT_MAC_DESKTOP_BRIEF_NAME " 2.x" @@ -530,6 +633,7 @@ #define PRODUCT_VERSION_MAC_DESKTOP_100 PRODUCT_MAC_DESKTOP_BRIEF_NAME " 10.x" #define PRODUCT_VERSION_MAC_DESKTOP_110 PRODUCT_MAC_DESKTOP_BRIEF_NAME " 11.x" #define PRODUCT_VERSION_MAC_DESKTOP_120 PRODUCT_MAC_DESKTOP_BRIEF_NAME " 12.x" +#define PRODUCT_VERSION_MAC_DESKTOP_122 PRODUCT_MAC_DESKTOP_BRIEF_NAME " 12.2.x" /* * VDFS Versions diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_tools_version.h open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_tools_version.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_tools_version.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_tools_version.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2021 VMware, Inc. All rights reserved. + * Copyright (c) 1998-2022 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 @@ -1590,6 +1590,13 @@ #define TOOLS_VERSION_JACKHAMMER_PATCH11_V_BASE 24 #ifndef RC_INVOKED +#define TOOLS_VERSION_JACKHAMMER_PATCH12 TOOLS_VERSION_TO_UINT(TOOLS_VERSION_JACKHAMMER_PATCH12_V) +#endif /* RC_INVOKED */ +#define TOOLS_VERSION_JACKHAMMER_PATCH12_V_MJR 10 +#define TOOLS_VERSION_JACKHAMMER_PATCH12_V_MNR 3 +#define TOOLS_VERSION_JACKHAMMER_PATCH12_V_BASE 25 + +#ifndef RC_INVOKED #define TOOLS_VERSION_SLEDGEHAMMER_RELEASE TOOLS_VERSION_TO_UINT(TOOLS_VERSION_SLEDGEHAMMER_RELEASE_V) #endif /* RC_INVOKED */ #define TOOLS_VERSION_SLEDGEHAMMER_RELEASE_V_MJR 11 @@ -1687,10 +1694,37 @@ #define TOOLS_VERSION_JIGSAW_UPDATE1_V_MNR 3 #define TOOLS_VERSION_JIGSAW_UPDATE1_V_BASE 5 +#ifndef RC_INVOKED +#define TOOLS_VERSION_SABRE_SAW_RELEASE TOOLS_VERSION_TO_UINT(TOOLS_VERSION_SABRE_SAW_RELEASE_V) +#endif /* RC_INVOKED */ +#define TOOLS_VERSION_SABRE_SAW_RELEASE_V_MJR 12 +#define TOOLS_VERSION_SABRE_SAW_RELEASE_V_MNR 0 +#define TOOLS_VERSION_SABRE_SAW_RELEASE_V_BASE 0 + +#ifndef RC_INVOKED +#define TOOLS_VERSION_SABRE_SAW_UPDATE1 TOOLS_VERSION_TO_UINT(TOOLS_VERSION_SABRE_SAW_UPDATE1_V) +#endif /* RC_INVOKED */ +#define TOOLS_VERSION_SABRE_SAW_UPDATE1_V_MJR 12 +#define TOOLS_VERSION_SABRE_SAW_UPDATE1_V_MNR 0 +#define TOOLS_VERSION_SABRE_SAW_UPDATE1_V_BASE 5 + +#ifndef RC_INVOKED +#define TOOLS_VERSION_MITER_SAW_RELEASE TOOLS_VERSION_TO_UINT(TOOLS_VERSION_MITER_SAW_RELEASE_V) +#endif /* RC_INVOKED */ +#define TOOLS_VERSION_MITER_SAW_RELEASE_V_MJR 12 +#define TOOLS_VERSION_MITER_SAW_RELEASE_V_MNR 1 +#define TOOLS_VERSION_MITER_SAW_RELEASE_V_BASE 0 + +#ifndef RC_INVOKED +#define TOOLS_VERSION_MITER_SAW_UPDATE1 TOOLS_VERSION_TO_UINT(TOOLS_VERSION_MITER_SAW_UPDATE1_V) +#endif /* RC_INVOKED */ +#define TOOLS_VERSION_MITER_SAW_UPDATE1_V_MJR 12 +#define TOOLS_VERSION_MITER_SAW_UPDATE1_V_MNR 1 +#define TOOLS_VERSION_MITER_SAW_UPDATE1_V_BASE 5 -#define TOOLS_VERSION_CURRENT TOOLS_VERSION_JIGSAW_UPDATE1 -#define TOOLS_VERSION_CURRENT_STR TOOLS_VERSION_TO_STR(TOOLS_VERSION_JIGSAW_UPDATE1) -#define TOOLS_VERSION_CURRENT_CSV TOOLS_VERSION_TO_CSV(TOOLS_VERSION_JIGSAW_UPDATE1) +#define TOOLS_VERSION_CURRENT TOOLS_VERSION_MITER_SAW_UPDATE1 +#define TOOLS_VERSION_CURRENT_STR TOOLS_VERSION_TO_STR(TOOLS_VERSION_MITER_SAW_UPDATE1) +#define TOOLS_VERSION_CURRENT_CSV TOOLS_VERSION_TO_CSV(TOOLS_VERSION_MITER_SAW_UPDATE1) /* * The extended Tools version is the current Tools version with the diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_valgrind.h open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_valgrind.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_valgrind.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_valgrind.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2014 VMware, Inc. All rights reserved. + * Copyright (C) 2014, 2021-2022 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 @@ -55,12 +55,24 @@ */ #define RUNNING_ON_VALGRIND 0 -#define VALGRIND_CHECK_VALUE_IS_DEFINED(__lvalue) 0 -#define VALGRIND_CHECK_MEM_IS_ADDRESSABLE(_qzz_addr, _qzz_len) 0 -#define VALGRIND_CHECK_MEM_IS_DEFINED(_qzz_addr, _qzz_len) 0 -#define VALGRIND_MAKE_MEM_DEFINED(_qzz_addr, _qzz_len) 0 -#define VALGRIND_MAKE_MEM_UNDEFINED(_qzz_addr, _qzz_len) 0 +#define VALGRIND_CHECK_VALUE_IS_DEFINED(__lvalue) (void)0 +#define VALGRIND_CHECK_MEM_IS_ADDRESSABLE(_qzz_addr, _qzz_len) (void)0 +#define VALGRIND_CHECK_MEM_IS_DEFINED(_qzz_addr, _qzz_len) (void)0 +#define VALGRIND_MAKE_MEM_NOACCESS(_qzz_addr, _qzz_len) (void)0 +#define VALGRIND_MAKE_MEM_DEFINED(_qzz_addr, _qzz_len) (void)0 +#define VALGRIND_MAKE_MEM_UNDEFINED(_qzz_addr, _qzz_len) (void)0 #endif +/* + * VALGRIND_SPEED_FACTOR is an approximation of how much Valgrind's + * instrumentation is likely to slow down execution. It is a _very_ rough + * guess because the actual slowdown will depend on the nature of the code + * being executed, but regardless this is a handy macro for adjusting (by + * multiplying or dividing) times or loop counts or anything else impacted by + * Valgrind's instrumentation overhead. + */ + +#define VALGRIND_SPEED_FACTOR (RUNNING_ON_VALGRIND ? 100 : 1) + #endif /* _VM_VALGRIND_H_ */ diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_version.h open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_version.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/vm_version.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/vm_version.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2019 VMware, Inc. All rights reserved. + * Copyright (c) 1998-2019,2022 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 @@ -21,6 +21,26 @@ * stored in 'buildNumber.h' is needed. */ +/* + * + * This file contain some of the code wrapped around marker tag like + * MARKER_XXX_START / MARKER_XXX_END + * + * code section wrapped around these marker tag are getting processed in + * bora/scons/modules/buildnum.sc to generate xx_fast.h header. these generated + * header which is free from MACROS e.g. BUILD_NUMBER + * + * These MACROS are changing with every build and causing the file content + * change. Eventually with every build the hash code of these headers and + * source file including these headers changed. Due to this reason file are not + * cacheable by build (both SCons/Bazel) and end up building them again and + * again in place of downloading their build artifact from cache. + * + * to avoid multiple copy of similar header, xx_fast.h code is generated from + * this file using these marker tag. + * + */ + #ifndef VM_VERSION_H #define VM_VERSION_H @@ -33,9 +53,11 @@ #define INCLUDE_ALLOW_VMCORE #include "includeCheck.h" #include "vm_product.h" +//MARKER_FAST_REMOVE_START #if defined(VMX86_TOOLS) || defined(VMX86_SYSIMAGE) #include "vm_tools_version.h" #endif +//MARKER_FAST_REMOVE_END #include "vm_vmx_type.h" #include "vm_compilation_options.h" @@ -44,16 +66,29 @@ * the build number defined by the BUILD_NUMBER and PRODUCT_BUILD_NUMBER * variables at the beginning of every build. */ +//MARKER_FAST_REMOVE_START #include "buildNumber.h" - +//MARKER_FAST_REMOVE_END +//MARKER_FAST_UNCOMMENT_START +//#include "buildNumberFast.h" +//MARKER_FAST_UNCOMMENT_END /* * This is used so we can identify the build and release type * in any generated core files. */ +//MARKER_FAST_UNCOMMENT_START +//#define BUILD_VERSION gBuildVersion +//MARKER_FAST_UNCOMMENT_END +//MARKER_FAST_REMOVE_START #define BUILD_VERSION COMPILATION_OPTION BUILD_NUMBER +//MARKER_FAST_REMOVE_END - +//MARKER_FAST_REMOVE_START #include "vm_product_versions.h" +//MARKER_FAST_REMOVE_END +//MARKER_FAST_UNCOMMENT_START +//#include "vm_product_versions_fast.h" +//MARKER_FAST_UNCOMMENT_END #endif /* VM_VERSION_H */ diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/vmware/guestrpc/containerInfo.h open-vm-tools-12.1.5/open-vm-tools/lib/include/vmware/guestrpc/containerInfo.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/vmware/guestrpc/containerInfo.h 1970-01-01 00:00:00.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/vmware/guestrpc/containerInfo.h 2022-11-29 21:17:22.000000000 +0000 @@ -0,0 +1,58 @@ +/********************************************************* + * Copyright (C) 2021 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 + * by the Free Software Foundation version 2.1 and no later version. + * + * 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 Lesser GNU General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + *********************************************************/ + +#ifndef _CONTAINERINFO_H_ +#define _CONTAINERINFO_H_ + +/** + * @file containerInfo.h + * + * Common declarations that aid in sending container information + * from 'containerInfo' plugin in 'VMware Tools' to the host. + */ + +/* + Sample JSON published to the guestinfo variable. + $ vmtoolsd --cmd "info-get guestinfo.vmtools.containerInfo" | jq + { + "version": "1", + "updateCounter": "11", + "publishTime": "2021-10-27T18:18:00.855Z", + "containerinfo": { + "k8s.io": [ + { + "i": "k8s.gcr.io/pause" + } + ] + } +} +*/ + +/* clang-format off */ + +#define CONTAINERINFO_KEY "containerinfo" +#define CONTAINERINFO_GUESTVAR_KEY "vmtools." CONTAINERINFO_KEY +#define CONTAINERINFO_VERSION_1 1 +#define CONTAINERINFO_KEY_VERSION "version" +#define CONTAINERINFO_KEY_UPDATE_COUNTER "updateCounter" +#define CONTAINERINFO_KEY_PUBLISHTIME "publishTime" +#define CONTAINERINFO_KEY_IMAGE "i" + +/* clang-format on */ + +#endif \ No newline at end of file diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/vmware/guestrpc/serviceDiscovery.h open-vm-tools-12.1.5/open-vm-tools/lib/include/vmware/guestrpc/serviceDiscovery.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/vmware/guestrpc/serviceDiscovery.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/vmware/guestrpc/serviceDiscovery.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2020 VMware, Inc. All rights reserved. + * Copyright (c) 2020-2021 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 @@ -38,6 +38,7 @@ */ #define SERVICE_DISCOVERY_KEY_READY "ready" #define SERVICE_DISCOVERY_KEY_SIGNAL "signal" +#define SERVICE_DISCOVERY_KEY_GDP_SIGNAL "gdp-signal" /* * keys for types of service data collected by plugin. @@ -54,5 +55,6 @@ #define SERVICE_DISCOVERY_WIN_KEY_RELATIONSHIP "pid-to-ppid" #define SERVICE_DISCOVERY_WIN_KEY_NET "net" #define SERVICE_DISCOVERY_WIN_KEY_IIS_PORTS "iis-ports-info" +#define SERVICE_DISCOVERY_WIN_KEY_SHAREPOINT_PORTS "sharepoint-ports-info" #endif /* _SERVICEDISCOVERY_H_ */ diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/vmware/guestrpc/timesync.h open-vm-tools-12.1.5/open-vm-tools/lib/include/vmware/guestrpc/timesync.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/vmware/guestrpc/timesync.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/vmware/guestrpc/timesync.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2009-2019 VMware, Inc. All rights reserved. + * Copyright (C) 2009-2019,2022 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 @@ -44,7 +44,9 @@ #define TOOLSOPTION_SYNCTIME_GUEST_RESYNC_TIMEOUT \ "time.synchronize.guest.resync.timeout" -#define TIMESYNC_SYNCHRONIZE "Time_Synchronize" +#define TIMESYNC_SYNCHRONIZE "Time_Synchronize" +#define TIMEINFO_UPDATE "TimeInfo_Update" + #endif /* _TIMESYNC_H_ */ diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/vmware/tools/log.h open-vm-tools-12.1.5/open-vm-tools/lib/include/vmware/tools/log.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/vmware/tools/log.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/vmware/tools/log.h 2022-11-29 21:17:22.000000000 +0000 @@ -139,6 +139,7 @@ #include #include "vmware/tools/guestrpc.h" +#include "vm_basic_types.h" #if defined(__GNUC__) # define FUNC __func__ @@ -355,6 +356,12 @@ const gchar *fmt, ...); +void +VMTools_VmxLogThrottled(uint32 *count, + RpcChannel *chan, + const gchar *fmt, + ...); + G_END_DECLS #define host_warning(fmt, ...) \ diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/vthreadBase.h open-vm-tools-12.1.5/open-vm-tools/lib/include/vthreadBase.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/vthreadBase.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/vthreadBase.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2006-2017 VMware, Inc. All rights reserved. + * Copyright (C) 2006-2021 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 @@ -38,10 +38,6 @@ #if !defined VMM -#if !defined WIN32 -#include -#endif - /* * Most major OSes now support __thread, so begin making TLS access via * __thread the common case. If VMW_HAVE_TLS is defined, __thread may diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/x86_basic_defs.h open-vm-tools-12.1.5/open-vm-tools/lib/include/x86_basic_defs.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/x86_basic_defs.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/x86_basic_defs.h 2022-11-29 21:17:22.000000000 +0000 @@ -75,7 +75,9 @@ #define CR3_PDB_MASK 0xfffff000 #define CR3_IGNORE 0xFFF #define PAE_CR3_IGNORE 0x1F +#ifndef CR3_PCID_MASK #define CR3_PCID_MASK 0xFFF +#endif #define CR3_NO_FLUSH (1ULL << 63) #define CR4_VME 0x00000001 @@ -101,6 +103,7 @@ #define CR4_PKE 0x00400000 #define CR4_CET 0x00800000 #define CR4_PKS 0x01000000 +#define CR4_UINTR 0x02000000 #define CR4_RESERVED CONST64U(0xfffffffffe089000) #define CR8_RESERVED CONST64U(0xfffffffffffffff0) diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/include/x86cpuid.h open-vm-tools-12.1.5/open-vm-tools/lib/include/x86cpuid.h --- open-vm-tools-11.3.5/open-vm-tools/lib/include/x86cpuid.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/include/x86cpuid.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2021 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2022 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 @@ -112,7 +112,7 @@ #endif /* - * CPUID levels the monitor caches. + * Table of known CPUID levels. * * The first parameter defines whether the level has its default masks * generated from the values in this file. Any level which is marked as FALSE @@ -134,14 +134,14 @@ */ /* MASKS, LVL, VAL, CNT, HWV */ -#define CPUID_CACHED_LEVELS \ +#define CPUID_KNOWN_LEVELS \ CPUIDLEVEL(TRUE, 0, 0x0, 0, 0) \ CPUIDLEVEL(TRUE, 1, 0x1, 0, 0) \ CPUIDLEVEL(FALSE, 2, 0x2, 0, 0) \ CPUIDLEVEL(FALSE, 4, 0x4, 7, 0) \ CPUIDLEVEL(FALSE, 5, 0x5, 0, 0) \ CPUIDLEVEL(TRUE, 6, 0x6, 0, 0) \ - CPUIDLEVEL(TRUE, 7, 0x7, 2, 0) \ + CPUIDLEVEL(TRUE, 7, 0x7, 3, 0) \ CPUIDLEVEL(TRUE, 9, 0x9, 0, 17) \ CPUIDLEVEL(FALSE, A, 0xa, 0, 0) \ CPUIDLEVEL(FALSE, B, 0xb, 3, 0) \ @@ -162,6 +162,7 @@ CPUIDLEVEL(TRUE, 1E, 0x1e, 1, 19) \ CPUIDLEVEL(FALSE, 1F, 0x1f, 6, 17) \ CPUIDLEVEL(TRUE, 20, 0x20, 1, 20) \ + CPUIDLEVEL(TRUE , 21, 0x21, 1, 20) \ CPUIDLEVEL(FALSE, 400, 0x40000000, 0, 0) \ CPUIDLEVEL(FALSE, 401, 0x40000001, 0, 0) \ CPUIDLEVEL(FALSE, 402, 0x40000002, 0, 0) \ @@ -188,22 +189,23 @@ CPUIDLEVEL(FALSE, 81E, 0x8000001e, 0, 0) \ CPUIDLEVEL(TRUE, 81F, 0x8000001f, 0, 14) \ CPUIDLEVEL(TRUE, 820, 0x80000020, 2, 17) \ - CPUIDLEVEL(TRUE, 821, 0x80000021, 0, 17) + CPUIDLEVEL(TRUE, 821, 0x80000021, 0, 17) \ + CPUIDLEVEL(TRUE, 822, 0x80000022, 0, 20) \ + CPUIDLEVEL(TRUE, 823, 0x80000023, 0, 20) \ + CPUIDLEVEL(FALSE, 826, 0x80000026, 4, 20) -#define CPUID_ALL_LEVELS CPUID_CACHED_LEVELS - -/* Define cached CPUID levels in the form: CPUID_LEVEL_ */ +/* Define all CPUID levels in the form: CPUID_LEVEL_ */ typedef enum { #define CPUIDLEVEL(t, s, v, c, h) CPUID_LEVEL_##s, - CPUID_CACHED_LEVELS + CPUID_KNOWN_LEVELS #undef CPUIDLEVEL - CPUID_NUM_CACHED_LEVELS -} CpuidCachedLevel; + CPUID_NUM_KNOWN_LEVELS +} CpuidLevel; /* Enum to translate between shorthand name and actual CPUID level value. */ enum { #define CPUIDLEVEL(t, s, v, c, h) CPUID_LEVEL_VAL_##s = v, - CPUID_ALL_LEVELS + CPUID_KNOWN_LEVELS #undef CPUIDLEVEL }; @@ -214,6 +216,7 @@ #define CPUID_MWAIT_FEATURES 5 #define CPUID_PMC_FEATURES 0xa #define CPUID_XSAVE_FEATURES 0xd +#define CPUID_RDT_FEATURES 0x10 #define CPUID_SGX_FEATURES 0x12 #define CPUID_PT_FEATURES 0x14 #define CPUID_HYPERVISOR_LEVEL_0 0x40000000 @@ -244,24 +247,26 @@ #define CPUID_CYRIX_VENDOR_STRING "CyriteadxIns" #define CPUID_VIA_VENDOR_STRING "CentaulsaurH" #define CPUID_HYGON_VENDOR_STRING "HygouinenGen" +#define CPUID_INTEL_TDX_VENDOR_STRING "Inte lTDX" #define CPUID_HYPERV_HYPERVISOR_VENDOR_STRING "Microsoft Hv" #define CPUID_KVM_HYPERVISOR_VENDOR_STRING "KVMKVMKVM\0\0\0" #define CPUID_VMWARE_HYPERVISOR_VENDOR_STRING "VMwareVMware" #define CPUID_XEN_HYPERVISOR_VENDOR_STRING "XenVMMXenVMM" -#define CPUID_INTEL_VENDOR_STRING_FIXED "GenuineIntel" -#define CPUID_AMD_VENDOR_STRING_FIXED "AuthenticAMD" -#define CPUID_CYRIX_VENDOR_STRING_FIXED "CyrixInstead" -#define CPUID_VIA_VENDOR_STRING_FIXED "CentaurHauls" -#define CPUID_HYGON_VENDOR_STRING_FIXED "HygonGenuine" +#define CPUID_INTEL_VENDOR_STRING_FIXED "GenuineIntel" +#define CPUID_AMD_VENDOR_STRING_FIXED "AuthenticAMD" +#define CPUID_CYRIX_VENDOR_STRING_FIXED "CyrixInstead" +#define CPUID_VIA_VENDOR_STRING_FIXED "CentaurHauls" +#define CPUID_HYGON_VENDOR_STRING_FIXED "HygonGenuine" +#define CPUID_INTEL_TDX_VENDOR_STRING_FIXED "IntelTDX " /* * FIELD can be defined to process the CPUID information provided in the * following CPUID_FIELD_DATA macro. * * The first parameter is the CPUID level of the feature (must be defined in - * CPUID_ALL_LEVELS, above). + * CPUID_KNOWN_LEVELS, above). * * The second parameter is the CPUID sub-level (subleaf) of the feature. Please * make sure here the number is consistent with the "subleaf count" in @@ -364,7 +369,7 @@ FLAG( 1, 0, ECX, 0, 1, SSE3, YES, 4 ) \ FLAG( 1, 0, ECX, 1, 1, PCLMULQDQ, YES, 4 ) \ FLAG( 1, 0, ECX, 2, 1, DTES64, NO, 0 ) \ -FLAG( 1, 0, ECX, 3, 1, MWAIT, YES, 4 ) \ +FLAG( 1, 0, ECX, 3, 1, MWAIT, YES, 7 ) \ FLAG( 1, 0, ECX, 4, 1, DSCPL, NO, 0 ) \ FLAG( 1, 0, ECX, 5, 1, VMX, YES, 8 ) \ FLAG( 1, 0, ECX, 6, 1, SMX, YES, FUT ) \ @@ -509,7 +514,7 @@ FLAG( 7, 0, EBX, 1, 1, TSC_ADJUST, ANY, 11 ) \ FLAG( 7, 0, EBX, 2, 1, SGX, ANY, 17 ) \ FLAG( 7, 0, EBX, 3, 1, BMI1, YES, 9 ) \ -FLAG( 7, 0, EBX, 4, 1, HLE, YES, 11 ) \ +FLAG( 7, 0, EBX, 4, 1, HLE, ANY, 11 ) \ FLAG( 7, 0, EBX, 5, 1, AVX2, YES, 11 ) \ FLAG( 7, 0, EBX, 6, 1, FDP_EXCPTN_ONLY, ANY, 4 ) \ FLAG( 7, 0, EBX, 7, 1, SMEP, YES, 9 ) \ @@ -520,7 +525,7 @@ FLAG( 7, 0, EBX, 12, 1, PQM, NO, 0 ) \ FLAG( 7, 0, EBX, 13, 1, FP_SEGMENT_ZERO, ANY, 11 ) \ FLAG( 7, 0, EBX, 14, 1, MPX, ANY, 13 ) \ -FLAG( 7, 0, EBX, 15, 1, PQE, NO, 0 ) \ +FLAG( 7, 0, EBX, 15, 1, PQE, YES, 20 ) \ FLAG( 7, 0, EBX, 16, 1, AVX512F, YES, 13 ) \ FLAG( 7, 0, EBX, 17, 1, AVX512DQ, YES, 13 ) \ FLAG( 7, 0, EBX, 18, 1, RDSEED, YES, 11 ) \ @@ -541,9 +546,9 @@ FLAG( 7, 0, ECX, 2, 1, UMIP, YES, 17 ) \ FLAG( 7, 0, ECX, 3, 1, PKU, YES, 13 ) \ FLAG( 7, 0, ECX, 4, 1, OSPKE, ANY, 13 ) \ -FLAG( 7, 0, ECX, 5, 1, WAITPKG, NO, 0 ) \ +FLAG( 7, 0, ECX, 5, 1, WAITPKG, YES, FUT ) \ FLAG( 7, 0, ECX, 6, 1, AVX512VBMI2, YES, 17 ) \ -FLAG( 7, 0, ECX, 7, 1, CET_SS, NO, 0 ) \ +FLAG( 7, 0, ECX, 7, 1, CET_SS, YES, 20 ) \ FLAG( 7, 0, ECX, 8, 1, GFNI, YES, 17 ) \ FLAG( 7, 0, ECX, 9, 1, VAES, YES, 17 ) \ FLAG( 7, 0, ECX, 10, 1, VPCLMULQDQ, YES, 17 ) \ @@ -555,12 +560,13 @@ FIELD( 7, 0, ECX, 17, 5, MAWA, NO, 0 ) \ FLAG( 7, 0, ECX, 22, 1, RDPID, YES, 17 ) \ FLAG( 7, 0, ECX, 23, 1, KEY_LOCKER, NO, 0 ) \ +FLAG( 7, 0, ECX, 24, 1, BUS_LOCK_DB, NO, 0 ) \ FLAG( 7, 0, ECX, 25, 1, CLDEMOTE, YES, 18 ) \ FLAG( 7, 0, ECX, 27, 1, MOVDIRI, YES, 18 ) \ FLAG( 7, 0, ECX, 28, 1, MOVDIR64B, YES, 18 ) \ FLAG( 7, 0, ECX, 29, 1, ENQCMD, NO, 0 ) \ FLAG( 7, 0, ECX, 30, 1, SGX_LC, ANY, 17 ) \ -FLAG( 7, 0, ECX, 31, 1, PKS, YES, FUT ) \ +FLAG( 7, 0, ECX, 31, 1, PKS, YES, 20 ) \ FLAG( 7, 0, EDX, 2, 1, AVX512QVNNIW, YES, 16 ) \ FLAG( 7, 0, EDX, 3, 1, AVX512QFMAPS, YES, 16 ) \ FLAG( 7, 0, EDX, 4, 1, FAST_SHORT_REPMOV, YES, 18 ) \ @@ -572,25 +578,26 @@ FLAG( 7, 0, EDX, 15, 1, HYBRID, NO, 0 ) \ FLAG( 7, 0, EDX, 16, 1, TSXLDTRK, NO, 0 ) \ FLAG( 7, 0, EDX, 18, 1, PCONFIG, NO, 0 ) \ -FLAG( 7, 0, EDX, 19, 1, ARCH_LBR, NO, 0 ) \ -FLAG( 7, 0, EDX, 20, 1, CET_IBT, NO, 0 ) \ -FLAG( 7, 0, EDX, 22, 1, AMX_BF16, NO, 0 ) \ -FLAG( 7, 0, EDX, 23, 1, AVX512FP16, NO, 0 ) \ -FLAG( 7, 0, EDX, 24, 1, AMX_TILE, NO, 0 ) \ -FLAG( 7, 0, EDX, 25, 1, AMX_INT8, NO, 0 ) \ +FLAG( 7, 0, EDX, 19, 1, ARCH_LBR, YES, 20 ) \ +FLAG( 7, 0, EDX, 20, 1, CET_IBT, YES, 20 ) \ +FLAG( 7, 0, EDX, 22, 1, AMX_BF16, YES, 20 ) \ +FLAG( 7, 0, EDX, 23, 1, AVX512FP16, YES, 20 ) \ +FLAG( 7, 0, EDX, 24, 1, AMX_TILE, YES, 20 ) \ +FLAG( 7, 0, EDX, 25, 1, AMX_INT8, YES, 20 ) \ FLAG( 7, 0, EDX, 26, 1, IBRSIBPB, ANY, 9 ) \ FLAG( 7, 0, EDX, 27, 1, STIBP, YES, 9 ) \ FLAG( 7, 0, EDX, 28, 1, FCMD, YES, 9 ) \ FLAG( 7, 0, EDX, 29, 1, ARCH_CAPABILITIES, ANY, 9 ) \ FLAG( 7, 0, EDX, 30, 1, CORE_CAPABILITIES, NO, 0 ) \ FLAG( 7, 0, EDX, 31, 1, SSBD, YES, 9 ) \ -FLAG( 7, 1, EAX, 4, 1, AVX_VNNI, YES, FUT ) \ +FLAG( 7, 1, EAX, 4, 1, AVX_VNNI, YES, 20 ) \ FLAG( 7, 1, EAX, 5, 1, AVX512BF16, YES, 18 ) \ -FLAG( 7, 1, EAX, 10, 1, FAST_ZERO_MOVSB, NO, 0 ) \ -FLAG( 7, 1, EAX, 11, 1, FAST_SHORT_STOSB, NO, 0 ) \ -FLAG( 7, 1, EAX, 12, 1, FAST_SHORT_CMPSB_SCASB, NO, 0 ) \ +FLAG( 7, 1, EAX, 10, 1, FAST_ZERO_MOVSB, YES, 20 ) \ +FLAG( 7, 1, EAX, 11, 1, FAST_SHORT_STOSB, YES, 20 ) \ +FLAG( 7, 1, EAX, 12, 1, FAST_SHORT_CMPSB_SCASB, YES, 20 ) \ FLAG( 7, 1, EAX, 22, 1, HRESET, NO, 0 ) \ -FLAG( 7, 1, EAX, 26, 1, LAM, NO, 0 ) +FLAG( 7, 1, EAX, 26, 1, LAM, NO, 0 ) \ +FLAG( 7, 2, EDX, 0, 1, PSFD, YES, 20 ) /* LEVEL, SUB-LEVEL, REG, POS, SIZE, NAME, MON SUPP, HWV */ #define CPUID_FIELD_DATA_LEVEL_9 \ @@ -637,8 +644,8 @@ FLAG( D, 0, EAX, 6, 1, XCR0_MASTER_ZMM_H, YES, 13 ) \ FLAG( D, 0, EAX, 7, 1, XCR0_MASTER_HI16_ZMM, YES, 13 ) \ FLAG( D, 0, EAX, 9, 1, XCR0_MASTER_PKRU, YES, 13 ) \ -FLAG( D, 0, EAX, 17, 1, XCR0_MASTER_XTILECFG, NO, 0 ) \ -FLAG( D, 0, EAX, 18, 1, XCR0_MASTER_XTILEDATA, NO, 0 ) \ +FLAG( D, 0, EAX, 17, 1, XCR0_MASTER_XTILECFG, YES, 20 ) \ +FLAG( D, 0, EAX, 18, 1, XCR0_MASTER_XTILEDATA, YES, 20 ) \ FIELD( D, 0, EBX, 0, 32, XSAVE_ENABLED_SIZE, ANY, 8 ) \ FIELD( D, 0, ECX, 0, 32, XSAVE_MAX_SIZE, YES, 8 ) \ FIELD( D, 0, EDX, 0, 29, XCR0_MASTER_UPPER, NO, 0 ) \ @@ -648,12 +655,12 @@ FLAG( D, 1, EAX, 1, 1, XSAVEC, YES, 13 ) \ FLAG( D, 1, EAX, 2, 1, XGETBV_ECX1, YES, 17 ) \ FLAG( D, 1, EAX, 3, 1, XSAVES, YES, 13 ) \ -FLAG( D, 1, EAX, 4, 1, XFD, NO, 0 ) \ +FLAG( D, 1, EAX, 4, 1, XFD, YES, 20 ) \ FIELD( D, 1, EBX, 0, 32, XSAVES_ENABLED_SIZE, ANY, 13 ) \ FLAG( D, 1, ECX, 8, 1, XSS_MASTER_PT, NO, 0 ) \ FLAG( D, 1, ECX, 10, 1, XSS_MASTER_PASID, NO, 0 ) \ -FLAG( D, 1, ECX, 11, 1, XSS_MASTER_CET_U, NO, 0 ) \ -FLAG( D, 1, ECX, 12, 1, XSS_MASTER_CET_S, NO, 0 ) \ +FLAG( D, 1, ECX, 11, 1, XSS_MASTER_CET_U, YES, 20 ) \ +FLAG( D, 1, ECX, 12, 1, XSS_MASTER_CET_S, YES, 20 ) \ FLAG( D, 1, ECX, 13, 1, XSS_MASTER_HDC, NO, 0 ) \ FLAG( D, 1, ECX, 14, 1, XSS_MASTER_UINTR, NO, 0 ) \ FLAG( D, 1, ECX, 15, 1, XSS_MASTER_LBR, NO, 0 ) \ @@ -702,14 +709,14 @@ FLAG( D, 10, ECX, 0, 1, XSAVES_PASID_STATE_SUP_BY_XSS, NO, 0 ) \ FLAG( D, 10, ECX, 1, 1, XSAVES_PASID_STATE_ALIGN, NO, 0 ) \ FLAG( D, 10, ECX, 2, 1, XSAVES_PASID_STATE_XFD, NO, 0 ) \ -FIELD( D, 11, EAX, 0, 32, XSAVES_CET_U_SIZE, NO, 0 ) \ -FLAG( D, 11, ECX, 0, 1, XSAVES_CET_U_SUP_BY_XSS, NO, 0 ) \ -FLAG( D, 11, ECX, 1, 1, XSAVES_CET_U_ALIGN, NO, 0 ) \ -FLAG( D, 11, ECX, 2, 1, XSAVES_CET_U_XFD, NO, 0 ) \ -FIELD( D, 12, EAX, 0, 32, XSAVES_CET_S_SIZE, NO, 0 ) \ -FLAG( D, 12, ECX, 0, 1, XSAVES_CET_S_SUP_BY_XSS, NO, 0 ) \ -FLAG( D, 12, ECX, 1, 1, XSAVES_CET_S_ALIGN, NO, 0 ) \ -FLAG( D, 12, ECX, 2, 1, XSAVES_CET_S_XFD, NO, 0 ) \ +FIELD( D, 11, EAX, 0, 32, XSAVES_CET_U_SIZE, YES, 20 ) \ +FLAG( D, 11, ECX, 0, 1, XSAVES_CET_U_SUP_BY_XSS, YES, 20 ) \ +FLAG( D, 11, ECX, 1, 1, XSAVES_CET_U_ALIGN, YES, 20 ) \ +FLAG( D, 11, ECX, 2, 1, XSAVES_CET_U_XFD, YES, 20 ) \ +FIELD( D, 12, EAX, 0, 32, XSAVES_CET_S_SIZE, YES, 20 ) \ +FLAG( D, 12, ECX, 0, 1, XSAVES_CET_S_SUP_BY_XSS, YES, 20 ) \ +FLAG( D, 12, ECX, 1, 1, XSAVES_CET_S_ALIGN, YES, 20 ) \ +FLAG( D, 12, ECX, 2, 1, XSAVES_CET_S_XFD, YES, 20 ) \ FIELD( D, 13, EAX, 0, 32, XSAVES_HDT_SIZE, NO, 0 ) \ FLAG( D, 13, ECX, 0, 1, XSAVES_HDT_SUP_BY_XSS, NO, 0 ) \ FLAG( D, 13, ECX, 1, 1, XSAVES_HDT_ALIGN, NO, 0 ) \ @@ -726,16 +733,16 @@ FLAG( D, 16, ECX, 0, 1, XSAVES_HWP_SUP_BY_XSS, NO, 0 ) \ FLAG( D, 16, ECX, 1, 1, XSAVES_HWP_ALIGN, NO, 0 ) \ FLAG( D, 16, ECX, 2, 1, XSAVES_HWP_XFD, NO, 0 ) \ -FIELD( D, 17, EAX, 0, 32, XSAVE_XTILECFG_SIZE, NO, 0 ) \ -FIELD( D, 17, EBX, 0, 32, XSAVE_XTILECFG_OFFSET, NO, 0 ) \ +FIELD( D, 17, EAX, 0, 32, XSAVE_XTILECFG_SIZE, YES, 20 ) \ +FIELD( D, 17, EBX, 0, 32, XSAVE_XTILECFG_OFFSET, YES, 20 ) \ FLAG( D, 17, ECX, 0, 1, XSAVE_XTILECFG_SUP_BY_XSS, NO, 0 ) \ -FLAG( D, 17, ECX, 1, 1, XSAVE_XTILECFG_ALIGN, NO, 0 ) \ -FLAG( D, 17, ECX, 2, 1, XSAVE_XTILECFG_XFD, NO, 0 ) \ -FIELD( D, 18, EAX, 0, 32, XSAVE_XTILEDATA_SIZE, NO, 0 ) \ -FIELD( D, 18, EBX, 0, 32, XSAVE_XTILEDATA_OFFSET, NO, 0 ) \ +FLAG( D, 17, ECX, 1, 1, XSAVE_XTILECFG_ALIGN, YES, 20 ) \ +FLAG( D, 17, ECX, 2, 1, XSAVE_XTILECFG_XFD, YES, 20 ) \ +FIELD( D, 18, EAX, 0, 32, XSAVE_XTILEDATA_SIZE, YES, 20 ) \ +FIELD( D, 18, EBX, 0, 32, XSAVE_XTILEDATA_OFFSET, YES, 20 ) \ FLAG( D, 18, ECX, 0, 1, XSAVE_XTILEDATA_SUP_BY_XSS, NO, 0 ) \ -FLAG( D, 18, ECX, 1, 1, XSAVE_XTILEDATA_ALIGN, NO, 0 ) \ -FLAG( D, 18, ECX, 2, 1, XSAVE_XTILEDATA_XFD, NO, 0 ) \ +FLAG( D, 18, ECX, 1, 1, XSAVE_XTILEDATA_ALIGN, YES, 20 ) \ +FLAG( D, 18, ECX, 2, 1, XSAVE_XTILEDATA_XFD, YES, 20 ) \ /* D, 62: AMD LWP leaf on BD, PD, SR. Dropped in Zen. Never referenced. */ /* LEVEL, SUB-LEVEL, REG, POS, SIZE, NAME, MON SUPP, HWV */ @@ -749,12 +756,19 @@ FLAG( F, 1, EDX, 2, 1, PQM_MBM_LOCAL, NO, 0 ) /* LEVEL, SUB-LEVEL, REG, POS, SIZE, NAME, MON SUPP, HWV */ -#define CPUID_FIELD_DATA_LEVEL_10 \ -FLAG( 10, 0, EBX, 1, 1, PQE_L3, NO, 0 ) \ -FIELD( 10, 1, EAX, 0, 5, PQE_L3_MASK_LENGTH, NO, 0 ) \ +#define CPUID_FIELD_DATA_LEVEL_10 \ +FLAG( 10, 0, EBX, 1, 1, PQE_L3, YES, 20 ) \ +FLAG( 10, 0, EBX, 2, 1, PQE_L2, NO, 0 ) \ +FLAG( 10, 0, EBX, 3, 1, PQE_MBA, NO, 0 ) \ +FIELD( 10, 1, EAX, 0, 5, PQE_L3_MASK_LENGTH, YES, 20 ) \ FIELD( 10, 1, EBX, 0, 32, PQE_L3_ISOLATION_UNIT_MAP, NO, 0 ) \ FLAG( 10, 1, ECX, 2, 1, PQE_L3_CDP, NO, 0 ) \ -FIELD( 10, 1, EDX, 0, 16, PQE_L3_MAX_COS_NUMBER, NO, 0 ) +FIELD( 10, 1, EDX, 0, 16, PQE_L3_MAX_COS_NUMBER, YES, 20 ) \ +FIELD( 10, 2, EAX, 0, 5, PQE_L2_MASK_LENGTH, NO, 0 ) \ +FIELD( 10, 2, EBX, 0, 32, PQE_L2_ISOLATION_UNIT_MAP, NO, 0 ) \ +FLAG( 10, 2, ECX, 2, 1, PQE_L2_CDP, NO, 0 ) \ +FIELD( 10, 2, EDX, 0, 16, PQE_L2_MAX_COS_NUMBER, NO, 0 ) + /* LEVEL, SUB-LEVEL, REG, POS, SIZE, NAME, MON SUPP, HWV */ #define CPUID_FIELD_DATA_LEVEL_12 \ @@ -874,29 +888,29 @@ /* LEVEL, SUB-LEVEL, REG, POS, SIZE, NAME, MON SUPP, HWV */ #define CPUID_FIELD_DATA_LEVEL_1C \ -FIELD( 1C, 0, EAX, 0, 8, LBR_DEPTH, NO, 0 ) \ -FLAG( 1C, 0, EAX, 30, 1, LBR_DEEP_CSTATE_RESET, NO, 0 ) \ -FLAG( 1C, 0, EAX, 31, 1, LBR_IP_CONTAINS_LIP, NO, 0 ) \ -FLAG( 1C, 0, EBX, 0, 1, LBR_CPL_FILTERING, NO, 0 ) \ -FLAG( 1C, 0, EBX, 1, 1, LBR_BRANCH_FILTERING, NO, 0 ) \ -FLAG( 1C, 0, EBX, 2, 1, LBR_CALL_STACK_MODE, NO, 0 ) \ -FLAG( 1C, 0, ECX, 0, 1, LBR_MISPREDICT, NO, 0 ) \ -FLAG( 1C, 0, ECX, 1, 1, LBR_TIMED_LBRS, NO, 0 ) \ -FLAG( 1C, 0, ECX, 2, 1, LBR_BRANCH_TYPE, NO, 0 ) \ +FIELD( 1C, 0, EAX, 0, 8, LBR_DEPTH, YES, 20 ) \ +FLAG( 1C, 0, EAX, 30, 1, LBR_DEEP_CSTATE_RESET, YES, 20 ) \ +FLAG( 1C, 0, EAX, 31, 1, LBR_IP_CONTAINS_LIP, YES, 20 ) \ +FLAG( 1C, 0, EBX, 0, 1, LBR_CPL_FILTERING, YES, 20 ) \ +FLAG( 1C, 0, EBX, 1, 1, LBR_BRANCH_FILTERING, YES, 20 ) \ +FLAG( 1C, 0, EBX, 2, 1, LBR_CALL_STACK_MODE, YES, 20 ) \ +FLAG( 1C, 0, ECX, 0, 1, LBR_MISPREDICT, YES, 20 ) \ +FLAG( 1C, 0, ECX, 1, 1, LBR_TIMED_LBRS, YES, 20 ) \ +FLAG( 1C, 0, ECX, 2, 1, LBR_BRANCH_TYPE, YES, 20 ) \ /* LEVEL, SUB-LEVEL, REG, POS, SIZE, NAME, MON SUPP, HWV */ #define CPUID_FIELD_DATA_LEVEL_1D \ -FLAG( 1D, 0, EAX, 0, 1, TILE_PALETTE_MAX, NO, 0 ) \ -FIELD( 1D, 1, EAX, 0, 15, TILE_PALETTE1_TOTAL_BYTES, NO, 0 ) \ -FIELD( 1D, 1, EAX, 16, 16, TILE_PALETTE1_BYTES_PER_TILE, NO, 0 ) \ -FIELD( 1D, 1, EBX, 0, 15, TILE_PALETTE1_BYTES_PER_ROW, NO, 0 ) \ -FIELD( 1D, 1, EBX, 16, 16, TILE_PALETTE1_NUM_REGS, NO, 0 ) \ -FIELD( 1D, 1, ECX, 0, 15, TILE_PALETTE1_MAX_ROWS, NO, 0 ) +FIELD( 1D, 0, EAX, 0, 32, TILE_PALETTE_MAX, YES, 20 ) \ +FIELD( 1D, 1, EAX, 0, 16, TILE_PALETTE1_TOTAL_BYTES, YES, 20 ) \ +FIELD( 1D, 1, EAX, 16, 16, TILE_PALETTE1_BYTES_PER_TILE, YES, 20 ) \ +FIELD( 1D, 1, EBX, 0, 16, TILE_PALETTE1_BYTES_PER_ROW, YES, 20 ) \ +FIELD( 1D, 1, EBX, 16, 16, TILE_PALETTE1_NUM_REGS, YES, 20 ) \ +FIELD( 1D, 1, ECX, 0, 16, TILE_PALETTE1_MAX_ROWS, YES, 20 ) /* LEVEL, SUB-LEVEL, REG, POS, SIZE, NAME, MON SUPP, HWV */ #define CPUID_FIELD_DATA_LEVEL_1E \ -FIELD( 1E, 0, EBX, 0, 7, TMUL_MAX_K, NO, 0 ) \ -FIELD( 1E, 0, EBX, 8, 16, TMUL_MAX_N, NO, 0 ) +FIELD( 1E, 0, EBX, 0, 8, TMUL_MAX_K, YES, 20 ) \ +FIELD( 1E, 0, EBX, 8, 16, TMUL_MAX_N, YES, 20 ) /* LEVEL, SUB-LEVEL, REG, POS, SIZE, NAME, MON SUPP, HWV */ #define CPUID_FIELD_DATA_LEVEL_1F \ @@ -912,6 +926,13 @@ FIELD( 20, 0, EBX, 0, 32, HRESET_ENABLE_MSR_VALID_BITS, NO, 0 ) /* LEVEL, SUB-LEVEL, REG, POS, SIZE, NAME, MON SUPP, HWV */ +#define CPUID_FIELD_DATA_LEVEL_21 \ +FIELD( 21, 0, EAX, 0, 32, TDX_MAX_SUBLEAF, NO, 0 ) \ +FIELD( 21, 0, EBX, 0, 32, TDX_VENDOR1, NO, 0 ) \ +FIELD( 21, 0, ECX, 0, 32, TDX_VENDOR3, NO, 0 ) \ +FIELD( 21, 0, EDX, 0, 32, TDX_VENDOR2, NO, 0 ) + +/* LEVEL, SUB-LEVEL, REG, POS, SIZE, NAME, MON SUPP, HWV */ #define CPUID_FIELD_DATA_LEVEL_400 \ FIELD(400, 0, EAX, 0, 32, MAX_HYP_LEVEL, NA, 0 ) \ FIELD(400, 0, EBX, 0, 32, HYPERVISOR_VENDOR0, NA, 0 ) \ @@ -977,7 +998,9 @@ FLAG( 403, 0, EDX, 11, 1, DEBUG_MSRS_AVAIL, NA, 0 ) \ FLAG( 403, 0, EDX, 12, 1, NPIEP1_AVAIL, NA, 0 ) \ FLAG( 403, 0, EDX, 13, 1, DISABLE_HYPERVISOR_AVAIL, NA, 0 ) \ -FLAG( 403, 0, EDX, 15, 1, XMM_REGS_FOR_HYPERCALL_OUTPUT, NA, 0 ) +FLAG( 403, 0, EDX, 15, 1, XMM_REGS_FOR_HYPERCALL_OUTPUT, NA, 0 ) \ +FLAG( 403, 0, EDX, 17, 1, SINT_POLLING_AVAIL, NA, 0 ) \ +FLAG( 403, 0, EDX, 19, 1, DIRECT_SYN_TIMER, NA, 0 ) /* LEVEL, SUB-LEVEL, REG, POS, SIZE, NAME, MON SUPP, HWV */ #define CPUID_FIELD_DATA_LEVEL_404 \ @@ -1015,7 +1038,6 @@ FIELD(410, 0, EBX, 0, 32, APICBUS_HZ, NA, 0 ) \ FLAG( 410, 0, ECX, 0, 1, VMMCALL_BACKDOOR, NA, 0 ) \ FLAG( 410, 0, ECX, 1, 1, VMCALL_BACKDOOR, NA, 0 ) \ -FLAG( 410, 0, ECX, 2, 1, TDX_ENABLED, NA, 0 ) \ FLAG( 410, 0, ECX, 3, 1, TDX_API_ENABLED, NA, 0 ) /* LEVEL, SUB-LEVEL, REG, POS, SIZE, NAME, MON SUPP, HWV */ @@ -1060,7 +1082,7 @@ FLAG( 81, 0, ECX, 26, 1, DATABK, NO, 0 ) \ FLAG( 81, 0, ECX, 27, 1, PERFTSC, NO, 0 ) \ FLAG( 81, 0, ECX, 28, 1, PERFL3, NO, 0 ) \ -FLAG( 81, 0, ECX, 29, 1, MWAITX, NO, 0 ) \ +FLAG( 81, 0, ECX, 29, 1, MONITORX, NO, 0 ) \ FLAG( 81, 0, ECX, 30, 1, ADDR_MASK_EXT, NO, 0 ) \ FLAG( 81, 0, EDX, 0, 1, LEAF81_FPU, YES, 4 ) \ FLAG( 81, 0, EDX, 1, 1, LEAF81_VME, YES, 4 ) \ @@ -1189,18 +1211,18 @@ FLAG( 88, 0, EBX, 10, 1, LBREXTN, NO, 0 ) \ FLAG( 88, 0, EBX, 12, 1, LEAF88_IBPB, ANY, 9 ) \ FLAG( 88, 0, EBX, 13, 1, WBINVD_INT, NO, 0 ) \ -FLAG( 88, 0, EBX, 14, 1, LEAF88_IBRS, NO, 0 ) \ +FLAG( 88, 0, EBX, 14, 1, LEAF88_IBRS, ANY, 20 ) \ FLAG( 88, 0, EBX, 15, 1, LEAF88_STIBP, NO, 0 ) \ -FLAG( 88, 0, EBX, 16, 1, LEAF88_IBRS_ALWAYS, NO, 0 ) \ +FLAG( 88, 0, EBX, 16, 1, LEAF88_IBRS_ALWAYS, YES, 20 ) \ FLAG( 88, 0, EBX, 17, 1, LEAF88_STIBP_ALWAYS, NO, 0 ) \ -FLAG( 88, 0, EBX, 18, 1, LEAF88_PREFER_IBRS, NO, 0 ) \ -FLAG( 88, 0, EBX, 19, 1, LEAF88_IBRS_SAME_MODE, NO, 0 ) \ +FLAG( 88, 0, EBX, 18, 1, LEAF88_PREFER_IBRS, YES, 20 ) \ +FLAG( 88, 0, EBX, 19, 1, LEAF88_IBRS_SAME_MODE, YES, 20 ) \ FLAG( 88, 0, EBX, 20, 1, LMSLE_UNSUPPORTED, NO, 0 ) \ FLAG( 88, 0, EBX, 23, 1, PPIN, NO, 0 ) \ -FLAG( 88, 0, EBX, 24, 1, LEAF88_SSBD_SPEC_CTRL, ANY, 9 ) \ -FLAG( 88, 0, EBX, 25, 1, LEAF88_SSBD_VIRT_SPEC_CTRL, ANY, 9 ) \ +FLAG( 88, 0, EBX, 24, 1, LEAF88_SSBD_SPEC_CTRL, YES, 20 ) \ +FLAG( 88, 0, EBX, 25, 1, LEAF88_SSBD_VIRT_SPEC_CTRL, NO, 0 ) \ FLAG( 88, 0, EBX, 26, 1, LEAF88_SSBD_NOT_NEEDED, NO, 0 ) \ -FLAG( 88, 0, EBX, 28, 1, PSFD, NO, 0 ) \ +FLAG( 88, 0, EBX, 28, 1, LEAF88_PSFD, YES, 20 ) \ FIELD( 88, 0, ECX, 0, 8, LEAF88_CORE_COUNT, YES, 4 ) \ FIELD( 88, 0, ECX, 12, 4, APICID_COREID_SIZE, YES, 7 ) \ FIELD( 88, 0, ECX, 16, 2, PERFTSC_SIZE, NO, 0 ) \ @@ -1236,7 +1258,8 @@ FLAG( 8A, 0, EDX, 15, 1, SVM_V_VMSAVE_VMLOAD, NO, 0 ) \ FLAG( 8A, 0, EDX, 16, 1, SVM_VGIF, NO, 0 ) \ FLAG( 8A, 0, EDX, 17, 1, SVM_GMET, YES, 17 ) \ -FIELD( 8A, 0, EDX, 18, 2, SVMEDX_RSVD3, NO, 0 ) \ +FLAG( 8A, 0, EDX, 18, 1, SVMEDX_RSVD3, NO, 0 ) \ +FLAG( 8A, 0, EDX, 19, 1, SVM_SSS, YES, 20 ) \ FLAG( 8A, 0, EDX, 20, 1, SVM_GUEST_SPEC_CTRL, NO, 0 ) \ FIELD( 8A, 0, EDX, 21, 3, SVMEDX_RSVD4, NO, 0 ) \ FLAG( 8A, 0, EDX, 24, 1, SVM_TLB_CTL, NO, 0 ) \ @@ -1339,6 +1362,7 @@ FLAG( 81F, 0, EAX, 3, 1, SEV_ES, YES, 17 ) \ FLAG( 81F, 0, EAX, 4, 1, SEV_SNP, NO, 0 ) \ FLAG( 81F, 0, EAX, 5, 1, VMPL, NO, 0 ) \ +FLAG( 81F, 0, EAX, 9, 1, TSC_AUX_VIRT, YES, 20 ) \ FLAG( 81F, 0, EAX, 10, 1, SEV_HEC, NO, 0 ) \ FLAG( 81F, 0, EAX, 11, 1, SEV_64BIT_REQ, NO, 0 ) \ FLAG( 81F, 0, EAX, 12, 1, SEV_RESTR_INJECTION, NO, 0 ) \ @@ -1357,7 +1381,14 @@ FIELD(820, 1, EAX, 0, 32, CAPACITY_MASK_LEN, NO, 0 ) \ FIELD(820, 1, EDX, 0, 32, NUM_SERVICE_CLASSES, NO, 0 ) -#define CPUID_FIELD_DATA_LEVEL_821 +#define CPUID_FIELD_DATA_LEVEL_821 \ +FLAG( 821, 0, EAX, 7, 1, UPPER_ADDRESS_IGNORE, YES, 20 ) + +#define CPUID_FIELD_DATA_LEVEL_822 + +#define CPUID_FIELD_DATA_LEVEL_823 + +#define CPUID_FIELD_DATA_LEVEL_826 #define CPUID_FIELD_DATA \ CPUID_FIELD_DATA_LEVEL_0 \ @@ -1387,6 +1418,7 @@ CPUID_FIELD_DATA_LEVEL_1E \ CPUID_FIELD_DATA_LEVEL_1F \ CPUID_FIELD_DATA_LEVEL_20 \ + CPUID_FIELD_DATA_LEVEL_21 \ CPUID_FIELD_DATA_LEVEL_400 \ CPUID_FIELD_DATA_LEVEL_401 \ CPUID_FIELD_DATA_LEVEL_402 \ @@ -1413,7 +1445,10 @@ CPUID_FIELD_DATA_LEVEL_81E \ CPUID_FIELD_DATA_LEVEL_81F \ CPUID_FIELD_DATA_LEVEL_820 \ - CPUID_FIELD_DATA_LEVEL_821 + CPUID_FIELD_DATA_LEVEL_821 \ + CPUID_FIELD_DATA_LEVEL_822 \ + CPUID_FIELD_DATA_LEVEL_823 \ + CPUID_FIELD_DATA_LEVEL_826 /* * Define all field and flag values as an enum. The result is a full @@ -1651,9 +1686,13 @@ #define CPUID_MODEL_CANNONLAKE_66 0x66 // Cannon Lake #define CPUID_MODEL_ICELAKE_7E 0x7e // Ice Lake U/Y #define CPUID_MODEL_ICELAKE_6A 0x6a // Ice Lake SP (ICX) -#define CPUID_MODEL_TIGERLAKE_8C 0x8c // Tiger Lake +#define CPUID_MODEL_ICELAKE_6C 0x6c // Ice Lake D +#define CPUID_MODEL_TIGERLAKE_8C 0x8c // Tiger Lake UP3/UP4/H35 +#define CPUID_MODEL_TIGERLAKE_8D 0x8d // Tiger Lake H81 #define CPUID_MODEL_KNM_85 0x85 // Knights Mill #define CPUID_MODEL_KABYLAKE_8E 0x8e // Kaby Lake U/Y QS +#define CPUID_MODEL_ALDERLAKE_97 0x97 // Alder Lake-S +#define CPUID_MODEL_ALDERLAKE_9A 0x9a // Alder Lake-P #define CPUID_MODEL_KABYLAKE_9E 0x9e // Kaby Lake S/H QS #define CPUID_MODEL_COMETLAKE_A5 0xa5 // Comet Lake S #define CPUID_MODEL_COMETLAKE_A6 0xa6 // Comet Lake U @@ -1726,7 +1765,7 @@ *---------------------------------------------------------------------- */ static INLINE Bool -CPUID_IsRawVendor(CPUIDRegs *id0, const char* vendor) +CPUID_IsRawVendor(const CPUIDRegs *id0, const char* vendor) { // hard to get strcmp() in some environments, so do it in the raw return (id0->ebx == *(const uint32 *)(uintptr_t) (vendor + 0) && @@ -1735,25 +1774,25 @@ } static INLINE Bool -CPUID_IsVendorAMD(CPUIDRegs *id0) +CPUID_IsVendorAMD(const CPUIDRegs *id0) { return CPUID_IsRawVendor(id0, CPUID_AMD_VENDOR_STRING); } static INLINE Bool -CPUID_IsVendorIntel(CPUIDRegs *id0) +CPUID_IsVendorIntel(const CPUIDRegs *id0) { return CPUID_IsRawVendor(id0, CPUID_INTEL_VENDOR_STRING); } static INLINE Bool -CPUID_IsVendorVIA(CPUIDRegs *id0) +CPUID_IsVendorVIA(const CPUIDRegs *id0) { return CPUID_IsRawVendor(id0, CPUID_VIA_VENDOR_STRING); } static INLINE Bool -CPUID_IsVendorHygon(CPUIDRegs *id0) +CPUID_IsVendorHygon(const CPUIDRegs *id0) { return CPUID_IsRawVendor(id0, CPUID_HYGON_VENDOR_STRING); } @@ -1766,7 +1805,8 @@ CPUID_GET(1, EAX, EXTENDED_FAMILY, v); } -/* Normally only used when FAMILY==CPUID_FAMILY_EXTENDED, but Intel is +/* + * Normally only used when FAMILY==CPUID_FAMILY_EXTENDED, but Intel is * now using the extended model field for FAMILY==CPUID_FAMILY_P6 to * refer to the newer Core2 CPUs */ @@ -2018,7 +2058,8 @@ /* Assumes the CPU manufacturer is Intel. */ return CPUID_FAMILY_IS_P6(v) && (CPUID_EFFECTIVE_MODEL(v) == CPUID_MODEL_ICELAKE_7E || - CPUID_EFFECTIVE_MODEL(v) == CPUID_MODEL_ICELAKE_6A); + CPUID_EFFECTIVE_MODEL(v) == CPUID_MODEL_ICELAKE_6A || + CPUID_EFFECTIVE_MODEL(v) == CPUID_MODEL_ICELAKE_6C); } static INLINE Bool @@ -2026,7 +2067,8 @@ { /* Assumes the CPU manufacturer is Intel. */ return CPUID_FAMILY_IS_P6(v) && - (CPUID_EFFECTIVE_MODEL(v) == CPUID_MODEL_TIGERLAKE_8C); + (CPUID_EFFECTIVE_MODEL(v) == CPUID_MODEL_TIGERLAKE_8C || + CPUID_EFFECTIVE_MODEL(v) == CPUID_MODEL_TIGERLAKE_8D); } static INLINE Bool @@ -2046,6 +2088,15 @@ CPUID_MODEL_IS_ROCKETLAKE(v); } +static INLINE Bool +CPUID_MODEL_IS_ALDERLAKE(uint32 v) // IN: %eax from CPUID with %eax=1. +{ + /* Assumes the CPU manufacturer is Intel. */ + return CPUID_FAMILY_IS_P6(v) && + (CPUID_EFFECTIVE_MODEL(v) == CPUID_MODEL_ALDERLAKE_97 || + CPUID_EFFECTIVE_MODEL(v) == CPUID_MODEL_ALDERLAKE_9A); +} + static INLINE Bool CPUID_UARCH_IS_HASWELL(uint32 v) // IN: %eax from CPUID with %eax=1. @@ -2254,6 +2305,7 @@ return CPUID_EFFECTIVE_FAMILY(eax) == CPUID_FAMILY_ZEN3; } + /* * AMD Barcelona (of either Opteron or Phenom kind). */ @@ -2385,15 +2437,11 @@ static INLINE Bool CPUID_MODEL_IS_ZEN3(uint32 eax) { - return CPUID_EFFECTIVE_FAMILY(eax) == CPUID_FAMILY_ZEN3 && - CPUID_EFFECTIVE_MODEL(eax) <= CPUID_MODEL_ZEN3_0F; + return CPUID_EFFECTIVE_FAMILY(eax) == CPUID_FAMILY_ZEN3 && + CPUID_EFFECTIVE_MODEL(eax) <= CPUID_MODEL_ZEN3_0F; } -#define CPUID_TYPE_PRIMARY 0 -#define CPUID_TYPE_OVERDRIVE 1 -#define CPUID_TYPE_SECONDARY 2 - #define CPUID_LEAF4_CACHE_TYPE_NULL 0 #define CPUID_LEAF4_CACHE_TYPE_DATA 1 #define CPUID_LEAF4_CACHE_TYPE_INST 2 @@ -2401,9 +2449,6 @@ #define CPUID_LEAF4_CACHE_INDEXING_DIRECT 0 #define CPUID_LEAF4_CACHE_INDEXING_COMPLEX 1 -#define CPUID_LEAF4_CACHE_SELF_INIT 0x00000100 -#define CPUID_LEAF4_CACHE_FULLY_ASSOC 0x00000200 - #define CPUID_TOPOLOGY_LEVEL_TYPE_INVALID 0 #define CPUID_TOPOLOGY_LEVEL_TYPE_SMT 1 #define CPUID_TOPOLOGY_LEVEL_TYPE_CORE 2 @@ -2418,20 +2463,11 @@ #define CPUID_AMD_LEAF81D_CACHE_TYPE_INST 2 #define CPUID_AMD_LEAF81D_CACHE_TYPE_UNIF 3 -/* - * For certain AMD processors, an lfence instruction is necessary at various - * places to ensure ordering. - */ - -static INLINE Bool -CPUID_RequiresFence(CpuidVendor vendor, // IN - uint32 version) // IN: %eax from CPUID with %eax=1. -{ - return vendor == CPUID_VENDOR_AMD && - CPUID_EFFECTIVE_FAMILY(version) == CPUID_FAMILY_K8 && - CPUID_EFFECTIVE_MODEL(version) < 0x40; -} - +#define CPUID_AMD_TOPOLOGY_LEVEL_TYPE_INVALID 0 +#define CPUID_AMD_TOPOLOGY_LEVEL_TYPE_CORE 1 +#define CPUID_AMD_TOPOLOGY_LEVEL_TYPE_COMPLEX 2 +#define CPUID_AMD_TOPOLOGY_LEVEL_TYPE_CCD 3 +#define CPUID_AMD_TOPOLOGY_LEVEL_TYPE_SOCKET 4 /* * Hypervisor CPUID space is 0x400000XX. @@ -2461,7 +2497,7 @@ case v: \ return c != 0; - CPUID_ALL_LEVELS + CPUID_KNOWN_LEVELS #undef CPUIDLEVEL diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/lock/ulInt.h open-vm-tools-12.1.5/open-vm-tools/lib/lock/ulInt.h --- open-vm-tools-11.3.5/open-vm-tools/lib/lock/ulInt.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/lock/ulInt.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2009-2019 VMware, Inc. All rights reserved. + * Copyright (C) 2009-2019, 2021 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 @@ -575,7 +575,7 @@ typedef struct MXUserHisto MXUserHisto; -MXUserHisto *MXUserHistoSetUp(char *typeName, +MXUserHisto *MXUserHistoSetUp(const char *typeName, uint64 minValue, uint32 decades); @@ -602,7 +602,7 @@ void MXUserBasicStatsSetUp(MXUserBasicStats *stats, - char *typeName); + const char *typeName); void MXUserBasicStatsSample(MXUserBasicStats *stats, diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/lock/ulStats.c open-vm-tools-12.1.5/open-vm-tools/lib/lock/ulStats.c --- open-vm-tools-11.3.5/open-vm-tools/lib/lock/ulStats.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/lock/ulStats.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2010-2019 VMware, Inc. All rights reserved. + * Copyright (C) 2010-2019, 2021 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 @@ -186,9 +186,9 @@ */ MXUserHisto * -MXUserHistoSetUp(char *typeName, // type (name) of histogram - uint64 minValue, // IN: ns; 1, 10, 100, 1000... - uint32 decades) // IN: decimal decades to cover from min +MXUserHistoSetUp(const char *typeName, // type (name) of histogram + uint64 minValue, // IN: ns; 1, 10, 100, 1000... + uint32 decades) // IN: decimal decades to cover from min { MXUserHisto *histo; @@ -448,7 +448,7 @@ void MXUserBasicStatsSetUp(MXUserBasicStats *stats, // IN/OUT: - char *typeName) // IN: + const char *typeName) // IN: { stats->typeName = Util_SafeStrdup(typeName); stats->numSamples = 0; @@ -831,7 +831,7 @@ static INLINE void MXUserForceHisto(Atomic_Ptr *histoPtr, // IN/OUT: - char *typeName, // IN: + const char *typeName, // IN: uint64 minValue, // IN: uint32 decades) // IN: { diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/misc/codesetOld.c open-vm-tools-12.1.5/open-vm-tools/lib/misc/codesetOld.c --- open-vm-tools-11.3.5/open-vm-tools/lib/misc/codesetOld.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/misc/codesetOld.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2017,2019 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2017,2019,2021 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 @@ -731,7 +731,7 @@ return ret; #elif defined(USE_ICONV) - static char *cachedCodeset; + static const char *cachedCodeset; /* * Mirror GLib behavior: @@ -756,16 +756,16 @@ * the first entry when converting to/from UTF-8. */ - if (!cachedCodeset) { + if (cachedCodeset == NULL) { char *gFilenameEncoding = getenv("G_FILENAME_ENCODING"); - if (gFilenameEncoding && *gFilenameEncoding) { + if (gFilenameEncoding != NULL && *gFilenameEncoding != '\0') { char *p; gFilenameEncoding = Util_SafeStrdup(gFilenameEncoding); p = strchr(gFilenameEncoding, ','); - if (p) { + if (p != NULL) { *p = '\0'; } if (!strcmp(gFilenameEncoding, "@locale")) { diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/misc/dynbuf.c open-vm-tools-12.1.5/open-vm-tools/lib/misc/dynbuf.c --- open-vm-tools-11.3.5/open-vm-tools/lib/misc/dynbuf.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/misc/dynbuf.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2019 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2022 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 @@ -376,10 +376,10 @@ /* *----------------------------------------------------------------------------- * - * DynBuf_Append -- + * DynBuf_Insert -- * - * Append data at the end of a dynamic buffer. 'size' is the size of the - * data. If it is <= 0, no operation is performed --hpreg + * Insert data at a given offset within a dynamic buffer. 'size' is the + * size of the data. If it is <= 0, no operation is performed. * * Results: * TRUE on success @@ -392,13 +392,15 @@ */ Bool -DynBuf_Append(DynBuf *b, // IN/OUT: +DynBuf_Insert(DynBuf *b, // IN/OUT: + size_t offset, // IN: void const *data, // IN: size_t size) // IN: { size_t new_size; ASSERT(b); + ASSERT(offset <= b->size); if (size <= 0) { return TRUE; @@ -419,7 +421,8 @@ } } - memcpy(b->data + b->size, data, size); + memmove(b->data + offset + size, b->data + offset, b->size - offset); + memcpy(b->data + offset, data, size); b->size = new_size; return TRUE; @@ -429,10 +432,70 @@ /* *----------------------------------------------------------------------------- * + * DynBuf_SafeInternalInsert -- + * + * Insert data at a given offset within a dynamic buffer. Memory + * allocation failure is handled the same way as Util_SafeMalloc, that is + * to say, with a Panic. + * + * Results: + * None + * + * Side effects: + * None + * + *----------------------------------------------------------------------------- + */ + +void +DynBuf_SafeInternalInsert(DynBuf *b, // IN/OUT: + size_t offset, // IN: + void const *data, // IN: + size_t size, // IN: + char const *file, // IN: + unsigned int lineno) // IN: +{ + if (!DynBuf_Insert(b, offset, data, size)) { + Panic("Unrecoverable memory allocation failure at %s:%u\n", + file, lineno); + } +} + + +/* + *----------------------------------------------------------------------------- + * + * DynBuf_Append -- + * + * Append data at the end of a dynamic buffer. 'size' is the size of the + * data. If it is <= 0, no operation is performed. + * + * Results: + * TRUE on success + * FALSE on failure (not enough memory) + * + * Side effects: + * None + * + *----------------------------------------------------------------------------- + */ + +Bool +DynBuf_Append(DynBuf *b, // IN/OUT: + void const *data, // IN: + size_t size) // IN: +{ + return DynBuf_Insert(b, b->size, data, size); +} + + +/* + *----------------------------------------------------------------------------- + * * DynBuf_SafeInternalAppend -- * * Append data at the end of a dynamic buffer. Memory allocation failure - * are handled the same way as Util_SafeMalloc, that is to say, with a + * is handled the same way as Util_SafeMalloc, that is to say, with a * Panic. * * Results: diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/misc/hostinfo.c open-vm-tools-12.1.5/open-vm-tools/lib/misc/hostinfo.c --- open-vm-tools-11.3.5/open-vm-tools/lib/misc/hostinfo.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/misc/hostinfo.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2019 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2022 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 @@ -335,3 +335,41 @@ return detailedData; } + +/* + *---------------------------------------------------------------------- + * + * Hostinfo_QueryProcessExistence -- + * + * Determine if a PID is "alive" or "dead". Failing to be able to + * do this perfectly, do not make any assumption - say the answer + * is unknown. + * + * Results: + * HOSTINFO_PROCESS_QUERY_ALIVE Process is alive + * HOSTINFO_PROCESS_QUERY_DEAD Process is dead + * HOSTINFO_PROCESS_QUERY_UNKNOWN Don't know + * + * Side effects: + * None + * + *---------------------------------------------------------------------- + */ + +HostinfoProcessQuery +Hostinfo_QueryProcessExistence(int pid) // IN: +{ + HostinfoProcessQuery ret; + HostinfoProcessSnapshot *s = Hostinfo_AcquireProcessSnapshot(); + + if (s == NULL) { + return HOSTINFO_PROCESS_QUERY_UNKNOWN; + } + + ret = Hostinfo_QueryProcessSnapshot(s, pid); + + Hostinfo_ReleaseProcessSnapshot(s); + + return ret; +} + diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/misc/hostinfoHV.c open-vm-tools-12.1.5/open-vm-tools/lib/misc/hostinfoHV.c --- open-vm-tools-11.3.5/open-vm-tools/lib/misc/hostinfoHV.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/misc/hostinfoHV.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2011-2021 VMware, Inc. All rights reserved. + * Copyright (C) 2011-2022 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 @@ -422,37 +422,6 @@ } -/* - *---------------------------------------------------------------------- - * - * Hostinfo_NestedHVReplaySupported -- - * - * Access the backdoor with a HV replay control query. This is used - * to determine if we are running in a VM that supports nested HV replay. - * This function should only be called after determining that the - * backdoor is present with Hostinfo_TouchBackdoor(). - * - * Results: - * TRUE if the outer VM supports nexted HV replay. - * FALSE otherwise. - * - * Side effects: - * Exception if not in a VM, so don't do that! - * - *---------------------------------------------------------------------- - */ - -Bool -Hostinfo_NestedHVReplaySupported(void) -{ -#if defined(__i386__) || defined(__x86_64__) - return Hostinfo_VCPUInfoBackdoor(BDOOR_CMD_VCPU_HV_REPLAY_OK); -#else - return FALSE; -#endif -} - - /* *---------------------------------------------------------------------- * diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/misc/hostinfoInt.h open-vm-tools-12.1.5/open-vm-tools/lib/misc/hostinfoInt.h --- open-vm-tools-11.3.5/open-vm-tools/lib/misc/hostinfoInt.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/misc/hostinfoInt.h 2022-11-29 21:17:22.000000000 +0000 @@ -34,8 +34,8 @@ */ typedef struct { - char *name; - char value[MAX_DETAILED_FIELD_LEN]; + const char *name; + char value[MAX_DETAILED_FIELD_LEN]; } DetailedDataField; /* Must be sorted. Keep in same ordering as detailedDataFields */ diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/misc/hostinfoPosix.c open-vm-tools-12.1.5/open-vm-tools/lib/misc/hostinfoPosix.c --- open-vm-tools-11.3.5/open-vm-tools/lib/misc/hostinfoPosix.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/misc/hostinfoPosix.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2021 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2022 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 @@ -72,8 +72,10 @@ #if !defined(USING_AUTOCONF) || defined(HAVE_SYS_VFS_H) #include #endif -#if !defined(sun) && !defined __ANDROID__ && (!defined(USING_AUTOCONF) || (defined(HAVE_SYS_IO_H) && defined(HAVE_SYS_SYSINFO_H))) -#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) +#if !defined(sun) && !defined __ANDROID__ && (!defined(USING_AUTOCONF) || \ + (defined(HAVE_SYS_IO_H) && \ + defined(HAVE_SYS_SYSINFO_H))) +#if defined(__i386__) || defined(__x86_64__) #include #else #define NO_IOPL @@ -159,8 +161,8 @@ #if !defined(__APPLE__) && !defined(VMX86_SERVER) && !defined(USERWORLD) typedef struct { - char *name; - char *scanString; + const char *name; + const char *scanString; } DistroNameScan; static const DistroNameScan lsbFields[] = { @@ -180,8 +182,8 @@ }; typedef struct { - char *name; - char *filename; + const char *name; + const char *filename; } DistroInfo; /* @@ -777,36 +779,16 @@ minor = 0; } - switch (major) { - case 0: - case 1: - case 2: - case 3: - case 4: + if (major <= 4) { Str_Strcpy(osName, STR_OS_VMKERNEL, sizeof osName); - break; - - case 5: - Str_Strcpy(osName, STR_OS_VMKERNEL "5", sizeof osName); - break; - - case 6: - if (minor < 5) { - Str_Strcpy(osName, STR_OS_VMKERNEL "6", sizeof osName); + } else { + if (minor == 0) { + Str_Sprintf(osName, sizeof osName, "%s%d", STR_OS_VMKERNEL, + major); } else { - Str_Strcpy(osName, STR_OS_VMKERNEL "65", sizeof osName); + Str_Sprintf(osName, sizeof osName, "%s%d%d", STR_OS_VMKERNEL, + major, minor); } - break; - - case 7: - default: - /* - * New osName are created IFF the VMX/monitor requires them (rare), - * not (simply) with every ESXi release. - */ - - Str_Strcpy(osName, STR_OS_VMKERNEL "7", sizeof osName); - break; } len = Str_Snprintf(osNameFull, sizeof osNameFull, "VMware ESXi %s", @@ -903,7 +885,7 @@ HostinfoArchString(void) { #if defined(VM_ARM_ANY) - return "arm-"; + return STR_OS_ARM_PREFIX; #elif defined(VM_X86_ANY) return ""; #else @@ -1174,18 +1156,18 @@ #define SUSE_SAP_LINUX "server for sap applications 12" static const ShortNameSet suseEnterpriseShortNameArray[] = { - {"desktop 10", STR_OS_SLES "10", HostinfoGenericSetShortName}, - {"desktop 11", STR_OS_SLES "11", HostinfoGenericSetShortName}, - {"desktop 12", STR_OS_SLES "12", HostinfoGenericSetShortName}, - {"desktop 15", STR_OS_SLES "15", HostinfoGenericSetShortName}, - {"desktop 16", STR_OS_SLES "16", HostinfoGenericSetShortName}, - {"server 10", STR_OS_SLES "10", HostinfoGenericSetShortName}, - {"server 11", STR_OS_SLES "11", HostinfoGenericSetShortName}, - {"server 12", STR_OS_SLES "12", HostinfoGenericSetShortName}, - {"server 15", STR_OS_SLES "15", HostinfoGenericSetShortName}, - {"server 16", STR_OS_SLES "16", HostinfoGenericSetShortName}, - {SUSE_SAP_LINUX, STR_OS_SLES "12", HostinfoGenericSetShortName}, - {NULL, NULL, NULL} // MUST BE LAST + { "desktop 10", STR_OS_SLES "10", HostinfoGenericSetShortName }, + { "desktop 11", STR_OS_SLES "11", HostinfoGenericSetShortName }, + { "desktop 12", STR_OS_SLES "12", HostinfoGenericSetShortName }, + { "desktop 15", STR_OS_SLES "15", HostinfoGenericSetShortName }, + { "desktop 16", STR_OS_SLES "16", HostinfoGenericSetShortName }, + { "server 10", STR_OS_SLES "10", HostinfoGenericSetShortName }, + { "server 11", STR_OS_SLES "11", HostinfoGenericSetShortName }, + { "server 12", STR_OS_SLES "12", HostinfoGenericSetShortName }, + { "server 15", STR_OS_SLES "15", HostinfoGenericSetShortName }, + { "server 16", STR_OS_SLES "16", HostinfoGenericSetShortName }, + { SUSE_SAP_LINUX, STR_OS_SLES "12", HostinfoGenericSetShortName }, + { NULL, NULL, NULL } // MUST BE LAST }; @@ -1196,9 +1178,9 @@ */ static const ShortNameSet suseShortNameArray[] = { - {"sun", STR_OS_SUN_DESK, HostinfoGenericSetShortName}, - {"novell", STR_OS_NOVELL, HostinfoGenericSetShortName}, - {NULL, NULL, NULL} // MUST BE LAST + { "sun", STR_OS_SUN_DESK, HostinfoGenericSetShortName }, + { "novell", STR_OS_NOVELL "9", HostinfoGenericSetShortName }, + { NULL, NULL, NULL } // MUST BE LAST }; @@ -1207,7 +1189,8 @@ * * HostinfoSetSuseShortName -- * - * Set the short name for the SUSE distros. + * Set the short name for the SUSE distros. Due to ownership and naming + * changes, other distros have to be "filtered" and named differently. * * Return value: * TRUE success @@ -1253,13 +1236,15 @@ /* - * Table mapping from distro name to the offically recognized shortname. - * - * Only distros that are officially supported by VMware are present in - * this table. If you're not VMware, do not add anything to this table. + * Table mapping from distro name to the officially recognized shortname. * - * A short name that is not officially supported by VMware will be ignored - * by the rest of the software stack. + * WARNING: If you are not VMware, do not change this table. Values that are + * not recognized by the VMware host will be ignored. Any change here must + * be accompanied by additional changes to the host. + * + * If you are interested in extending this table, do not send a pull request. + * Instead, submit a request via the open-vm-tools github issue tracker + * https://github.com/vmware/open-vm-tools/issues. * * Some distros do not have a simple substitution and special logic is * necessary to handle distros that do not have simple substitutions. @@ -1269,44 +1254,46 @@ */ static const ShortNameSet shortNameArray[] = { -/* Long distro name Short distro name Short name set function */ -{"amazon", NULL, HostinfoSetAmazonShortName}, -{"annvix", STR_OS_ANNVIX, HostinfoGenericSetShortName}, -{"arch", STR_OS_ARCH, HostinfoGenericSetShortName}, -{"arklinux", STR_OS_ARKLINUX, HostinfoGenericSetShortName}, -{"asianux", NULL, HostinfoSetAsianuxShortName}, -{"aurox", STR_OS_AUROX, HostinfoGenericSetShortName}, -{"black cat", STR_OS_BLACKCAT, HostinfoGenericSetShortName}, -{"centos", NULL, HostinfoSetCentosShortName}, -{"cobalt", STR_OS_COBALT, HostinfoGenericSetShortName}, -{"conectiva", STR_OS_CONECTIVA, HostinfoGenericSetShortName}, -{"debian", NULL, HostinfoSetDebianShortName}, -{"red hat", NULL, HostinfoSetRedHatShortName}, +/* Long distro name Short distro name Short name set function */ +{ "almalinux", STR_OS_ALMA_LINUX, HostinfoGenericSetShortName }, +{ "amazon", NULL, HostinfoSetAmazonShortName }, +{ "annvix", STR_OS_ANNVIX, HostinfoGenericSetShortName }, +{ "arch", STR_OS_ARCH, HostinfoGenericSetShortName }, +{ "arklinux", STR_OS_ARKLINUX, HostinfoGenericSetShortName }, +{ "asianux", NULL, HostinfoSetAsianuxShortName }, +{ "aurox", STR_OS_AUROX, HostinfoGenericSetShortName }, +{ "black cat", STR_OS_BLACKCAT, HostinfoGenericSetShortName }, +{ "centos", NULL, HostinfoSetCentosShortName }, +{ "cobalt", STR_OS_COBALT, HostinfoGenericSetShortName }, +{ "conectiva", STR_OS_CONECTIVA, HostinfoGenericSetShortName }, +{ "debian", NULL, HostinfoSetDebianShortName }, +{ "red hat", NULL, HostinfoSetRedHatShortName }, /* Red Hat must come before the Enterprise Linux entry */ -{"enterprise linux", NULL, HostinfoSetOracleShortName}, -{"fedora", STR_OS_FEDORA, HostinfoGenericSetShortName}, -{"gentoo", STR_OS_GENTOO, HostinfoGenericSetShortName}, -{"immunix", STR_OS_IMMUNIX, HostinfoGenericSetShortName}, -{"linux-from-scratch", STR_OS_LINUX_FROM_SCRATCH, HostinfoGenericSetShortName}, -{"linux-ppc", STR_OS_LINUX_PPC, HostinfoGenericSetShortName}, -{"mandrake", STR_OS_MANDRAKE, HostinfoGenericSetShortName}, -{"mandriva", STR_OS_MANDRIVA, HostinfoGenericSetShortName}, -{"mklinux", STR_OS_MKLINUX, HostinfoGenericSetShortName}, -{"opensuse", STR_OS_OPENSUSE, HostinfoGenericSetShortName}, -{"oracle", NULL, HostinfoSetOracleShortName}, -{"pld", STR_OS_PLD, HostinfoGenericSetShortName}, -{"slackware", STR_OS_SLACKWARE, HostinfoGenericSetShortName}, -{"sme server", STR_OS_SMESERVER, HostinfoGenericSetShortName}, -{"suse", NULL, HostinfoSetSuseShortName}, -{"tiny sofa", STR_OS_TINYSOFA, HostinfoGenericSetShortName}, -{"turbolinux", STR_OS_TURBO, HostinfoGenericSetShortName}, -{"ubuntu", STR_OS_UBUNTU, HostinfoGenericSetShortName}, -{"ultra penguin", STR_OS_ULTRAPENGUIN, HostinfoGenericSetShortName}, -{"united linux", STR_OS_UNITEDLINUX, HostinfoGenericSetShortName}, -{"va linux", STR_OS_VALINUX, HostinfoGenericSetShortName}, -{"vmware photon", STR_OS_PHOTON, HostinfoGenericSetShortName}, -{"yellow dog", STR_OS_YELLOW_DOG, HostinfoGenericSetShortName}, -{NULL, NULL, NULL} // MUST BE LAST +{ "enterprise linux", NULL, HostinfoSetOracleShortName }, +{ "fedora", STR_OS_FEDORA, HostinfoGenericSetShortName }, +{ "gentoo", STR_OS_GENTOO, HostinfoGenericSetShortName }, +{ "immunix", STR_OS_IMMUNIX, HostinfoGenericSetShortName }, +{ "linux-from-scratch", STR_OS_LINUX_FROM_SCRATCH, HostinfoGenericSetShortName }, +{ "linux-ppc", STR_OS_LINUX_PPC, HostinfoGenericSetShortName }, +{ "mandrake", STR_OS_MANDRAKE, HostinfoGenericSetShortName }, +{ "mandriva", STR_OS_MANDRIVA, HostinfoGenericSetShortName }, +{ "mklinux", STR_OS_MKLINUX, HostinfoGenericSetShortName }, +{ "opensuse", STR_OS_OPENSUSE, HostinfoGenericSetShortName }, +{ "oracle", NULL, HostinfoSetOracleShortName }, +{ "pld", STR_OS_PLD, HostinfoGenericSetShortName }, +{ "rocky linux", STR_OS_ROCKY_LINUX, HostinfoGenericSetShortName }, +{ "slackware", STR_OS_SLACKWARE, HostinfoGenericSetShortName }, +{ "sme server", STR_OS_SMESERVER, HostinfoGenericSetShortName }, +{ "suse", NULL, HostinfoSetSuseShortName }, +{ "tiny sofa", STR_OS_TINYSOFA, HostinfoGenericSetShortName }, +{ "turbolinux", STR_OS_TURBO, HostinfoGenericSetShortName }, +{ "ubuntu", STR_OS_UBUNTU, HostinfoGenericSetShortName }, +{ "ultra penguin", STR_OS_ULTRAPENGUIN, HostinfoGenericSetShortName }, +{ "united linux", STR_OS_UNITEDLINUX, HostinfoGenericSetShortName }, +{ "va linux", STR_OS_VALINUX, HostinfoGenericSetShortName }, +{ "vmware photon", STR_OS_PHOTON, HostinfoGenericSetShortName }, +{ "yellow dog", STR_OS_YELLOW_DOG, HostinfoGenericSetShortName }, +{ NULL, NULL, NULL } // MUST BE LAST }; @@ -1842,8 +1829,8 @@ size_t distroShortSize) // IN: { char generic[128]; - char *distroOut = NULL; - char *distroShortOut = NULL; + const char *distroOut = NULL; + const char *distroShortOut = NULL; int majorVersion = Hostinfo_OSVersion(0); int minorVersion = Hostinfo_OSVersion(1); @@ -1882,6 +1869,11 @@ distroShortOut = STR_OS_OTHER_5X; break; + case 6: + distroOut = STR_OS_OTHER_6X_FULL; + distroShortOut = STR_OS_OTHER_6X; + break; + default: /* * Anything newer than this code explicitly handles returns the @@ -3337,8 +3329,8 @@ */ static char * -HostinfoGetCpuInfo(int nCpu, // IN: - char *name) // IN: +HostinfoGetCpuInfo(int nCpu, // IN: + const char *name) // IN: { FILE *f; char *line; @@ -3921,7 +3913,7 @@ static Bool HostinfoFindEntry(char *buffer, // IN: Buffer - char *string, // IN: String sought + const char *string, // IN: String sought unsigned int *value) // OUT: Value { char *p = strstr(buffer, string); @@ -3969,8 +3961,8 @@ */ static Bool -HostinfoGetMemInfo(char *name, // IN: - unsigned int *value) // OUT: +HostinfoGetMemInfo(const char *name, // IN: + unsigned int *value) // OUT: { size_t len; char buffer[4096]; @@ -4404,11 +4396,67 @@ /* *---------------------------------------------------------------------- * - * Hostinfo_QueryProcessExistence -- + * Hostinfo_AcquireProcessSnapshot -- + * + * Acquire a snapshot of the process table. On POSIXen, this is + * a NOP. + * + * Results: + * !NULL - A process snapshot pointer. + * + * Side effects: + * None + * + *---------------------------------------------------------------------- + */ + +struct HostinfoProcessSnapshot { + int dummy; +}; + +static HostinfoProcessSnapshot hostinfoProcessSnapshot = { 0 }; + +HostinfoProcessSnapshot * +Hostinfo_AcquireProcessSnapshot(void) +{ + return &hostinfoProcessSnapshot; +} + + +/* + *---------------------------------------------------------------------- + * + * Hostinfo_ReleaseProcessSnapshot -- * - * Determine if a PID is "alive" or "dead". Failing to be able to - * do this perfectly, do not make any assumption - say the answer - * is unknown. + * Release a snapshot of the process table. On POSIXen, this is + * a NOP. + * + * Results: + * None + * + * Side effects: + * None + * + *---------------------------------------------------------------------- + */ + +void +Hostinfo_ReleaseProcessSnapshot(HostinfoProcessSnapshot *s) // IN/OPT: +{ + if (s != NULL) { + VERIFY(s == &hostinfoProcessSnapshot); + } +} + + +/* + *---------------------------------------------------------------------- + * + * Hostinfo_QueryProcessSnapshot -- + * + * Determine if a PID is "alive" or "dead" within the specified + * process snapshot. Failing to be able to do this perfectly, + * do not make any assumption - say the answer is unknown. * * Results: * HOSTINFO_PROCESS_QUERY_ALIVE Process is alive @@ -4422,12 +4470,14 @@ */ HostinfoProcessQuery -Hostinfo_QueryProcessExistence(int pid) // IN: +Hostinfo_QueryProcessSnapshot(HostinfoProcessSnapshot *s, // IN: + int pid) // IN: { HostinfoProcessQuery ret; - int err = (kill(pid, 0) == -1) ? errno : 0; - switch (err) { + ASSERT(s != NULL); + + switch ((kill(pid, 0) == -1) ? errno : 0) { case 0: case EPERM: ret = HOSTINFO_PROCESS_QUERY_ALIVE; @@ -4442,3 +4492,4 @@ return ret; } + diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/misc/jsonUTF8.c open-vm-tools-12.1.5/open-vm-tools/lib/misc/jsonUTF8.c --- open-vm-tools-11.3.5/open-vm-tools/lib/misc/jsonUTF8.c 1970-01-01 00:00:00.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/misc/jsonUTF8.c 2022-11-29 21:17:22.000000000 +0000 @@ -0,0 +1,483 @@ +/********************************************************* + * Copyright (C) 2020-2022 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 + * by the Free Software Foundation version 2.1 and no later version. + * + * 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 Lesser GNU General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + *********************************************************/ + +#include +#include "vmware.h" +#include "codeset.h" +#include "vm_ctype.h" +#include "dynbuf.h" +#include "strutil.h" +#include "unicodeBase.h" + + +/* + *----------------------------------------------------------------------------- + * + * CodeSet_JsonEscape -- + * + * Escape a unicode string following JSON rules. + * + * From https://www.rfc-editor.org/rfc/rfc8259.html#section-7: + * + * ... All Unicode characters may be placed within the + * quotation marks, except for the characters that MUST be escaped: + * quotation mark, reverse solidus, and the control characters (U+0000 + * through U+001F). + * + * ... If the character is in the Basic + * Multilingual Plane (U+0000 through U+FFFF), then it may be + * represented as a six-character sequence: a reverse solidus, followed + * by the lowercase letter u, followed by four hexadecimal digits that + * encode the character's code point.... + * + * Alternatively, there are two-character sequence escape + * representations of some popular characters. So, for example, a + * string containing only a single reverse solidus character may be + * represented more compactly as "\\" + * + * ... + * + * %x62 / ; b backspace U+0008 + * %x66 / ; f form feed U+000C + * %x6E / ; n line feed U+000A + * %x72 / ; r carriage return U+000D + * %x74 / ; t tab U+0009 + * + * Results: + * NULL Failure! + * !NULL Success! The escaped string. The caller is responsible to free + * this. + * + * Side effects: + * Memory is allocated + * + *----------------------------------------------------------------------------- + */ + +char * +CodeSet_JsonEscape(const char *utf8) // IN: +{ + DynBuf b; + char *res; + const char *p; + const char *end; + Bool success = TRUE; + + ASSERT(utf8 != NULL); + if (utf8 == NULL) { + return NULL; + } + + DynBuf_Init(&b); + + p = utf8; + end = p + strlen(utf8); + + while (p < end) { + uint32 len = CodeSet_GetUtf8(p, end, NULL); + + if (len == 0) { + success = FALSE; + break; + } + + if (len > 1 || (*p > 0x001F && *p != '"' && *p != '\\')) { + DynBuf_SafeAppend(&b, p, len); + } else { + DynBuf_SafeAppend(&b, "\\", 1); + switch (*p) { + case '"': + case '\\': + DynBuf_SafeAppend(&b, p, 1); + break; + case '\b': + DynBuf_SafeAppend(&b, "b", 1); + break; + case '\f': + DynBuf_SafeAppend(&b, "f", 1); + break; + case '\n': + DynBuf_SafeAppend(&b, "n", 1); + break; + case '\r': + DynBuf_SafeAppend(&b, "r", 1); + break; + case '\t': + DynBuf_SafeAppend(&b, "t", 1); + break; + default: + StrUtil_SafeDynBufPrintf(&b, "u%04x", *p); + break; + } + } + p += len; + } + + if (success) { + res = DynBuf_DetachString(&b); + } else { + res = NULL; + } + + DynBuf_Destroy(&b); + + return res; +} + + +/* Constants used by json unescape routines. */ + +/* Number of hex digits in a "\u" escape sequence. */ +#define JSON_UESC_NDIGITS 4 + +/* + * Maximum number of UTF-8 code units (bytes) per Unicode code point. + * From bora/lib/unicode/unicode/utf8.h. + */ +#ifndef U8_MAX_LENGTH +#define U8_MAX_LENGTH 4 +#endif + +/* + *---------------------------------------------------------------------------- + * + * CodeSet_JsonGetHex -- + * + * Retrieve and convert to an integer the four hex digits that are + * part of the six character escape sequence that starts with "\u". + * + * On entry, p points to the first code point following "\u." + * + * Results: + * TRUE on success, with *value set to the integer value. + * + * FALSE on failure. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------------- + */ + +static Bool +CodeSet_JSonGetHex(const char *p, // IN: + const char *end, // IN: + int32 *value) // OUT: +{ + char hexBuf[JSON_UESC_NDIGITS + 1]; /* +1 for NUL */ + int numHexDigits = 0; + + ASSERT(p <= end); + + /* + * Assumes called with p set to first code point following "\u" and looks + * for four hex digits. No need to call CodeSet_GetUtf8 to verify that + * the code point length of these characters is one since it's always on + * a code point boundary and it's OK to check directly for specific + * ASCII characters in such a case, and if there's a match to an ASCII + * character then advancing the pointer by a single character will advance + * to the next code point. + */ + while (numHexDigits < JSON_UESC_NDIGITS) { + if (p >= end || !CType_IsXDigit(*p)) { + return FALSE; + } + hexBuf[numHexDigits++] = *p++; + } + + hexBuf[numHexDigits] = '\0'; + *value = strtol(hexBuf, NULL, 16); + return TRUE; +} + + +/* + *---------------------------------------------------------------------------- + * + * CodeSet_JsonUnescapeU -- + * + * Handle a JSON escape sequence beginning with "\u", consisting either + * of: + * (1) "\u" followed by four hex digits; or + * (2) two such consecutive sequences encoding a character + * outside the Basic MultiLingual Plane as a UTF-16 + * surrogate pair. + * + * Note "\u0000" is not allowed and is considered an error if + * encountered. + * + * On entry to the routine, p should be pointing at the backslash + * character that starts the (possible) escape sequence. + * + * outBuf is the base of a char array of size >= U8_MAX_LENGTH + 1, i.e., + * large enough to hold a NUL-terminated UTF-8 encoding of any Unicode + * code point. + * + * Results: + * On success, the length of the escape sequence, with the unescaped + * result plus a NUL terminator in outBuf. + * + * 0 on failure. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------------- + */ + +static int +CodeSet_JsonUnescapeU(const char *p, // IN: + const char *end, // IN: + char *outBuf) // OUT: +{ + uint32 w; + uint32 utf32Buf[2]; /* code point value plus 0 terminator */ + char *utf8String; + uint32 len; + const char *start = p; + + /* + * Assumes called only if starts with "\u". No need to call + * CodeSet_GetUtf8 in this ASSERT since this is checking for specific ASCII + * characters - see comment preceding ASSERT in CodeSet_JsonUnescapeOne + * below. + */ + ASSERT(p < end && *p == '\\'); + ASSERT(&p[1] < end && p[1] == 'u'); + + /* Code point of 0 ("\u0000") not allowed. */ + if (!CodeSet_JSonGetHex(&p[2], end, &w) || w == 0) { + return 0; + } + + /* Advance p past "\u" and the hex digits that follow. */ + p += 2 + JSON_UESC_NDIGITS; + + /* If the value is a leading surrogate, then handle the trailing one. */ + if (U16_IS_LEAD(w)) { + uint32 trail; + + /* + * Check for '\', 'u', and four digits representing a trailer. As + * elsewhere, no need to call CodeSet_GetUtf8 since this is checking for + * specific ASCII characters, and bails out if any of the checks fail. + */ + if (p < end && *p++ == '\\' && p < end && *p++ == 'u' && + CodeSet_JSonGetHex(p, end, &trail) && U16_IS_TRAIL(trail)) { + w = U16_GET_SUPPLEMENTARY(w, trail); + + /* Advance p past the digits that follow "\u". */ + p += JSON_UESC_NDIGITS; + } else { + return 0; + } + } else if (U16_IS_TRAIL(w)) { + return 0; + } + + /* + * To get the UTF-8 for this code point, create a UTF-32 string + * and convert to UTF-8. + */ + utf32Buf[0] = w; + utf32Buf[1] = 0; /* needs a 4-byte 0 terminator */ + + if (!CodeSet_UTF32ToUTF8((char *)utf32Buf, &utf8String)) { + return 0; + } + + len = strlen(utf8String); + ASSERT(Unicode_IsBufferValid(utf8String, len, STRING_ENCODING_UTF8)); + ASSERT(len <= U8_MAX_LENGTH); + memcpy(outBuf, utf8String, len + 1); + + free(utf8String); + return p - start; +} + + +/* + *---------------------------------------------------------------------------- + * + * CodeSet_JsonUnescapeOne -- + * + * Handle a single JSON escape sequence. + * + * On entry to the routine, p should be pointing at the backslash + * character that starts the (possible) escape sequence. + * + * outBuf is the base of a char array of size >= U8_MAX_LENGTH + 1, i.e., + * large enough to hold a NUL-terminated UTF-8 encoding of any Unicode + * code point. + * + * Results: + * On success, the length of the escape sequence, with the unescaped + * result plus a NUL terminator in outBuf. + * + * 0 on failure. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------------- + */ + +static int +CodeSet_JsonUnescapeOne(const char *p, // IN: + const char *end, // IN: + char *outBuf) // OUT: +{ + int len = 0; + const char *start = p; + + /* + * Assumes called only if first character is '\'. Note that in the + * ASSERT it's not necessary to call CodeSet_GetUtf8 to verify the + * code point length is 1. Since this is on a code point boundary, + * if the byte matches a specific ASCII character (in this case, '\') + * that is sufficient to verify the code point length of 1. + */ + ASSERT(p < end && *p == '\\'); + + /* + * Advance p by a single char to get to the next code point since it's + * known to be an ASCII character (i.e., '\') and therefore code point + * length is 1. + */ + if (++p < end) { + /* + * Preset len and outBuf for common case of valid two-character escape + * sequence with one-character output; different values will be assigned + * if the sequence turns out to start with "\u" or is invalid. + */ + len = 2; + outBuf[1] = '\0'; + + /* + * As above, since this on a code point boundary and checking whether + * it matches specific ASCII characters, it's not necessary to call + * CodeSet_GetUtf8 to verify that the code point length is 1. In the + * event *p is the first byte of a multi-byte UTF-8 code point, we'll + * end up in the default case of the switch and fail. + */ + switch (*p) { + case '\"': + case '\\': + case '/': + outBuf[0] = *p; + break; + case 'b': + outBuf[0] = '\b'; + break; + case 'f': + outBuf[0] = '\f'; + break; + case 'r': + outBuf[0] = '\r'; + break; + case 'n': + outBuf[0] = '\n'; + break; + case 't': + outBuf[0] = '\t'; + break; + case 'u': + len = CodeSet_JsonUnescapeU(start, end, outBuf); + break; + default: + len = 0; + break; + } + } + return len; +} + + +/* + *----------------------------------------------------------------------------- + * + * CodeSet_JsonUnescape -- + * + * Copy a UTF8 string, reverting any JSON escape sequences found within + * the string according to the STD-90 spec at + * https://tools.ietf.org/html/std90. This processes the same + * escape sequences that are allowed by the jsmn parser, and generally + * tries to follow the same logic as the jsmn escape parsing. Any + * strings passed in to this routine have likely been through jsmn, and + * any invalid escape sequences should have been rejected. However, this + * routine and those it calls still check for the possibility of + * invalid escape sequences and return failure when running into one, as + * opposed to assuming and/or asserting they are valid. + * + * A general unescape routine is difficult to do, so the logic here is + * specific to JSON (as opposed to CodeSet_JsonEscape, which relies on + * the more general CodeSet_Utf8Escape). + * + * Results: + * NULL Failure! + * !NULL Success! The un-escaped string. The caller is responsible to free + * this. + * + * Side effects: + * Returns a dynamically allocated string that must be freed by the + * caller. + * + *----------------------------------------------------------------------------- + */ + +char * +CodeSet_JsonUnescape(const char *utf8) // IN: +{ + DynBuf b; + char *res; + const char *p; + const char *end; + Bool success = TRUE; + + ASSERT(utf8 != NULL); + + DynBuf_Init(&b); + p = utf8; + end = p + strlen(p); + + while (p < end && success) { + char unescaped[U8_MAX_LENGTH + 1]; /* +1 for NUL */ + uint32 len = CodeSet_GetUtf8(p, end, NULL); + + if (len == 0) { + success = FALSE; + } else if (len > 1 || *p != '\\') { + DynBuf_SafeAppend(&b, p, len); + } else if ((len = CodeSet_JsonUnescapeOne(p, end, unescaped)) != 0) { + DynBuf_SafeAppend(&b, unescaped, strlen(unescaped)); + } else { + success = FALSE; + } + p += len; + } + + if (success) { + res = DynBuf_DetachString(&b); + } else { + res = NULL; + } + + DynBuf_Destroy(&b); + + return res; +} diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/misc/Makefile.am open-vm-tools-12.1.5/open-vm-tools/lib/misc/Makefile.am --- open-vm-tools-11.3.5/open-vm-tools/lib/misc/Makefile.am 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/misc/Makefile.am 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ ################################################################################ -### Copyright (C) 2007-2017 VMware, Inc. All rights reserved. +### Copyright (C) 2007-2017,2021 VMware, Inc. All rights reserved. ### ### This program is free software; you can redistribute it and/or modify ### it under the terms of version 2 of the GNU General Public License as @@ -34,6 +34,7 @@ libMisc_la_SOURCES += hostType.c libMisc_la_SOURCES += idLinux.c libMisc_la_SOURCES += iovector.c +libMisc_la_SOURCES += jsonUTF8.c libMisc_la_SOURCES += logFixed.c libMisc_la_SOURCES += machineID.c libMisc_la_SOURCES += miscSolaris.c diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/misc/strutil.c open-vm-tools-12.1.5/open-vm-tools/lib/misc/strutil.c --- open-vm-tools-11.3.5/open-vm-tools/lib/misc/strutil.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/misc/strutil.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2019, 2021 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2019, 2021-2022 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 @@ -1040,6 +1040,48 @@ } +/** + *----------------------------------------------------------------------------- + * + * StrUtil_CaselessStrstr -- + * + * This is a case-insensitive version of strstr in C string.h. + * + * Results: + * return a pointer to the first occurrence of strSearch in str, or NULL + * if strSearch does not appear in str. If strSearch is zero length, the + * function returns str. + * + * Side effects: + * none + * + *----------------------------------------------------------------------------- + */ + +const char * +StrUtil_CaselessStrstr(const char *str, // IN + const char *strSearch) // IN +{ + size_t len; + + if (strSearch == NULL || *strSearch == '\0') { + return str; + } + + if (str == NULL || *str == '\0') { + return NULL; + } + + len = strlen(strSearch); + for (; *str; str++) { + if (strncasecmp(str, strSearch, len) == 0) { + return str; + } + } + return NULL; +} + + /* *----------------------------------------------------------------------------- * diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/misc/timeutil.c open-vm-tools-12.1.5/open-vm-tools/lib/misc/timeutil.c --- open-vm-tools-11.3.5/open-vm-tools/lib/misc/timeutil.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/misc/timeutil.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2021 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2022 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 @@ -894,18 +894,6 @@ VmTimeType ntTime) // IN: Time in Windows NT format { ASSERT(unixTime); -#ifndef VM_64BIT - /* We assume that time_t is 32bit */ - ASSERT(sizeof (unixTime->tv_sec) == 4); - - /* Cap NT time values that are outside of Unix time's range */ - - if (ntTime >= UNIX_S32_MAX) { - unixTime->tv_sec = 0x7FFFFFFF; - unixTime->tv_nsec = 0; - return 1; - } -#endif // ifndef VM_64BIT if (ntTime < UNIX_EPOCH) { unixTime->tv_sec = 0; @@ -913,19 +901,27 @@ return -1; } -#ifdef __i386__ // only for 32-bit x86 - { - uint32 sec; - uint32 nsec; +#ifdef __i386__ + if (sizeof unixTime->tv_sec == 4) { + uint32 sec,nsec; + + /* Cap NT time values that are outside of Unix time's range */ + if (ntTime >= UNIX_S32_MAX) { + unixTime->tv_sec = 0x7FFFFFFF; + unixTime->tv_nsec = 0; + return 1; + } Div643232(ntTime - UNIX_EPOCH, 10000000, &sec, &nsec); unixTime->tv_sec = sec; unixTime->tv_nsec = nsec * 100; + + return 0; } -#else +#endif + unixTime->tv_sec = (ntTime - UNIX_EPOCH) / 10000000; unixTime->tv_nsec = ((ntTime - UNIX_EPOCH) % 10000000) * 100; -#endif // __i386__ return 0; } diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/misc/util_misc.c open-vm-tools-12.1.5/open-vm-tools/lib/misc/util_misc.c --- open-vm-tools-11.3.5/open-vm-tools/lib/misc/util_misc.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/misc/util_misc.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2019 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2019, 2021 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 @@ -370,7 +370,7 @@ * Returns TRUE if character is a digit or a letter, FALSE otherwise. * * Side effects: - * None. + * None. * *----------------------------------------------------------------------------- */ @@ -530,8 +530,8 @@ * * Results: * - * Return a newly allocated string. The caller is responsible - * for deallocating it. + * Return a newly allocated string. The caller is responsible + * for deallocating it. * * Return NULL in case of error. * @@ -540,8 +540,8 @@ * * Bugs: * the handling of enviroment variable references is very - * simplistic: there can be only one in a pathname segment - * and it must appear last in the string + * simplistic: there can be only one in a pathname segment + * and it must appear last in the string * *---------------------------------------------------------------------- */ @@ -560,7 +560,7 @@ char *cp; int i; - ASSERT(fileName); + ASSERT(fileName != NULL); copy = Unicode_Duplicate(fileName); @@ -586,24 +586,24 @@ */ nchunk = 0; - for (cp = copy; *cp;) { + for (cp = copy; *cp != '\0';) { size_t len; if (*cp == '$') { - char *p; - for (p = cp + 1; UtilIsAlphaOrNum(*p) || *p == '_'; p++) { - } - len = p - cp; + char *p; + for (p = cp + 1; UtilIsAlphaOrNum(*p) || *p == '_'; p++) { + } + len = p - cp; #if !defined(_WIN32) } else if (cp == copy && *cp == '~') { - len = strcspn(cp, DIRSEPS); + len = strcspn(cp, DIRSEPS); #endif } else { - len = strcspn(cp, "$"); + len = strcspn(cp, "$"); } if (nchunk >= UTIL_MAX_PATH_CHUNKS) { Log("%s: Filename \"%s\" has too many chunks.\n", __FUNCTION__, fileName); - goto out; + goto out; } chunks[nchunk] = cp; chunkSize[nchunk] = len; @@ -617,7 +617,7 @@ */ #if !defined(_WIN32) - if (chunks[0][0] == '~') { + if (nchunk > 0 && chunks[0][0] == '~') { char save = (cp = chunks[0])[chunkSize[0]]; cp[chunkSize[0]] = 0; ASSERT(!freeChunk[0]); @@ -654,7 +654,7 @@ * $ will be kept as a part of the pathname. */ - continue; + continue; } save = cp[chunkSize[i]]; @@ -668,22 +668,22 @@ expand = Unicode_Duplicate(Posix_Getenv(cp + 1)); if (expand != NULL) { } else if (strcasecmp(cp + 1, "PID") == 0) { - Str_Snprintf(buf, sizeof buf, "%"FMTPID, getpid()); - expand = Util_SafeStrdup(buf); + Str_Snprintf(buf, sizeof buf, "%"FMTPID, getpid()); + expand = Util_SafeStrdup(buf); } else if (strcasecmp(cp + 1, "USER") == 0) { #if !defined(_WIN32) struct passwd *pwd = Posix_Getpwuid(getuid()); expand = UtilGetLoginName(pwd); Posix_Endpwent(); #else - DWORD n = ARRAYSIZE(bufW); - if (GetUserNameW(bufW, &n)) { - expand = Unicode_AllocWithUTF16(bufW); - } -#endif - if (expand == NULL) { - expand = Unicode_Duplicate("unknown"); - } + DWORD n = ARRAYSIZE(bufW); + if (GetUserNameW(bufW, &n)) { + expand = Unicode_AllocWithUTF16(bufW); + } +#endif + if (expand == NULL) { + expand = Unicode_Duplicate("unknown"); + } } else { Log("Environment variable '%s' not defined in '%s'.\n", cp + 1, fileName); @@ -692,7 +692,7 @@ * Strip off the env variable string from the pathname. */ - expand = Unicode_Duplicate(""); + expand = Unicode_Duplicate(""); #else // _WIN32 @@ -720,9 +720,9 @@ ASSERT(!freeChunk[i]); chunks[i] = expand; if (chunks[i] == NULL) { - Log("%s: Cannot allocate memory to expand $ in \"%s\".\n", + Log("%s: Cannot allocate memory to expand $ in \"%s\".\n", __FUNCTION__, fileName); - goto out; + goto out; } chunkSize[i] = strlen(expand); freeChunk[i] = TRUE; @@ -733,9 +733,9 @@ */ { - int size = 1; // 1 for the terminating null + int size = 1; // 1 for the terminating null for (i = 0; i < nchunk; i++) { - size += chunkSize[i]; + size += chunkSize[i]; } result = malloc(size); } @@ -758,7 +758,7 @@ for (i = 0; i < nchunk; i++) { if (freeChunk[i]) { - free(chunks[i]); + free(chunks[i]); } } free(copy); diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/poll/poll.c open-vm-tools-12.1.5/open-vm-tools/lib/poll/poll.c --- open-vm-tools-11.3.5/open-vm-tools/lib/poll/poll.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/poll/poll.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2020 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2021 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 @@ -114,6 +114,30 @@ pollImpl->Init(); } + +/* + *---------------------------------------------------------------------- + * + * Poll_IsInitialized -- + * + * Allows libraries to determine if they can use poll or not. + * + * Results: + * TRUE if and only if poll is initialized. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +Bool +Poll_IsInitialized(void) +{ + return pollImpl != NULL; +} + + /* *---------------------------------------------------------------------- * @@ -132,9 +156,10 @@ void Poll_Exit(void) { - pollImpl->Exit(); - - pollImpl = NULL; + if (pollImpl) { + pollImpl->Exit(); + pollImpl = NULL; + } } diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/procMgr/procMgrPosix.c open-vm-tools-12.1.5/open-vm-tools/lib/procMgr/procMgrPosix.c --- open-vm-tools-11.3.5/open-vm-tools/lib/procMgr/procMgrPosix.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/procMgr/procMgrPosix.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2021 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2022 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 @@ -1952,7 +1952,7 @@ * ProcMgr_KillByPid -- * * Attempt to terminate the process of procId. - * First try TERM for 5 seconds, then KILL for 15 + * First try SIGTERM for 5 seconds, then SIGKILL for 15 * if that is unsuccessful. * * Results: diff -Nru open-vm-tools-11.3.5/open-vm-tools/lib/rpcVmx/rpcvmx.c open-vm-tools-12.1.5/open-vm-tools/lib/rpcVmx/rpcvmx.c --- open-vm-tools-11.3.5/open-vm-tools/lib/rpcVmx/rpcvmx.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/lib/rpcVmx/rpcvmx.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2004-2018,2019 VMware, Inc. All rights reserved. + * Copyright (C) 2004-2018,2019,2021 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 @@ -178,7 +178,8 @@ * returns two character strings "1 " on success and "0 " on * failure, so we don't need a sizeable buffer. */ - RpcOut_SendOneRawPreallocated(RpcVMX.logBuf, RpcVMX.logOffset + payloadLen, + RpcOut_SendOneRawPreallocated(RpcVMX.logBuf, + (size_t)RpcVMX.logOffset + payloadLen, receiveBuffer, sizeof receiveBuffer); } diff -Nru open-vm-tools-11.3.5/open-vm-tools/libDeployPkg/linuxDeployment.c open-vm-tools-12.1.5/open-vm-tools/libDeployPkg/linuxDeployment.c --- open-vm-tools-11.3.5/open-vm-tools/libDeployPkg/linuxDeployment.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/libDeployPkg/linuxDeployment.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2006-2021 VMware, Inc. All rights reserved. + * Copyright (C) 2006-2022 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 @@ -98,6 +98,10 @@ // the maximum length of cloud-init version stdout #define MAX_LENGTH_CLOUDINIT_VERSION 256 +// the maximum length of cloud-init status stdout +#define MAX_LENGTH_CLOUDINIT_STATUS 256 +// the default timeout of waiting for cloud-init execution done +#define DEFAULT_TIMEOUT_WAIT_FOR_CLOUDINIT_DONE 30 /* * Constant definitions @@ -113,6 +117,7 @@ #ifndef IMGCUST_UNITTEST static const char* RUNDIR = "/run"; static const char* VARRUNDIR = "/var/run"; +static const char* VARRUNIMCDIR = "/var/run/vmware-imc"; #endif static const char* TMPDIR = "/tmp"; @@ -122,6 +127,7 @@ static const int CUST_NETWORK_ERROR = 254; static const int CUST_NIC_ERROR = 253; static const int CUST_DNS_ERROR = 252; +static const int CUST_SCRIPT_DISABLED_ERROR = 6; // the error code to use cloudinit workflow typedef enum USE_CLOUDINIT_ERROR_CODE { @@ -134,6 +140,16 @@ USE_CLOUDINIT_IGNORE, } USE_CLOUDINIT_ERROR_CODE; +// the user-visible cloud-init application status code +typedef enum CLOUDINIT_STATUS_CODE { + CLOUDINIT_STATUS_NOT_RUN = 0, + CLOUDINIT_STATUS_RUNNING, + CLOUDINIT_STATUS_DONE, + CLOUDINIT_STATUS_ERROR, + CLOUDINIT_STATUS_DISABLED, + CLOUDINIT_STATUS_UNKNOWN, +} CLOUDINIT_STATUS_CODE; + /* * Linked list definition * @@ -189,6 +205,8 @@ LogFunction sLog = NoLogging; static uint16 gProcessTimeout = DEPLOYPKG_PROCESSTIMEOUT_DEFAULT; static bool gProcessTimeoutSetByLauncher = false; +static uint16 gWaitForCloudinitDoneTimeout = + DEFAULT_TIMEOUT_WAIT_FOR_CLOUDINIT_DONE; // ..................................................................................... @@ -224,6 +242,31 @@ } } +/* + *------------------------------------------------------------------------------ + * + * DeployPkg_SetWaitForCloudinitDoneTimeout + * + * Set the timeout value of customization process waits for cloud-init + * execution done before trigger reboot and after connect network adapters. + * Tools deployPkg plugin reads this timeout value from tools.conf and + * checks if the timeout value is valid, then calls this API to set the + * valid timeout value to gWaitForCloudinitDoneTimeout. + * + * @param timeout [in] + * timeout value to be used for waiting for cloud-init execution done + * + *------------------------------------------------------------------------------ + */ + +void +DeployPkg_SetWaitForCloudinitDoneTimeout(uint16 timeout) +{ + gWaitForCloudinitDoneTimeout = timeout; + sLog(log_debug, "Wait for cloud-init execution done timeout value: %d.", + gWaitForCloudinitDoneTimeout); +} + // ..................................................................................... /** @@ -273,11 +316,10 @@ Debug(const char *fmtstr, ...) { #ifdef VMX86_DEBUG - va_list args; - char *tmp = malloc(MAXSTRING); if (tmp != NULL) { + va_list args; va_start(args, fmtstr); Str_Vsnprintf(tmp, MAXSTRING, fmtstr, args); va_end(args); @@ -363,7 +405,8 @@ sLog(log_debug, "Got VMX response '%s'.", response); if (responseLength > responseBufferSize - 1) { sLog(log_warning, - "The VMX response is too long (only %d chars are allowed).", + "The VMX response is too long " + "(only %"FMTSZ"u chars are allowed).", responseBufferSize - 1); responseLength = responseBufferSize - 1; } @@ -465,11 +508,10 @@ /* * No Error check is employed since this is only an advisory service. */ - va_list args; - char* tmp = malloc(MAXSTRING); if (tmp != NULL) { + va_list args; va_start(args, format); Str_Vsnprintf(tmp, MAXSTRING, format, args); va_end(args); @@ -1183,13 +1225,14 @@ * - cloud-init is enabled. * * @param [IN] dirPath Path where the package is extracted. + * @param [IN] ignoreCloudInit whether ignore cloud-init workflow. * @returns the error code to use cloud-init work flow * *---------------------------------------------------------------------------- * */ static USE_CLOUDINIT_ERROR_CODE -UseCloudInitWorkflow(const char* dirPath) +UseCloudInitWorkflow(const char* dirPath, bool ignoreCloudInit) { static const char cfgName[] = "cust.cfg"; static const char metadataName[] = "metadata"; @@ -1198,24 +1241,29 @@ char cloudInitCommandOutput[MAX_LENGTH_CLOUDINIT_VERSION]; int forkExecResult; - if (NULL == dirPath) { - return USE_CLOUDINIT_INTERNAL_ERROR; - } - - // check if cust.cfg file exists - if (!CheckFileExist(dirPath, cfgName)) { - return USE_CLOUDINIT_NO_CUST_CFG; - } - forkExecResult = ForkExecAndWaitCommand(cloudInitCommand, false, cloudInitCommandOutput, sizeof(cloudInitCommandOutput)); if (forkExecResult != 0) { - sLog(log_info, "cloud-init is not installed."); + sLog(log_info, "Cloud-init is not installed."); return USE_CLOUDINIT_NOT_INSTALLED; } else { - sLog(log_info, "cloud-init is installed."); + sLog(log_info, "Cloud-init is installed."); + if (ignoreCloudInit) { + sLog(log_info, + "Ignoring cloud-init workflow according to header flags."); + return USE_CLOUDINIT_IGNORE; + } + } + + if (NULL == dirPath) { + return USE_CLOUDINIT_INTERNAL_ERROR; + } + + // check if cust.cfg file exists + if (!CheckFileExist(dirPath, cfgName)) { + return USE_CLOUDINIT_NO_CUST_CFG; } // If cloud-init metadata exists, check if cloud-init support to handle @@ -1225,12 +1273,12 @@ if (CheckFileExist(dirPath, metadataName)) { int major, minor; GetCloudinitVersion(cloudInitCommandOutput, &major, &minor); - sLog(log_info, "metadata exists, check cloud-init version..."); + sLog(log_info, "Metadata exists, check cloud-init version..."); if (major < CLOUDINIT_SUPPORT_RAW_DATA_MAJOR_VERSION || (major == CLOUDINIT_SUPPORT_RAW_DATA_MAJOR_VERSION && minor < CLOUDINIT_SUPPORT_RAW_DATA_MINOR_VERSION)) { sLog(log_info, - "cloud-init version %d.%d is older than required version %d.%d", + "Cloud-init version %d.%d is older than required version %d.%d.", major, minor, CLOUDINIT_SUPPORT_RAW_DATA_MAJOR_VERSION, @@ -1251,6 +1299,113 @@ /** * + * Function which gets the current cloud-init execution status. + * The status messages are copied from cloud-init offcial upstream + * https://github.com/canonical/cloud-init/blob/main/cloudinit/cmd/status.py + * These status messages are consistent since year 2017 + * + * @returns the status code of cloud-init application + * + **/ + +static CLOUDINIT_STATUS_CODE +GetCloudinitStatus() { + // Cloud-init execution status messages + static const char* NOT_RUN = "not run"; + static const char* RUNNING = "running"; + static const char* DONE = "done"; + static const char* ERROR = "error"; + static const char* DISABLED = "disabled"; + + static const char cloudinitStatusCmd[] = "/usr/bin/cloud-init status"; + char cloudinitStatusCmdOutput[MAX_LENGTH_CLOUDINIT_STATUS]; + int forkExecResult; + + forkExecResult = ForkExecAndWaitCommand(cloudinitStatusCmd, + false, + cloudinitStatusCmdOutput, + MAX_LENGTH_CLOUDINIT_STATUS); + if (forkExecResult != 0) { + sLog(log_info, "Unable to get cloud-init status."); + return CLOUDINIT_STATUS_UNKNOWN; + } else { + if (strstr(cloudinitStatusCmdOutput, NOT_RUN) != NULL) { + sLog(log_info, "Cloud-init status is '%s'.", NOT_RUN); + return CLOUDINIT_STATUS_NOT_RUN; + } else if (strstr(cloudinitStatusCmdOutput, RUNNING) != NULL) { + sLog(log_info, "Cloud-init status is '%s'.", RUNNING); + return CLOUDINIT_STATUS_RUNNING; + } else if (strstr(cloudinitStatusCmdOutput, DONE) != NULL) { + sLog(log_info, "Cloud-init status is '%s'.", DONE); + return CLOUDINIT_STATUS_DONE; + } else if (strstr(cloudinitStatusCmdOutput, ERROR) != NULL) { + sLog(log_info, "Cloud-init status is '%s'.", ERROR); + return CLOUDINIT_STATUS_ERROR; + } else if (strstr(cloudinitStatusCmdOutput, DISABLED) != NULL) { + sLog(log_info, "Cloud-init status is '%s'.", DISABLED); + return CLOUDINIT_STATUS_DISABLED; + } else { + sLog(log_warning, "Cloud-init status is unknown."); + return CLOUDINIT_STATUS_UNKNOWN; + } + } +} + + +/** + * + * Function which waits for cloud-init execution done. + * + * This function is called only when below conditions are fulfilled: + * - cloud-init is installed + * - guest os reboot is not skipped (so traditional GOSC workflow only) + * - deployment processed successfully in guest + * + * Default waiting timeout is DEFAULT_TIMEOUT_WAIT_FOR_CLOUDINIT_DONE seconds, + * when the timeout is reached, reboot will be triggered no matter what the + * cloud-init execution status is then. + * The timeout can be overwritten by the value which is set in tools.conf, + * if 0 is set in tools.conf, no waiting will be performed. + * + **/ + +static void +WaitForCloudinitDone() { + const int CheckStatusInterval = 5; + int timeoutSec = 0; + int elapsedSec = 0; + CLOUDINIT_STATUS_CODE cloudinitStatus = CLOUDINIT_STATUS_UNKNOWN; + + // No waiting when gWaitForCloudinitDoneTimeout is set to 0 + if (gWaitForCloudinitDoneTimeout == 0) { + return; + } + + timeoutSec = gWaitForCloudinitDoneTimeout; + + while (1) { + if (elapsedSec == timeoutSec) { + sLog(log_info, "Timed out waiting for cloud-init execution done."); + return; + } + if (elapsedSec % CheckStatusInterval == 0) { + cloudinitStatus = GetCloudinitStatus(); + // CLOUDINIT_STATUS_NOT_RUN and CLOUDINIT_STATUS_RUNNING represent + // cloud-init execution has not finished + if (cloudinitStatus != CLOUDINIT_STATUS_NOT_RUN && + cloudinitStatus != CLOUDINIT_STATUS_RUNNING) { + sLog(log_info, "Cloud-init execution is not on-going."); + return; + } + } + sleep(1); + elapsedSec++; + } +} + + +/** + * * Function which cleans up the deployment directory imcDirPath. * This function is called when customization deployment is completed or * any unexpected error happens before deployment begins. @@ -1316,6 +1471,7 @@ char *imcDirPath = NULL; USE_CLOUDINIT_ERROR_CODE useCloudInitWorkflow = USE_CLOUDINIT_IGNORE; int imcDirPathSize = 0; + bool ignoreCloudInit = false; TransitionState(NULL, INPROGRESS); // Notify the vpx of customization in-progress state @@ -1328,8 +1484,11 @@ #ifdef IMGCUST_UNITTEST baseDirPath = TMPDIR; #else + // PR 2942062, Use /var/run/vmware-imc if the directory exists // PR 2127543, Use /var/run or /run but /tmp firstly - if (File_IsDirectory(VARRUNDIR)) { + if (File_IsDirectory(VARRUNIMCDIR)) { + baseDirPath = VARRUNIMCDIR; + } else if (File_IsDirectory(VARRUNDIR)) { baseDirPath = VARRUNDIR; } else if (File_IsDirectory(RUNDIR)) { baseDirPath = RUNDIR; @@ -1397,11 +1556,8 @@ } } - if (!(flags & VMWAREDEPLOYPKG_HEADER_FLAGS_IGNORE_CLOUD_INIT)) { - useCloudInitWorkflow = UseCloudInitWorkflow(imcDirPath); - } else { - sLog(log_info, "Ignoring cloud-init."); - } + ignoreCloudInit = flags & VMWAREDEPLOYPKG_HEADER_FLAGS_IGNORE_CLOUD_INIT; + useCloudInitWorkflow = UseCloudInitWorkflow(imcDirPath, ignoreCloudInit); sLog(log_info, "UseCloudInitWorkflow return: %d", useCloudInitWorkflow); @@ -1444,6 +1600,11 @@ SetCustomizationStatusInVmx(TOOLSDEPLOYPKG_RUNNING, GUESTCUST_EVENT_NETWORK_SETUP_FAILED, NULL); + } else if (deploymentResult == CUST_SCRIPT_DISABLED_ERROR) { + sLog(log_info, + "Setting custom script disabled error status in vmx."); + SetCustomizationStatusInVmx(TOOLSDEPLOYPKG_RUNNING, + TOOLSDEPLOYPKG_ERROR_CUST_SCRIPT_DISABLED, NULL); } else { sLog(log_info, "Setting '%s' error status in vmx.", deploymentResult == CUST_GENERIC_ERROR ? "generic" : "unknown"); @@ -1503,6 +1664,10 @@ //Reset the guest OS if (!sSkipReboot && !deploymentResult) { + if (useCloudInitWorkflow != USE_CLOUDINIT_NOT_INSTALLED) { + sLog(log_info, "Do not trigger reboot if cloud-init is executing."); + WaitForCloudinitDone(); + } pid_t pid = fork(); if (pid == -1) { sLog(log_error, "Failed to fork: '%s'.", strerror(errno)); @@ -1883,6 +2048,16 @@ { DeployPkgStatus retStatus; +#if !defined(OPEN_VM_TOOLS) && !defined(USERWORLD) + sLog(log_info, "libDeployPkg.so version: %s (%s)", + SYSIMAGE_VERSION_EXT_STR, BUILD_NUMBER); +#else + /* + * For OPEN_VM_TOOLS and USERWORLD, the vmtoolsd version is logged in + * function DeployPkgDeployPkgInGuest from + * services/plugins/deployPkg/deployPkg.c + */ +#endif sLog(log_info, "Initializing deployment module."); Init(); diff -Nru open-vm-tools-11.3.5/open-vm-tools/libvmtools/vmtoolsConfig.c open-vm-tools-12.1.5/open-vm-tools/libvmtools/vmtoolsConfig.c --- open-vm-tools-11.3.5/open-vm-tools/libvmtools/vmtoolsConfig.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/libvmtools/vmtoolsConfig.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2008-2021 VMware, Inc. All rights reserved. + * Copyright (C) 2008-2022 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 @@ -150,6 +150,8 @@ goto exit; } + /* On error, 'err' will be set, null otherwise */ + /* coverity[check_return] */ g_key_file_load_from_file(cfg, localPath, flags, &err); if (err == NULL || err->code == G_KEY_FILE_ERROR_GROUP_NOT_FOUND) { goto exit; diff -Nru open-vm-tools-11.3.5/open-vm-tools/libvmtools/vmtoolsLog.c open-vm-tools-12.1.5/open-vm-tools/libvmtools/vmtoolsLog.c --- open-vm-tools-11.3.5/open-vm-tools/libvmtools/vmtoolsLog.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/libvmtools/vmtoolsLog.c 2022-11-29 21:17:22.000000000 +0000 @@ -59,6 +59,11 @@ #include "err.h" #include "logToHost.h" #include "vthreadBase.h" +#include "hostinfo.h" +#include "vm_tools_version.h" +#include "buildNumber.h" +#include "vm_product.h" +#include "util.h" #define LOGGING_GROUP "logging" @@ -120,6 +125,8 @@ #define VMX_LOG_CMD "log " #define VMX_LOG_CMD_LEN (sizeof(VMX_LOG_CMD) - 1) +#define LOG_HEADER_MAX_ENTRIES 2 + typedef struct LogHandler { GlibLogger *logger; @@ -194,6 +201,9 @@ */ static GLogLevelFlags gLevelMask; +static gchar *gLogHeaderBuf[LOG_HEADER_MAX_ENTRIES]; +static guint gLogHeaderCount; + static enum RpcMode { RPC_OFF = 0, RPC_GUEST_LOG_TEXT, @@ -212,6 +222,7 @@ const gchar *domain, const gchar *fmt, va_list args); +static LogHandler *GetLogHandlerByDomain(const gchar *domain); /* Internal functions. */ @@ -497,6 +508,31 @@ /** + * Function that logs a cached log header of Tools version, build details + * and Guest OS details. + * + * @param[in] _data LogEntry pointer. + */ + +static void +VMToolsLogHeader(gpointer _data) +{ + LogEntry *entry = _data; + GlibLogger *logger = entry->handler->logger; + guint i; + + for (i = 0; i < gLogHeaderCount; i++) { + char *message = VMToolsLogFormat(gLogHeaderBuf[i], entry->domain, + G_LOG_LEVEL_MESSAGE, entry->handler, + FALSE); + + logger->logfn(entry->domain, G_LOG_LEVEL_MESSAGE, message, logger); + g_free(message); + } +} + + +/** * Function that calls the log handler. * * Also, frees the _data to avoid having separate free call. @@ -513,6 +549,10 @@ gboolean usedSyslog = FALSE; if (logger != NULL) { + if (logger->logHeader) { + VMToolsLogHeader(entry); + logger->logHeader = FALSE; + } logger->logfn(entry->domain, entry->level, entry->msg, logger); usedSyslog = entry->handler->isSysLog; } else if (gErrorData->logger != NULL) { @@ -1416,6 +1456,7 @@ GPtrArray *oldDomains = NULL; LogHandler *oldDefault = NULL; GError *err = NULL; + char *gosDetails; g_return_if_fail(defaultDomain != NULL); @@ -1489,6 +1530,34 @@ gLogEnabled |= force; MarkLogInitialized(); + /* + * Cache Tools version, build number and guest OS details. + * Cached log headers will be logged at log rotation and reset. + * No need to re-init the log headers in case of config reload. + */ + if (gLogHeaderCount == 0) { + LogHandler *handler = GetLogHandlerByDomain(gLogDomain); + GlibLogger *logger = handler->logger; + + logger->logHeader = TRUE; + + gLogHeaderBuf[gLogHeaderCount++] = Str_Asprintf(NULL, + "%s Version: %s (%s)", + VMWARE_TOOLS_SHORT_NAME, + TOOLS_VERSION_EXT_CURRENT_STR, + BUILD_NUMBER); + + gosDetails = Hostinfo_GetOSDetailedData(); + if (gosDetails != NULL && gLogHeaderCount < LOG_HEADER_MAX_ENTRIES) { + gLogHeaderBuf[gLogHeaderCount++] = Str_Asprintf(NULL, + "Guest OS details: %s", + gosDetails); + } + free(gosDetails); + + ASSERT(gLogHeaderCount <= LOG_HEADER_MAX_ENTRIES); + } + gMaxCacheEntries = g_key_file_get_integer(cfg, LOGGING_GROUP, "maxCacheEntries", &err); if (err != NULL || gMaxCacheEntries < 0) { @@ -2720,35 +2789,33 @@ /* ****************************************************************************** - * VMTools_VmxLog -- + * VMToolsVmxLogV -- * * Sends the log message through RPC to vmx to be logged on the host. * Also, logs the message to vmsvc log file inside guest. * * @param[in] chan The RPC channel instance. * @param[in] fmt Log message output format. + * @param[in] args The argument list. * * @return None * ****************************************************************************** */ -void -VMTools_VmxLog(RpcChannel *chan, +static void +VMToolsVmxLogV(RpcChannel *chan, const gchar *fmt, - ...) + va_list args) { char *reply = NULL; size_t replyLen; gchar msg[4096] = VMX_LOG_CMD; - va_list args; gint len; - va_start(args, fmt); len = g_vsnprintf(msg + VMX_LOG_CMD_LEN, sizeof msg - VMX_LOG_CMD_LEN, fmt, args); - va_end(args); if (len <= 0) { g_warning("%s: g_vsnprintf failed: return value: %d.\n", __FUNCTION__, @@ -2770,3 +2837,61 @@ g_message("%s\n", msg + VMX_LOG_CMD_LEN); } + + +/* + ****************************************************************************** + * VMTools_VmxLog -- + * + * Passes through VMToolsVmxLogV but takes the arguments inline. + * + * @param[in] chan The RPC channel instance. + * @param[in] fmt Log message output format. + * + * @return None + * + ****************************************************************************** + */ + +void +VMTools_VmxLog(RpcChannel *chan, + const gchar *fmt, + ...) +{ + va_list args; + + va_start(args, fmt); + VMToolsVmxLogV(chan, fmt, args); + va_end(args); +} + + +/* + ****************************************************************************** + * VMTools_VmxLogThrottled -- + * + * Passes through VMToolsVmxLogV to log the message after checking for the + * throttling condition. Takes the arguments inline. + * + * @param[in/out] count Throttle count. + * @param[in] chan The RPC channel instance. + * @param[in] fmt Log message output format. + * + * @return None + * + ****************************************************************************** + */ + +void +VMTools_VmxLogThrottled(uint32 *count, + RpcChannel *chan, + const gchar *fmt, + ...) +{ + va_list args; + if (Util_Throttle(++*count)) { + va_start(args, fmt); + VMToolsVmxLogV(chan, fmt, args); + va_end(args); + } +} diff -Nru open-vm-tools-11.3.5/open-vm-tools/modules/shared/vmmemctl/dbllnklst.h open-vm-tools-12.1.5/open-vm-tools/modules/shared/vmmemctl/dbllnklst.h --- open-vm-tools-11.3.5/open-vm-tools/modules/shared/vmmemctl/dbllnklst.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/modules/shared/vmmemctl/dbllnklst.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2017,2020 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2017,2020,2022 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 @@ -69,6 +69,7 @@ #define INCLUDE_ALLOW_MODULE #define INCLUDE_ALLOW_USERLEVEL +#define INCLUDE_ALLOW_VMCORE #include "includeCheck.h" #include "vm_basic_types.h" diff -Nru open-vm-tools-11.3.5/open-vm-tools/modules/shared/vmmemctl/kernelStubs.h open-vm-tools-12.1.5/open-vm-tools/modules/shared/vmmemctl/kernelStubs.h --- open-vm-tools-11.3.5/open-vm-tools/modules/shared/vmmemctl/kernelStubs.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/modules/shared/vmmemctl/kernelStubs.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2006-2019 VMware, Inc. All rights reserved. + * Copyright (C) 2006-2019,2021 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 @@ -66,10 +66,11 @@ #ifndef __KERNELSTUBS_H__ #define __KERNELSTUBS_H__ -#define KRNL_STUBS_DRIVER_TYPE_POSIX 1 -#define KRNL_STUBS_DRIVER_TYPE_GDI 2 -#define KRNL_STUBS_DRIVER_TYPE_WDM 3 -#define KRNL_STUBS_DRIVER_TYPE_NDIS 4 +#define KRNL_STUBS_DRIVER_TYPE_POSIX 1 +#define KRNL_STUBS_DRIVER_TYPE_GDI 2 +#define KRNL_STUBS_DRIVER_TYPE_WDM 3 +#define KRNL_STUBS_DRIVER_TYPE_NDIS 4 +#define KRNL_STUBS_DRIVER_TYPE_STORPORT 5 // For now (vsphere-2015), choose a good default. Later we'll modify all the // build files using KernelStubs to set this. @@ -107,6 +108,16 @@ # include "kernelStubsFloorFixes.h" #pragma warning(disable:4201) // unnamed struct/union # include +# elif KRNL_STUBS_DRIVER_TYPE == KRNL_STUBS_DRIVER_TYPE_STORPORT +# include "vm_basic_types.h" +# include /* kernel memory APIs, DbgPrintEx */ +# include /* for _vsnprintf, vsprintf */ +# include /* for va_start stuff */ +# include /* for min macro. */ +# include /* for Storport functions */ +# include "vm_basic_defs.h" +# include "vm_assert.h" /* Our assert macros */ +# include "kernelStubsFloorFixes.h" # elif KRNL_STUBS_DRIVER_TYPE == KRNL_STUBS_DRIVER_TYPE_WDM # include "vm_basic_types.h" # if defined(NTDDI_WINXP) && (NTDDI_VERSION >= NTDDI_WINXP) diff -Nru open-vm-tools-11.3.5/open-vm-tools/modules/shared/vmxnet/eth_public.h open-vm-tools-12.1.5/open-vm-tools/modules/shared/vmxnet/eth_public.h --- open-vm-tools-11.3.5/open-vm-tools/modules/shared/vmxnet/eth_public.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/modules/shared/vmxnet/eth_public.h 2022-11-29 21:17:22.000000000 +0000 @@ -48,6 +48,7 @@ #include "includeCheck.h" #include "vm_basic_defs.h" +#include "vm_assert.h" #if defined __cplusplus extern "C" { diff -Nru open-vm-tools-11.3.5/open-vm-tools/modules/shared/vmxnet/vmnet_def.h open-vm-tools-12.1.5/open-vm-tools/modules/shared/vmxnet/vmnet_def.h --- open-vm-tools-11.3.5/open-vm-tools/modules/shared/vmxnet/vmnet_def.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/modules/shared/vmxnet/vmnet_def.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2004-2014,2017-2019,2021 VMware, Inc. All rights reserved. + * Copyright (C) 2004-2014,2017-2019,2021,2022 VMware, Inc. All rights reserved. * * 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 @@ -75,6 +75,7 @@ #define VMNET_CAP_RX_CHAIN CONST64U(0x8000) /* a pkt can span multiple rx entries */ #define VMNET_CAP_LPD CONST64U(0x10000) /* large pkt delivery */ #define VMNET_CAP_BPF CONST64U(0x20000) /* BPF Support in VMXNET Virtual Hardware */ +#define VMNET_CAP_AUTO_REBIND CONST64U(0x20000) /* BPF support is not for uplink, reuse this bit for uplink auto rebind */ #define VMNET_CAP_SG_SPAN_PAGES CONST64U(0x40000) /* Can do scatter-gather span multiple pages transmits. */ #define VMNET_CAP_IP6_CSUM CONST64U(0x80000) /* Can do IPv6 csum offload. */ #define VMNET_CAP_TSO6 CONST64U(0x100000) /* Can do TSO segmentation offload for IPv6 pkts. */ @@ -90,6 +91,7 @@ #define VMNET_CAP_SCHED CONST64U(0x40000000) /* compliant with network scheduling */ #define VMNET_CAP_SRIOV CONST64U(0x80000000) /* Supports SR-IOV */ +#define VMNET_CAP_PREFERRED_MGMT_NIC CONST64U(0x100000000) /* Uplink should be given preference when selecting the management NIC */ #define VMNET_CAP_SG_TX VMNET_CAP_SG #define VMNET_CAP_SG_RX CONST64U(0x200000000) /* Scatter-gather receive capability */ #define VMNET_CAP_PRIV_STATS CONST64U(0x400000000) /* Driver supports accessing private stats */ diff -Nru open-vm-tools-11.3.5/open-vm-tools/modules/shared/vmxnet/vmxnet3_defs.h open-vm-tools-12.1.5/open-vm-tools/modules/shared/vmxnet/vmxnet3_defs.h --- open-vm-tools-11.3.5/open-vm-tools/modules/shared/vmxnet/vmxnet3_defs.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/modules/shared/vmxnet/vmxnet3_defs.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2007-2021 VMware, Inc. All rights reserved. + * Copyright (C) 2007-2022 VMware, Inc. All rights reserved. * * 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 @@ -749,9 +749,9 @@ typedef enum { - VMXNET3_PKTSTEERING_NOACTION, - VMXNET3_PKTSTEERING_ACCEPT, - VMXNET3_PKTSTEERING_REJECT, + VMXNET3_PKTSTEERING_NOACTION, /* Not currently supported */ + VMXNET3_PKTSTEERING_ACCEPT, /* Steer the packet to a specified rxQid */ + VMXNET3_PKTSTEERING_REJECT, /* Drop the packet */ VMXNET3_PKTSTEERING_ACTION_MAX, } Vmxnet3_PktSteeringAction; @@ -1118,29 +1118,38 @@ #define VMXNET3_DCR_ERROR 31 /* error when bit 31 of DCR * is set */ -#define VMXNET3_CAP_UDP_RSS 0 /* bit 0 of DCR 0 */ -#define VMXNET3_CAP_ESP_RSS_IPV4 1 /* bit 1 of DCR 0 */ + +#define VMXNET3_CAP_UDP_RSS 0 /* bit 0 of DCR 0 */ +#define VMXNET3_CAP_ESP_RSS_IPV4 1 /* bit 1 of DCR 0 */ #define VMXNET3_CAP_GENEVE_CHECKSUM_OFFLOAD 2 /* bit 2 of DCR 0 */ #define VMXNET3_CAP_GENEVE_TSO 3 /* bit 3 of DCR 0 */ #define VMXNET3_CAP_VXLAN_CHECKSUM_OFFLOAD 4 /* bit 4 of DCR 0 */ #define VMXNET3_CAP_VXLAN_TSO 5 /* bit 5 of DCR 0 */ #define VMXENT3_CAP_GENEVE_OUTER_CHECKSUM_OFFLOAD 6 /* bit 6 of DCR 0 */ #define VMXNET3_CAP_VXLAN_OUTER_CHECKSUM_OFFLOAD 7 /* bit 7 of DCR 0 */ +#define VMXNET3_CAP_VERSION_4_MAX \ + (VMXNET3_CAP_VXLAN_OUTER_CHECKSUM_OFFLOAD + 1) + #define VMXNET3_CAP_PKT_STEERING_IPV4 8 /* bit 8 of DCR 0 */ -#define VMXNET3_CAP_VERSION_4_MAX VMXNET3_CAP_PKT_STEERING_IPV4 +#define VMXNET3_CAP_VERSION_5_MAX (VMXNET3_CAP_PKT_STEERING_IPV4 + 1) + #define VMXNET3_CAP_ESP_RSS_IPV6 9 /* bit 9 of DCR 0 */ -#define VMXNET3_CAP_VERSION_5_MAX VMXNET3_CAP_ESP_RSS_IPV6 -#define VMXNET3_CAP_ESP_OVER_UDP_RSS 10 /* bit 10 of DCR 0 */ -#define VMXNET3_CAP_INNER_RSS 11 /* bit 11 of DCR 0 */ -#define VMXNET3_CAP_INNER_ESP_RSS 12 /* bit 12 of DCR 0 */ -#define VMXNET3_CAP_CRC32_HASH_FUNC 13 /* bit 13 of DCR 0 */ -#define VMXNET3_CAP_VERSION_6_MAX VMXNET3_CAP_CRC32_HASH_FUNC -#define VMXNET3_CAP_OAM_FILTER 14 /* bit 14 of DCR 0 */ -#define VMXNET3_CAP_ESP_QS 15 /* bit 15 of DCR 0 */ -#define VMXNET3_CAP_LARGE_BAR 16 /* bit 16 of DCR 0 */ -#define VMXNET3_CAP_OOORX_COMP 17 /* bit 17 of DCR 0 */ -#define VMXNET3_CAP_VERSION_7_MAX 18 +#define VMXNET3_CAP_ESP_OVER_UDP_RSS 10 /* bit 10 of DCR 0 */ +#define VMXNET3_CAP_INNER_RSS 11 /* bit 11 of DCR 0 */ +#define VMXNET3_CAP_INNER_ESP_RSS 12 /* bit 12 of DCR 0 */ +#define VMXNET3_CAP_VERSION_6_MAX (VMXNET3_CAP_INNER_ESP_RSS + 1) + +#define VMXNET3_CAP_CRC32_HASH_FUNC 13 /* bit 13 of DCR 0 */ +#define VMXNET3_CAP_OAM_FILTER 14 /* bit 14 of DCR 0 */ +#define VMXNET3_CAP_ESP_QS 15 /* bit 15 of DCR 0 */ +#define VMXNET3_CAP_LARGE_BAR 16 /* bit 16 of DCR 0 */ +#define VMXNET3_CAP_OOORX_COMP 17 /* bit 17 of DCR 0 */ +#define VMXNET3_CAP_VERSION_7_MAX (VMXNET3_CAP_OOORX_COMP + 1) + +#define VMXNET3_CAP_PKT_STEERING_IPV6 18 /* bit 19 of DCR 0 */ +#define VMXNET3_CAP_VERSION_8_MAX (VMXNET3_CAP_PKT_STEERING_IPV6 + 1) + /* when new capability is introduced, update VMXNET3_CAP_MAX */ -#define VMXNET3_CAP_MAX VMXNET3_CAP_VERSION_7_MAX +#define VMXNET3_CAP_MAX VMXNET3_CAP_VERSION_8_MAX #endif /* _VMXNET3_DEFS_H_ */ diff -Nru open-vm-tools-11.3.5/open-vm-tools/modules/solaris/vmhgfs/kernelStubs.h open-vm-tools-12.1.5/open-vm-tools/modules/solaris/vmhgfs/kernelStubs.h --- open-vm-tools-11.3.5/open-vm-tools/modules/solaris/vmhgfs/kernelStubs.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/modules/solaris/vmhgfs/kernelStubs.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2006-2019 VMware, Inc. All rights reserved. + * Copyright (C) 2006-2019,2021 VMware, Inc. All rights reserved. * * The contents of this file are subject to the terms of the Common * Development and Distribution License (the "License") version 1.0 @@ -25,10 +25,11 @@ #ifndef __KERNELSTUBS_H__ #define __KERNELSTUBS_H__ -#define KRNL_STUBS_DRIVER_TYPE_POSIX 1 -#define KRNL_STUBS_DRIVER_TYPE_GDI 2 -#define KRNL_STUBS_DRIVER_TYPE_WDM 3 -#define KRNL_STUBS_DRIVER_TYPE_NDIS 4 +#define KRNL_STUBS_DRIVER_TYPE_POSIX 1 +#define KRNL_STUBS_DRIVER_TYPE_GDI 2 +#define KRNL_STUBS_DRIVER_TYPE_WDM 3 +#define KRNL_STUBS_DRIVER_TYPE_NDIS 4 +#define KRNL_STUBS_DRIVER_TYPE_STORPORT 5 // For now (vsphere-2015), choose a good default. Later we'll modify all the // build files using KernelStubs to set this. @@ -66,6 +67,16 @@ # include "kernelStubsFloorFixes.h" #pragma warning(disable:4201) // unnamed struct/union # include +# elif KRNL_STUBS_DRIVER_TYPE == KRNL_STUBS_DRIVER_TYPE_STORPORT +# include "vm_basic_types.h" +# include /* kernel memory APIs, DbgPrintEx */ +# include /* for _vsnprintf, vsprintf */ +# include /* for va_start stuff */ +# include /* for min macro. */ +# include /* for Storport functions */ +# include "vm_basic_defs.h" +# include "vm_assert.h" /* Our assert macros */ +# include "kernelStubsFloorFixes.h" # elif KRNL_STUBS_DRIVER_TYPE == KRNL_STUBS_DRIVER_TYPE_WDM # include "vm_basic_types.h" # if defined(NTDDI_WINXP) && (NTDDI_VERSION >= NTDDI_WINXP) diff -Nru open-vm-tools-11.3.5/open-vm-tools/namespacetool/namespacetool.c open-vm-tools-12.1.5/open-vm-tools/namespacetool/namespacetool.c --- open-vm-tools-11.3.5/open-vm-tools/namespacetool/namespacetool.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/namespacetool/namespacetool.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2016-2020 VMware, Inc. All rights reserved. + * Copyright (C) 2016-2020,2022 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 @@ -279,7 +279,7 @@ *fileContents = NULL; *length = 0; } - g_free(gErr); + g_error_free(gErr); return retVal; } diff -Nru open-vm-tools-11.3.5/open-vm-tools/scripts/common/vm-support open-vm-tools-12.1.5/open-vm-tools/scripts/common/vm-support --- open-vm-tools-11.3.5/open-vm-tools/scripts/common/vm-support 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/scripts/common/vm-support 2022-11-29 21:17:22.000000000 +0000 @@ -1,6 +1,6 @@ #!/bin/sh ########################################################## -# Copyright (C) 2006-2021 VMware, Inc. All rights reserved. +# Copyright (C) 2006-2022 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 @@ -133,26 +133,6 @@ } -# addGrubFile(): adds a grub file to the archive after -# replacing password hash with 'xxxxxx' -addGrubFile() -{ - file="$1" - - addfile "$file" - if [ $? != 0 ]; then - return - fi - - # Avoid tempering with links - if [ ! -L "${OUTPUT_DIR}$file" ]; then - cat "${OUTPUT_DIR}$file" | \ - sed 's/password[[:space:]]\+\(.*\)[[:space:]]\+\(.*\)$/password \1 xxxxxx/g' > \ - "${OUTPUT_DIR}$file.modified" - mv "${OUTPUT_DIR}$file.modified" "${OUTPUT_DIR}$file" - fi -} - # runcmd($out, $cmd): executes the command redirected to a file runcmd() { @@ -181,12 +161,6 @@ # Try to collect bootloader config. addfile /etc/lilo.conf - # And for grub we are not sure about the exact default location so collect them - # all. - addGrubFile /boot/grub/grub.conf - addGrubFile /boot/grub/menu.lst - addGrubFile /etc/grub.conf - # Old linux kernel use modules.conf while new kernel use modprobe.conf and modprobe.d addfile /etc/modules.conf addfile /etc/modprobe.conf @@ -280,7 +254,7 @@ export PATH=/bin:/sbin:/usr/bin:/usr/sbin TARFILE=vm-`date +%Y-%m-%d`.$$.tar.gz -VER=0.93 +VER=0.95 # Parse args for option in $@ @@ -362,6 +336,8 @@ addfile /var/log/cloud-init.log addfile /var/log/cloud-init-output.log addfile /etc/cloud/cloud.cfg +addfile /etc/default/locale +addfile /etc/locale.conf runcmd "/tmp/df.txt" df collectNetworkDetails @@ -371,6 +347,8 @@ runcmd "/tmp/uptime.txt" uptime runcmd "/tmp/date.txt" date runcmd "/tmp/umask.txt" umask +runcmd "/tmp/locale-current.txt" locale +runcmd "/tmp/locale-list.txt" locale -a case `uname` in Linux) diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/appInfo/appInfo.c open-vm-tools-12.1.5/open-vm-tools/services/plugins/appInfo/appInfo.c --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/appInfo/appInfo.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/appInfo/appInfo.c 2022-11-29 21:17:22.000000000 +0000 @@ -30,6 +30,7 @@ #include "appInfoInt.h" #include "vmware.h" +#include "codeset.h" #include "conf.h" #include "dynbuf.h" #include "escape.h" @@ -50,10 +51,6 @@ VM_EMBED_VERSION(VMTOOLSD_VERSION_STRING); #endif -#if defined(_WIN32) -#include "codeset.h" -#endif - /** * Maximum size of the packet size that appInfo plugin should send * to the VMX. Currently, this is set to 62 KB. @@ -74,6 +71,14 @@ #define APP_INFO_CONF_DEFAULT_DISABLED_VALUE FALSE /** + * Default value for CONFNAME_APPINFO_REMOVE_DUPLICATES setting in + * tools configuration file. + * + * TRUE will remove duplicate applications. + */ +#define APP_INFO_CONF_DEFAULT_REMOVE_DUPLICATES TRUE + +/** * Default value for CONFNAME_APPINFO_USE_WMI setting in * tools configuration file. * @@ -104,51 +109,6 @@ /* ***************************************************************************** - * EscapeJSONString -- - * - * Escapes a string to be included in JSON content. - * - * @param[in] str The string to be escaped. - * - * @retval Pointer to a heap-allocated memory. This holds the escaped content - * of the string passed by the caller. - * - ***************************************************************************** - */ - -static char * -EscapeJSONString(const char *str) // IN -{ - /* - * Escape '"' and '\' characters in the JSON string. - */ - - static const int bytesToEscape[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // " - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, // '\' - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - }; - - return Escape_DoString("\\u00", bytesToEscape, str, strlen(str), - NULL); -} - - -/* - ***************************************************************************** * SetGuestInfo -- * * Sends a simple key-value update request to the VMX. @@ -291,6 +251,8 @@ GSList *appNode; static Atomic_uint64 updateCounter = {0}; uint64 counter = (uint64) Atomic_ReadInc64(&updateCounter) + 1; + GHashTable *appsAdded = NULL; + gchar *key = NULL; static char headerFmt[] = "{\n" "\"" APP_INFO_KEY_VERSION "\":\"%d\", \n" @@ -305,6 +267,11 @@ "\"" APP_INFO_KEY_APP_VERSION "\":\"%s\"" "}"; static char jsonSuffix[] = "]}"; + gboolean removeDup = + VMTools_ConfigGetBoolean(ctx->config, + CONFGROUPNAME_APPINFO, + CONFNAME_APPINFO_REMOVE_DUPLICATES, + APP_INFO_CONF_DEFAULT_REMOVE_DUPLICATES); DynBuf_Init(&dynBuffer); @@ -323,6 +290,10 @@ DynBuf_Append(&dynBuffer, tmpBuf, len); appList = AppInfo_SortAppList(AppInfo_GetAppList(ctx->config)); + if (removeDup) { + appsAdded = g_hash_table_new_full(g_str_hash, g_str_equal, + g_free, NULL); + } for (appNode = appList; appNode != NULL; appNode = appNode->next) { size_t currentBufferSize = DynBuf_GetSize(&dynBuffer); @@ -333,7 +304,17 @@ goto next_entry; } - escapedCmd = EscapeJSONString(appInfo->appName); + if (removeDup) { + key = g_strdup_printf("%s|%s", appInfo->appName, appInfo->version); + /* + * If the key already exists, then this app is a duplicate. Free + * the key and move to the next application. + */ + if (g_hash_table_contains(appsAdded, key)) { + goto next_entry; + } + } + escapedCmd = CodeSet_JsonEscape(appInfo->appName); if (NULL == escapedCmd) { g_warning("%s: Failed to escape the content of cmdName.\n", @@ -341,7 +322,7 @@ goto quit; } - escapedVersion = EscapeJSONString(appInfo->version); + escapedVersion = CodeSet_JsonEscape(appInfo->version); if (NULL == escapedVersion) { g_warning("%s: Failed to escape the content of version information.\n", __FUNCTION__); @@ -373,8 +354,14 @@ } DynBuf_Append(&dynBuffer, tmpBuf, len); + if (removeDup) { + g_hash_table_add(appsAdded, key); + key = NULL; + } next_entry: + g_free(key); + key = NULL; free(escapedCmd); escapedCmd = NULL; free(escapedVersion); @@ -388,6 +375,10 @@ free(escapedCmd); free(escapedVersion); AppInfo_DestroyAppList(appList); + if (appsAdded != NULL) { + g_hash_table_destroy(appsAdded); + } + g_free(key); g_free(tstamp); DynBuf_Destroy(&dynBuffer); } @@ -514,7 +505,7 @@ CONFNAME_APPINFO_POLLINTERVAL, APP_INFO_POLL_INTERVAL); - if (pollInterval < 0) { + if (pollInterval < 0 || pollInterval > (G_MAXINT / 1000)) { g_warning("%s: Invalid poll interval %d. Using default %us.\n", __FUNCTION__, pollInterval, APP_INFO_POLL_INTERVAL); pollInterval = APP_INFO_POLL_INTERVAL; diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/componentMgr/componentMgr.c open-vm-tools-12.1.5/open-vm-tools/services/plugins/componentMgr/componentMgr.c --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/componentMgr/componentMgr.c 1970-01-01 00:00:00.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/componentMgr/componentMgr.c 2022-11-29 21:17:22.000000000 +0000 @@ -0,0 +1,414 @@ +/********************************************************* + * Copyright (C) 2021 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 + * by the Free Software Foundation version 2.1 and no later version. + * + * 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 Lesser GNU General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + *********************************************************/ + +/* + * componentMgr.c -- + * + * Adds/removes components in the guest OS. Periodically polls + * for all the components managed by the plugin and fetches the guestVar + * guestinfo./vmware.components..desiredstate for present or + * absent action and accordingly adds/removes the component from the + * system. + * All actions on a component runs as an async process. + */ + +#include "componentMgrPlugin.h" +#include "str.h" +#include "vm_version.h" +#include "embed_version.h" +#include "vmtoolsd_version.h" +VM_EMBED_VERSION(VMTOOLSD_VERSION_STRING); + + +/* + * componentMgr plugin poll interval timeout source. + */ +static GSource *gComponentMgrTimeoutSource = NULL; + +/* + * Tools application context. + */ +static ToolsAppCtx *gCtx; + +/* + * componentMgr plugin poll interval. + */ +static guint gComponentMgrPollInterval = 0; + +static gboolean ComponentMgrCb(gpointer data); + + +/* + ***************************************************************************** + * ComponentMgr_GetToolsAppCtx -- + * + * A getter function to fetch the tools application context in all points of + * the plugin. + * + * @return + * Main ToolsAppCtx of the plugin. + * + ***************************************************************************** + */ + +ToolsAppCtx* +ComponentMgr_GetToolsAppCtx() +{ + return gCtx; +} + + +/* + ***************************************************************************** + * ReconfigureComponentMgrPollLoopEx -- + * + * Start, stop and reconfigure componentMgr plugin poll loop. + * This function is responsible for creating, handling, and resetting the + * componentMgr loop timeout source. + * + * @param[in] ctx Tools application context. + * @param[in] pollInterval Poll interval in seconds. + * + * @return + * None + * + * Side effects: + * Deletes the existing timeout source and recreates a new one. + * + ***************************************************************************** + */ + +static void +ReconfigureComponentMgrPollLoopEx(ToolsAppCtx *ctx, // IN + gint pollInterval) // IN +{ + if (gComponentMgrPollInterval == pollInterval) { + g_debug("%s: ComponentMgr poll interval has not been changed since" + " last time.\n", __FUNCTION__); + return; + } + + if (gComponentMgrTimeoutSource != NULL) { + /* + * Destroy the existing timeout source. + */ + g_source_destroy(gComponentMgrTimeoutSource); + gComponentMgrTimeoutSource = NULL; + } + + if (pollInterval != 0) { + if (pollInterval < COMPONENTMGR_MIN_POLL_INTERVAL || + pollInterval > (G_MAXINT / 1000)) { + g_warning("%s: Invalid poll interval. Using default %us.\n", + __FUNCTION__, COMPONENTMGR_DEFAULT_POLL_INTERVAL); + pollInterval = COMPONENTMGR_DEFAULT_POLL_INTERVAL; + } + + g_info("%s: New value for %s is %us.\n", __FUNCTION__, + COMPONENTMGR_CONF_POLLINTERVAL, + pollInterval); + + gComponentMgrTimeoutSource = g_timeout_source_new(pollInterval * 1000); + VMTOOLSAPP_ATTACH_SOURCE(ctx, gComponentMgrTimeoutSource, + ComponentMgrCb, ctx, NULL); + g_source_unref(gComponentMgrTimeoutSource); + } else { + /* + * Plugin will be disabled since poll interval configured is 0. + * No components will be managed. Publish guestVar available. + */ + g_info("%s: ComponentMgr plugin disabled.\n", __FUNCTION__); + ComponentMgr_PublishAvailableComponents(ctx, + COMPONENTMGR_NONECOMPONENTS); + } + + gComponentMgrPollInterval = pollInterval; +} + + +/* + ***************************************************************************** + * ComponentMgrCb -- + * + * This function updates the component status managed by the plugin. + * This function internally calls present/absent actions on the respective + * components. + * + * @param[in] data Tools application context. + * + * @return + * G_SOURCE_CONTINUE To continue polling. + * + * Side effects: + * None. + * + ***************************************************************************** + */ + +static gboolean +ComponentMgrCb(gpointer data) // IN +{ + ToolsAppCtx *ctx = data; + + if (ComponentMgr_CheckAnyAsyncProcessRunning()) { + g_debug("%s: A component has an async process running. Skipping " + "component status update.\n", __FUNCTION__); + return G_SOURCE_CONTINUE; + } + + /* + * Update the enabled components managed by the plugin and publish + * guestVar for all the available components. + */ + ComponentMgr_UpdateComponentEnableStatus(ctx); + + /* + * Main function which handles the core logic of taking actions present or + * absent on the components by reading action from the component guestVars. + */ + ComponentMgr_UpdateComponentStatus(ctx); + + return G_SOURCE_CONTINUE; +} + + +/* + ***************************************************************************** + * ComponentMgrPollLoop -- + * + * This function reads the poll interval and included configurations from the + * config file and reconfigures the poll loop of the plugin. + * + * @param[in] data Tools application context. + * + * @return + * None. + * + * Side effects: + * None. + * + ***************************************************************************** + */ + +static void +ComponentMgrPollLoop(ToolsAppCtx *ctx) // IN +{ + gint pollInterval; + gchar *listString; + + pollInterval = VMTools_ConfigGetInteger(ctx->config, + COMPONENTMGR_CONF_GROUPNAME, + COMPONENTMGR_CONF_POLLINTERVAL, + COMPONENTMGR_DEFAULT_POLL_INTERVAL); + + listString = VMTools_ConfigGetString(ctx->config, + COMPONENTMGR_CONF_GROUPNAME, + COMPONENTMGR_CONF_INCLUDEDCOMPONENTS, + COMPONENTMGR_ALLCOMPONENTS); + + /* + * If the included conf value is not present or is empty, no components will + * be enabled and plugin will be disabled until further change. + */ + if (listString == NULL || *listString == '\0' || + Str_Strcmp(listString, COMPONENTMGR_NONECOMPONENTS) == 0) { + g_info("%s: No components managed by the plugin. Plugin disabled." + " Set value included in configuration.\n", __FUNCTION__); + pollInterval = 0; + } + + g_free(listString); + ReconfigureComponentMgrPollLoopEx(ctx, pollInterval); +} + + +/* + ****************************************************************************** + * ComponentMgrServerShutdown -- + * + * This function cleans up plugin internal data on shutdown. + * + * @param[in] src The source object. + * @param[in] ctx Tools application context. + * @param[in] data Unused. + * + * @return + * None + * + * Side effects: + * Destroys all timeout sources for all the components. + * Destroys all running async process for all the components. + * + ****************************************************************************** + */ + +static void +ComponentMgrServerShutdown(gpointer src, // IN + ToolsAppCtx *ctx, // IN + gpointer data) // IN +{ + if (gComponentMgrTimeoutSource != NULL) { + /* + * Destroy the existing timeout source. + */ + g_source_destroy(gComponentMgrTimeoutSource); + gComponentMgrTimeoutSource = NULL; + } + + // Destroy all GSource timers for all managed components. + ComponentMgr_Destroytimers(); + + // Destroy and free all running async process for all components. + ComponentMgr_DestroyAsyncProcess(); +} + + +/* + ****************************************************************************** + * ComponentMgrServerConfReload -- + * + * This function reconfigures the poll loop interval upon config file reload. + * + * @param[in] src The source object. + * @param[in] ctx Tools application context. + * @param[in] data Unused. + * + * @return + * None. + * + * Side effects: + * None. + * + ****************************************************************************** + */ + +static void +ComponentMgrServerConfReload(gpointer src, // IN + ToolsAppCtx *ctx, // IN + gpointer data) // IN +{ + ComponentMgrPollLoop(ctx); +} + + +/* + ****************************************************************************** + * ComponentMgrServerReset -- + * + * Callback function that gets called whenever the RPC channel gets reset. + * + * @param[in] src The source object. + * @param[in] ctx Tools application context. + * @param[in] data Unused. + * + * @return + * None. + * + * Side effects: + * Reinitializes the plugin timeout source. + * + ****************************************************************************** + */ + +static void +ComponentMgrServerReset(gpointer src, // IN + ToolsAppCtx *ctx, // IN + gpointer data) // IN +{ + /* + * Handle reset for componentMgr loop. + */ + if (gComponentMgrTimeoutSource != NULL) { + ASSERT(gComponentMgrPollInterval != 0); + + ReconfigureComponentMgrPollLoopEx(ctx, gComponentMgrPollInterval); + } else { + ComponentMgrPollLoop(ctx); + } +} + +/* + ***************************************************************************** + * ToolsOnLoad -- + * + * Plugin entry point. Initializes internal plugin state. + * + * @param[in] ctx Tools application context. + * + * @return + * Plugin registration data. + * + * Side effects: + * None. + * + ***************************************************************************** + */ + +TOOLS_MODULE_EXPORT ToolsPluginData * +ToolsOnLoad(ToolsAppCtx *ctx) // IN +{ + static ToolsPluginData regData = { + "componentMgr", + NULL, + NULL + }; + + /* + * Return NULL to disable the plugin if not running in a VMware VM. + */ + if (!ctx->isVMware) { + g_info("%s: Not running in a VMware VM.\n", __FUNCTION__); + return NULL; + } + + /* + * Return NULL to disable the plugin if not running in vmsvc daemon. + */ + if (!TOOLS_IS_MAIN_SERVICE(ctx)) { + g_info("%s: Not running in vmsvc daemon: container name='%s'.\n", + __FUNCTION__, ctx->name); + return NULL; + } + + gCtx = ctx; + + /* + * This plugin is useless without an RpcChannel. If we don't have one, + * just bail. + */ + if (ctx->rpc != NULL) { + ToolsPluginSignalCb sigs[] = { + { TOOLS_CORE_SIG_CONF_RELOAD, ComponentMgrServerConfReload, NULL }, + { TOOLS_CORE_SIG_RESET, ComponentMgrServerReset, NULL }, + { TOOLS_CORE_SIG_SHUTDOWN, ComponentMgrServerShutdown, NULL } + }; + ToolsAppReg regs[] = { + { TOOLS_APP_SIGNALS, + VMTools_WrapArray(sigs, sizeof *sigs, ARRAYSIZE(sigs)) + } + }; + + regData.regs = VMTools_WrapArray(regs, + sizeof *regs, + ARRAYSIZE(regs)); + + return ®Data; + } + + return NULL; +} diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/componentMgr/componentMgrInstallAction.c open-vm-tools-12.1.5/open-vm-tools/services/plugins/componentMgr/componentMgrInstallAction.c --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/componentMgr/componentMgrInstallAction.c 1970-01-01 00:00:00.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/componentMgr/componentMgrInstallAction.c 2022-11-29 21:17:22.000000000 +0000 @@ -0,0 +1,1216 @@ +/********************************************************* + * Copyright (C) 2021 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 + * by the Free Software Foundation version 2.1 and no later version. + * + * 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 Lesser GNU General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + *********************************************************/ + +/* + * componentMgrInstallAction.c -- + * + * Functions to manage the known and enabled components by the componentMgr. + * Consists of functions periodically handling adding/removing of + * components in the guest OS. Periodically read the guestVar + * guestinfo./vmware.components..desiredstate and take present or + * absent action on the components. + * Adding/removing a component managed by the plugin is performed + * asynchronously using Proc_Manager API's. + * + */ + + +#include "componentMgrPlugin.h" +#include "str.h" +#include "file.h" +#include "util.h" +#include "guestApp.h" +#include "codeset.h" + + +/* + * Structure to store information about the scripts to be invoked for + * present/absent action on the components by the plugin. + * The script to be invoked shall be predefined with default arguments + * in the structure according to actions present/absent/checkstatus. + */ + +typedef struct ComponentAction { + const char *componentName; /* The name of the enabled + component. */ + + const char *scriptName; /* The default script to be invoked + to take actions for a particular + component */ + + const char *addActionArguments; /* Default arguments to the script + to execute present action towards + the component in the guest OS. */ + + const char *removeActionArguments; /* Default arguments to the script + to execute absent action towards + the component in the guest OS. */ + + const char *checkStatusActionArguments; /* Default arguments to the script + to execute checkstatus towards + the component in the guest OS. */ + + const char* mandatoryParameters; /* Arguments that are mandatory to + be passed to script. */ + + const char *componentDirectory; /* The name of directory in which + scripts will be installed.*/ + + char* (*customizeRemoveAction)(); /* A custom callback function + to customize arguments for + absent action on the component + script. */ + + char* (*customizeAddAction)(); /* A custom callback function + to customize arguments for + present action on the component + script. */ +} ComponentAction; + + +static char* +ComponentMgrCustomizeSaltAddAction(); + + +/* + * An array to store all the state information of the component over the + * life time for the plugin. The array consists of cached values of enabled + * status, async process info, GSource timers, status count down counter and + * current action to be run on the component. + */ + +static struct ComponentInfo components[] = { + {SALT_MINION, TRUE, NOTINSTALLED, NULL, NULL, COMPONENTMGR_CHECK_STATUS_COUNT_DOWN, INVALIDACTION} +}; + +/* + * An array containing information of the component and its related + * scripts and respective default arguments for actions present/absent + * or checkstatus. + */ +#if defined(_WIN32) +static const char powershellExecutable[] = "\\WindowsPowerShell\\v1.0\\PowerShell.exe"; + +static const char componentMgrExecutionPolicy[] = "-ExecutionPolicy RemoteSigned -File"; + +static ComponentAction executionScripts[] = { + {SALT_MINION,"svtminion.ps1", "-Install", "-Remove", "-Status", "-Loglevel debug", "saltMinion", NULL, &ComponentMgrCustomizeSaltAddAction} +}; +#else +static ComponentAction executionScripts[] = { + {SALT_MINION,"svtminion.sh", "--install", "--remove", "--status", "--loglevel debug", "saltMinion", NULL, &ComponentMgrCustomizeSaltAddAction} +}; +#endif + + +/* + ***************************************************************************** + * ComponentMgr_GetComponentName -- + * + * This function fetches the name of component from the components array. + * + * @param[in] componentIndex Index of the component in the global array of + * components. + * + * @return + * Name of component. + * + * Side effects: + * None. + * + ***************************************************************************** + */ + +const char* +ComponentMgr_GetComponentName(int componentIndex) // IN +{ + return components[componentIndex].name; +} + + +/* + ***************************************************************************** + * ComponentMgr_CheckAnyAsyncProcessRunning -- + * + * This function checks if any async process is running for any component + * inside the plugin. + * + * @return + * FALSE if no async process is running for a component. + * TRUE if an async process is running for a component. + * + * Side effects: + * None. + * + ***************************************************************************** + */ + +gboolean +ComponentMgr_CheckAnyAsyncProcessRunning() // IN +{ + int i; + for (i = 0; i < ARRAYSIZE(components); i++) { + if (ComponentMgr_IsAsyncProcessRunning(i)) { + return TRUE; + } + } + return FALSE; +} + + +/* + ***************************************************************************** + * ComponentMgr_IsAsyncProcessRunning -- + * + * This function indicates whether any async process is already running for + * a component. + * + * @param[in] componentIndex Index of the component in the global array of + * components. + * + * @return + * FALSE if no async process is running for a component. + * TRUE if an async process is running for a component. + * + * Side effects: + * None. + * + ***************************************************************************** + */ + +gboolean +ComponentMgr_IsAsyncProcessRunning(int componentIndex) // IN +{ + if (components[componentIndex].procInfo != NULL) { + g_info("%s: Component %s has an async process still running.\n", + __FUNCTION__, components[componentIndex].name); + return TRUE; + } else { + return FALSE; + } +} + + +/* + ***************************************************************************** + * ComponentMgr_SetComponentAsyncProcInfo -- + * + * This function caches info of the async process currently running for a + * component. + * + * @param[in] asyncProcInfo An asyncProcInfo object of the currently running + async process. + * @param[in] componentIndex Index of the component in the global array of + * components. + * + * @return + * None. + * + * Side effects: + * None. + * + ***************************************************************************** + */ + +void +ComponentMgr_SetComponentAsyncProcInfo(AsyncProcessInfo *asyncProcInfo, // IN + int componentIndex) // IN +{ + ASSERT(components[componentIndex].procInfo == NULL); + components[componentIndex].procInfo = asyncProcInfo; +} + + +/* + ***************************************************************************** + * ComponentMgr_ResetComponentAsyncProcInfo -- + * + * This function resets the state of any async process running for a component. + * + * @param[in] componentIndex Index of the component in the global array of + * components. + * + * @return + * None. + * + * Side effects: + * None. + * + ***************************************************************************** + */ + +void +ComponentMgr_ResetComponentAsyncProcInfo(int componentIndex) // IN +{ + components[componentIndex].procInfo = NULL; +} + + +/* + ***************************************************************************** + * ComponentMgr_SetComponentGSourceTimer -- + * + * This function caches the GSource timer running for an async process for a + * component. The timer is used to monitor the state of async process. + * + * @param[in] componentTimer A GSource timer created when performing present + * or absent action on a component. + * @param[in] componentIndex Index of the component in the global array of + * components. + * + * @return + * None. + * + * Side effects: + * Sets the GSource timer of an async process running for a component. + * + ***************************************************************************** + */ + +void +ComponentMgr_SetComponentGSourceTimer(GSource *componentTimer, // IN + int componentIndex) // IN +{ + ASSERT(components[componentIndex].sourceTimer == NULL); + components[componentIndex].sourceTimer = componentTimer; +} + + +/* + ***************************************************************************** + * ComponentMgr_ResetComponentGSourceTimer -- + * + * This function resets the component GSource timer to make way for creation + * a new async process. + * + * @param[in] componentIndex Index of the component in the global array of + * components. + * @return + * None. + * + * Side effects: + * Reset the GSource timer of an async process running for a component. + * + ***************************************************************************** + */ + +void +ComponentMgr_ResetComponentGSourceTimer(int componentIndex) // IN +{ + components[componentIndex].sourceTimer = NULL; +} + + +/* + ***************************************************************************** + * ComponentMgrGetScriptFullPath -- + * + * This function returns a full path to the component script based on the + * installed path of open-vm-tools or VMware Tools. + * + * @param[in] scriptName Name of the component script. + * @param[in] componentDir Directory of the component. + * + * @return + * A full path to the script file based on open-vm-tools or VMware Tools + * installation. + * + * Side effects: + * Caller needs to free the full script path value. + * + ***************************************************************************** + */ + +static gchar* +ComponentMgrGetScriptFullPath(const char *scriptName, // IN + const char *componentDir) // IN +{ + gchar *scriptInstallDir; + gchar *toolsInstallDir; + +#if defined(OPEN_VM_TOOLS) + toolsInstallDir = Util_SafeStrdup(VMTOOLS_COMPONENTMGR_PATH); + scriptInstallDir = g_strdup_printf("%s%s%s%s", toolsInstallDir, + componentDir, DIRSEPS, scriptName); +#else + toolsInstallDir = GuestApp_GetInstallPath(); + scriptInstallDir = g_strdup_printf("%s%s%s%s%s%s%s", toolsInstallDir, DIRSEPS, + COMPONENTMGR_DIRECTORY, DIRSEPS, + componentDir, DIRSEPS, scriptName); +#endif + + g_free(toolsInstallDir); + return scriptInstallDir; +} + + +/* + ***************************************************************************** + * ComponentMgrCustomizeSaltAddAction -- + * + * This function customizes the custom arguments for the present action for the + * salt component script. + * + * @return + * A customized argument string for the salt component script. + * + * Side effects: + * Caller has to free the returned custom arguments. + * + ***************************************************************************** + */ + +static char* +ComponentMgrCustomizeSaltAddAction() +{ + size_t replylen; + gchar *msg; + gboolean status; + char *actionArguments = NULL; + + msg = g_strdup_printf("%s.%s.args", COMPONENTMGR_ACTION, SALT_MINION); + status = ComponentMgr_SendRpc(ComponentMgr_GetToolsAppCtx(), msg, + &actionArguments, &replylen); + g_free(msg); + + if (!status) { + vm_free(actionArguments); + return NULL; + } + + return actionArguments; +} + + +/* + ***************************************************************************** + * ComponentMgrConstructCommandline -- + * + * The function constructs the commandline for linux and windows to execute + * the script as an async process to perform present/absent action on a + * component. + * + * The windows counterpart is constructed as: + * -ExecutionPolicy RemoteSigned -File \ + * + * + * The linux counterpart is constructed as: + * + * + * @param[in] scriptName Name of the component script. + * @param[in] defaultArguments Default arguments to the component script. + * @param[in] mandatoryParams mandatory params to the component script. + * @param[in] customizeAction A callback function to customize the arguments + for the component script. + * + * @return + * A commandline to be directly run as an async process. + * + * Side effects: + * Caller needs to free the commandline. + * + ***************************************************************************** + */ + +static char * +ComponentMgrConstructCommandline(gchar *scriptPath, // IN + const char *defaultArguments, // IN + const char *mandatoryParams, // IN + char* (*customizeAction)()) // IN +{ + char *commandline = NULL; + const char *mandatoryParamsExists = NULL; + char *customArguments = NULL; +#if defined(_WIN32) + WCHAR sysDirW[MAX_PATH]; + UINT retLen; + char *sysDir = NULL; +#endif + + // Customize the arguments for the specific action via the callback function + if (customizeAction != NULL) { + g_info("%s: Customizing arguments with function.\n", __FUNCTION__); + customArguments = customizeAction(); + } + +#if defined(_WIN32) + retLen = GetSystemDirectoryW(sysDirW, _countof(sysDirW)); + if (retLen == 0 || retLen >= _countof(sysDirW)) { + g_warning("%s: Unable to get system directory.\n", __FUNCTION__); + goto proceedexit; + } + + if (!CodeSet_Utf16leToUtf8((const char *)sysDirW, + wcslen(sysDirW) * sizeof sysDirW[0], + &sysDir, + NULL)) { + g_warning("%s: Could not convert system directory to UTF-8.\n", + __FUNCTION__); + goto proceedexit; + } + + if (customArguments != NULL) { + mandatoryParamsExists = strstr(customArguments, mandatoryParams); + if (mandatoryParamsExists == NULL) { + commandline = Str_SafeAsprintf(NULL, "\"%s%s\" %s \"%s\" %s %s %s", + sysDir, powershellExecutable, + componentMgrExecutionPolicy, + scriptPath, + defaultArguments, customArguments, + mandatoryParams); + } else { + commandline = Str_SafeAsprintf(NULL, "\"%s%s\" %s \"%s\" %s %s", + sysDir, powershellExecutable, + componentMgrExecutionPolicy, + scriptPath, + defaultArguments, customArguments); + + } + } else { + commandline = Str_SafeAsprintf(NULL, "\"%s%s\" %s \"%s\" %s %s", + sysDir, powershellExecutable, + componentMgrExecutionPolicy, + scriptPath, + defaultArguments, + mandatoryParams); + } + + free(sysDir); +#else + if (customArguments != NULL) { + mandatoryParamsExists = strstr(customArguments, mandatoryParams); + if (mandatoryParamsExists == NULL) { + commandline = Str_SafeAsprintf(NULL, "%s %s %s %s", scriptPath, + defaultArguments, customArguments, + mandatoryParams); + } else { + commandline = Str_SafeAsprintf(NULL, "%s %s %s", scriptPath, + defaultArguments, customArguments); + + } + } else { + commandline = Str_SafeAsprintf(NULL, "%s %s %s", scriptPath, + defaultArguments, mandatoryParams); + } + // To satisfy a complier warning of missing label. + goto proceedexit; +#endif + +proceedexit: + if (customArguments != NULL) { + vm_free(customArguments); + } + return commandline; +} + + +/* + ***************************************************************************** + * ComponentMgr_CheckStatusCommandLine -- + * + * This function fetches the commandline needed to be executed to check the + * current status of component installation. It provides the commandline as + * + * + * @param[in] componentIndex Index of the component in the global array of + * components. + * + * @return + * Commandline to check current status of component. + * + * Side effects: + * Caller needs to free the commandline value. + * + ***************************************************************************** + */ + +char * +ComponentMgr_CheckStatusCommandLine(int componentIndex) // IN +{ + char *commandline; + gchar *scriptFullPath; + + /* + * Always check for component enabled state before proceeding, since check + * status can be called at any part of component action. + */ + if (!components[componentIndex].isEnabled) { + g_info("%s: Component %s is disabled.\n", __FUNCTION__, + components[componentIndex].name); + return NULL; + } + + scriptFullPath = ComponentMgrGetScriptFullPath(executionScripts[componentIndex].scriptName, + executionScripts[componentIndex].componentDirectory); + if (!File_Exists(scriptFullPath)) { + g_info("%s: Script file for component %s does not exist at path %s.\n", + __FUNCTION__, components[componentIndex].name, scriptFullPath); + return NULL; + } + + commandline = ComponentMgrConstructCommandline(scriptFullPath, + executionScripts[componentIndex].checkStatusActionArguments, + executionScripts[componentIndex].mandatoryParameters, + NULL); + + g_free(scriptFullPath); + + return commandline; +} + + +/* + ***************************************************************************** + * ComponentMgrSetEnabledComponentInfo -- + * + * This function sets the isEnabled state of the component which determines + * whether the component managed by the plugin is enabled or disabled. + * + * @param[in] componentName Name of the component to enable or disable. + * @param[in] enabled A boolean value indicating component enabled status. + * + * @return + * None + * Side effects: + * Sets the enabled/disabled status of a component. + * + ***************************************************************************** + */ + +static void +ComponentMgrSetEnabledComponentInfo(const char *componentName, // IN + gboolean enabled) // IN +{ + int i; + gboolean componentFound = FALSE; + + for (i = 0; i < ARRAYSIZE(components); i++) { + if (Str_Strcmp(components[i].name, componentName) == 0) { + components[i].isEnabled = enabled; + componentFound = TRUE; + break; + } + } + + if (!componentFound) { + g_info("%s: Invalid component name %s.\n", + __FUNCTION__, componentName); + } +} + + +/* + ***************************************************************************** + * ComponentMgr_SetStatusComponentInfo -- + * + * This function sets the status of the component managed by the plugin and + * publishes guestVar guestinfo.vmware.components..laststatus. + * + * @param[in] ctx Tools application context. + * @param[in] componentIndex Index of the component in the global array of + * components. + * @param[in] exitCode The exit code of the async process running check status + * operation on a component. + * + * @return + * None. + * + * Side effects: + * Sets the current status for a component. + * + ***************************************************************************** + */ + +void +ComponentMgr_SetStatusComponentInfo(ToolsAppCtx *ctx, // IN + int exitCode, // IN + int componentIndex) // IN +{ + gchar *msg; + gboolean status; + + msg = g_strdup_printf("%s.%s.%s %d", COMPONENTMGR_PUBLISH_COMPONENTS, + components[componentIndex].name, + COMPONENTMGR_INFOLASTSTATUS, + exitCode); + + status = ComponentMgr_SendRpc(ctx, msg, NULL, NULL); + g_free(msg); + components[componentIndex].status = exitCode; +} + + +/* + ***************************************************************************** + * ComponentMgrSetEnabledAllComponents -- + * + * This function enables/disables all the components managed by the plugin. + * + * @param[in] enabled A boolean value to enable/disable all components. + * + * @return + * None. + * + * Side effects: + * None. + * + ***************************************************************************** + */ + +static void +ComponentMgrSetEnabledAllComponents(gboolean enabled) // IN +{ + int i; + for (i = 0; i < ARRAYSIZE(components); i++) { + components[i].isEnabled = enabled; + } +} + + +/* + ***************************************************************************** + * ComponentMgr_ExecuteComponentAction -- + * + * This function validates the current status of the component against + * current action be to be taken for a component and constructs a commandline + * to execute present/absent action on a component as an async process. + * + * @param[in] componentIndex Index of the component in the global array of + * components. + * + * @return + * None. + * + * Side effects: + * None. + * + ***************************************************************************** + */ + +void +ComponentMgr_ExecuteComponentAction(int componentIndex) // IN +{ + gchar *scriptFullPath; + const char *action = NULL; + const char *defaultArguments = NULL; + char *commandline = NULL; + char* (*customizeAction)() = NULL; + Action installaction = components[componentIndex].action; + + if (!components[componentIndex].isEnabled) { + g_debug("%s: Component %s is disabled", __FUNCTION__, + components[componentIndex].name); + return; + } + + action = ComponentMgr_GetComponentAction(installaction); + if((Str_Strcmp(action, COMPONENTMGR_COMPONENTPRESENT) == 0) && + (components[componentIndex].status == NOTINSTALLED || + components[componentIndex].status == INSTALLFAILED || + components[componentIndex].status == REMOVEFAILED)) { + installaction = PRESENT; + } else if((Str_Strcmp(action, COMPONENTMGR_COMPONENTABSENT) == 0) && + (components[componentIndex].status == INSTALLED || + components[componentIndex].status == INSTALLFAILED || + components[componentIndex].status == REMOVEFAILED)) { + installaction = ABSENT; + } else { + g_debug("%s: Action %s will not be executed for component %s with " + "current status %s.\n", __FUNCTION__, action, + components[componentIndex].name, + ComponentMgr_GetComponentInstallStatus(components[componentIndex].status)); + return; + } + + g_info("%s: Executing action %s for component %s current status %s.\n", + __FUNCTION__, action, components[componentIndex].name, + ComponentMgr_GetComponentInstallStatus(components[componentIndex].status)); + + /* + * The main logic which handles the present/absent action on a component. + * Internally spins off async process to add/remove the component + * on the guest. + */ + switch(installaction) { + case PRESENT: + defaultArguments = executionScripts[componentIndex].addActionArguments; + customizeAction = executionScripts[componentIndex].customizeAddAction; + break; + case ABSENT: + defaultArguments = executionScripts[componentIndex].removeActionArguments; + customizeAction = executionScripts[componentIndex].customizeRemoveAction; + break; + default: + break; + } // end switch + scriptFullPath = ComponentMgrGetScriptFullPath(executionScripts[componentIndex].scriptName, + executionScripts[componentIndex].componentDirectory); + + commandline = ComponentMgrConstructCommandline(scriptFullPath, + defaultArguments, + executionScripts[componentIndex].mandatoryParameters, + customizeAction); + g_free(scriptFullPath); + + if (commandline == NULL) { + g_info("%s: Construction of command line failed for component %s.\n", + __FUNCTION__, components[componentIndex].name); + return; + } + + g_info("%s: Commandline %s to perform %s action on component %s.\n", + __FUNCTION__, commandline, action, components[componentIndex].name); + ComponentMgr_AsynchronousComponentActionStart(ComponentMgr_GetToolsAppCtx(), + commandline, componentIndex); + free(commandline); +} + + +/* + ***************************************************************************** + * ComponentMgrPublishKnownComponents -- + * + * This function publishes guestVar guestinfo.vmware.components.available + * with all the components managed by the plugin. + * + * @param[in] ctx Tools application context + * + * @return + * None. + * + * Side effects: + * Updates the enabled/disabled status of the all the components managed + * by the plugin. + * + ***************************************************************************** + */ + +static void +ComponentMgrPublishKnownComponents(ToolsAppCtx *ctx) // IN +{ + int i; + DynBuf enabledComponents; + DynBuf_Init(&enabledComponents); + + for (i = 0; i < ARRAYSIZE(components); i++) { + if (components[i].isEnabled) { + gchar *scriptFullPath; + /* + * We need to check the existence of the script for a particular + * component before we begin the preset/absent action on the component. + * Skipping the component if no script is installed. + */ + scriptFullPath = ComponentMgrGetScriptFullPath(executionScripts[i].scriptName, + executionScripts[i].componentDirectory); + + if (!File_Exists(scriptFullPath)) { + g_info("%s: Script file for component %s does not exist " + "under path %s.\n", __FUNCTION__, components[i].name, + scriptFullPath); + g_free(scriptFullPath); + components[i].isEnabled = FALSE; + continue; + } + + g_free(scriptFullPath); + + if (DynBuf_GetSize(&enabledComponents) != 0) { + DynBuf_Append(&enabledComponents, ",", 1); + } + DynBuf_Append(&enabledComponents, components[i].name, + strlen(components[i].name)); + } + } + + if (DynBuf_GetSize(&enabledComponents) == 0) { + ComponentMgr_PublishAvailableComponents(ctx, COMPONENTMGR_NONECOMPONENTS); + } else { + ComponentMgr_PublishAvailableComponents(ctx, + DynBuf_GetString(&enabledComponents)); + } + + DynBuf_Destroy(&enabledComponents); +} + + +/* + ***************************************************************************** + * ComponentMgrIncludedComponents -- + * + * This function checks and validates the comma seperated list fetched from + * included tools.conf configuration and classifies the first occurrence of + * all or none which are special values and returns the result. + * + * @param[in] componentString Comma seperated string from the included + * tools.conf configuration. + * + * @retun + * Classify first occurrence of all or none in the string and return. + * + * Side effects + * None. + * + ***************************************************************************** + */ + +static IncludedComponents +ComponentMgrIncludedComponents(const char* componentString) // IN +{ + int i; + gchar **componentList = NULL; + IncludedComponents include = NOSPECIALVALUES; + + if (componentString == NULL || *componentString == '\0') { + g_info("%s: No components included in the ComponentMgr plugin.\n", + __FUNCTION__); + return NONECOMPONENTS; + } + + componentList = g_strsplit(componentString, ",", 0); + for (i = 0; componentList[i] != NULL; i++ ) { + g_strstrip(componentList[i]); + + if (strcmp(componentList[i], COMPONENTMGR_ALLCOMPONENTS) == 0) { + include = ALLCOMPONENTS; + break; + } + if (strcmp(componentList[i], COMPONENTMGR_NONECOMPONENTS) == 0) { + include = NONECOMPONENTS; + break; + } + } + + g_strfreev(componentList); + return include; +} + + +/* + ***************************************************************************** + * ComponentMgr_UpdateComponentEnableStatus -- + * + * This functions reads the comma seperated list of components in the included + * tools.conf configuration and sets the enabled/disabled status for all the + * components managed by the plugin. + * It also publishes guestvar guestinfo.vmware.components.available with + * info of all the components managed by the plugin. + * + * @param[in] ctx Tools application context. + * + * @return + * None. + * + * Side effects: + * Updates the enabled/disabled status of the all the components managed + * by the plugin. + * + ***************************************************************************** + */ + +void +ComponentMgr_UpdateComponentEnableStatus(ToolsAppCtx *ctx) // IN +{ + gchar *listString; + IncludedComponents included; + char *token; + char *context = NULL; + + listString = VMTools_ConfigGetString(ctx->config, + COMPONENTMGR_CONF_GROUPNAME, + COMPONENTMGR_CONF_INCLUDEDCOMPONENTS, + COMPONENTMGR_ALLCOMPONENTS); + + included = ComponentMgrIncludedComponents(listString); + switch (included) { + case ALLCOMPONENTS: + ComponentMgrSetEnabledAllComponents(TRUE); + goto publishComponents; + case NONECOMPONENTS: + ComponentMgrSetEnabledAllComponents(FALSE); + goto publishComponents; + default: + break; + } + + /* + * Setting all components to disabled state. + */ + ComponentMgrSetEnabledAllComponents(FALSE); + + /* + * Split the comma separated list of included components and individually + * set the status of each component as TRUE. + */ + token = strtok_r(listString, ",", &context); + while (token != NULL) { + ComponentMgrSetEnabledComponentInfo(token, TRUE); + token = strtok_r(NULL, ",", &context); + } + +publishComponents: + g_free(listString); + ComponentMgrPublishKnownComponents(ctx); +} + + +/* + ***************************************************************************** + * ComponentMgrCheckExecuteComponentAction -- + * + * This function validates the current status of the component against + * current action for the component and waits for status update counter + * to reach zero to run a check status operation if the component status + * and component action are not compliant. + * If the component action and component status are compliant, it spins off + * an async check status operation. + * + * @param[in] ctx Tools application context. + * @param[in] componentIndex Index of the component in the global array of + * components. + * @param[in] action The action that shall be performed on a component. + * + * @return + * None. + * + * Side effects: + * Run an asynchronous process to check current status of the component. + * + ***************************************************************************** + */ + +static void +ComponentMgrCheckExecuteComponentAction(ToolsAppCtx *ctx, // IN + int componentIndex, // IN + const char *action) // IN +{ + char* commandline; + void (*callbackFunction)(int) = &ComponentMgr_ExecuteComponentAction; + Action installaction = INVALIDACTION; + + /* + * It is possible at this stage, an async process for checkstatus or + * present/absent action may be running for the component. In such a scenario + * the plugin shall not trigger any other async process. + */ + ASSERT(components[componentIndex].isEnabled); + ASSERT(!ComponentMgr_IsAsyncProcessRunning(componentIndex)); + + commandline = ComponentMgr_CheckStatusCommandLine(componentIndex); + if (commandline == NULL) { + g_info("%s: Unable to construct commandline instruction to run check " + "status for the component %s\n", __FUNCTION__, + components[componentIndex].name); + return; + } + + /* + * Add the component to the guest only if it is NOTINSTALLED, + * INSTALLFAILED or REMOVEFAILED. + * Remove the component on the guest only if it is INSTALLED, + * INSTALLFAILED or REMOVEFAILED. + */ + if((Str_Strcmp(action, COMPONENTMGR_COMPONENTPRESENT) == 0) && + (components[componentIndex].status == NOTINSTALLED || + components[componentIndex].status == INSTALLFAILED || + components[componentIndex].status == REMOVEFAILED)) { + installaction = PRESENT; + } else if((Str_Strcmp(action, COMPONENTMGR_COMPONENTABSENT) == 0) && + (components[componentIndex].status == INSTALLED || + components[componentIndex].status == INSTALLFAILED || + components[componentIndex].status == REMOVEFAILED)) { + installaction = ABSENT; + } else { + components[componentIndex].statuscount -= 1; + if (components[componentIndex].statuscount != 0) { + /* + * Status count down for the component has not reached 0 + * come back again in next interval. + */ + g_debug("%s: Status count down for component %s is %d.\n", + __FUNCTION__, components[componentIndex].name, + components[componentIndex].statuscount); + free(commandline); + return; + } else { + /* + * Status count down has reached 0. We need to call the async + * check status once and update the last status of the component. + * Set the callback function for the async check status call NULL, + * since it's a single check status operation. + */ + callbackFunction = NULL; + } + } + + /* + * Resetting the value of status count of a component, since the action + * might have changed or status count down has reached 0. + */ + components[componentIndex].action = installaction; + components[componentIndex].statuscount = COMPONENTMGR_CHECK_STATUS_COUNT_DOWN; + + /* + * Before invoking any action for a component, we need to check the current + * status for that component. We run the pre configured script with pre + * configured check status arguments to the script. + * An async process will be spun off to perform check status of a component + * with an option of sequenced operation after check status call. + */ + g_debug("%s: Checking current status of component %s with commandline %s.\n", + __FUNCTION__, components[componentIndex].name, commandline); + ComponentMgr_AsynchronousComponentCheckStatus(ctx, commandline, + componentIndex, + callbackFunction); + free(commandline); +} + + +/* + ***************************************************************************** + * ComponentMgr_DestroyAsyncProcess -- + * + * Destroy and free any or all async process running for a component. + * + * @return + * None. + * + * Side effects: + * Kills the async process runing any action for a component instantly. + * + ***************************************************************************** + */ + +void +ComponentMgr_DestroyAsyncProcess() +{ + int i; + + for (i = 0; i < ARRAYSIZE(components); i++) { + if (components[i].procInfo != NULL) { + g_debug("%s: Destroying running async process for component %s.\n", + __FUNCTION__, components[i].name); + ComponentMgr_FreeAsyncProc(components[i].procInfo); + } else { + g_debug("%s: No async process running for component %s.\n", + __FUNCTION__, components[i].name); + } + } +} + + +/* + ***************************************************************************** + * ComponentMgr_Destroytimers -- + * + * This function destroys the GSource timers for all components. + * + * @return + * None. + * + * Side effects: + * Destroys the timeout GSource timers for all the components. + * + ***************************************************************************** + */ + +void +ComponentMgr_Destroytimers(void) +{ + int i; + + for (i = 0; i < ARRAYSIZE(components); i++) { + if (components[i].sourceTimer != NULL) { + g_debug("%s: Destroying timers for component %s.\n", __FUNCTION__, + components[i].name); + g_source_destroy(components[i].sourceTimer); + components[i].sourceTimer = NULL; + } else { + g_debug("%s: Source timers for component %s has already been " + "destroyed.\n", __FUNCTION__, components[i].name); + } + } +} + + +/* + ***************************************************************************** + * ComponentMgr_UpdateComponentStatus -- + * + * This function loops through all the enabled components in the plugin and + * fetches the action for individual components from the guestVar + * guestinfo./vmware.components..desiredstate and triggers + * check status and execute action for a component. + * + * @param[in] ctx Tools application context. + * + * @return + * None. + * + * Side effects: + * None. + * + ***************************************************************************** + */ + +void +ComponentMgr_UpdateComponentStatus(ToolsAppCtx *ctx) // IN +{ + int i; + + for (i = 0; i < ARRAYSIZE(components); i++) { + gboolean status; + char *componentDesiredState = NULL; + size_t replylen; + gchar *msg; + + /* + * Proceed only if the component script is installed and + * the component is enabled by the plugin. + */ + if (!components[i].isEnabled) { + continue; + } + + msg = g_strdup_printf("%s.%s.%s", COMPONENTMGR_ACTION, + components[i].name, + COMPONENTMGR_INFODESIREDSTATE); + /* + * Fetch the action for a component from the guestVar + * guestinfo./vmware.components..desiredstate + */ + status = ComponentMgr_SendRpc(ctx, msg, &componentDesiredState, &replylen); + g_free(msg); + + if (!status) { + g_info("%s: Install action not available for component %s.\n", + __FUNCTION__, components[i].name); + vm_free(componentDesiredState); + componentDesiredState = NULL; + continue; + } + + if (componentDesiredState != NULL && + (Str_Strcmp(componentDesiredState, COMPONENTMGR_COMPONENTPRESENT) == 0 || + Str_Strcmp(componentDesiredState, COMPONENTMGR_COMPONENTABSENT) == 0)) { + ComponentMgrCheckExecuteComponentAction(ctx, i, componentDesiredState); + } + + vm_free(componentDesiredState); + componentDesiredState = NULL; + } +} diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/componentMgr/componentMgrInstallManager.c open-vm-tools-12.1.5/open-vm-tools/services/plugins/componentMgr/componentMgrInstallManager.c --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/componentMgr/componentMgrInstallManager.c 1970-01-01 00:00:00.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/componentMgr/componentMgrInstallManager.c 2022-11-29 21:17:22.000000000 +0000 @@ -0,0 +1,497 @@ +/********************************************************* + * Copyright (C) 2021 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 + * by the Free Software Foundation version 2.1 and no later version. + * + * 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 Lesser GNU General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + *********************************************************/ + +/* + * componentMgrInstallManager.c -- + * + * This file contains all the neccessary functions and handling of performing + * check status operation and add/remove of a component. + * The operations are triggerred as an async process and GSource timers are + * created to monitor the execution status of the async process. + * After successful completion of the async process, it's resources are + * released to make way for a new async process. + * Contains functions related to creation of new async process, monitoring of + * an async process and freeing of a async process resources. + * + */ + +#include "componentMgrPlugin.h" + + +/* + ***************************************************************************** + * ComponentMgr_FreeAsyncProc -- + * + * This function frees the async process resources. + * First we kill the commandline process which is child's child by pid. + * Then we kill the child process which is vmtoolsd. + * + * @param[in] asyncProcessInfo Asynchronous process resources to be freed. + * + * @return + * None. + * + * Side effects: + * Destroys and frees the async process resources. + * + ***************************************************************************** + */ + +void +ComponentMgr_FreeAsyncProc(AsyncProcessInfo *procInfo) // IN +{ + int componentIndex = procInfo->componentIndex; +#if defined(__linux__) + if (ProcMgr_IsAsyncProcRunning(procInfo->asyncProc)) { + ProcMgr_Pid procPid = ProcMgr_GetPid(procInfo->asyncProc); + ProcMgr_KillByPid(procPid); + } +#endif + ProcMgr_Kill(procInfo->asyncProc); + ProcMgr_Free(procInfo->asyncProc); + g_free(procInfo); + + // Reset the async process info in the components array since the async + // process is no longer available. + ComponentMgr_ResetComponentAsyncProcInfo(componentIndex); +} + + +/* + ***************************************************************************** + * ComponentMgrCheckStatusMonitor -- + * + * This function monitors the state the async process running check status + * command for a component. On completion of async process, the exit code + * is captured and set in the components structure for that component. + * On expiry of timer the async process will be killed. + * + * @param[in] data asyncProcessInfo pointer containing async process and + component info. + * + * @return + * G_SOURCE_CONTINUE To continue polling. + * G_SOURCE_REMOVE to stop polling. + * + * Side effects: + * Monitor the asyncProcess for its successful termination by polling. + * Kill the asyncProcess if it's taking long to terminate. + * + ***************************************************************************** + */ + +static gboolean +ComponentMgrCheckStatusMonitor(void *data) // IN +{ + ProcMgr_Pid procPid; + int componentIndex; + const char *componentName; + void (*callbackFunction)(int compIndex) = NULL; + + AsyncProcessInfo *procInfo = (AsyncProcessInfo*)data; + ASSERT(procInfo->asyncProc != NULL); + + /* + * For every timeout callback from the timeout source, decrease + * the remaining execution time for the component. + */ + procInfo->backoffTimer -= COMPONENTMGR_ASYNC_CHECK_STATUS_POLL_INTERVAL; + procPid = ProcMgr_GetPid(procInfo->asyncProc); + componentIndex = procInfo->componentIndex; + componentName = ComponentMgr_GetComponentName(componentIndex); + + g_debug("%s: Callback received for process ID %d and component %s." + " Remaining time before termination %ds.\n", __FUNCTION__, procPid, + componentName, procInfo->backoffTimer); + + if (!ProcMgr_IsAsyncProcRunning(procInfo->asyncProc)) { + int exitCode = -1; +#if defined(__linux__) + if (ProcMgr_GetExitCode(procInfo->asyncProc, &exitCode) || exitCode == -1) { + exitCode = SCRIPTFAILED; + } +#else + if (ProcMgr_GetExitCode(procInfo->asyncProc, &exitCode)) { + exitCode = SCRIPTFAILED; + } +#endif + g_debug("%s: Checking status of a component has terminated gracefully" + " with exit code %d.\n", __FUNCTION__, exitCode); + + ComponentMgr_SetStatusComponentInfo(procInfo->ctx, + exitCode, + procInfo->componentIndex); + callbackFunction = procInfo->callbackFunction; + + /* + * At this stage free the asyncProcInfo object to make way for new async + * process. Source timer for a component will be no longer valid from here + * set it to NULL for next async process. + */ + ComponentMgr_FreeAsyncProc(procInfo); + ComponentMgr_ResetComponentGSourceTimer(componentIndex); + + /* + * After checkstatus operation has completed sucessfully, we can have a + * next sequence of operations to be executed on a component. + */ + if (callbackFunction != NULL) { + callbackFunction(componentIndex); + } + + return G_SOURCE_REMOVE; + } else { + /* + * At this stage the async process seems to be still running check + * status operation on a component. If the backoff timer value is not + * reached for a component, we proceed and wait for the async process + * to terminate. If the backoff timer has reached 0, the timed wait + * for the component is completed hence we kill the async process. + * First we kill the command process which is child's child by pid. + * Then we kill the child process which is vmtoolsd. + */ + g_debug("%s: Process still running for component %s.\n", __FUNCTION__, + componentName); + + if (procInfo->backoffTimer == 0) { + g_warning("%s: Backoff timer expired for process %d running check " + "status for component %s. Async process will be killed.", + __FUNCTION__, procPid, componentName); + + ComponentMgr_SetStatusComponentInfo(procInfo->ctx, + SCRIPTTERMINATED, + componentIndex); + + /* + * At this point the async process has timed out, so we need to + * kill the async process to make way for a new async process. + * Source timer for a component will be no longer valid from here + * set it to NULL for the next async process. + */ + ComponentMgr_FreeAsyncProc(procInfo); + ComponentMgr_ResetComponentGSourceTimer(componentIndex); + return G_SOURCE_REMOVE; + } + } + + return G_SOURCE_CONTINUE; +} + + +/* + ***************************************************************************** + * ComponentMgrProcessMonitor -- + * + * This function monitors the async process running the present/absent action + * on a component. + * + * @param[in] data asyncProcessInfo pointer containing async process and + component info. + * + * @return + * G_SOURCE_CONTINUE To continue polling. + * G_SOURCE_REMOVE To stop polling. + * + * Side effects: + * Monitor the async process for its successful termination by polling. + * Kill the async process if it's taking long to terminate. + * + ***************************************************************************** + */ + +static gboolean +ComponentMgrProcessMonitor(void *data) // IN +{ + ProcMgr_Pid procPid; + int componentIndex; + char *commandline; + const char *componentName; + + AsyncProcessInfo *procInfo = (AsyncProcessInfo*)data; + ASSERT(procInfo->asyncProc != NULL); + + procInfo->backoffTimer -= COMPONENTMGR_ASYNCPROCESS_POLL_INTERVAL; + procPid = ProcMgr_GetPid(procInfo->asyncProc); + componentIndex = procInfo->componentIndex; + componentName = ComponentMgr_GetComponentName(componentIndex); + + g_debug("%s: Callback received for process ID %d and component %s." + " Remaining time before termination %ds.\n", __FUNCTION__, procPid, + componentName, procInfo->backoffTimer); + + if (!ProcMgr_IsAsyncProcRunning(procInfo->asyncProc)) { + /* + * At this stage the async process has completed its execution. + * Free all the async process resources and destroy the GSource timer. + */ + g_debug("%s: Async process has exited.\n", __FUNCTION__); + + ComponentMgr_FreeAsyncProc(procInfo); + ComponentMgr_ResetComponentGSourceTimer(componentIndex); + + commandline = ComponentMgr_CheckStatusCommandLine(componentIndex); + if (commandline == NULL) { + g_info("%s: Unable to construct commandline instruction to run check " + "status for the component %s\n", __FUNCTION__, + ComponentMgr_GetComponentName(componentIndex)); + ComponentMgr_SetStatusComponentInfo(ComponentMgr_GetToolsAppCtx(), + SCRIPTTERMINATED, componentIndex); + return G_SOURCE_REMOVE; + } + + /* + * At this stage the async process running present/absent has completed. + * We need to check the status of a component asynchronously and set the + * component status. + */ + ComponentMgr_AsynchronousComponentCheckStatus(ComponentMgr_GetToolsAppCtx(), + commandline, + componentIndex, + NULL); + free(commandline); + return G_SOURCE_REMOVE; + } else { + /* + * At this stage the async process seems to be still running for a + * component. If the backoff timer value has not reached 0, + * we proceed and wait for the async process to terminate. + * If the backoff timer has reached 0, the timed wait + * has reached limit for the component and we kill the async process. + */ + g_debug("%s: Process still running for component %s.\n", __FUNCTION__, + componentName); + + if (procInfo->backoffTimer == 0) { + g_warning("%s: Backoff timer expired for process %d running action for" + "component %s. Async process will be killed.", + __FUNCTION__, procPid, componentName); + + /* + * At this point the async process has to be terminated. We can + * free the structure to make way for newer async process. + * Source timer for a component will be no longer valid from here + * set it to NULL for next async process. + */ + ComponentMgr_FreeAsyncProc(procInfo); + ComponentMgr_ResetComponentGSourceTimer(componentIndex); + + commandline = ComponentMgr_CheckStatusCommandLine(componentIndex); + if (commandline == NULL) { + g_info("%s: Unable to construct commandline instruction to run check " + "status for the component %s\n", __FUNCTION__, + ComponentMgr_GetComponentName(componentIndex)); + ComponentMgr_SetStatusComponentInfo(ComponentMgr_GetToolsAppCtx(), + SCRIPTTERMINATED, componentIndex); + return G_SOURCE_REMOVE; + } + + ComponentMgr_AsynchronousComponentCheckStatus(ComponentMgr_GetToolsAppCtx(), + commandline, + componentIndex, + NULL); + + free(commandline); + return G_SOURCE_REMOVE; + } + } + /* + * The async process has not yet completed its action. So poll again + * using the same GSource timer for that particular component. + */ + return G_SOURCE_CONTINUE; +} + + +/* + ***************************************************************************** + * ComponentMgrCreateAsyncProcessInfo -- + * + * This function creates the asynProcessInfo object related to an async process + * + * @param[in] asyncProc A ProcMgr_AsyncProc pointer containing information + about the created async process. + * @param[in] ctx Tools application context. + * @param[in] backoffTimer A timer value after expiry of which the async + process will be killed. + * @param[in] componentIndex Index of the component in the global array of + * components. + * @param[in] callbackFunction A callback function to sequence the operation + * after async process finishes. + * + * @return + * An asyncProcessInfo object. + * + * Side effects: + * The created asyncProcesInfo object should be freed after process + * is completed or terminated. + * + ***************************************************************************** + */ + +static AsyncProcessInfo* +ComponentMgrCreateAsyncProcessInfo(ProcMgr_AsyncProc *asyncProc, // IN + ToolsAppCtx *ctx, // IN + int backoffTimer, // IN + int componentIndex, // IN + void (*callbackFunction)(int componentIndex)) // IN +{ + AsyncProcessInfo *procInfo; + procInfo = g_malloc(sizeof *procInfo); + procInfo->asyncProc = asyncProc; + procInfo->ctx = ctx; + procInfo->backoffTimer = backoffTimer; + procInfo->componentIndex = componentIndex; + procInfo->callbackFunction = callbackFunction; + + return procInfo; +} + + +/* + ***************************************************************************** + * ComponentMgr_AsynchronousComponentCheckStatus -- + * + * This function launches an async process to check the current status of the + * component on the system. + * + * @param[in] ctx Tools application context. + * @param[in] commandline command to be + * executed to add/remove the component. + * @param[in] componentIndex Index of the component in the global array of + * components. + * @param[in] callbackFunction A callback function to sequence the operation + * after async call completes. + * + * @return + * None. + * + * Side effects: + * Async process creation may fail for many reasons. + * + ***************************************************************************** + */ + +void +ComponentMgr_AsynchronousComponentCheckStatus(ToolsAppCtx *ctx, // IN + const char *commandline, // IN + int componentIndex, // IN + void (*callback)(int compIndex)) // IN +{ + ProcMgr_ProcArgs userArgs; + GSource *sourceTimer; + AsyncProcessInfo *procInfo; + ProcMgr_AsyncProc *asyncProc; + + /* + * If an async process is already running for the component. + * Do not spin another async process. + */ + ASSERT(commandline != NULL); + ASSERT(!ComponentMgr_IsAsyncProcessRunning(componentIndex)); + + memset(&userArgs, 0, sizeof userArgs); + asyncProc = ProcMgr_ExecAsync(commandline, &userArgs); + if (asyncProc == NULL) { + g_warning("%s: Failed to create process", __FUNCTION__); + return; + } + + /* + * We need information about the async process, component and backoff + * timer value, hence populate the same and store for future references. + */ + procInfo = ComponentMgrCreateAsyncProcessInfo(asyncProc, ctx, + COMPONENTMGR_ASYNC_CHECK_STATUS_TERMINATE_PERIOD, + componentIndex, + callback); + /* + * Set the asyncProcInfo field and GSource timer in the components array + * to cache information of a running async process for a component. + */ + sourceTimer = g_timeout_source_new(COMPONENTMGR_ASYNC_CHECK_STATUS_POLL_INTERVAL * 1000); + ComponentMgr_SetComponentAsyncProcInfo(procInfo, componentIndex); + ComponentMgr_SetComponentGSourceTimer(sourceTimer, componentIndex); + VMTOOLSAPP_ATTACH_SOURCE(ctx, sourceTimer, ComponentMgrCheckStatusMonitor, + procInfo, NULL); + g_source_unref(sourceTimer); +} + + +/* + ***************************************************************************** + * ComponentMgr_AsynchronousComponentActionStart -- + * + * This function invokes the component script as an async process to perform + * present/absent action and a GSource timer to poll the progress. + * + * @param[in] ctx Tools application context. + * @param[in] commandline command to be + * executed to add/remove the component. + * @param[in] componentIndex Index of component in global array of components. + * + * @return + * None. + * + * Side effects: + * Async process creation may fail for many reasons. + * + ***************************************************************************** + */ + +void +ComponentMgr_AsynchronousComponentActionStart(ToolsAppCtx *ctx, // IN + const char *commandline, // IN + int componentIndex) // IN +{ + ProcMgr_ProcArgs userArgs; + GSource *sourceTimer; + AsyncProcessInfo *procInfo; + ProcMgr_AsyncProc *asyncProc; + + /* + * If an async process is already running for the component. + * Do not spin another async process. + */ + ASSERT(commandline != NULL); + ASSERT(!ComponentMgr_IsAsyncProcessRunning(componentIndex)); + + memset(&userArgs, 0, sizeof userArgs); + asyncProc = ProcMgr_ExecAsync(commandline, &userArgs); + if (asyncProc == NULL) { + g_warning("%s: Failed to create process", __FUNCTION__); + return; + } + + /* + * We need information about the async process, component and backoff + * timer value, hence populate the same and store for future references. + */ + procInfo = ComponentMgrCreateAsyncProcessInfo(asyncProc, ctx, + COMPONENTMGR_ASYNCPROCESS_TERMINATE_PERIOD, + componentIndex, NULL); + /* + * Set the asyncProcInfo field and GSource timer field in the components + * array to cache info of running async process for a component. + */ + sourceTimer = g_timeout_source_new(COMPONENTMGR_ASYNCPROCESS_POLL_INTERVAL * 1000); + ComponentMgr_SetComponentAsyncProcInfo(procInfo, componentIndex); + ComponentMgr_SetComponentGSourceTimer(sourceTimer, componentIndex); + VMTOOLSAPP_ATTACH_SOURCE(ctx, sourceTimer, + ComponentMgrProcessMonitor, procInfo, NULL); + g_source_unref(sourceTimer); +} diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/componentMgr/componentMgrPlugin.h open-vm-tools-12.1.5/open-vm-tools/services/plugins/componentMgr/componentMgrPlugin.h --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/componentMgr/componentMgrPlugin.h 1970-01-01 00:00:00.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/componentMgr/componentMgrPlugin.h 2022-11-29 21:17:22.000000000 +0000 @@ -0,0 +1,370 @@ +/********************************************************* + * Copyright (C) 2021 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 + * by the Free Software Foundation version 2.1 and no later version. + * + * 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 Lesser GNU General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + *********************************************************/ + +#ifndef _COMPONENTMGRPlugin_H_ +#define _COMPONENTMGRPlugin_H_ + +/* + * componentMgrPlugin.h -- + * + * This file contains macros used by the componentMgr plugin having references + * for timer related information, guestVar information, component information + * and configuration related information. + * Defines functions shared across the componentMgr plugin. + * Defines states structures to be used to cache and store information related + * to a component and async process. + * + */ + + +#include "conf.h" + +#define G_LOG_DOMAIN COMPONENTMGR_CONF_GROUPNAME + +#include "vm_basic_defs.h" +#include "vmware/tools/plugin.h" +#include "procMgr.h" + +#if defined(_WIN32) +#include +#endif + + +//********************** Timer Definitions **************************** + +/** + * Default and minimum poll interval for componentMgr in seconds. + */ +#define COMPONENTMGR_DEFAULT_POLL_INTERVAL 180 + +/** + * Minimum poll interval for componentMgr in seconds. + * For development and beta builds the poll-interval can be configured + * lower than the default poll-interval. + */ +#ifdef VMX86_DEBUG +#define COMPONENTMGR_MIN_POLL_INTERVAL 5 +#else +#define COMPONENTMGR_MIN_POLL_INTERVAL COMPONENTMGR_DEFAULT_POLL_INTERVAL +#endif + +/* + * Poll interval between 2 consecutive check status operation in seconds. + */ +#define COMPONENTMGR_ASYNC_CHECK_STATUS_POLL_INTERVAL 1 + +/* + * Max time in seconds after which the async process running check status + * command will be terminated. + */ +#define COMPONENTMGR_ASYNC_CHECK_STATUS_TERMINATE_PERIOD 15 + +/* + * Poll interval for waiting on the async process runnning the action for a + * component in seconds. + */ +#define COMPONENTMGR_ASYNCPROCESS_POLL_INTERVAL 5 + +/* + * The wait period after which the async proces needs to be killed for a + * component in seconds. + */ +#define COMPONENTMGR_ASYNCPROCESS_TERMINATE_PERIOD 600 + +/* + * The amount of times the check status operation needs to wait before any + * change in the guetsVar to trigger another checkstatus opeartion. + */ +#define COMPONENTMGR_CHECK_STATUS_COUNT_DOWN 10 + +//********************** Component Action Definitions ********************* + +/** + * Defines check status action on the component. + */ +#define COMPONENTMGR_COMPONENTCHECKSTATUS "checkstatus" + +/** + * Defines an invalid action on the component. + */ +#define COMPONENTMGR_COMPONENINVALIDACTION "invalidaction" + +/** + * Defines present action for a component to be installed on a system. + */ +#define COMPONENTMGR_COMPONENTPRESENT "present" + +/** + * Defines absent action for a component to be removed from a system. + */ +#define COMPONENTMGR_COMPONENTABSENT "absent" + +//********************** Guest Variable Definitions ********************* + +/** + * Defines argument to publish installed and enabled components. + */ +#define COMPONENTMGR_INFOAVAILABLE "available" + +/** + * Defines argument to publish last status of a particular component. + */ +#define COMPONENTMGR_INFOLASTSTATUS "laststatus" + +/** + * Defines action to be taken on a component. + * guestinfo./vmware.components..desiredstate + */ +#define COMPONENTMGR_INFODESIREDSTATE "desiredstate" + +/* + * GuestVar prefix string to fetch the action required for a component. + */ +#define COMPONENTMGR_ACTION "info-get guestinfo./vmware.components" + +/** + * String to set informational guestVar exposed by the plugin. + */ +#define COMPONENTMGR_PUBLISH_COMPONENTS "info-set guestinfo.vmware.components" + +//********************** Component Definitions ********************* + +/** + * Defines the directory for the plugin to host the scripts. + */ +#define COMPONENTMGR_DIRECTORY "componentMgr" + +/** + * Defines none to indicate no component is managed by the plugin. + */ +#define COMPONENTMGR_NONECOMPONENTS "none" + +/** + * Define all the names of components under this section. + */ +#define SALT_MINION "salt_minion" + +/** + * Defines a config all in included to indicate all the components are + * managed by the plugin. + */ +#define COMPONENTMGR_ALLCOMPONENTS "all" + +/* + * The included param in the tools.conf contains comma seperated list + * of components and can have special values. + * Defines various special values present in the included tools.conf param. + */ + +typedef enum IncludedComponents +{ + ALLCOMPONENTS, + NONECOMPONENTS, + NOSPECIALVALUES +} IncludedComponents; + +//******************************************************************* + +/* + * Installation status of the components managed by the componentMgr plugin. + * The status for each component will be updated based on the exit code + * returned by the script executing check status operation. + */ + +typedef enum InstallStatus +{ + INSTALLED = 100, /* The component is installed on the guest OS. */ + INSTALLING, /* The component is being installed on the guest + OS. */ + NOTINSTALLED, /* The component is not installed on the guest OS. + */ + INSTALLFAILED, /* The component install failed on the guest OS. */ + REMOVING, /* The component is being removed on the guest OS. + */ + REMOVEFAILED, /* The component remove failed on the guest OS. */ + SCRIPTFAILED = 126, /* The component script failed for some reason. */ + SCRIPTTERMINATED = 130 /* The component script terminated for some reason. + */ +} InstallStatus; + + +/* + * Actions currently supported by the componentMgr plugin for the known and + * enabled components. + */ + +typedef enum Action +{ + PRESENT, /* The action adds/installs the components on the guest. */ + ABSENT, /* The action removes/uninstalls the components on the guest.*/ + CHECKSTATUS, /* The action calls the preconfigured script to check the + current status of the component. */ + INVALIDACTION /* Action not recongnised by the plugin. */ +} Action; + + +/* + * Structure to store information about the asynchronous process being run + * for a particular component. + */ + +typedef struct AsyncProcessInfo { + ProcMgr_AsyncProc *asyncProc; /* ProcMgr_AsyncProc structure consisting of + the process data running an action on the + component. */ + ToolsAppCtx *ctx; /* Tools application context. */ + int backoffTimer; /* Backoff timer to wait until timeout + to kill the asynchronous process. */ + int componentIndex; /* The index of the component in the global + array of components. */ + void (*callbackFunction)(int componentIndex); /* A callback function to + sequence a new operation + */ +} AsyncProcessInfo; + + +/* + * This structure contains all the information related to all the components + * managed by the plugin. The component states is maintained in this structure. + */ + +typedef struct ComponentInfo +{ + const char *name; /* The name of the component. */ + gboolean isEnabled; /* Component enabled/disabled by the plugin. */ + InstallStatus status; /* Contains current status of the component. */ + GSource *sourceTimer; /* A GSource timer for async process monitoring running + an operation for a component. */ + AsyncProcessInfo *procInfo; /* A structure to store information about the + * current running async process for a component. + */ + int statuscount; /* A counter value to store max number of times to + wait before starting another checkstatus opeartion + */ + Action action; /* Contains information about the action to be + performed on a component. */ +} ComponentInfo; + + +void +ComponentMgrUpdateComponentEnableStatus(ToolsAppCtx *ctx); + + +void +ComponentMgr_UpdateComponentStatus(ToolsAppCtx *ctx); + + +gboolean +ComponentMgr_SendRpc(ToolsAppCtx *ctx, + const char *guestInfoCmd, + char **outBuffer, + size_t *outBufferLen); + + +void +ComponentMgr_Destroytimers(); + + +const char* +ComponentMgr_GetComponentInstallStatus(InstallStatus installStatus); + + +const char* +ComponentMgr_GetComponentAction(Action action); + + +void +ComponentMgr_AsynchronousComponentActionStart(ToolsAppCtx *ctx, + const char *commandline, + int componetIndex); + + +void +ComponentMgr_SetStatusComponentInfo(ToolsAppCtx *ctx, + int exitCode, + int componentIndex); + + +char * +ComponentMgr_CheckStatusCommandLine(int componentIndex); + + +void +ComponentMgr_UpdateComponentEnableStatus(ToolsAppCtx *ctx); + + +void +ComponentMgr_SetComponentGSourceTimer(GSource *componentTimer, + int componentIndex); + +void +ComponentMgr_ResetComponentGSourceTimer(int componentIndex); + + +void +ComponentMgr_ExecuteComponentAction(int componentIndex); + + +void +ComponentMgr_AsynchronousComponentCheckStatus(ToolsAppCtx *ctx, + const char *commandline, + int componentIndex, + void (*callback)(int compIndex)); + + +ToolsAppCtx* +ComponentMgr_GetToolsAppCtx(); + + +const char* +ComponentMgr_GetIncludedComponents(IncludedComponents pos); + + +void +ComponentMgr_SetComponentAsyncProcInfo(AsyncProcessInfo *asyncProcInfo, + int componentIndex); + + +void +ComponentMgr_ResetComponentAsyncProcInfo(int componentIndex); + + +gboolean +ComponentMgr_IsAsyncProcessRunning(int componentIndex); + + +const char* +ComponentMgr_GetComponentName(int componentIndex); + + +void +ComponentMgr_FreeAsyncProc(AsyncProcessInfo *procInfo); + + +void +ComponentMgr_DestroyAsyncProcess(); + + +void +ComponentMgr_PublishAvailableComponents(ToolsAppCtx *ctx, + const char *components); + + +gboolean +ComponentMgr_CheckAnyAsyncProcessRunning(); +#endif /* _ComponentMgrPlugin_H_ */ diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/componentMgr/componentMgrUtil.c open-vm-tools-12.1.5/open-vm-tools/services/plugins/componentMgr/componentMgrUtil.c --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/componentMgr/componentMgrUtil.c 1970-01-01 00:00:00.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/componentMgr/componentMgrUtil.c 2022-11-29 21:17:22.000000000 +0000 @@ -0,0 +1,216 @@ +/********************************************************* + * Copyright (C) 2021 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 + * by the Free Software Foundation version 2.1 and no later version. + * + * 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 Lesser GNU General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + *********************************************************/ + +/* + * componentMgrUtil.c -- + * + * Common utility functions used by the componentMgr plugin. + * + */ + + +#include "componentMgrPlugin.h" +#include "vmware/tools/log.h" + + +/* + ****************************************************************************** + * ComponentMgr_SendRpc -- + * + * Sends RPC message to fetch the guestVars. + * + * @param[in] ctx Tools application context. + * @param[in] guestInfoCmd Guestinfo command to fetch the guestVar. + * @param[out] outBuffer Output buffer to hold RPC result (optional). + * @param[out] outBufferLen Output buffer len (optional). + * + * @return + * TRUE if cmd executed successfully, otherwise FALSE + * + * @note: outBuffer and outBufferLen are optional parameters and be used when + * RPC command output required. Both output parameters are required for output. + * Users have to call RpcChannel_Free on output buffer if supplied. + * + * Side effects: + * None. + * + ****************************************************************************** + */ + +gboolean +ComponentMgr_SendRpc(ToolsAppCtx *ctx, // IN + const char *guestInfoCmd, // IN + char **outBuffer, // OUT + size_t *outBufferLen) // OUT +{ + gboolean status; + size_t replyLen; + char *reply = NULL; + + ASSERT(ctx != NULL); + ASSERT(ctx->rpc != NULL); + ASSERT(guestInfoCmd != NULL); + + status = RpcChannel_Send(ctx->rpc, + guestInfoCmd, + strlen(guestInfoCmd) + 1, + &reply, + &replyLen); + if (!status) { + g_info("%s: Failed to send RPC message, request: \'%s\'," + " reply: \'%s\'.\n", __FUNCTION__, guestInfoCmd, + VM_SAFE_STR(reply)); + } + + if (outBuffer != NULL && outBufferLen != NULL) { + *outBuffer = reply; + *outBufferLen = replyLen; + } else { + RpcChannel_Free(reply); + } + return status; +} + + +/* + ************************************************************************** + * ComponentMgr_GetComponentInstallStatus -- + * + * This function returns an enum equivalent of the current status of the + * component. + * + * @param[in] installStatus Enum value of status of component. + * + * @return + * String equivalent of the component current status. + * + * @Side effects + * None. + * + ************************************************************************** + */ + +const char* +ComponentMgr_GetComponentInstallStatus(InstallStatus installStatus) // IN +{ + switch (installStatus) { + case NOTINSTALLED: return "NOTINSTALLED"; + case INSTALLING: return "INSTALLING"; + case INSTALLED: return "INSTALLED"; + case REMOVING: return "REMOVING"; + case INSTALLFAILED: return "INSTALLFAILED"; + case REMOVEFAILED: return "REMOVEFAILED"; + case SCRIPTFAILED: return "SCRIPTFAILED"; + case SCRIPTTERMINATED: return "SCRIPTTERMINATED"; + } + return "INVALIDSTATUS"; +} + + +/* + ************************************************************************** + * ComponentMgr_GetComponentAction -- + * + * This function returns an enum equivalent of component action to be executed. + * + * @param[in] action The action to be taken on the component. + * + * @return + * String equivalent of the component action. + * + * @Side effects + * None. + * + ************************************************************************** + */ + +const char* +ComponentMgr_GetComponentAction(Action action) // IN +{ + switch (action) { + case PRESENT: return COMPONENTMGR_COMPONENTPRESENT; + case ABSENT: return COMPONENTMGR_COMPONENTABSENT; + case CHECKSTATUS: return COMPONENTMGR_COMPONENTCHECKSTATUS; + case INVALIDACTION: return COMPONENTMGR_COMPONENINVALIDACTION; + } + return COMPONENTMGR_COMPONENINVALIDACTION; +} + + +/* + ************************************************************************** + * ComponentMgr_GetIncludedComponents -- + * + * This function returns an enum equivalent of the special values in the + * included tools.conf param. + * + * @param[in] specialvalue The enum value of special value in the param. + * + * @return + * String equivalent of the special value in the param. + * + * @Side effects + * None. + * + ************************************************************************** + */ + + +const char* +ComponentMgr_GetIncludedComponents(IncludedComponents specialValue) // IN +{ + switch (specialValue) { + case ALLCOMPONENTS: return "ALLCOMPONENTS"; + case NONECOMPONENTS: return "NONECOMPONENTS"; + case NOSPECIALVALUES: return "NOSPECIALVALUES"; + } + return "NOSPECIALVALUES"; +} + + +/* + ***************************************************************************** + * ComponentMgr_PublishAvailableComponents -- + * + * This function publishes guestVar guestinfo.vmware.components.available with + * requested components. + * + * @param[in] ctx Tools application context. + * @param[in] components Comma seperated list of available components. + * + * @return + * None + * + * Side effects: + * None. + * + ***************************************************************************** + */ + +void +ComponentMgr_PublishAvailableComponents(ToolsAppCtx *ctx, // IN + const char *components) // IN +{ + gboolean status; + gchar *msg = g_strdup_printf("%s.%s %s", COMPONENTMGR_PUBLISH_COMPONENTS, + COMPONENTMGR_INFOAVAILABLE, + components); + + status = ComponentMgr_SendRpc(ctx, msg, NULL, NULL); + g_free(msg); +} diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/componentMgr/COPYING open-vm-tools-12.1.5/open-vm-tools/services/plugins/componentMgr/COPYING --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/componentMgr/COPYING 1970-01-01 00:00:00.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/componentMgr/COPYING 2022-11-29 21:17:22.000000000 +0000 @@ -0,0 +1,502 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/componentMgr/Makefile.am open-vm-tools-12.1.5/open-vm-tools/services/plugins/componentMgr/Makefile.am --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/componentMgr/Makefile.am 1970-01-01 00:00:00.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/componentMgr/Makefile.am 2022-11-29 21:17:22.000000000 +0000 @@ -0,0 +1,46 @@ +################################################################################ +### Copyright (c) 2021 VMware, Inc. All rights reserved. +### +### This program is free software; you can redistribute it and/or modify +### it under the terms of version 2 of the GNU General Public License as +### published by the Free Software Foundation. +### +### 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, write to the Free Software +### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +################################################################################ + +SUBDIRS = + +plugindir = @VMSVC_PLUGIN_INSTALLDIR@ +plugin_LTLIBRARIES = libcomponentMgr.la + +libcomponentMgr_la_CPPFLAGS = +libcomponentMgr_la_CPPFLAGS += @PLUGIN_CPPFLAGS@ +libcomponentMgr_la_CPPFLAGS += -DVMTOOLS_COMPONENTMGR_PATH=\"$(pkglibdir)/componentMgr/\" + +libcomponentMgr_la_LDFLAGS = +libcomponentMgr_la_LDFLAGS += @PLUGIN_LDFLAGS@ + +libcomponentMgr_la_LIBADD = +libcomponentMgr_la_LIBADD += @VMTOOLS_LIBS@ +libcomponentMgr_la_LIBADD += @GOBJECT_LIBS@ + +libcomponentMgr_la_SOURCES = +libcomponentMgr_la_SOURCES += componentMgr.c +libcomponentMgr_la_SOURCES += componentMgrPlugin.h +libcomponentMgr_la_SOURCES += componentMgrUtil.c +libcomponentMgr_la_SOURCES += componentMgrInstallAction.c +libcomponentMgr_la_SOURCES += componentMgrInstallManager.c + +install-data-local: +if ENABLE_SALTMINION + $(INSTALL) -d $(DESTDIR)/$(pkglibdir)/componentMgr/saltMinion/ + $(INSTALL) -m 700 $(srcdir)/svtminion.sh \ + $(DESTDIR)/$(pkglibdir)/componentMgr/saltMinion/ +endif diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/componentMgr/svtminion.sh open-vm-tools-12.1.5/open-vm-tools/services/plugins/componentMgr/svtminion.sh --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/componentMgr/svtminion.sh 1970-01-01 00:00:00.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/componentMgr/svtminion.sh 2022-11-29 21:17:22.000000000 +0000 @@ -0,0 +1,2134 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2022 VMware, Inc. All rights reserved. + +## Salt VMware Tools Integration script +## integration with Component Manager and GuestStore Helper + +## set -u +## set -xT +set -o functrace +set -o pipefail +## set -o errexit + +# using bash for now +# run this script as root, as needed to run salt + +readonly SCRIPT_VERSION='1.3' + +# definitions + +CURL_DOWNLOAD_RETRY_COUNT=5 + +## Repository locations and naming +readonly default_salt_url_version="latest" +readonly salt_name="salt" +readonly repo_json_file="repo.json" +salt_url_version="${default_salt_url_version}" +base_url="https://repo.saltproject.io/salt/vmware-tools-onedir" + +# Salt file and directory locations +readonly base_salt_location="/opt/saltstack" +readonly salt_dir="${base_salt_location}/${salt_name}" +readonly test_exists_file="${salt_dir}/run/run" + +readonly salt_conf_dir="/etc/salt" +readonly salt_minion_conf_name="minion" +readonly salt_minion_conf_file="${salt_conf_dir}/${salt_minion_conf_name}" +readonly salt_master_sign_dir="${salt_conf_dir}/pki/${salt_minion_conf_name}" + +readonly log_dir="/var/log" + +readonly list_file_dirs_to_remove="${base_salt_location} +/etc/salt +/var/run/salt +/var/cache/salt +/var/log/salt +/usr/bin/salt-* +/lib/systemd/system/salt-minion.service +/usr/lib/systemd/system/salt-minion.service +/usr/local/lib/systemd/system/salt-minion.service +/etc/systemd/system/salt-minion.service +" +## /var/log/vmware-${SCRIPTNAME}-* + +readonly salt_dep_file_list="systemctl +curl +sha512sum +vmtoolsd +grep +awk +sed +cut +wget +" + +readonly allowed_log_file_action_names="status +depend +install +clear +remove +default +" + +readonly salt_wrapper_file_list="minion +call +" + +readonly salt_minion_service_wrapper=\ +"# Copyright (c) 2021-2022 VMware, Inc. All rights reserved. + +[Unit] +Description=The Salt Minion +Documentation=man:salt-minion(1) file:///usr/share/doc/salt/html/contents.html https://docs.saltproject.io/en/latest/contents.html +After=network.target +# After=ConnMgr.service ProcMgr.service sockets.target + +[Service] +KillMode=process +Type=notify +NotifyAccess=all +LimitNOFILE=8192 +MemoryLimit=250M +Nice=19 +ExecStart=/opt/saltstack/salt/run/run minion + +[Install] +WantedBy=multi-user.target +" + + +## VMware file and directory locations +readonly vmtools_base_dir_etc="/etc/vmware-tools" +readonly vmtools_conf_file="tools.conf" +readonly vmtools_salt_minion_section_name="salt_minion" + +## VMware guestVars file and directory locations +readonly guestvars_base_dir="guestinfo./vmware.components" +readonly \ +guestvars_salt_dir="${guestvars_base_dir}.${vmtools_salt_minion_section_name}" +readonly guestvars_salt_args="${guestvars_salt_dir}.args" +readonly guestvars_salt_desiredstate="${guestvars_salt_dir}.desiredstate" + + +# Array for minion configuration keys and values +# allows for updates from number of configuration sources before final +# write to /etc/salt/minion +declare -a m_cfg_keys +declare -a m_cfg_values + + +## Component Manager Installer/Script return/exit status codes +# return/exit Status codes +# 100 + 0 => installed +# 100 + 1 => installing +# 100 + 2 => notInstalled +# 100 + 3 => installFailed +# 100 + 4 => removing +# 100 + 5 => removeFailed +# 126 => scriptFailed +# 130 => scriptTerminated +declare -A STATUS_CODES_ARY +STATUS_CODES_ARY[installed]=100 +STATUS_CODES_ARY[installing]=101 +STATUS_CODES_ARY[notInstalled]=102 +STATUS_CODES_ARY[installFailed]=103 +STATUS_CODES_ARY[removing]=104 +STATUS_CODES_ARY[removeFailed]=105 +STATUS_CODES_ARY[scriptFailed]=126 +STATUS_CODES_ARY[scriptTerminated]=130 + +# log levels available for logging, order sensitive +readonly LOG_MODES_AVAILABLE=(silent error warning info debug) +declare -A LOG_LEVELS_ARY +LOG_LEVELS_ARY[silent]=0 +LOG_LEVELS_ARY[error]=1 +LOG_LEVELS_ARY[warning]=2 +LOG_LEVELS_ARY[info]=3 +LOG_LEVELS_ARY[debug]=4 + + +STATUS_CHK=0 +DEPS_CHK=0 +USAGE_HELP=0 +UNINSTALL_FLAG=0 +VERBOSE_FLAG=0 +VERSION_FLAG=0 + +CLEAR_ID_KEYS_FLAG=0 +CLEAR_ID_KEYS_PARAMS="" + +INSTALL_FLAG=0 +INSTALL_PARAMS="" + +MINION_VERSION_FLAG=0 +MINION_VERSION_PARAMS="" + +LOG_LEVEL_FLAG=0 +LOG_LEVEL_PARAMS="" + +#default logging level to errors, similar to Windows script +LOG_LEVEL=${LOG_LEVELS_ARY[warning]} + +SOURCE_FLAG=0 +SOURCE_PARAMS="" + +# helper functions + +_timestamp() { + date -u "+%Y-%m-%d %H:%M:%S" +} + +_log() { + echo "$(_timestamp) $*" >> \ + "${log_dir}/vmware-${SCRIPTNAME}-${LOG_ACTION}-${logdate}.log" +} + +_display() { + if [[ ${VERBOSE_FLAG} -eq 1 ]]; then echo "$1"; fi + _log "$*" +} + +_error_log() { + if [[ ${LOG_LEVELS_ARY[error]} -le ${LOG_LEVEL} ]]; then + local log_file="" + log_file="${log_dir}/vmware-${SCRIPTNAME}-${LOG_ACTION}-${logdate}.log" + msg="ERROR: $*" + echo "$msg" 1>&2 + echo "$(_timestamp) $msg" >> "${log_file}" + echo "One or more errors found. See ${log_file} for details." 1>&2 + CURRENT_STATUS=${STATUS_CODES_ARY[scriptFailed]} + exit ${STATUS_CODES_ARY[scriptFailed]} + fi +} + +_info_log() { + if [[ ${LOG_LEVELS_ARY[info]} -le ${LOG_LEVEL} ]]; then + msg="INFO: $*" + _log "${msg}" + fi +} + +_warning_log() { + if [[ ${LOG_LEVELS_ARY[error]} -le ${LOG_LEVEL} ]]; then + msg="WARNING: $*" + _log "${msg}" + fi +} + +_debug_log() { + if [[ ${LOG_LEVELS_ARY[debug]} -le ${LOG_LEVEL} ]]; then + msg="DEBUG: $*" + _log "${msg}" + fi +} + +_yesno() { +read -r -p "Continue (y/n)?" choice +case "$choice" in + y|Y ) echo "yes";; + n|N ) echo "no";; + * ) echo "invalid";; +esac +} + + +# +# _usage +# +# Prints out help text +# + + _usage() { + echo "" + echo "usage: ${0}" + echo " [-c|--clear] [-d|--depend] [-h|--help] [-i|--install]" + echo " [-j|--source] [-l|--loglevel] [-m|--minionversion]" + echo " [-r|--remove] [-s|--status] [-v|--version]" + echo "" + echo " -c, --clear clear previous minion identifer and keys," + echo " and set specified identifer if present" + echo " -d, --depend check dependencies required to run script exist" + echo " -h, --help this message" + echo " -i, --install install and activate salt-minion configuration" + echo " parameters key=value can also be passed on CLI" + echo " -j, --source specify location to install Salt Minion from" + echo " default is repo.saltproject.io location" + echo " for example: url location" + echo " http://my_web_server.com/my_salt_onedir" + echo " https://my_web_server.com/my_salt_onedir" + echo " file://my_path/my_salt_onedir" + echo " //my_path/my_salt_onedir" + echo " if specific version of Salt Minion specified, -m" + echo " then its appended to source, default[latest]" + echo " -l, --loglevel set log level for logging," + echo " silent error warning debug info" + echo " default loglevel is warning" + echo " -m, --minionversion install salt-minion version, default[latest]" + echo " -r, --remove deactivate and remove the salt-minion" + echo " -s, --status return status for this script" + echo " -v, --version version of this script" + echo "" + echo " salt-minion vmtools integration script" + echo " example: $0 --status" +} + + +# work functions + +# +# _cleanup +# +# Cleanups any running process and areas on control-C +# +# +# Results: +# Exits with hard-coded value 130 +# + +_cleanup() { + exit ${STATUS_CODES_ARY[scriptTerminated]} +} + +trap _cleanup INT + + +# cheap trim relying on echo to convert tabs to spaces and +# all multiple spaces to a single space +_trim() { + echo "$1" +} + + +# +# _set_log_level +# +# Set log_level for logging, +# log_level 'silent','error','warning','info','debug' +# default 'warning' +# +# Results: +# Returns with exit code +# + +_set_log_level() { + + _info_log "$0:${FUNCNAME[0]} processing setting set log_level for logging" + + local ip_level="" + local valid_level=0 + local old_log_level=${LOG_LEVEL} + + ip_level=$( echo "$1" | cut -d ' ' -f 1) + scam=${#LOG_MODES_AVAILABLE[@]} + for ((i=0; i "${vmtools_base_dir_etc}/${vmtools_conf_file}" + _warning_log "$0:${FUNCNAME[0]} creating empty configuration"\ + "file ${vmtools_base_dir_etc}/${vmtools_conf_file}" + else + # need to extract configuration for salt-minion + # find section name ${vmtools_salt_minion_section_name} + # read configuration till next section, output salt-minion conf file + + local salt_config_flag=0 + while IFS= read -r line + do + line_value=$(_trim "${line}") + if [[ -n "${line_value}" ]]; then + _debug_log "$0:${FUNCNAME[0]} processing tools.conf"\ + "line '${line}'" + if echo "${line_value}" | grep -q '^\[' ; then + if [[ ${salt_config_flag} -eq 1 ]]; then + # if new section after doing salt config, we are done + break; + fi + if [[ ${line_value} = \ + "[${vmtools_salt_minion_section_name}]" ]]; then + # have section, get configuration values, set flag and + # start fresh salt-minion configuration file + salt_config_flag=1 + fi + elif [[ ${salt_config_flag} -eq 1 ]]; then + # read config ahead of section check, better logic flow + cfg_key=$(echo "${line}" | cut -d '=' -f 1) + cfg_value=$(echo "${line}" | cut -d '=' -f 2) + _update_minion_conf_ary "${cfg_key}" "${cfg_value}" || { + _error_log "$0:${FUNCNAME[0]} error updating minion"\ + "configuration array with key '${cfg_key}' and"\ + "value '${cfg_value}', retcode '$?'"; + } + else + _debug_log "$0:${FUNCNAME[0]} skipping tools.conf"\ + "line '${line}'" + fi + fi + done < "${vmtools_base_dir_etc}/${vmtools_conf_file}" + fi + return ${_retn} +} + + +# +# _fetch_vmtools_salt_minion_conf_guestvars +# +# Retrieve the configuration for salt-minion from vmtools guest variables +# +# Results: +# salt-minion configuration file updated with configuration read +# from vmtools guest variables +# configuration file section for salt_minion +# + +_fetch_vmtools_salt_minion_conf_guestvars() { + # fetch the current configuration for section salt_minion + # from guest variables args + + local _retn=0 + local gvar_args="" + + gvar_args=$(vmtoolsd --cmd "info-get ${guestvars_salt_args}" 2>/dev/null)\ + || { _warning_log "$0:${FUNCNAME[0]} unable to retrieve arguments"\ + "from guest variables location ${guestvars_salt_args},"\ + "retcode '$?'"; + } + + if [[ -z "${gvar_args}" ]]; then return ${_retn}; fi + + _debug_log "$0:${FUNCNAME[0]} processing arguments from guest variables"\ + "location ${guestvars_salt_args}" + + for idx in ${gvar_args} + do + cfg_key=$(echo "${idx}" | cut -d '=' -f 1) + cfg_value=$(echo "${idx}" | cut -d '=' -f 2) + _update_minion_conf_ary "${cfg_key}" "${cfg_value}" || { + _error_log "$0:${FUNCNAME[0]} error updating minion configuration"\ + "array with key '${cfg_key}' and value '${cfg_value}',"\ + "retcode '$?'"; + } + done + + return ${_retn} +} + + +# +# _fetch_vmtools_salt_minion_conf_cli_args +# +# Retrieve the configuration for salt-minion from any args '$@' passed +# on the command line +# +# Results: +# Exits with new vmtools configuration file if none found +# or salt-minion configuration file updated with configuration read +# from vmtools configuration file section for salt_minion +# + +_fetch_vmtools_salt_minion_conf_cli_args() { + local _retn=0 + local cli_args="" + local cli_no_args=0 + + cli_args="$*" + cli_no_args=$# + if [[ ${cli_no_args} -ne 0 ]]; then + _debug_log "$0:${FUNCNAME[0]} processing command line"\ + "arguments '${cli_args}'" + for idx in ${cli_args} + do + # check for start of next option, idx starts with '-' (covers '--') + if [[ "${idx}" = --* ]]; then + break + fi + cfg_key=$(echo "${idx}" | cut -d '=' -f 1) + cfg_value=$(echo "${idx}" | cut -d '=' -f 2) + _update_minion_conf_ary "${cfg_key}" "${cfg_value}" || { + _error_log "$0:${FUNCNAME[0]} error updating minion"\ + "configuration array with key '${cfg_key}' and"\ + "value '${cfg_value}', retcode '$?'"; + } + done + fi + return ${_retn} +} + + +# +# _randomize_minion_id +# +# Added 5 digit random number to input minion identifier +# +# Input: +# String to add random number to +# if no input, default string 'minion_' used +# +# Results: +# exit, return value etc +# + +_randomize_minion_id() { + + local ran_minion="" + local ip_string="$1" + + if [[ -z "${ip_string}" ]]; then + ran_minion="minion_${RANDOM:0:5}" + else + #provided input + ran_minion="${ip_string}_${RANDOM:0:5}" + fi + _debug_log "$0:${FUNCNAME[0]} generated randomized minion"\ + "identifier '${ran_minion}'" + echo "${ran_minion}" +} + + +# +# _fetch_vmtools_salt_minion_conf +# +# Retrieve the configuration for salt-minion +# precendence order: L -> H +# from VMware Tools guest Variables +# from VMware Tools configuration file tools.conf +# from any command line parameters +# +# Results: +# Exits with new salt-minion configuration file written +# + +_fetch_vmtools_salt_minion_conf() { + # fetch the current configuration for section salt_minion + # from vmtoolsd configuration file + + _debug_log "$0:${FUNCNAME[0]} retrieving minion configuration parameters" + _fetch_vmtools_salt_minion_conf_guestvars || { + _error_log "$0:${FUNCNAME[0]} failed to process guest variable"\ + "arguments, retcode '$?'"; + } + _fetch_vmtools_salt_minion_conf_tools_conf || { + _error_log "$0:${FUNCNAME[0]} failed to process tools.conf file,"\ + "retcode '$?'"; + } + _fetch_vmtools_salt_minion_conf_cli_args "$*" || { + _error_log "$0:${FUNCNAME[0]} failed to process command line"\ + "arguments, retcode '$?'"; + } + + # now write minion conf array to salt-minion configuration file + local mykey_ary_sz=${#m_cfg_keys[@]} + local myvalue_ary_sz=${#m_cfg_values[@]} + if [[ "${mykey_ary_sz}" -ne "${myvalue_ary_sz}" ]]; then + _error_log "$0:${FUNCNAME[0]} key '${mykey_ary_sz}' and"\ + "value '${myvalue_ary_sz}' array sizes for minion_conf"\ + "don't match" + else + mkdir -p "${salt_conf_dir}" + echo "# Minion configuration file - created by vmtools salt script"\ + > "${salt_minion_conf_file}" + echo "enable_fqdns_grains: False" >> "${salt_minion_conf_file}" + for ((chk_idx=0; chk_idx> "${salt_minion_conf_file}" + mkdir -p "/etc/salt/pki/minion" + cp -f "${m_cfg_values[${chk_idx}]}" \ + "${salt_master_sign_dir}/" + else + echo "${m_cfg_keys[${chk_idx}]}: ${m_cfg_values[${chk_idx}]}" \ + >> "${salt_minion_conf_file}" + fi + done + fi + + _info_log "$0:${FUNCNAME[0]} successfully retrieved the salt-minion"\ + "configuration from configuration sources" + return 0 +} + + +# +# _curl_download +# +# Retrieve file from specifed url to specific file +# +# Results: +# Exits with 0 or error code +# + +_curl_download() { + local file_name="$1" + local file_url="$2" + local download_retry_failed=1 # assume issues + local _retn=0 + + _info_log "$0:${FUNCNAME[0]} attempting download of file '${file_name}'" + + for ((i=0; i/dev/null + _retn=$? + if [[ ${_retn} -ne 0 ]]; then + CURRENT_STATUS=${STATUS_CODES_ARY[installFailed]} + _error_log "$0:${FUNCNAME[0]} tar xzf expansion of downloaded"\ + "file '${salt_pkg_name}' failed, return code '${_retn}'" + fi + if [[ ! -f ${test_exists_file} ]]; then + CURRENT_STATUS=${STATUS_CODES_ARY[installFailed]} + _error_log "$0:${FUNCNAME[0]} expansion of downloaded file"\ + "'${salt_url}' failed to provide critical file"\ + "'${test_exists_file}'" + fi + CURRENT_STATUS=${STATUS_CODES_ARY[installed]} + cd "${CURRDIR}" || return $? + + _info_log "$0:${FUNCNAME[0]} successfully retrieved salt-minion" + return 0 +} + + +# +# _check_multiple_script_running +# +# check if more than one version of the script is running +# +# Results: +# Echos the number of scripts running, allowing for forks etc +# from bash etc, a single instance of the script returns 3 +# + +_check_multiple_script_running() { + local count=0 + local procs_found="" + + _info_log "$0:${FUNCNAME[0]} checking how many versions of the"\ + "script are running" + + procs_found=$(pgrep -f "${SCRIPTNAME}") + count=$(echo "${procs_found}" | wc -l) + + _debug_log "$0:${FUNCNAME[0]} checking versions of script are running,"\ + "bashpid '${BASHPID}', processes found '${procs_found}',"\ + "and count '${count}'" + + echo "${count}" + return 0 +} + + +# +# _check_std_minion_install +# +# Check if standard salt-minion is installed for the OS +# for example: install salt-minion from rpm or deb package +# +# Results: +# 0 - No standard install found and empty string output +# !0 - Standard install found and Salt version found output +# + +_check_std_minion_install() { + + # checks for /usr/bin, then /usr/local/bin + # this catches 80% to 90% of the reqular cases + # if salt-call is there, then so is a salt-minion + # as they are installed together + + local _retn=0 + local max_file_sz=200 + local list_of_files_check=" +/usr/bin/salt-call +/usr/local/bin/salt-call +" + _info_log "$0:${FUNCNAME[0]} check if standard salt-minion installed" + + for idx in ${list_of_files_check} + do + if [[ -f "${idx}" ]]; then + #check size of file, if larger than 200, not script wrapper file + local file_sz=0 + file_sz=$(( $(wc -c < "${idx}") )) + _debug_log "$0:${FUNCNAME[0]} found file '${idx}',"\ + "size '${file_sz}'" + if [[ ${file_sz} -gt ${max_file_sz} ]]; then + # get salt-version + local s_ver="" + s_ver=$("${idx}" --local test.version |grep -v 'local:' |xargs) + _debug_log "$0:${FUNCNAME[0]} found standard salt-minion,"\ + "Salt version: '${s_ver}'" + echo "${s_ver}" + _retn=1 + break + fi + fi + done + echo "" + return ${_retn} +} + + +# +# _find_salt_pid +# +# finds the pid for the salt process +# +# Results: +# Echos ${salt_pid} which could be empty '' if salt process not found +# + +_find_salt_pid() { + # find the pid for salt-minion if active + local salt_pid=0 + salt_pid=$(pgrep -f "${salt_name}\/run\/run minion" | head -n 1 | + awk -F " " '{print $1}') + _debug_log "$0:${FUNCNAME[0]} checking for salt-minion process id,"\ + "found '${salt_pid}'" + echo "${salt_pid}" +} + +# +# _ensure_id_or_fqdn +# +# Ensures that a valid minion identifier has been specified, and if not a +# valid Fully Qualified Domain Name exists (not default Unknown.example.org) +# else generates a minion id to use. +# +# Note: this function should only be run before starting the salt-minion +# via systemd after it has been installed +# +# Side Effect: +# Updates salt-minion configuration file with generated identifer +# if no valid FQDN +# +# Results: +# salt-minion configuration contains a valid identifier or FQDN to use. +# Exits with 0 +# + +_ensure_id_or_fqdn () { + # ensure minion id or fqdn for salt-minion + + local minion_fqdn="" + + # quick check if id specified + if grep -q '^id:' < "${salt_minion_conf_file}"; then + _debug_log "$0:${FUNCNAME[0]} salt-minion identifier found, no"\ + "need to check further" + return 0 + fi + + _debug_log "$0:${FUNCNAME[0]} ensuring salt-minion identifier or"\ + "FQDN is specified for salt-minion configuration" + minion_fqdn=$(/usr/bin/salt-call --local grains.get fqdn | + grep -v 'local:' | xargs) + if [[ -n "${minion_fqdn}" && + "${minion_fqdn}" != "Unknown.example.org" ]]; then + _debug_log "$0:${FUNCNAME[0]} non-default salt-minion FQDN"\ + "'${minion_fqdn}' is specified for salt-minion configuration" + return 0 + fi + + # default FQDN, no id is specified, generate one and update conf file + local minion_genid="" + minion_genid=$(_generate_minion_id) + echo "id: ${minion_genid}" >> "${salt_minion_conf_file}" + _debug_log "$0:${FUNCNAME[0]} no salt-minion identifier found,"\ + "generated identifier '${minion_genid}'" + + return 0 +} + + +# +# _create_helper_scripts +# +# Create helper scripts for salt-call and salt-minion +# +# Example: _create_helper_scripts +# +# Results: +# Exits with 0 or error code +# + +_create_helper_scripts() { + + for idx in ${salt_wrapper_file_list} + do + local abs_filepath="" + abs_filepath="/usr/bin/salt-${idx}" + + _debug_log "$0:${FUNCNAME[0]} creating helper file 'salt-${idx}'"\ + "in directory /usr/bin" + + echo "#!/usr/bin/env bash + +# Copyright (c) 2021 VMware, Inc. All rights reserved. +" > "${abs_filepath}" || { + _error_log "$0:${FUNCNAME[0]} failed to create helper file"\ + "'salt-${idx}' in directory /usr/bin, retcode '$?'"; + } + { + echo -n "exec /opt/saltstack/salt/run/run ${idx} "; + echo -n "\"$"; + echo -n "{"; + echo -n "@"; + echo -n ":"; + echo -n "1}"; + echo -n "\""; + } >> "${abs_filepath}" || { + _error_log "$0:${FUNCNAME[0]} failed to finish creating helper"\ + "file 'salt-${idx}' in directory /usr/bin, retcode '$?'"; + } + echo "" >> "${abs_filepath}" + + # ensure executable + chmod 755 "${abs_filepath}" || { + _error_log "$0:${FUNCNAME[0]} failed to make helper file"\ + "'salt-${idx}' executable in directory /usr/bin, retcode '$?'"; + } + done + +} + + +# +# _status_fn +# +# discover and return the current status +# +# 0 => installed +# 1 => installing +# 2 => notInstalled +# 3 => installFailed +# 4 => removing +# 5 => removeFailed +# 126 => scriptFailed +# +# Side Effects: +# CURRENT_STATUS updated +# +# Results: +# Exits numerical status +# + +_status_fn() { + # return status + local _retn_status=${STATUS_CODES_ARY[notInstalled]} + local script_count=0 + + _info_log "$0:${FUNCNAME[0]} checking status for script" + script_count=$(_check_multiple_script_running) + if [[ ${script_count} -gt 3 ]]; then + _error_log "$0:${FUNCNAME[0]} failed to check status, " \ + "multiple versions of the script are running" + fi + + svpid=$(_find_salt_pid) + if [[ ! -f "${test_exists_file}" && -z ${svpid} ]]; then + # check not installed and no process id + CURRENT_STATUS=${STATUS_CODES_ARY[notInstalled]} + _retn_status=${STATUS_CODES_ARY[notInstalled]} + elif [[ -f "${test_exists_file}" ]]; then + # check installed + CURRENT_STATUS=${STATUS_CODES_ARY[installed]} + _retn_status=${STATUS_CODES_ARY[installed]} + # normal case but double-check + svpid=$(_find_salt_pid) + if [[ -z ${svpid} ]]; then + # Note: someone could have stopped the salt-minion, + # so installed but not running, + # status codes don't allow for that case + CURRENT_STATUS=${STATUS_CODES_ARY[installFailed]} + _retn_status=${STATUS_CODES_ARY[installFailed]} + fi + elif [[ -z ${svpid} ]]; then + # check no process id and main directory still left, then removeFailed + if [[ -f "${test_exists_file}" ]]; then + CURRENT_STATUS=${STATUS_CODES_ARY[removeFailed]} + _retn_status=${STATUS_CODES_ARY[removeFailed]} + fi + fi + + + return ${_retn_status} +} + + +# +# _deps_chk_fn +# +# Check dependencies for using salt-minion +# +# Side Effects: +# Results: +# Exits with 0 or error code +# +_deps_chk_fn() { + # return dependency check + local error_missing_deps="" + + _info_log "$0:${FUNCNAME[0]} checking script dependencies" + for idx in ${salt_dep_file_list} + do + command -v "${idx}" 1>/dev/null || { + if [[ -z "${error_missing_deps}" ]]; then + error_missing_deps="${idx}" + else + error_missing_deps="${error_missing_deps} ${idx}" + fi + } + done + if [[ -n "${error_missing_deps}" ]]; then + _error_log "$0:${FUNCNAME[0]} failed to find required"\ + "dependenices '${error_missing_deps}'"; + fi + return 0 +} + +# +# _find_system_lib_path +# +# find with systemd library path to use +# +# Result: +# echos the systemd library path +# will error if no systemd library path can be determined +# +# Note: +# /lib/systemd/system +# System units installed by the distribution package manage +# /usr/lib/systemd/system +# System units installed by the Administrator +# /usr/local/lib/systemd/system +# System units installed by the Administrator (possible on some OS) +# +# Will use /usr/lib/systemd/system available, since this is generally +# the default used on modern Linux OS by salt-minion, some earlier OS's +# (Debian 9, Ubuntu 18.04) use /lib/systemd/system +# +_find_system_lib_path () { + + local path_found="" + _info_log "$0:${FUNCNAME[0]} finding systemd library path to use" + if [[ -d "/usr/lib/systemd/system" ]]; then + path_found="/usr/lib/systemd/system" + elif [[ -d "/lib/systemd/system" ]]; then + path_found="/lib/systemd/system" + elif [[ -d "/usr/local/lib/systemd/system" ]]; then + path_found="/usr/local/lib/systemd/system" + else + _error_log "$0:${FUNCNAME[0]} unable to determine systemd"\ + "library path to use" + fi + _debug_log "$0:${FUNCNAME[0]} found library path to use ${path_found}" + echo "${path_found}" +} + + +# +# _install_fn +# +# Executes scripts to install Salt from Salt repository +# and start the salt-minion using systemd +# +# Results: +# Exits with 0 or error code +# + +_install_fn () { + # execute install of Salt minion + local _retn=0 + local script_count=0 + local existing_chk="" + local found_salt_ver="" + + _info_log "$0:${FUNCNAME[0]} processing script install" + + script_count=$(_check_multiple_script_running) + if [[ ${script_count} -gt 3 ]]; then + _error_log "$0:${FUNCNAME[0]} failed to install, " \ + "multiple versions of the script are running" + fi + + found_salt_ver=$(_check_std_minion_install) + if [[ -n "${found_salt_ver}" ]]; then + _error_log "$0:${FUNCNAME[0]} failed to install, " \ + "existing Standard Salt Installation detected,"\ + "Salt version: '${found_salt_ver}'" + else + _debug_log "$0:${FUNCNAME[0]} no standardized install found" + fi + + # check if salt-minion or salt-master (salt-cloud etc req master) + # and log warning that they will be overwritten + existing_chk=$(pgrep -l "salt-minion|salt-master" | cut -d ' ' -f 2 | uniq) + if [[ -n "${existing_chk}" ]]; then + for idx in ${existing_chk} + do + local salt_fn="" + salt_fn="$(basename "${idx}")" + _warning_log "$0:${FUNCNAME[0]} existing salt functionality"\ + "${salt_fn} shall be stopped and replaced when new"\ + "salt-minion is installed" + done + fi + + # fetch salt-minion form repository + _fetch_salt_minion || { + _error_log "$0:${FUNCNAME[0]} failed to fetch salt-minion"\ + "from repository , retcode '$?'"; + } + + # get configuration for salt-minion + _fetch_vmtools_salt_minion_conf "$@" || { + _error_log "$0:${FUNCNAME[0]} failed, read configuration for"\ + "salt-minion, retcode '$?'"; + } + + if [[ ${_retn} -eq 0 && -f "${test_exists_file}" ]]; then + # create helper scripts for /usr/bin to ensure they are present + # before attempting to use them in _ensure_id_or_fqdn + _debug_log "$0:${FUNCNAME[0]} creating helper files salt-call"\ + "and salt-minion in directory /usr/bin" + _create_helper_scripts || { + _error_log "$0:${FUNCNAME[0]} failed to create helper files"\ + "salt-call or salt-minion in directory /usr/bin, retcode '$?'"; + } + fi + + # ensure minion id or fqdn for salt-minion + _ensure_id_or_fqdn + + if [[ ${_retn} -eq 0 && -f "${test_exists_file}" ]]; then + if [[ -n "${existing_chk}" ]]; then + # be nice and stop any current salt functionalty found + for idx in ${existing_chk} + do + local salt_fn="" + salt_fn="$(basename "${idx}")" + _warning_log "$0:${FUNCNAME[0]} stopping salt functionality"\ + " ${salt_fn} its replaced with new installed salt-minion" + systemctl stop "${salt_fn}" || { + _warning_log "$0:${FUNCNAME[0]} stopping existing salt"\ + "functionality ${salt_fn} encountered difficulties"\ + "using systemctl, it will be over-written with the"\ + "new installed salt-minion regarlessly, retcode '$?'"; + } + done + fi + + # install salt-minion systemd service script + # first find with systemd library path to use + local systemd_lib_path="" + systemd_lib_path=$(_find_system_lib_path) + local name_service="salt-minion.service" + _debug_log "$0:${FUNCNAME[0]} copying systemd service script"\ + "${name_service} to directory ${systemd_lib_path}" + echo "${salt_minion_service_wrapper}" \ + > "${systemd_lib_path}/${name_service}" || { + _error_log "$0:${FUNCNAME[0]} failed to copy systemd service"\ + "file ${name_service} to directory"\ + "${systemd_lib_path}, retcode '$?'"; + } + cd /etc/systemd/system || return $? + rm -f "${name_service}" + ln -s "${systemd_lib_path}/${name_service}" \ + "${name_service}" || { + _error_log "$0:${FUNCNAME[0]} failed to symbolic link"\ + "systemd service file ${name_service} in"\ + "directory /etc/systemd/system, retcode '$?'"; + } + _debug_log "$0:${FUNCNAME[0]} symbolically linked systemd service"\ + "file ${name_service} in directory /etc/systemd/system" + cd "${CURRDIR}" || return $? + + # start the salt-minion using systemd + systemctl daemon-reload || { + _error_log "$0:${FUNCNAME[0]} reloading the systemd daemon"\ + "failed , retcode '$?'"; + } + _debug_log "$0:${FUNCNAME[0]} successfully executed systemctl"\ + "daemon-reload" + systemctl restart "${name_service}" || { + _error_log "$0:${FUNCNAME[0]} starting the salt-minion using"\ + "systemctl failed , retcode '$?'"; + } + _debug_log "$0:${FUNCNAME[0]} successfully executed systemctl"\ + "restart '${name_service}'" + systemctl enable "${name_service}" || { + _error_log "$0:${FUNCNAME[0]} enabling the salt-minion using"\ + "systemctl failed , retcode '$?'"; + } + _debug_log "$0:${FUNCNAME[0]} successfully executed systemctl"\ + "enable '${name_service}'" + fi + return ${_retn} +} + + +# +# _source_fn +# +# Set the location to retrieve the Salt Minion from +# default is to use the Salt Project repository +# +# Set the version of Salt Minion wanted to install +# default 'latest' +# +# Note: handle all protocols (http, https, ftp, file, unc, etc) +# for example: +# http://my_web_server.com/my_salt_onedir +# https://my_web_server.com/my_salt_onedir +# ftp://my_ftp_server.com/my_salt_onedir +# file://mytopdir/mymiddledir/my_salt_onedir +# ///mytopdir/mymiddledir/my_salt_onedir +# +# If a specific version of the Salt Minion is specified +# then it will be appended to the specified source location +# otherwise a default of 'latest' is applied. +# +# Results: +# Exits with 0 or error code +# + +_source_fn () { + local _retn=0 + local salt_source="" + + if [[ $# -ne 1 ]]; then + _error_log "$0:${FUNCNAME[0]} error expected one parameter"\ + "specifying the source for location of onedir files" + fi + + _info_log "$0:${FUNCNAME[0]} processing script source for location"\ + "of onedir files" + + salt_source=$(echo "$1" | cut -d ' ' -f 1) + _debug_log "$0:${FUNCNAME[0]} input salt source is '${salt_source}'" + + if [[ -n "${salt_source}" ]]; then + base_url=${salt_source} + fi + _debug_log "$0:${FUNCNAME[0]} input salt source for salt-minion to"\ + "install from is '${base_url}'" + + return ${_retn} +} + + +# +# _generate_minion_id +# +# Searchs salt-minion configuration file for current id, and disables it +# and generates a new id based from the existng id found, +# or an older commented out id, and provides it with a randomized 5 digit +# postpended to it, for example: myminion_12345 +# +# if no previous id found, a generated minion_ is output +# +# Side Effects: +# Disables any id found in minion configuration file +# +# Result: +# Outputs randomized minion id for use in a minion configuration file +# Exits with 0 or error code +# + +_generate_minion_id () { + + local salt_id_flag=0 + local minion_id="" + local cfg_value="" + local ifield="" + local tfields="" + + _debug_log "$0:${FUNCNAME[0]} generating a salt-minion identifier" + + # always comment out what was there + sed -i 's/^id:/# id:/g' "${salt_minion_conf_file}" + + while IFS= read -r line + do + line_value=$(_trim "${line}") + if [[ -n "${line_value}" ]]; then + if echo "${line_value}" | grep -q '^# id:' ; then + # get value and write out value_ + cfg_value=$(echo "${line_value}" | cut -d ' ' -f 3) + if [[ -n "${cfg_value}" ]]; then + salt_id_flag=1 + minion_id=$(_randomize_minion_id "${cfg_value}") + _debug_log "$0:${FUNCNAME[0]} found previously used id"\ + "field, randomizing it" + fi + elif echo "${line_value}" | grep -q -w 'id:' ; then + # might have commented out id, get value and + # write out value_ + tfields=$(echo "${line_value}"|awk -F ':' '{print $2}'|xargs) + ifield=$(echo "${tfields}" | cut -d ' ' -f 1) + if [[ -n ${ifield} ]]; then + minion_id=$(_randomize_minion_id "${ifield}") + salt_id_flag=1 + _debug_log "$0:${FUNCNAME[0]} found previously used"\ + "id field, randomizing it" + fi + else + _debug_log "$0:${FUNCNAME[0]} skipping line '${line}'" + fi + fi + done < "${salt_minion_conf_file}" + + if [[ ${salt_id_flag} -eq 0 ]]; then + # no id field found, write minion_> "${salt_minion_conf_file}" + _debug_log "$0:${FUNCNAME[0]} updated salt-minion identifer"\ + "'${minion_id}' in configuration file '${salt_minion_conf_file}'" + + if [[ ${salt_minion_pre_active_flag} -eq 1 ]]; then + # restart the stopped salt-minion using systemd + systemctl restart salt-minion || { + _error_log "$0:${FUNCNAME[0]} failed to restart salt-minion"\ + "using systemctl, retcode '$?'"; + } + + _debug_log "$0:${FUNCNAME[0]} successfully executed systemctl"\ + "restart salt-minion" + fi + + return ${_retn} +} + + +# +# _remove_installed_files_dirs +# +# Removes all Salt files and directories that may be used +# +# Results: +# Exits with 0 or error code +# + +_remove_installed_files_dirs() { + _debug_log "$0:${FUNCNAME[0]} removing directories and files"\ + "in '${list_file_dirs_to_remove}'" + for idx in ${list_file_dirs_to_remove} + do + rm -fR "${idx}" || { + _error_log "$0:${FUNCNAME[0]} failed to remove file or"\ + "directory '${idx}' , retcode '$?'"; + } + done + return 0 +} + + +# +# _uninstall_fn +# +# Executes scripts to uninstall Salt from system +# stopping the salt-minion using systemd +# +# Side Effects: +# CURRENT_STATUS updated +# +# Results: +# Exits with 0 or error code +# + +_uninstall_fn () { + # remove Salt minion + local _retn=0 + local script_count=0 + + _info_log "$0:${FUNCNAME[0]} processing script remove" + + script_count=$(_check_multiple_script_running) + if [[ ${script_count} -gt 3 ]]; then + _error_log "$0:${FUNCNAME[0]} failed to remove,"\ + "multiple versions of the script are running" + fi + + found_salt_ver=$(_check_std_minion_install) + if [[ -n "${found_salt_ver}" ]]; then + _error_log "$0:${FUNCNAME[0]} failed to remove,"\ + "existing Standard Salt Installation detected,"\ + "Salt version: '${found_salt_ver}'" + else + _debug_log "$0:${FUNCNAME[0]} no standardized install found" + fi + + if [[ ! -f "${test_exists_file}" ]]; then + CURRENT_STATUS=${STATUS_CODES_ARY[notInstalled]} + + # assumme rest is gone + # TBD enhancement, could loop thru and check all of files to remove + # and if salt_pid empty but we error out if issues when uninstalling, + # so safe for now. + _retn=0 + else + CURRENT_STATUS=${STATUS_CODES_ARY[removing]} + svpid=$(_find_salt_pid) + if [[ -n ${svpid} ]]; then + # stop the active salt-minion using systemd + # and give it a little time to stop + systemctl stop salt-minion || { + _error_log "$0:${FUNCNAME[0]} failed to stop salt-minion"\ + "using systemctl, retcode '$?'"; + } + _debug_log "$0:${FUNCNAME[0]} successfully executed systemctl"\ + "stop salt-minion" + systemctl disable salt-minion || { + _error_log "$0:${FUNCNAME[0]} disabling the salt-minion"\ + "using systemctl failed , retcode '$?'"; + } + _debug_log "$0:${FUNCNAME[0]} successfully executed systemctl"\ + "disable salt-minion" + fi + + if [[ ${_retn} -eq 0 ]]; then + svpid=$(_find_salt_pid) + if [[ -n ${svpid} ]]; then + _debug_log "$0:${FUNCNAME[0]} found salt-minion process"\ + "id '${salt_pid}', systemctl stop should have"\ + "eliminated it, killing it now" + kill "${svpid}" + ## given it a little time + sleep 5 + fi + svpid=$(_find_salt_pid) + if [[ -n ${svpid} ]]; then + CURRENT_STATUS=${STATUS_CODES_ARY[removeFailed]} + _error_log "$0:${FUNCNAME[0]} failed to kill the"\ + "salt-minion, pid '${svpid}' during uninstall" + else + _remove_installed_files_dirs || { + _error_log "$0:${FUNCNAME[0]} failed to remove all"\ + "installed salt-minion files and directories,"\ + "retcode '$?'"; + } + CURRENT_STATUS=${STATUS_CODES_ARY[notInstalled]} + fi + fi + fi + + _info_log "$0:${FUNCNAME[0]} successfuly removed salt-minion and"\ + "associated files and directories" + return ${_retn} +} + + +# +# _clean_up_log_files +# +# Limits number of log files by removing oldest log files which exceed +# limit LOG_FILE_NUMBER +# +# Results: +# Exits with 0 or error code +# +_clean_up_log_files() { + + _info_log "$0:${FUNCNAME[0]} removing and limiting log files" + for idx in ${allowed_log_file_action_names} + do + local count_f=0 + local found_f="" + local -a found_f_ary + found_f=$(ls -t "${log_dir}/vmware-${SCRIPTNAME}-${idx}"* 2>/dev/null) + count_f=$(echo "${found_f}" | wc | awk -F" " '{print $2}') + mapfile -t found_f_ary <<< "${found_f}" + + if [[ ${count_f} -gt ${LOG_FILE_NUMBER} ]]; then + # allow for org-0 + for ((i=count_f-1; i>=LOG_FILE_NUMBER; i--)); do + _debug_log "$0:${FUNCNAME[0]} removing log file"\ + "'${found_f_ary[i]}', for count '${i}',"\ + "limit '${LOG_FILE_NUMBER}'" + rm -f "${found_f_ary[i]}" || { + _error_log "$0:${FUNCNAME[0]} failed to remove file"\ + "'${found_f_ary[i]}', for count '${i}',"\ + "limit '${LOG_FILE_NUMBER}'" + } + done + else + _debug_log "$0:${FUNCNAME[0]} found '${count_f}'"\ + "log files starting with"\ + "${log_dir}/vmware-${SCRIPTNAME}-${idx}-"\ + ", limit '${LOG_FILE_NUMBER}'" + fi + done + return 0 +} + +################################### MAIN #################################### + +# static definitions + +CURRDIR=$(pwd) + +# default status is notInstalled +CURRENT_STATUS=${STATUS_CODES_ARY[notInstalled]} +export CURRENT_STATUS + +## build date-time tag used for logging UTC YYYYMMDDhhmmss +## YearMontDayHourMinuteSecondMicrosecond aka jid +logdate=$(date -u +%Y%m%d%H%M%S) + +# set logging infomation +LOG_FILE_NUMBER=5 +SCRIPTNAME=$(basename "$0") +mkdir -p "${log_dir}" + +# set to action e.g. 'remove', 'install' +# default is for any logging not associated with a specific action +# for example: debug logging and --version +LOG_ACTION="default" + +CLI_ACTION=0 + +while true; do + if [[ -z "$1" ]]; then break; fi + case "$1" in + -c | --clear ) + CLEAR_ID_KEYS_FLAG=1; + shift; + CLEAR_ID_KEYS_PARAMS=$*; + ;; + -d | --depend ) + DEPS_CHK=1; + shift; + ;; + -h | --help ) + USAGE_HELP=1; + shift; + ;; + -i | --install ) + INSTALL_FLAG=1; + shift; + INSTALL_PARAMS="$*"; + ;; + -j | --source ) + SOURCE_FLAG=1; + shift; + SOURCE_PARAMS="$*"; + ;; + -l | --loglevel ) + LOG_LEVEL_FLAG=1; + shift; + LOG_LEVEL_PARAMS="$*"; + ;; + -m | --minionversion ) + MINION_VERSION_FLAG=1; + shift; + MINION_VERSION_PARAMS="$*"; + ;; + -r | --remove ) + UNINSTALL_FLAG=1; + shift; + ;; + -s | --status ) + STATUS_CHK=1; + shift; + ;; + -v | --version ) + VERSION_FLAG=1; + shift; + ;; + -- ) + shift; + break; + ;; + * ) + shift; + ;; + esac +done + +## check if want help, display usage and exit +if [[ ${USAGE_HELP} -eq 1 ]]; then + _usage + exit 0 +fi + + +## MAIN BODY OF SCRIPT + +retn=0 + +if [[ ${LOG_LEVEL_FLAG} -eq 1 ]]; then + # ensure logging level changes are processed before any actions + CLI_ACTION=1 + _set_log_level "${LOG_LEVEL_PARAMS}" + retn=$? +fi +if [[ ${STATUS_CHK} -eq 1 ]]; then + CLI_ACTION=1 + LOG_ACTION="status" + _status_fn + retn=$? +fi +if [[ ${DEPS_CHK} -eq 1 ]]; then + CLI_ACTION=1 + LOG_ACTION="depend" + _deps_chk_fn + retn=$? +fi +if [[ ${SOURCE_FLAG} -eq 1 ]]; then + echo "DGM SOURCE source params ${SOURCE_PARAMS}" + CLI_ACTION=1 + LOG_ACTION="install" + # ensure this is processed before install + _source_fn "${SOURCE_PARAMS}" + retn=$? +fi +if [[ ${MINION_VERSION_FLAG} -eq 1 ]]; then + CLI_ACTION=1 + # ensure this is processed before install + _set_install_minion_version_fn "${MINION_VERSION_PARAMS}" + retn=$? +fi +if [[ ${INSTALL_FLAG} -eq 1 ]]; then + CLI_ACTION=1 + LOG_ACTION="install" + _install_fn "${INSTALL_PARAMS}" + retn=$? +fi +if [[ ${CLEAR_ID_KEYS_FLAG} -eq 1 ]]; then + CLI_ACTION=1 + LOG_ACTION="clear" + _clear_id_key_fn "${CLEAR_ID_KEYS_PARAMS}" + retn=$? +fi +if [[ ${UNINSTALL_FLAG} -eq 1 ]]; then + CLI_ACTION=1 + LOG_ACTION="remove" + _uninstall_fn + retn=$? +fi +if [[ ${VERSION_FLAG} -eq 1 ]]; then + CLI_ACTION=1 + echo "${SCRIPT_VERSION}" + retn=0 +fi + +if [[ ${CLI_ACTION} -eq 0 ]]; then + # check if guest variables have an action since none from CLI + # since none presented on the command line + gvar_action=$(vmtoolsd --cmd "info-get ${guestvars_salt_desiredstate}" \ + 2>/dev/null) || { + _warning_log "$0 unable to retrieve any action arguments from"\ + "guest variables ${guestvars_salt_desiredstate}, retcode '$?'"; + } + + if [[ -n "${gvar_action}" ]]; then + case "${gvar_action}" in + depend) + LOG_ACTION="depend" + _deps_chk_fn + retn=$? + ;; + present) + LOG_ACTION="install" + _install_fn + retn=$? + ;; + absent) + LOG_ACTION="remove" + _uninstall_fn + retn=$? + ;; + status) + LOG_ACTION="status" + _status_fn + retn=$? + ;; + *) + ;; + esac + fi +fi + +_clean_up_log_files + +exit ${retn} diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/containerInfo/containerInfo.c open-vm-tools-12.1.5/open-vm-tools/services/plugins/containerInfo/containerInfo.c --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/containerInfo/containerInfo.c 1970-01-01 00:00:00.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/containerInfo/containerInfo.c 2022-11-29 21:17:22.000000000 +0000 @@ -0,0 +1,1016 @@ +/********************************************************* + * Copyright (C) 2021-2022 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 + * by the Free Software Foundation version 2.1 and no later version. + * + * 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 Lesser GNU General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + *********************************************************/ + +/* + * containerInfo.c -- + * + * Captures the information about running containers inside the guest + * and publishes it to a guest variable. + */ + +#ifndef __linux__ +# error This file should not be compiled. +#endif + +#include +#include +#include + +#include "containerInfoInt.h" +#include "codeset.h" +#include "procMgr.h" +#include "str.h" +#include "strutil.h" +#include "conf.h" +#include "util.h" +#include "vm_atomic.h" +#include "vmware/guestrpc/containerInfo.h" +#include "vmware/guestrpc/tclodefs.h" +#include "vmware/tools/log.h" +#include "vmware/tools/threadPool.h" + +#include "vm_version.h" +#include "embed_version.h" +#include "vmtoolsd_version.h" +VM_EMBED_VERSION(VMTOOLSD_VERSION_STRING); + +/** + * Default poll interval for containerInfo is 6 hours + */ +#define CONTAINERINFO_DEFAULT_POLL_INTERVAL (6 * 60 * 60) + +/** + * Name of the containerd process. This is used to figure + * out if the containerd process is running in the list + * of processes. + */ +#define CONTAINERD_PROCESS_NAME "containerd" + +/** + * Default value for containerinfo query-limit conf key. + */ +#define CONTAINERINFO_DEFAULT_CONTAINER_MAX 256 + +/** + * Default value for CONFNAME_CONTAINERINFO_REMOVE_DUPLICATES setting in + * tools configuration file. + * + * TRUE will remove duplicate containers. + */ +#define CONTAINERINFO_DEFAULT_REMOVE_DUPLICATES TRUE + +/** + * Default value for containerd-unix-socket conf key. + */ +#define CONTAINERINFO_DEFAULT_CONTAINERDSOCKET "/run/containerd/containerd.sock" + +/** + * Default value for docker-unix-socket conf key. + */ +#define CONTAINERINFO_DEFAULT_DOCKER_SOCKET "/var/run/docker.sock" + +/** + * Default value for allowed-namespaces conf key. + */ +#define CONTAINERINFO_DEFAULT_ALLOWED_NAMESPACES "moby,k8s.io,default" + +/** + * Name of the 'moby' namespace used by docker. + */ +#define CONTAINERINFO_DOCKER_NAMESPACE_NAME "moby" + +/** + * Maximum size of the guestinfo packet that holds the containerinfo + * information. + */ +#define CONTAINERINFO_MAX_GUESTINFO_PACKET_SIZE (63 * 1024) + +/** + * Defines current containerinfo poll interval (in seconds). + * + * Controlled by containerinfo.poll-interval config file option. + */ +static Atomic_uint32 gContainerInfoPollInterval = { 0 }; + +/** + * ContainerInfo gather loop timeout source. + */ +static GSource *gContainerInfoTimeoutSource = NULL; + +/** + * ContainerInfo and AppInfo share the same host side switch so this + * defines the state of the AppInfo at the host side. + */ +static gboolean gAppInfoEnabledInHost = TRUE; + +/** + * Defines whether task is currently in progress. libcurl initialization + * is not thread safe so this atomic bool will ensure only one task is + * running at a time. + */ +static Atomic_Bool gTaskSubmitted = { FALSE }; // Task has not been submitted. + +static void TweakGatherLoop(ToolsAppCtx *ctx, gboolean force); + + +/* + ***************************************************************************** + * SetGuestInfo -- + * + * Sends a simple key-value update request to the VMX. + * + * @param[in] ctx Application context. + * @param[in] key Key sent to the VMX + * @param[in] value GuestInfo data sent to the VMX + * + ***************************************************************************** + */ + +static void +SetGuestInfo(ToolsAppCtx *ctx, // IN + const char *guestVariableName, // IN + const char *value) // IN +{ + char *reply = NULL; + gchar *msg; + size_t replyLen; + + ASSERT(guestVariableName != NULL); + ASSERT(value != NULL); + + msg = g_strdup_printf("info-set guestinfo.%s %s", + guestVariableName, + value); + + if (!RpcChannel_Send(ctx->rpc, + msg, + strlen(msg) + 1, + &reply, + &replyLen)) { + g_warning("%s: Error sending RPC message: %s\n", __FUNCTION__, + VM_SAFE_STR(reply)); + } else { + g_info("%s: Successfully published the container information.\n", + __FUNCTION__); + } + + g_free(msg); + vm_free(reply); + return; +} + + +/* + ***************************************************************************** + * CheckContainerdRunning -- + * + * When containers are run, the containerd-shim process gets called. + * This function checks if containerd process exists in the list of processes, + * which will signal that the containerinfo loop should be started. + * + * @retval TRUE found containerd process. + * @retval FALSE not found. + * + ***************************************************************************** + */ + +static gboolean +CheckContainerdRunning(void) +{ + ProcMgrProcInfoArray *procList; + size_t procCount; + int i; + gboolean result = FALSE; + + procList = ProcMgr_ListProcesses(); + if (procList == NULL) { + g_warning("%s: Failed to get the list of processes.\n", + __FUNCTION__); + return result; + } + + procCount = ProcMgrProcInfoArray_Count(procList); + for (i = 0; i < procCount; i++) { + ProcMgrProcInfo *procInfo = ProcMgrProcInfoArray_AddressOf(procList, i); + if (procInfo->procCmdName != NULL && + strstr(procInfo->procCmdName, CONTAINERD_PROCESS_NAME)) { + result = TRUE; + break; + } + } + + ProcMgr_FreeProcList(procList); + return result; +} + + +/* + ****************************************************************************** + * ContainerInfo_DestroyContainerData -- + * + * Free function for container data. This function is called by the glib + * for each element in the container list while freeing. + * + * @param[in] data Pointer to the container data. + * + * @retval NONE + * + ****************************************************************************** + */ + +void +ContainerInfo_DestroyContainerData(void *pointer) +{ + ContainerInfo *info = pointer; + + if (info == NULL) { + return; + } + + g_free(info->id); + g_free(info->image); + g_free(info); +} + + +/* + ***************************************************************************** + * ContainerInfo_DestroyContainerList -- + * + * Frees the entire memory allocated for the container list. + * + * @param[in] containerList Pointer to the container list. + * + * @retval NONE + * + ***************************************************************************** + */ + +void +ContainerInfo_DestroyContainerList(GSList *containerList) +{ + if (containerList == NULL) { + return; + } + + g_slist_free_full(containerList, ContainerInfo_DestroyContainerData); +} + + +/* + ***************************************************************************** + * ContainerInfoGetNsJson -- + * + * Iterates through the list of containers and prepares the JSON string for + * a specified namespace. The caller must free the resulting JSON string. + * + * @param[in] ns The name of the namespace + * @param[in] containerList The list of the running containers + * @param[in] dockerSocketPath The path to the unix socket used by docker. + * @param[in] removeDuplicates Remove duplicate containers from the output. + * @param[in] maxSize Maximum size of the JSON output + * @param[out] resultJson JSON string that is prepared. + * + * @retVal The size of the JSON string returned. + * + ***************************************************************************** + */ + +size_t +ContainerInfoGetNsJson(const char *ns, // IN + GSList *containerList, // IN + const char *dockerSocketPath, // IN + gboolean removeDuplicates, // IN + unsigned int maxSize, // IN + char **resultJson) // OUT +{ + static const char headerFmt[] = "\"%s\": ["; + static const char footer[] = "]"; + + GSList *info; + gboolean nodeAdded; + DynBuf dynBuffer; + size_t resultSize = 0; + GHashTable *dockerContainerTable = NULL; + GHashTable *imagesAdded = NULL; + gchar *escapedImageName = NULL; + + ASSERT(resultJson != NULL); + + DynBuf_Init(&dynBuffer); + StrUtil_SafeDynBufPrintf(&dynBuffer, headerFmt, ns); + + nodeAdded = FALSE; + + /* + * The image name may not be set for containers managed by docker. + * To handle such cases, get the list of containers using Docker APIs. + */ + if (strcmp(ns, CONTAINERINFO_DOCKER_NAMESPACE_NAME) == 0) { + dockerContainerTable = + ContainerInfo_GetDockerContainers(dockerSocketPath); + } + + if (removeDuplicates) { + imagesAdded = g_hash_table_new_full(g_str_hash, g_str_equal, + g_free, NULL); + } + + for (info = containerList; info != NULL; info = info->next) { + static const char *nodeFmt = "%s{\"" + CONTAINERINFO_KEY_IMAGE + "\":\"%s\"}"; + size_t currentBufferSize = DynBuf_GetSize(&dynBuffer); + gchar *tmpNode; + size_t len; + ContainerInfo *node = (ContainerInfo *) info->data; + + g_free(escapedImageName); + escapedImageName = NULL; + + if (node->image == NULL || node->image[0] == '\0') { + const char *newImage = NULL; + + if (dockerContainerTable != NULL) { + newImage = g_hash_table_lookup(dockerContainerTable, node->id); + } + + if (newImage != NULL) { + escapedImageName = g_strdup(newImage); + } else { + g_warning("%s: Skipping '%s' since image name couldn't " + "be retrieved.\n", __FUNCTION__, node->id); + continue; + } + } else { + escapedImageName = CodeSet_JsonEscape(node->image); + if (NULL == escapedImageName) { + g_warning("%s: Failed to escape the image. Skipping '%s'\n", + __FUNCTION__, node->id); + continue; + } + } + + if (removeDuplicates) { + /* + * Check if the container was already added. If already added, just + * skip to the next container. + */ + if (g_hash_table_contains(imagesAdded, escapedImageName)) { + continue; + } + } + + tmpNode = Str_Asprintf(&len, nodeFmt, + nodeAdded ? "," : "", escapedImageName); + if (tmpNode == NULL) { + g_warning("%s: Out of memory. Skipping '%s'\n", + __FUNCTION__, node->id); + break; + } + + if (currentBufferSize + len + sizeof footer > maxSize) { + g_warning("%s: Skipping '%s' due to insufficient size.\n", + __FUNCTION__, node->id); + } else { + if (removeDuplicates) { + g_hash_table_add(imagesAdded, escapedImageName); + escapedImageName = NULL; + } + DynBuf_Append(&dynBuffer, tmpNode, len); + nodeAdded = TRUE; + } + g_free(tmpNode); + } + + if (nodeAdded) { + DynBuf_Append(&dynBuffer, footer, strlen(footer)); + resultSize = DynBuf_GetSize(&dynBuffer); + *resultJson = DynBuf_DetachString(&dynBuffer); + } else { + resultSize = 0; + *resultJson = NULL; + } + + g_free(escapedImageName); + + if (imagesAdded != NULL) { + g_hash_table_destroy(imagesAdded); + } + + if (dockerContainerTable != NULL) { + g_hash_table_destroy(dockerContainerTable); + } + + DynBuf_Destroy(&dynBuffer); + return resultSize; +} + + +/* + ***************************************************************************** + * ContainerInfoGatherTask -- + * + * Collects all the desired container related information. + * + * @param[in] ctx The application context. + * @param[in] data Unused + * + ***************************************************************************** + */ + +static void +ContainerInfoGatherTask(ToolsAppCtx *ctx, // IN + gpointer data) // IN +{ + gchar *timeStampString = NULL; + int limit; + gint64 startInfoGatherTime; + gint64 endInfoGatherTime; + gchar *containerdSocketPath = NULL; + gchar *nsConfValue = NULL; + gchar **nsList; + static Atomic_uint64 updateCounter = {1}; + uint64 counter; + int i; + DynBuf dynBuffer; + gchar tmpBuf[256]; + size_t len; + gboolean nsAdded; + char *dockerSocketPath = NULL; + GHashTable *nsParsed; + gboolean removeDuplicates; + + static char headerFmt[] = "{" + "\"" CONTAINERINFO_KEY_VERSION "\":\"%d\"," + "\"" CONTAINERINFO_KEY_UPDATE_COUNTER "\":%"FMT64"u," + "\"" CONTAINERINFO_KEY_PUBLISHTIME "\":\"%s\"," + "\"" CONTAINERINFO_KEY "\":{"; + static char footer[] = "}}"; + + if (Atomic_ReadIfEqualWriteBool(&gTaskSubmitted, FALSE, TRUE)) { + g_info("%s: Previously submitted task is not completed\n", __FUNCTION__); + return; + } + + timeStampString = VMTools_GetTimeAsString(); + counter = (uint64) Atomic_ReadInc64(&updateCounter); + + DynBuf_Init(&dynBuffer); + len = Str_Snprintf(tmpBuf, sizeof tmpBuf, + headerFmt, + CONTAINERINFO_VERSION_1, + counter, + (timeStampString != NULL) ? timeStampString : ""); + ASSERT(len > 0); + + DynBuf_Append(&dynBuffer, tmpBuf, len); + + if (!CheckContainerdRunning()) { + g_info("%s: Could not find running containerd process on the system.\n", + __FUNCTION__); + goto exit; + } + + limit = + VMTools_ConfigGetInteger(ctx->config, + CONFGROUPNAME_CONTAINERINFO, + CONFNAME_CONTAINERINFO_LIMIT, + CONTAINERINFO_DEFAULT_CONTAINER_MAX); + + if (limit < 1) { + g_warning("%s: invalid max-containers %d. Using default %d.\n", + __FUNCTION__, + limit, + CONTAINERINFO_DEFAULT_CONTAINER_MAX); + limit = CONTAINERINFO_DEFAULT_CONTAINER_MAX; + } + + nsConfValue = + VMTools_ConfigGetString(ctx->config, + CONFGROUPNAME_CONTAINERINFO, + CONFNAME_CONTAINERINFO_ALLOWED_NAMESPACES, + CONTAINERINFO_DEFAULT_ALLOWED_NAMESPACES); + g_strstrip(nsConfValue); + + if (nsConfValue[0] == '\0') { + g_warning("%s: Empty value found for %s.%s key. Ignoring.", + __FUNCTION__, CONFGROUPNAME_CONTAINERINFO, + CONFNAME_CONTAINERINFO_ALLOWED_NAMESPACES); + goto exit; + } + + containerdSocketPath = + VMTools_ConfigGetString(ctx->config, + CONFGROUPNAME_CONTAINERINFO, + CONFNAME_CONTAINERINFO_CONTAINERDSOCKET, + CONTAINERINFO_DEFAULT_CONTAINERDSOCKET); + g_strstrip(containerdSocketPath); + + dockerSocketPath = + VMTools_ConfigGetString(ctx->config, + CONFGROUPNAME_CONTAINERINFO, + CONFNAME_CONTAINERINFO_DOCKERSOCKET, + CONTAINERINFO_DEFAULT_DOCKER_SOCKET); + g_strstrip(dockerSocketPath); + + if (dockerSocketPath[0] == '\0') { + g_warning("%s: Empty value found for %s.%s key. Using default %s.", + __FUNCTION__, CONFGROUPNAME_CONTAINERINFO, + CONFNAME_CONTAINERINFO_DOCKERSOCKET, + CONTAINERINFO_DEFAULT_DOCKER_SOCKET); + g_free(dockerSocketPath); + dockerSocketPath = g_strdup(CONTAINERINFO_DEFAULT_DOCKER_SOCKET); + } + + removeDuplicates = + VMTools_ConfigGetBoolean(ctx->config, + CONFGROUPNAME_CONTAINERINFO, + CONFNAME_CONTAINERINFO_REMOVE_DUPLICATES, + CONTAINERINFO_DEFAULT_REMOVE_DUPLICATES); + + startInfoGatherTime = g_get_monotonic_time(); + + nsList = g_strsplit(nsConfValue, ",", 0); + nsAdded = FALSE; + nsParsed = g_hash_table_new(g_str_hash, g_str_equal); + + for (i = 0; nsList[i] != NULL; i++) { + size_t currentBufferSize = DynBuf_GetSize(&dynBuffer); + size_t maxSizeRemaining = CONTAINERINFO_MAX_GUESTINFO_PACKET_SIZE - + currentBufferSize - sizeof(footer); + + gchar *nsJsonString; + size_t nsJsonSize; + GSList *containerList; + + g_strstrip(nsList[i]); + if (nsList[i][0] == '\0') { + g_warning("%s: Empty value found for the namespace. Skipping.", + __FUNCTION__); + continue; + } + + if (g_hash_table_contains(nsParsed, nsList[i])) { + g_debug("%s: Skipping the duplicate namespace: %s", + __FUNCTION__, nsList[i]); + continue; + } + + if (nsAdded) { + maxSizeRemaining--; // Minus size of ',' + } + + if (maxSizeRemaining == 0 || + maxSizeRemaining > CONTAINERINFO_MAX_GUESTINFO_PACKET_SIZE) { + break; + } + + containerList = + ContainerInfo_GetContainerList(nsList[i], containerdSocketPath, + (unsigned int) limit); + g_hash_table_add(nsParsed, nsList[i]); + if (containerList == NULL) { + continue; + } + + nsJsonSize = ContainerInfoGetNsJson(nsList[i], containerList, + dockerSocketPath, removeDuplicates, maxSizeRemaining, + &nsJsonString); + if (nsJsonSize > 0 && nsJsonSize <= maxSizeRemaining) { + if (nsAdded) { + DynBuf_Append(&dynBuffer, ",", 1); + } + DynBuf_Append(&dynBuffer, nsJsonString, nsJsonSize); + nsAdded = TRUE; + } + g_free(nsJsonString); + ContainerInfo_DestroyContainerList(containerList); + } + + g_hash_table_destroy(nsParsed); + g_strfreev(nsList); + + endInfoGatherTime = g_get_monotonic_time(); + + g_info("%s: time to complete containerInfo gather = %" G_GINT64_FORMAT " us\n", + __FUNCTION__, endInfoGatherTime - startInfoGatherTime); + +exit: + if (Atomic_Read32(&gContainerInfoPollInterval) == 0) { + /* + * If gatherLoop is disabled then make sure this thread + * did not overwrite the guestVar. The guestVar should be + * cleared out in this case. + */ + SetGuestInfo(ctx, CONTAINERINFO_GUESTVAR_KEY, ""); + } else { + DynBuf_Append(&dynBuffer, footer, sizeof(footer)); + SetGuestInfo(ctx, + CONTAINERINFO_GUESTVAR_KEY, + DynBuf_GetString(&dynBuffer)); + } + + DynBuf_Destroy(&dynBuffer); + g_free(dockerSocketPath); + g_free(containerdSocketPath); + g_free(nsConfValue); + g_free(timeStampString); + Atomic_WriteBool(&gTaskSubmitted, FALSE); +} + + +/* + ***************************************************************************** + * ContainerInfoGather -- + * + * Creates a new thread that collects all the desired container related + * information and updates the VMX. Tweaks the poll gather loop as per the + * tools configuration after creating the thread. + * + * @param[in] data The application context. + * + * @retval G_SOURCE_REMOVE to indicate that the timer should be removed. + * + ***************************************************************************** + */ + +static gboolean +ContainerInfoGather(gpointer data) // IN +{ + ToolsAppCtx *ctx = data; + + g_debug("%s: Submitting a task to capture container information.\n", + __FUNCTION__); + + if (!ToolsCorePool_SubmitTask(ctx, ContainerInfoGatherTask, NULL, NULL)) { + g_warning("%s: Failed to submit the task for capturing container " + "information\n", __FUNCTION__); + } + + TweakGatherLoop(ctx, TRUE); + + return G_SOURCE_REMOVE; +} + + +/* + ***************************************************************************** + * TweakGatherLoopEx -- + * + * Start, stop, reconfigure a ContainerInfo Gather poll loop. + * + * This function is responsible for creating, manipulating, and resetting a + * ContainerInfo Gather loop timeout source. The poll loop will be disabled if + * the poll interval is 0. + * + * @param[in] ctx The application context. + * @param[in] pollInterval Poll interval in seconds. A value of 0 will + * disable the loop. + * + ***************************************************************************** + */ + +static void +TweakGatherLoopEx(ToolsAppCtx *ctx, // IN + guint pollInterval) // IN +{ + if (gContainerInfoTimeoutSource != NULL) { + /* + * Destroy the existing timeout source. + */ + g_source_destroy(gContainerInfoTimeoutSource); + gContainerInfoTimeoutSource = NULL; + } + + if (pollInterval > 0) { + if (Atomic_Read32(&gContainerInfoPollInterval) != pollInterval) { + g_info("%s: New value for %s is %us.\n", + __FUNCTION__, + CONFNAME_CONTAINERINFO_POLLINTERVAL, + pollInterval); + } + + gContainerInfoTimeoutSource = g_timeout_source_new(pollInterval * 1000); + VMTOOLSAPP_ATTACH_SOURCE(ctx, gContainerInfoTimeoutSource, + ContainerInfoGather, ctx, NULL); + g_source_unref(gContainerInfoTimeoutSource); + Atomic_Write32(&gContainerInfoPollInterval, pollInterval); + } else if (Atomic_Read32(&gContainerInfoPollInterval) > 0) { + g_info("%s: Poll loop for %s disabled.\n", + __FUNCTION__, CONFNAME_CONTAINERINFO_POLLINTERVAL); + Atomic_Write32(&gContainerInfoPollInterval, 0); + SetGuestInfo(ctx, CONTAINERINFO_GUESTVAR_KEY, ""); + } +} + + +/* + ***************************************************************************** + * TweakGatherLoop -- + * + * Configures the ContainerInfo Gather poll loop based on the settings in the + * tools configuration. + * + * This function is responsible for creating, manipulating, and resetting a + * ContainerInfo Gather loop timeout source. + * + * @param[in] ctx The application context. + * @param[in] force If set to TRUE, the poll loop will be + * tweaked even if the poll interval hasn't + * changed from the previous value. + * + ***************************************************************************** + */ + +static void +TweakGatherLoop(ToolsAppCtx *ctx, // IN + gboolean force) // IN +{ + gint pollInterval; + + if (gAppInfoEnabledInHost) { + pollInterval = + VMTools_ConfigGetInteger(ctx->config, + CONFGROUPNAME_CONTAINERINFO, + CONFNAME_CONTAINERINFO_POLLINTERVAL, + CONTAINERINFO_DEFAULT_POLL_INTERVAL); + + if (pollInterval < 0 || pollInterval > (G_MAXINT / 1000)) { + g_warning("%s: Invalid poll interval %d. Using default %us.\n", + __FUNCTION__, pollInterval, + CONTAINERINFO_DEFAULT_POLL_INTERVAL); + pollInterval = CONTAINERINFO_DEFAULT_POLL_INTERVAL; + } + } else { + pollInterval = 0; + } + + if (force || (Atomic_Read32(&gContainerInfoPollInterval) != pollInterval)) { + /* + * pollInterval can never be a negative value. Typecasting into + * guint should not be a problem. + */ + TweakGatherLoopEx(ctx, (guint) pollInterval); + } +} + + +/* + ***************************************************************************** + * ContainerInfoServerConfReload -- + * + * Reconfigures the poll loop interval upon config file reload. + * + * @param[in] src The source object. + * @param[in] ctx The application context. + * @param[in] data Unused. + * + ***************************************************************************** + */ + +static void +ContainerInfoServerConfReload(gpointer src, // IN + ToolsAppCtx *ctx, // IN + gpointer data) // IN +{ + g_info("%s: Reloading the tools configuration.\n", __FUNCTION__); + + TweakGatherLoop(ctx, FALSE); +} + + +/* + ***************************************************************************** + * ContainerInfoServerShutdown -- + * + * Cleanup internal data on shutdown. + * + * @param[in] src The source object. + * @param[in] ctx Application context. + * @param[in] data Unused. + * + ***************************************************************************** + */ + +static void +ContainerInfoServerShutdown(gpointer src, // IN + ToolsAppCtx *ctx, // IN + gpointer data) // IN +{ + if (gContainerInfoTimeoutSource != NULL) { + g_source_destroy(gContainerInfoTimeoutSource); + gContainerInfoTimeoutSource = NULL; + } + + SetGuestInfo(ctx, CONTAINERINFO_GUESTVAR_KEY, ""); +} + + +/* + *---------------------------------------------------------------------------- + * + * ContainerInfoServerSetOption -- + * + * Handle TOOLSOPTION_ENABLE_APPINFO Set_Option callback. This callback is + * necessary because containerInfo shares AppInfo's host side switch. + * + * @param[in] src The source object. + * @param[in] ctx The app context. + * @param[in] option Option being set. + * @param[in] value Option value. + * @param[in] plugin Plugin registration data. + * + * @retval TRUE if the specified option is TOOLSOPTION_ENABLE_APPINFO and + * the containerInfo Gather poll loop is reconfigured. + * @retval FALSE if the specified option is not TOOLSOPTION_ENABLE_APPINFO + * or containerInfo Gather poll loop is not reconfigured. + *---------------------------------------------------------------------------- + */ + +static gboolean +ContainerInfoServerSetOption(gpointer src, // IN + ToolsAppCtx *ctx, // IN + const gchar *option, // IN + const gchar *value, // IN + gpointer data) // IN +{ + gboolean stateChanged = FALSE; + + if (strcmp(option, TOOLSOPTION_ENABLE_APPINFO) == 0) { + g_debug("%s: Tools set option %s=%s.\n", + __FUNCTION__, TOOLSOPTION_ENABLE_APPINFO, value); + + if (strcmp(value, "1") == 0 && !gAppInfoEnabledInHost) { + gAppInfoEnabledInHost = TRUE; + stateChanged = TRUE; + } else if (strcmp(value, "0") == 0 && gAppInfoEnabledInHost) { + gAppInfoEnabledInHost = FALSE; + stateChanged = TRUE; + } + + if (stateChanged) { + g_info("%s: State of AppInfo is changed to '%s' at host side.\n", + __FUNCTION__, gAppInfoEnabledInHost ? "enabled" : "disabled"); + TweakGatherLoop(ctx, TRUE); + } + } + + return stateChanged; +} + + +/* + ***************************************************************************** + * ContainerInfoServerReset -- + * + * Callback function that gets called whenever the RPC channel gets reset. + * Disable the current timer and set a timer for random interval; after that + * interval, the timer will be resumed at the standard interval. + * The one time random interval is intended to avoid the possibility that the + * containerinfo plugin might run at the same time in a collection of + * VMs - such as might be created by instant clone - which could in turn cause + * a load spike on the host. + * + * @param[in] src The source object. + * @param[in] ctx Application context. + * @param[in] data Unused. + * + ***************************************************************************** + */ + +static void +ContainerInfoServerReset(gpointer src, // IN + ToolsAppCtx *ctx, // IN + gpointer data) // IN +{ + /* + * Handle reset for containerinfo loop. + */ + if (gContainerInfoTimeoutSource != NULL) { + guint interval; + + ASSERT(Atomic_Read32(&gContainerInfoPollInterval) != 0); + +#define MIN_CONTAINERINFO_INTERVAL 30 + + if (Atomic_Read32(&gContainerInfoPollInterval) > + MIN_CONTAINERINFO_INTERVAL) { + GRand *gRand = g_rand_new(); + + interval = g_rand_int_range(gRand, + MIN_CONTAINERINFO_INTERVAL, + Atomic_Read32(&gContainerInfoPollInterval)); + g_rand_free(gRand); + } else { + interval = Atomic_Read32(&gContainerInfoPollInterval); + } + +#undef MIN_CONTAINERINFO_INTERVAL + + g_info("%s: Using poll interval for containerinfo loop: %u.\n", + __FUNCTION__, interval); + + TweakGatherLoopEx(ctx, interval); + } else { + /* + * Channel got reset. VM might have vMotioned to an older host + * that doesn't send the 'Set_Option enableAppInfo'. + * Set gAppInfoEnabledInHost to TRUE and tweak the gather loop. + * Else, the application information may never be captured. + */ + if (!gAppInfoEnabledInHost) { + gAppInfoEnabledInHost = TRUE; + TweakGatherLoop(ctx, TRUE); + } else { + g_debug("%s: Poll loop disabled. Ignoring.\n", __FUNCTION__); + } + } +} + + +/* + ***************************************************************************** + * ToolsOnLoad -- + * + * Plugin entry point. Initializes internal plugin state. + * + * @param[in] ctx The app context. + * + * @retval The registration data. + * + ***************************************************************************** + */ + +TOOLS_MODULE_EXPORT ToolsPluginData * +ToolsOnLoad(ToolsAppCtx *ctx) // IN +{ + static ToolsPluginData regData = { + "containerInfo", + NULL, + NULL + }; + + /* + * Return NULL to disable the plugin if not running in a VMware VM. + */ + if (!ctx->isVMware) { + g_info("%s: Not running in a VMware VM.\n", __FUNCTION__); + return NULL; + } + + /* + * Return NULL to disable the plugin if not running in vmsvc daemon. + */ + if (!TOOLS_IS_MAIN_SERVICE(ctx)) { + g_info("%s: Not running in vmsvc daemon: container name='%s'.\n", + __FUNCTION__, ctx->name); + return NULL; + } + + /* + * This plugin is useless without an RpcChannel. If we don't have one, + * just bail. + */ + if (ctx->rpc != NULL) { + ToolsPluginSignalCb sigs[] = { + { TOOLS_CORE_SIG_CONF_RELOAD, ContainerInfoServerConfReload, NULL }, + { TOOLS_CORE_SIG_SHUTDOWN, ContainerInfoServerShutdown, NULL }, + { TOOLS_CORE_SIG_RESET, ContainerInfoServerReset, NULL }, + { TOOLS_CORE_SIG_SET_OPTION, ContainerInfoServerSetOption, NULL } + }; + ToolsAppReg regs[] = { + { TOOLS_APP_SIGNALS, + VMTools_WrapArray(sigs, sizeof *sigs, ARRAYSIZE(sigs)) + } + }; + + regData.regs = VMTools_WrapArray(regs, + sizeof *regs, + ARRAYSIZE(regs)); + + /* + * Set up the containerInfo gather loop. + */ + TweakGatherLoop(ctx, TRUE); + + return ®Data; + } + + return NULL; +} diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/containerInfo/containerInfo_docker.c open-vm-tools-12.1.5/open-vm-tools/services/plugins/containerInfo/containerInfo_docker.c --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/containerInfo/containerInfo_docker.c 1970-01-01 00:00:00.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/containerInfo/containerInfo_docker.c 2022-11-29 21:17:22.000000000 +0000 @@ -0,0 +1,503 @@ +/********************************************************* + * Copyright (C) 2021 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 + * by the Free Software Foundation version 2.1 and no later version. + * + * 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 Lesser GNU General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + *********************************************************/ + +/* + * containerInfo_docker.c -- + * + * This file defines docker specific functions which are needed by + * containerInfo. Docker API is called using libcurl to find runnning + * docker containers and collect relevant info. + */ + +#include +#include +#include "containerInfoInt.h" +#include "jsmn.h" +#include +#include "vm_assert.h" + +#define HTTP_HEADER "HTTP" +#define HTTP_HEADER_LENGTH (sizeof HTTP_HEADER - 1) +#define HTTP_STATUS_SUCCESS "200" +#define HTTP_STATUS_SUCCESS_LENGTH (sizeof HTTP_STATUS_SUCCESS - 1) +#define TOKENS_PER_ALLOC 500 +#define MAX_TOKENS 100000 + +/* + * docker API versions are backwards compatible with older docker Engine + * versions so this is the oldest API version that is documented by docker + * at https://docs.docker.com/engine/api/ + */ +#define DOCKER_API_VERSION "v1.18" + +typedef struct DockerBuffer { + char *response; + size_t size; +} DockerBuffer; + + +/* + ****************************************************************************** + * ContainerInfoJsonEq -- + * + * @brief Utility function to check whether a string jsmn token has value + * equal to @param s + * + * @param[in] json The json string + * @param[in] tok The jsmn token structure pointer + * @param[in] s The string to match in the token + * + * @retval TRUE successfully matched the string in the json token + * @retval FALSE did not match the string in the json token + * + ****************************************************************************** + */ + +static gboolean +ContainerInfoJsonEq(const char *json, + jsmntok_t *tok, + const char *s) +{ + if (tok->type == JSMN_STRING && + (int) strlen(s) == tok->end - tok->start && + tok->start >= 0 && tok->end < strlen(json) && + strncmp(json + tok->start, s, tok->end - tok->start) == 0) { + return TRUE; + } + return FALSE; +} + + +/* + ****************************************************************************** + * ContainerInfoJsonEqIsKey -- + * + * @brief Utility function that is same as ContainerInfoJsonEq() but also + * checks token is of the key type in the json. + * + * @param[in] json The json string + * @param[in] tok The jsmn token structure pointer + * @param[in] s The string to match in the token + * + * @retval TRUE successfully matched the string and token is a key + * @retval FALSE did not match the string or token is not a key + * + ****************************************************************************** + */ + +static gboolean +ContainerInfoJsonEqIsKey(const char *json, + jsmntok_t *tok, + const char *s) +{ + /* + * Check tok->size. If tok is a key, tok->size will be 1. + */ + return tok->size == 1 && ContainerInfoJsonEq(json, tok, s);; +} + + +/* + ****************************************************************************** + * DockerWriteCB -- + * + * @brief Sets callback for writing received data when using libcurl to access + * docker API. This function prototype is based on + * https://curl.se/libcurl/c/CURLOPT_WRITEFUNCTION.html + * + * @param[in] data info received from API + * @param[in] size this value is always 1 (according to curl docs) + * @param[in] nitems size of data + * @param[in] userdata pointer to DockerBuffer + * + * @retval number of bytes successfully written + * + ****************************************************************************** + */ + +static size_t +DockerWriteCB(void *data, // IN + size_t size, // IN + size_t nitems, // IN + void *userdata) // IN +{ + size_t realsize = size * nitems; + DockerBuffer *mem = (DockerBuffer *) userdata; + char *realptr; + size_t newsize = mem->size + realsize + 1; + + if (newsize < mem->size) { + g_warning("%s:%d: size overflow\n", __FUNCTION__, __LINE__); + g_free(mem->response); + mem->response = NULL; + return 0; + } + + realptr = g_try_realloc(mem->response, newsize); + if (realptr == NULL) { + g_warning("%s:%d: out of memory\n", __FUNCTION__, __LINE__); + g_free(mem->response); + mem->response = NULL; + return 0; + } + + mem->response = realptr; + memcpy(&mem->response[mem->size], data, realsize); + mem->size += realsize; + mem->response[mem->size] = '\0'; + + return realsize; +} + + +/* + ****************************************************************************** + * DockerHeaderCB -- + * + * @brief Sets callback for receiving header data and saving HTTP status + * when using libcurl to access docker API. For more info see + * https://curl.se/libcurl/c/CURLOPT_HEADERFUNCTION.html + * + * @param[in] buffer info received from API + * @param[in] size this value is always 1 (according to curl docs) + * @param[in] nitems size of buffer + * @param[in] userdata pointer to string to store docker status code + * + * @retval number of bytes of header data successfully received + * + ****************************************************************************** + */ + +static size_t +DockerHeaderCB(char *buffer, // IN + size_t size, // IN + size_t nitems, // IN + void *userdata) // IN +{ + size_t realSize = size * nitems; + char **statusCode = (char **) userdata; + char *statusStart; + char *statusEnd; + char *bufPtr; + char *bufEnd; + + /* + * Example of buffer: HTTP/1.1 404 Not Found\r\n + * Do not assume that buffer is null-terminated! + */ + if (realSize <= HTTP_HEADER_LENGTH || + memcmp(buffer, HTTP_HEADER, HTTP_HEADER_LENGTH) != 0) { + /* + * This is a separated header line, like: Api-Version: 1.41 + */ + return realSize; + } + + bufEnd = buffer + realSize; + bufPtr = buffer + HTTP_HEADER_LENGTH; + statusStart = memchr(bufPtr, ' ', bufEnd - bufPtr); + + if (statusStart == NULL) { + g_debug("%s:%d: HTTP header has unexpected format: %.*s\n", + __FUNCTION__, __LINE__, (int) realSize, buffer); + return 0; + } + + bufPtr = ++statusStart; + statusEnd = memchr(bufPtr, ' ', bufEnd - bufPtr); + + if (statusEnd == NULL) { + g_debug("%s:%d: HTTP header has unexpected format: %.*s\n", + __FUNCTION__, __LINE__, (int) realSize, buffer); + return 0; + } + + *statusCode = g_strndup(statusStart, statusEnd - statusStart); + return realSize; +} + + +/* + ****************************************************************************** + * DockerCallAPI -- + * + * @brief Uses libcurl to access docker API and loads response to jsonString. + * + * @param[in] url url of docker API endpoint. + * e.g. http://v1.18/containers/json + * @param[in] unixSocket unix socket to communicate with docker. + * @param[in/out] jsonString stores the response from docker API. + * + * @retval TRUE successfully wrote valid response to jsonString + * @retval FALSE on failure + * + ****************************************************************************** + */ + +static gboolean +DockerCallAPI(const char *url, // IN + const char *unixSocket, // IN + char **jsonString) // OUT +{ + DockerBuffer result = {0}; + char *dockerStatus = NULL; + CURLcode ret; + char errBuf[CURL_ERROR_SIZE] = {'\0'}; + gboolean retVal = FALSE; + CURL *curl = curl_easy_init(); + + if (curl == NULL) { + g_warning("%s:%d: curl failed to initialize\n", + __FUNCTION__, __LINE__); + return retVal; + } + + curl_easy_setopt(curl, CURLOPT_UNIX_SOCKET_PATH, unixSocket); + curl_easy_setopt(curl, CURLOPT_URL, url); + curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errBuf); + curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, DockerHeaderCB); + curl_easy_setopt(curl, CURLOPT_HEADERDATA, &dockerStatus); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, (void *) DockerWriteCB); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *) &result); + + ret = curl_easy_perform(curl); + + if (ret == CURLE_OK && result.size > 0) { + /* + * might receive CURLE_OK from libcurl but dockerStatus does not + * equal 200. e.g. when page is not found by docker engine. + */ + if (dockerStatus != NULL && + strncmp(dockerStatus, HTTP_STATUS_SUCCESS, + HTTP_STATUS_SUCCESS_LENGTH) == 0) { + *jsonString = result.response; + retVal = TRUE; + } else { + g_warning("%s:%d: error response from docker engine. response: %s", + __FUNCTION__, __LINE__, result.response != NULL ? + result.response : "No response from docker engine."); + g_free(result.response); + } + } else { + if (errBuf[0] != '\0') { + g_warning("%s:%d: %s\n", __FUNCTION__, __LINE__, errBuf); + } else { + g_warning("%s:%d: docker request unsuccessful. strerror: %s\n", + __FUNCTION__, __LINE__, curl_easy_strerror(ret)); + } + g_free(result.response); + } + + g_free(dockerStatus); + curl_easy_cleanup(curl); + return retVal; +} + + +/* + ****************************************************************************** + * ContainerInfoParseString -- + * + * @brief parses and stores input string as tokens. + * + * @param[in] jsonString The string to parse. + * @param[in/out] tokens Stores tokenized version of jsonString. + * + * @retval number of tokens parsed from jsonString or -1 on failure. + ****************************************************************************** + */ + +static int +ContainerInfoParseString(char *jsonString, // IN + jsmntok_t **tokens) // IN/OUT +{ + gsize jsonLength; + jsmn_parser parser; + int numTokens; + int ret; + + ASSERT(jsonString); + jsmn_init(&parser); + jsonLength = strlen(jsonString); + numTokens = TOKENS_PER_ALLOC; + *tokens = (jsmntok_t *) g_malloc0(numTokens * sizeof(jsmntok_t)); + + while ((ret = jsmn_parse(&parser, jsonString, jsonLength, + *tokens, numTokens)) == JSMN_ERROR_NOMEM) { + numTokens += TOKENS_PER_ALLOC; + if (numTokens > MAX_TOKENS) { + g_warning("%s:%d: number of jsmn tokens: %d exceeded max :%d", + __FUNCTION__, __LINE__, + numTokens, MAX_TOKENS); + g_free(*tokens); + *tokens = NULL; + return -1; + } + *tokens = g_realloc(*tokens, numTokens * sizeof(jsmntok_t)); + } + + if (ret < 0) { + g_warning("%s:%d: jsmn error: %d parsing failed at character %d\n", + __FUNCTION__, __LINE__, ret, parser.pos); + g_free(*tokens); + *tokens = NULL; + } + + return ret; +} + + +/* + ***************************************************************************** + * ContainerInfo_GetDockerContainers -- + * + * @brief Entry point for gathering running docker container info + * + * + * @retval TRUE successfully collected docker container info + * @retval FALSE on failure + * + ***************************************************************************** + */ + +GHashTable * +ContainerInfo_GetDockerContainers(const char *dockerSocketPath) // IN +{ + jsmntok_t *t = NULL; + int i; + int numTokens; + char *dockerContainerString = NULL; + char *endpt = g_strdup_printf("http://%s/containers/json?" + "filters={\"status\":[\"running\"]}", + DOCKER_API_VERSION); + GHashTable *containerTable = NULL; + + if (!DockerCallAPI(endpt, + dockerSocketPath, + &dockerContainerString)) { + g_warning("%s: Failed to get the list of containers.", __FUNCTION__); + goto exit; + } + + numTokens = ContainerInfoParseString(dockerContainerString, &t); + + if (numTokens <= 0 || t[0].type != JSMN_ARRAY) { + g_warning("%s: invalid json response\n", + __FUNCTION__); + goto exit; + } + + containerTable = g_hash_table_new_full(g_str_hash, g_str_equal, + g_free, g_free); + + /* Example of "GET containers/json" response. + * Each item in the array is a running container. + * [{"Id":"370a480816ec5207c620fe628bd162925b85d150b3303601f76c3fe47ed863de", + * "Names":["/fervent_goldwasser"], + * "Image":"redis", + * "ImageID":"sha256:de974760ddb2f32dbddb74b7bb8cff4c1eee06d43d36d11bbc", + * "Command":"docker-entrypoint.sh redis-server", + * "Created":1623742538, + * "Ports":[{"PrivatePort":6379,"Type":"tcp"}], + * "Labels":{}, + * "State":"running", + * "Status":"Up 29 minutes", + * "HostConfig":{"NetworkMode":"default"}, + * "NetworkSettings":{...}, + * "Mounts":[...]}, + * {"Id":"b3ba5ed8b84816c66a6b6fe5903565164ea953ecdddf190263d52ed6ad0f6088", + * "Names":["/bold_solomon"], + * "Image":"nginx", + * "ImageID":"sha256:62d49f9bab67f7c70ac3395855bf01389eb3175b374e621f6f19", + * "Command":"/docker-entrypoint.sh nginx -g 'daemon off;'", + * "Created":1623742533, + * "Ports":[{"PrivatePort":80,"Type":"tcp"}], + * "Labels":{"maintainer":"NGINX Docker Maintainers"}, + * "State":"running", + * "Status":"Up 29 minutes", + * "HostConfig":{"NetworkMode":"default"}, + * "NetworkSettings":{...}, + * "Mounts":[]}] + */ + i = 1; + while (i < numTokens) { + if (t[i].type == JSMN_OBJECT) { + char *id = NULL; + char *image = NULL; + int end = t[i].end; + + i++; + while (i < numTokens - 1 && t[i + 1].start < end) { + if (t[i].type == JSMN_STRING && + t[i + 1].type == JSMN_STRING) { + if (ContainerInfoJsonEqIsKey(dockerContainerString, + &t[i], "Id")) { + if (id != NULL) { + g_warning("%s:%d: found duplicate key for \"Id\". Json" + "has improper format\n", __FUNCTION__, __LINE__); + break; + } + + id = g_strdup_printf("%.*s", + t[i + 1].end - t[i + 1].start, + dockerContainerString + t[i + 1].start); + } else if (ContainerInfoJsonEqIsKey(dockerContainerString, + &t[i], "Image")) { + if (image != NULL) { + g_warning("%s:%d: found duplicate key for \"Image\". Json" + "has improper format\n", __FUNCTION__, __LINE__); + break; + } + + image = + g_strdup_printf("%.*s", + t[i + 1].end - t[i + 1].start, + dockerContainerString + t[i + 1].start); + } + } + + if (image != NULL && id != NULL) { + g_debug("%s: Found docker container id: %s and image: %s", + __FUNCTION__, id, image); + g_hash_table_insert(containerTable, id, image); + id = NULL; + image = NULL; + break; + } + i++; + } + + /* + * Check id and image in the case of (image && !id) and (!image && id) + */ + if (id != NULL) { + g_free(id); + } + if (image != NULL) { + g_free(image); + } + } + i++; + } + +exit: + g_free(t); + g_free(endpt); + g_free(dockerContainerString); + return containerTable; +} diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/containerInfo/containerInfo_grpc.cc open-vm-tools-12.1.5/open-vm-tools/services/plugins/containerInfo/containerInfo_grpc.cc --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/containerInfo/containerInfo_grpc.cc 1970-01-01 00:00:00.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/containerInfo/containerInfo_grpc.cc 2022-11-29 21:17:22.000000000 +0000 @@ -0,0 +1,156 @@ +/********************************************************* + * Copyright (C) 2021-2022 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 + * by the Free Software Foundation version 2.1 and no later version. + * + * 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 Lesser GNU General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + *********************************************************/ + +/* + * containerInfo_grpc.cc -- + * + * This file defines specific functions which are needed to query + * the containerd daemon and retrieve the list of running + * containers. A gRPC connection is created using the containerd unix + * socket and the specified namespace is queried for any running containers. + */ + +#include "containerInfoInt.h" +#include "containers.grpc.pb.h" +#include "tasks.grpc.pb.h" +#include +#include + +using namespace containerd::services::containers::v1; +using namespace containerd::services::tasks::v1; +using namespace containerd::v1::types; +using namespace google::protobuf; + + +/* + ****************************************************************************** + * ContainerInfo_GetContainerList -- + * + * @brief A gRPC connection is created with the containerd unix + * socket and specified namespace is inspected for + * running containers. + * + * @param[in] ns Namespace to be queried. + * @param[in] containerdSocketPath Path of the socket. + * @param[in] maxContainers Maximum number of containers to be + * returned in the list. + * + * @retval the list of running containers. + * NULL if any error occurs or no containers are running. + * + ****************************************************************************** + */ + +GSList * +ContainerInfo_GetContainerList(const char *ns, // IN + const char *containerdSocketPath, // IN + unsigned int maxContainers) // IN +{ + GSList *containerList = NULL; + std::shared_ptr channel; + std::unique_ptr containerStub; + std::unique_ptr taskStub; + grpc::Status status; + int i; + unsigned int containersAdded; + const ListContainersRequest req; + std::unique_ptr res; + grpc::ClientContext containerContext; + static const std::string namespaceKey = "containerd-namespace"; + gchar *unixSocket = NULL; + + if (ns == NULL || containerdSocketPath == NULL) { + g_warning("%s: Invalid arguments specified.\n", __FUNCTION__); + goto exit; + } + + unixSocket = g_strdup_printf("unix://%s", containerdSocketPath); + + containerContext.AddMetadata(namespaceKey, ns); + + channel = + grpc::CreateChannel(unixSocket, grpc::InsecureChannelCredentials()); + + if (channel == nullptr) { + g_warning("%s: Failed to create gRPC channel\n", __FUNCTION__); + goto exit; + } + + containerStub = Containers::NewStub(channel); + if (containerStub == nullptr) { + g_warning("%s: Failed to create containerStub\n", __FUNCTION__); + goto exit; + } + + taskStub = Tasks::NewStub(channel); + if (taskStub == nullptr) { + g_warning("%s: Failed to create taskStub\n", __FUNCTION__); + goto exit; + } + + res = std::make_unique(); + status = containerStub->List(&containerContext, req, res.get()); + + if (!status.ok()) { + g_warning("%s: Failed to list containers. Error: %s\n", __FUNCTION__, + status.error_message().c_str()); + goto exit; + } + + g_debug("%s: Namespace: '%s', number of containers found: %d", __FUNCTION__, + ns, res->containers_size()); + + for (i = 0, containersAdded = 0; + i < res->containers_size() && containersAdded < maxContainers; i++) { + Container curContainer = res->containers(i); + std::string id = curContainer.id(); + std::string image = curContainer.image(); + ContainerInfo *info; + GetRequest taskReq; + std::unique_ptr taskRes; + grpc::Status taskStatus; + grpc::ClientContext taskContext; + + taskContext.AddMetadata(namespaceKey, ns); + + /* + * Get pid for container using taskStub. + */ + taskRes = std::make_unique(); + taskReq.set_container_id(id); + taskStatus = taskStub->Get(&taskContext, taskReq, taskRes.get()); + if (!taskStatus.ok()) { + g_debug("%s: Task get service failed: %s. skipping container: %s\n", + __FUNCTION__, taskStatus.error_message().c_str(), id.c_str()); + continue; + } + + info = (ContainerInfo *)g_malloc(sizeof(*info)); + info->id = g_strdup(id.c_str()); + info->image = g_strdup(image.c_str()); + + g_debug("%s: Found container id: %s and image: %s\n", __FUNCTION__, + info->id, info->image); + containerList = g_slist_prepend(containerList, info); + containersAdded++; + } + +exit: + g_free(unixSocket); + return containerList; +} diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/containerInfo/containerInfoInt.h open-vm-tools-12.1.5/open-vm-tools/services/plugins/containerInfo/containerInfoInt.h --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/containerInfo/containerInfoInt.h 1970-01-01 00:00:00.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/containerInfo/containerInfoInt.h 2022-11-29 21:17:22.000000000 +0000 @@ -0,0 +1,56 @@ +/********************************************************* + * Copyright (C) 2021 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 + * by the Free Software Foundation version 2.1 and no later version. + * + * 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 Lesser GNU General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + *********************************************************/ + +#ifndef _CONTAINERINFOINT_H_ +#define _CONTAINERINFOINT_H_ + +#include "conf.h" + +#define G_LOG_DOMAIN CONFGROUPNAME_CONTAINERINFO + +#include + +/** + * @file containerInfoInt.h + * + * Header file with few functions that are internal to containerInfo plugin. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct ContainerInfo { + char *id; + char *image; +} ContainerInfo; + +void ContainerInfo_DestroyContainerData(void *pointer); +void ContainerInfo_DestroyContainerList(GSList *containerList); + +GHashTable *ContainerInfo_GetDockerContainers(const char *dockerSocketPath); + +GSList *ContainerInfo_GetContainerList(const char *ns, + const char *containerdSocketPath, + unsigned int maxContainers); + +#ifdef __cplusplus +} +#endif + +#endif /* _CONTAINERINFOINT_H_ */ diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/containerInfo/COPYING open-vm-tools-12.1.5/open-vm-tools/services/plugins/containerInfo/COPYING --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/containerInfo/COPYING 1970-01-01 00:00:00.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/containerInfo/COPYING 2022-11-29 21:17:22.000000000 +0000 @@ -0,0 +1,502 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/containerInfo/Makefile.am open-vm-tools-12.1.5/open-vm-tools/services/plugins/containerInfo/Makefile.am --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/containerInfo/Makefile.am 1970-01-01 00:00:00.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/containerInfo/Makefile.am 2022-11-29 21:17:22.000000000 +0000 @@ -0,0 +1,98 @@ +################################################################################ +### Copyright (c) 2021-2022 VMware, Inc. All rights reserved. +### +### This program is free software; you can redistribute it and/or modify +### it under the terms of version 2 of the GNU General Public License as +### published by the Free Software Foundation. +### +### 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, write to the Free Software +### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +################################################################################ + +SUBDIRS = + +plugindir = @VMSVC_PLUGIN_INSTALLDIR@ +plugin_LTLIBRARIES = libcontainerInfo.la + +libcontainerInfo_la_CPPFLAGS = +libcontainerInfo_la_CPPFLAGS += @PLUGIN_CPPFLAGS@ + +libcontainerInfo_la_LDFLAGS = +libcontainerInfo_la_LDFLAGS += @PLUGIN_LDFLAGS@ + +libcontainerInfo_la_LIBADD = +libcontainerInfo_la_LIBADD += @VMTOOLS_LIBS@ +libcontainerInfo_la_LIBADD += @GOBJECT_LIBS@ + +libcontainerInfo_la_SOURCES = +libcontainerInfo_la_SOURCES += containerInfo.h +libcontainerInfo_la_SOURCES += containerInfoInt.h +libcontainerInfo_la_SOURCES += containerInfo.c + +libcontainerInfo_la_SOURCES += containerInfo_docker.c +libcontainerInfo_la_LDFLAGS += -lcurl +libcontainerInfo_la_CPPFLAGS += @CURL_CPPFLAGS@ +libcontainerInfo_la_LIBADD += ../../../lib/jsmn/libJsmn.la + +libcontainerInfo_la_SOURCES += gogoproto/gogo.pb.h +libcontainerInfo_la_SOURCES += gogoproto/gogo.pb.cc +libcontainerInfo_la_SOURCES += $(TYPES_DIR)/mount.pb.h +libcontainerInfo_la_SOURCES += $(TYPES_DIR)/mount.pb.cc +libcontainerInfo_la_SOURCES += $(TYPES_DIR)/metrics.pb.h +libcontainerInfo_la_SOURCES += $(TYPES_DIR)/metrics.pb.cc +libcontainerInfo_la_SOURCES += $(TYPES_DIR)/descriptor.pb.h +libcontainerInfo_la_SOURCES += $(TYPES_DIR)/descriptor.pb.cc +libcontainerInfo_la_SOURCES += $(TYPES_DIR)/task/task.pb.h +libcontainerInfo_la_SOURCES += $(TYPES_DIR)/task/task.pb.cc +libcontainerInfo_la_SOURCES += tasks.pb.h +libcontainerInfo_la_SOURCES += tasks.pb.cc +libcontainerInfo_la_SOURCES += containers.pb.h +libcontainerInfo_la_SOURCES += containers.pb.cc +libcontainerInfo_la_SOURCES += tasks.grpc.pb.h +libcontainerInfo_la_SOURCES += tasks.grpc.pb.cc +libcontainerInfo_la_SOURCES += containers.grpc.pb.h +libcontainerInfo_la_SOURCES += containers.grpc.pb.cc +libcontainerInfo_la_SOURCES += containerInfo_grpc.cc + +libcontainerInfo_la_CPPFLAGS += @GRPC_CPPFLAGS@ +libcontainerInfo_la_LDFLAGS += -lprotobuf +libcontainerInfo_la_LDFLAGS += -lgrpc++ + +tasks.grpc.pb.cc containers.grpc.pb.cc: %.grpc.pb.cc : %.proto %.pb.cc + $(PROTOC) -I. -I$(GOGO_PROTOPATH) \ + --grpc_out=. --plugin=protoc-gen-grpc=`which $(GRPC_CPP)` $< + +containerInfo_grpc.cc : containers.grpc.pb.cc tasks.grpc.pb.cc + +$(TYPES_DIR)/mount.proto \ +$(TYPES_DIR)/metrics.proto \ +$(TYPES_DIR)/descriptor.proto \ +$(TYPES_DIR)/task/task.proto: %.proto : $(DEP_PROTOPATH)/%.proto + $(MKDIR_P) $(@D) + sed 's/import weak /import /' $< > $@ + +$(TYPES_DIR)/mount.pb.cc \ +$(TYPES_DIR)/metrics.pb.cc \ +$(TYPES_DIR)/descriptor.pb.cc \ +$(TYPES_DIR)/task/task.pb.cc: %.pb.cc : %.proto + $(PROTOC) --cpp_out=. -I$(GOGO_PROTOPATH) -I. $< + +tasks.proto: $(TASKS_PROTOPATH)/tasks.proto + sed 's/import weak /import /' $< > $@ + +containers.proto: $(CONTAINERD_PROTOPATH)/containers.proto + sed 's/import weak /import /' $< > $@ + +tasks.pb.cc containers.pb.cc: %.pb.cc : %.proto + $(PROTOC) --cpp_out=. -I. -I$(GOGO_PROTOPATH) $< + +gogoproto/gogo.pb.cc: $(GOGO_PROTOPATH)/gogoproto/gogo.proto + $(MKDIR_P) $(@D) + $(PROTOC) --cpp_out=. -I$(GOGO_PROTOPATH) $< + diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/deployPkg/deployPkg.c open-vm-tools-12.1.5/open-vm-tools/services/plugins/deployPkg/deployPkg.c --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/deployPkg/deployPkg.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/deployPkg/deployPkg.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2006-2021 VMware, Inc. All rights reserved. + * Copyright (C) 2006-2022 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 @@ -38,6 +38,10 @@ #include "unicodeBase.h" #include "conf.h" +#include "vm_tools_version.h" +#include "buildNumber.h" +#include "vm_product.h" + #ifdef __cplusplus extern "C" { #endif @@ -55,6 +59,9 @@ // Using 3600s as the upper limit of timeout value in tools.conf. #define MAX_TIMEOUT_FROM_TOOLCONF 3600 +// Using 1800s as the upper limit of waiting for cloud-init execution done +// timeout value in tools.conf. +#define MAX_TIMEOUT_WAIT_FOR_CLOUDINIT_DONE 1800 static char *DeployPkgGetTempDir(void); @@ -86,6 +93,7 @@ ToolsDeployPkgError ret = TOOLSDEPLOYPKG_ERROR_SUCCESS; #ifndef _WIN32 int processTimeout; + int waitForCloudinitDoneTimeout; #endif /* @@ -123,6 +131,8 @@ } DeployPkg_SetLogger(DeployPkgLog_Log); + DeployPkgLog_Log(log_info, "%s Version: %s (%s)", VMWARE_TOOLS_SHORT_NAME, + TOOLS_VERSION_EXT_CURRENT_STR, BUILD_NUMBER); DeployPkgLog_Log(log_debug, "Deploying %s", pkgFile); #ifdef _WIN32 @@ -150,10 +160,10 @@ * Using 0 as the default value of CONFNAME_DEPLOYPKG_PROCESSTIMEOUT in tools.conf */ processTimeout = - VMTools_ConfigGetInteger(ctx->config, - CONFGROUPNAME_DEPLOYPKG, - CONFNAME_DEPLOYPKG_PROCESSTIMEOUT, - 0); + VMTools_ConfigGetInteger(ctx->config, + CONFGROUPNAME_DEPLOYPKG, + CONFNAME_DEPLOYPKG_PROCESSTIMEOUT, + 0); if (processTimeout > 0 && processTimeout <= MAX_TIMEOUT_FROM_TOOLCONF) { DeployPkgLog_Log(log_debug, "[%s] %s in tools.conf: %d", CONFGROUPNAME_DEPLOYPKG, @@ -168,6 +178,41 @@ DeployPkgLog_Log(log_debug, "The valid timeout value range: 1 ~ %d", MAX_TIMEOUT_FROM_TOOLCONF); } + + /* + * Get timeout of waiting for cloud-init execution done from tools.conf. + * Only when a valid 'timeout' got from tools.conf, deployPkg will call + * DeployPkg_SetWaitForCloudinitDoneTimeout to overwrite the default timeout + * of waiting for cloud-init execution done. + * The valid value range is from 0 to MAX_TIMEOUT_WAIT_FOR_CLOUDINIT_DONE. + * Return an invalid value -1 if CONFNAME_DEPLOYPKG_WAIT_CLOUDINIT_TIMEOUT is + * not set in tools.conf. + */ + waitForCloudinitDoneTimeout = + VMTools_ConfigGetInteger(ctx->config, + CONFGROUPNAME_DEPLOYPKG, + CONFNAME_DEPLOYPKG_WAIT_CLOUDINIT_TIMEOUT, + -1); + if (waitForCloudinitDoneTimeout >= 0 && + waitForCloudinitDoneTimeout <= MAX_TIMEOUT_WAIT_FOR_CLOUDINIT_DONE) { + DeployPkgLog_Log(log_debug, "[%s] %s in tools.conf: %d", + CONFGROUPNAME_DEPLOYPKG, + CONFNAME_DEPLOYPKG_WAIT_CLOUDINIT_TIMEOUT, + waitForCloudinitDoneTimeout); + DeployPkg_SetWaitForCloudinitDoneTimeout(waitForCloudinitDoneTimeout); + } else { + if (waitForCloudinitDoneTimeout != -1) { + DeployPkgLog_Log(log_debug, + "Ignore invalid value %d from tools.conf [%s] %s", + waitForCloudinitDoneTimeout, + CONFGROUPNAME_DEPLOYPKG, + CONFNAME_DEPLOYPKG_WAIT_CLOUDINIT_TIMEOUT); + } + DeployPkgLog_Log(log_debug, "The valid [%s] %s value range: 0 ~ %d", + CONFGROUPNAME_DEPLOYPKG, + CONFNAME_DEPLOYPKG_WAIT_CLOUDINIT_TIMEOUT, + MAX_TIMEOUT_WAIT_FOR_CLOUDINIT_DONE); + } #endif if (0 != DeployPkg_DeployPackageFromFile(pkgFile)) { @@ -435,23 +480,26 @@ int randIndex; #ifndef _WIN32 /* - * PR 2115630. On Linux, use /var/run or /run directory - * to hold the package. + * The directories in the array must be sorted by priority from high to low. + * PR 2942062. On Nested ESXi, use /var/run/vmware-imc directory to hold the + * package if it exists. + * PR 2115630. On Linux, use /var/run or /run directory to hold the package. */ - const char *runDir = "/run"; - const char *varRunDir = "/var/run"; - - if (File_IsDirectory(varRunDir)) { - dir = strdup(varRunDir); - if (dir == NULL) { - g_warning("%s: strdup failed\n", __FUNCTION__); - goto exit; - } - } else if (File_IsDirectory(runDir)) { - dir = strdup(runDir); - if (dir == NULL) { - g_warning("%s: strdup failed\n", __FUNCTION__); - goto exit; + const char *searchDirs[] = { + "/var/run/vmware-imc", // The highest priority + "/var/run", + "/run" // The lowest priority + }; + + size_t index; + for (index = 0; index < ARRAYSIZE(searchDirs); index++) { + if (File_IsDirectory(searchDirs[index])) { + dir = strdup(searchDirs[index]); + if (dir == NULL) { + g_warning("%s: strdup failed\n", __FUNCTION__); + goto exit; + } + break; } } #endif diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/deployPkg/deployPkgPlugin.c open-vm-tools-12.1.5/open-vm-tools/services/plugins/deployPkg/deployPkgPlugin.c --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/deployPkg/deployPkgPlugin.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/deployPkg/deployPkgPlugin.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2008-2016 VMware, Inc. All rights reserved. + * Copyright (C) 2008-2016,2022 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 @@ -23,9 +23,11 @@ */ #include +#include #include "vm_basic_defs.h" #include "deployPkgInt.h" +#include "vmcheck.h" #include "vmware/tools/plugin.h" #include "vmware/tools/utils.h" @@ -52,17 +54,56 @@ NULL }; - RpcChannelCallback rpcs[] = { - { "deployPkg.begin", DeployPkg_TcloBegin, NULL, NULL, NULL, 0 }, - { "deployPkg.deploy", DeployPkg_TcloDeploy, NULL, NULL, NULL, 0 } - }; - ToolsAppReg regs[] = { - { TOOLS_APP_GUESTRPC, VMTools_WrapArray(rpcs, sizeof *rpcs, ARRAYSIZE(rpcs)) } - }; + uint32 vmxVersion = 0; + uint32 vmxType = VMX_TYPE_UNSET; - srand(time(NULL)); - regData.regs = VMTools_WrapArray(regs, sizeof *regs, ARRAYSIZE(regs)); + /* + * Return NULL to disable the plugin if not running in a VMware VM. + */ + if (!ctx->isVMware) { + g_info("%s: Not running in a VMware VM.\n", __FUNCTION__); + return NULL; + } + + /* + * Return NULL to disable the plugin if VM is not running on ESX host. + */ + if (!VmCheck_GetVersion(&vmxVersion, &vmxType) || + vmxType != VMX_TYPE_SCALABLE_SERVER) { + g_info("%s, VM is not running on ESX host.\n", __FUNCTION__); + return NULL; + } + + /* + * Return NULL to disable the plugin if not running in vmsvc daemon. + */ + if (!TOOLS_IS_MAIN_SERVICE(ctx)) { + g_info("%s: Not running in vmsvc daemon: container name='%s'.\n", + __FUNCTION__, ctx->name); + return NULL; + } + + /* + * RpcChannel is neccessary for DeployPkg plugin. + */ + if (ctx->rpc != NULL) { + RpcChannelCallback rpcs[] = { + { "deployPkg.begin", DeployPkg_TcloBegin, NULL, NULL, NULL, 0 }, + { "deployPkg.deploy", DeployPkg_TcloDeploy, NULL, NULL, NULL, 0 } + }; + ToolsAppReg regs[] = { + { TOOLS_APP_GUESTRPC, VMTools_WrapArray(rpcs, sizeof *rpcs, ARRAYSIZE(rpcs)) } + }; + + srand(time(NULL)); + regData.regs = VMTools_WrapArray(regs, sizeof *regs, ARRAYSIZE(regs)); + + return ®Data; + } else { + g_info("%s: Do not load DeployPkg plugin because RpcChannel is unavailable.\n", + __FUNCTION__); + } - return ®Data; + return NULL; } diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/dndcp/dnd/copyPasteRpc.hh open-vm-tools-12.1.5/open-vm-tools/services/plugins/dndcp/dnd/copyPasteRpc.hh --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/dndcp/dnd/copyPasteRpc.hh 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/dndcp/dnd/copyPasteRpc.hh 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2007-2017 VMware, Inc. All rights reserved. + * Copyright (C) 2007-2017,2022 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 @@ -25,7 +25,8 @@ #ifndef COPY_PASTE_RPC_HH #define COPY_PASTE_RPC_HH -#include +#include +#include #include "dndCPLibExport.hh" #include "rpcBase.h" diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/dndcp/dnd/dndRpc.hh open-vm-tools-12.1.5/open-vm-tools/services/plugins/dndcp/dnd/dndRpc.hh --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/dndcp/dnd/dndRpc.hh 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/dndcp/dnd/dndRpc.hh 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2007-2017 VMware, Inc. All rights reserved. + * Copyright (C) 2007-2017,2022 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 @@ -25,7 +25,8 @@ #ifndef DND_RPC_HH #define DND_RPC_HH -#include +#include +#include #include "dndCPLibExport.hh" #include "rpcBase.h" diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/dndcp/dnd/fileTransferRpc.hh open-vm-tools-12.1.5/open-vm-tools/services/plugins/dndcp/dnd/fileTransferRpc.hh --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/dndcp/dnd/fileTransferRpc.hh 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/dndcp/dnd/fileTransferRpc.hh 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2010-2017 VMware, Inc. All rights reserved. + * Copyright (C) 2010-2017,2022 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 @@ -25,7 +25,8 @@ #ifndef FILE_TRANSFER_RPC_HH #define FILE_TRANSFER_RPC_HH -#include +#include +#include #include "dndCPLibExport.hh" #include "rpcBase.h" diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/dndcp/dndGuest/rpcV3Util.cpp open-vm-tools-12.1.5/open-vm-tools/services/plugins/dndcp/dndGuest/rpcV3Util.cpp --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/dndcp/dndGuest/rpcV3Util.cpp 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/dndcp/dndGuest/rpcV3Util.cpp 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2010-2019 VMware, Inc. All rights reserved. + * Copyright (C) 2010-2021 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 @@ -306,7 +306,13 @@ { DnDTransportPacketHeader *packetV3 = (DnDTransportPacketHeader *)packet; ASSERT(packetV3); - if (packetSize <= 0 || packetSize > DND_MAX_TRANSPORT_PACKET_SIZE || + /* + * Adding extra check to verify the validity of packetSize, + * In case payload is corrupted its causing illegal access exceptions. + * bug: 2639178 + */ + if (packetSize < sizeof(DnDTransportPacketHeader) || + packetSize > DND_MAX_TRANSPORT_PACKET_SIZE || packetV3->payloadSize > DND_MAX_TRANSPORT_PACKET_PAYLOAD_SIZE || (packetV3->payloadSize + DND_TRANSPORT_PACKET_HEADER_SIZE) != packetSize) { goto invalid_packet; diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/dndcp/dndGuestBase/guestDnD.hh open-vm-tools-12.1.5/open-vm-tools/services/plugins/dndcp/dndGuestBase/guestDnD.hh --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/dndcp/dndGuestBase/guestDnD.hh 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/dndcp/dndGuestBase/guestDnD.hh 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2010-2019 VMware, Inc. All rights reserved. + * Copyright (C) 2010-2021 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 @@ -120,7 +120,7 @@ protected: virtual void OnRpcSrcDragBegin(uint32 sessionId, const CPClipboard *clip) = 0; - void OnRpcQueryExiting(uint32 sessionId, int32 x, int32 y); + virtual void OnRpcQueryExiting(uint32 sessionId, int32 x, int32 y); void OnRpcUpdateUnityDetWnd(uint32 sessionId, bool show, uint32 unityWndId); diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/dndcp/stringxx/string.hh open-vm-tools-12.1.5/open-vm-tools/services/plugins/dndcp/stringxx/string.hh --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/dndcp/stringxx/string.hh 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/dndcp/stringxx/string.hh 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2008-2019 VMware, Inc. All rights reserved. + * Copyright (C) 2008-2019,2022 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 @@ -55,6 +55,7 @@ * need to include here. */ #include +#include // For GIOMM_*_VERSION macros #include #ifdef _WIN32 @@ -101,6 +102,18 @@ static const size_type npos; // Normalize mode map to Glib::NormalizeMode +#if GIOMM_MAJOR_VERSION >= 2 && GIOMM_MINOR_VERSION >= 68 + typedef enum { + NORMALIZE_DEFAULT = (int)Glib::NormalizeMode::DEFAULT, + NORMALIZE_NFD = (int)Glib::NormalizeMode::NFD, + NORMALIZE_DEFAULT_COMPOSE = (int)Glib::NormalizeMode::DEFAULT_COMPOSE, + NORMALIZE_NFC = (int)Glib::NormalizeMode::NFC, + NORMALIZE_ALL = (int)Glib::NormalizeMode::ALL, + NORMALIZE_NFKD = (int)Glib::NormalizeMode::NFKD, + NORMALIZE_ALL_COMPOSE = (int)Glib::NormalizeMode::ALL_COMPOSE, + NORMALIZE_NFKC = (int)Glib::NormalizeMode::NFKC + } NormalizeMode; +#else typedef enum { NORMALIZE_DEFAULT = Glib::NORMALIZE_DEFAULT, NORMALIZE_NFD = Glib::NORMALIZE_NFD, @@ -111,6 +124,7 @@ NORMALIZE_ALL_COMPOSE = Glib::NORMALIZE_ALL_COMPOSE, NORMALIZE_NFKC = Glib::NORMALIZE_NFKC } NormalizeMode; +#endif string(); string(const char *s); diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/dndcp/stringxx/ubstr_t.hh open-vm-tools-12.1.5/open-vm-tools/services/plugins/dndcp/stringxx/ubstr_t.hh --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/dndcp/stringxx/ubstr_t.hh 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/dndcp/stringxx/ubstr_t.hh 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2008-2019,2021 VMware, Inc. All rights reserved. + * Copyright (C) 2008-2019,2021-2022 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 @@ -32,6 +32,7 @@ #include #include +#include // For GIOMM_*_VERSION #include #include "autoCPtr.hh" @@ -115,6 +116,9 @@ { } +#if GIOMM_MAJOR_VERSION >= 2 && GIOMM_MINOR_VERSION >= 68 + // Glib::RefPtr is now just a std::shared_ptr so no extras are needed +#else // For Glib::RefPtr. void reference() { @@ -129,6 +133,7 @@ delete this; } } +#endif // Takes ownership of the input string. void Set(char *utf8String) // IN/OUT: May be NULL. @@ -145,13 +150,18 @@ return mUTF8String; } +#if GIOMM_MAJOR_VERSION >= 2 && GIOMM_MINOR_VERSION >= 68 + public: +#else private: // Only destructible via unreference(). +#endif ~UTF8Data() { free(mUTF8String); } + private: char *mUTF8String; unsigned int mRefCount; diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c open-vm-tools-12.1.5/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c 2022-11-29 21:17:22.000000000 +0000 @@ -545,6 +545,7 @@ gchar *osNameOverride; gchar *osNameFullOverride; Bool maxNicsError = FALSE; + static uint32 logThrottleCount = 0; g_debug("Entered guest info gather.\n"); @@ -767,8 +768,9 @@ nicInfo = Util_SafeCalloc(1, sizeof (struct NicInfoV3)); } if (maxNicsError) { - VMTools_VmxLog(ctx->rpc, "%s: NIC limit (%d) reached.", - __FUNCTION__, NICINFO_MAX_NICS); + VMTools_VmxLogThrottled(&logThrottleCount, ctx->rpc, + "%s: NIC limit (%d) reached.", + __FUNCTION__, NICINFO_MAX_NICS); } /* @@ -1604,6 +1606,12 @@ return FALSE; } + if (infoType == INFO_OS_NAME) { + g_message("Updated Guest OS name to %s\n", (char *) info); + } else if (infoType == INFO_OS_NAME_FULL) { + g_message("Updated Guest OS full name to %s\n", (char *) info); + } + /* Update the value in the cache as well. */ free(gInfoCache.value[infoType]); gInfoCache.value[infoType] = Util_SafeStrdup((char *) info); @@ -1978,29 +1986,20 @@ gint pollInterval = 0; if (enable) { - pollInterval = defInterval * 1000; - /* * Check the config registry for custom poll interval, * converting from seconds to milliseconds. */ - if (g_key_file_has_key(ctx->config, CONFGROUPNAME_GUESTINFO, - cfgKey, NULL)) { - GError *gError = NULL; - - pollInterval = g_key_file_get_integer(ctx->config, - CONFGROUPNAME_GUESTINFO, - cfgKey, &gError); - pollInterval *= 1000; - - if (pollInterval < 0 || gError) { - g_warning("Invalid %s.%s value. Using default %us.\n", - CONFGROUPNAME_GUESTINFO, cfgKey, defInterval); - pollInterval = defInterval * 1000; - } - - g_clear_error(&gError); + pollInterval = VMTools_ConfigGetInteger(ctx->config, + CONFGROUPNAME_GUESTINFO, + cfgKey, defInterval); + if (pollInterval < 0 || pollInterval > (G_MAXINT / 1000)) { + g_warning("Invalid %s.%s value. Using default %us.\n", + CONFGROUPNAME_GUESTINFO, cfgKey, defInterval); + pollInterval = defInterval; } + + pollInterval *= 1000; } if (*timeoutSource != NULL) { diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/guestStore/guestStorePlugin.c open-vm-tools-12.1.5/open-vm-tools/services/plugins/guestStore/guestStorePlugin.c --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/guestStore/guestStorePlugin.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/guestStore/guestStorePlugin.c 2022-11-29 21:17:22.000000000 +0000 @@ -1390,7 +1390,7 @@ clientRecvTimeout = GUESTSTORE_CONFIG_GET_INT("clientRecvTimeout", DEFAULT_CLIENT_RECV_TIMEOUT); - if (clientRecvTimeout <= 0) { + if (clientRecvTimeout <= 0 || clientRecvTimeout > (G_MAXINT / 1000)) { g_warning("Invalid clientRecvTimeout (%d); Using default (%d).\n", clientRecvTimeout, DEFAULT_CLIENT_RECV_TIMEOUT); clientRecvTimeout = DEFAULT_CLIENT_RECV_TIMEOUT; @@ -2282,7 +2282,8 @@ theVmxConn->connTimeout = GUESTSTORE_CONFIG_GET_INT("connTimeout", GUESTSTORE_DEFAULT_CONN_TIMEOUT); - if (theVmxConn->connTimeout <= 0) { + if (theVmxConn->connTimeout <= 0 || + theVmxConn->connTimeout > (G_MAXINT / 1000)) { g_warning("Invalid connTimeout (%d); Using default (%d).\n", theVmxConn->connTimeout, GUESTSTORE_DEFAULT_CONN_TIMEOUT); theVmxConn->connTimeout = GUESTSTORE_DEFAULT_CONN_TIMEOUT; diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/Makefile.am open-vm-tools-12.1.5/open-vm-tools/services/plugins/Makefile.am --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/Makefile.am 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/Makefile.am 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ ################################################################################ -### Copyright (c) 2009-2020 VMware, Inc. All rights reserved. +### Copyright (c) 2009-2021 VMware, Inc. All rights reserved. ### ### This program is free software; you can redistribute it and/or modify ### it under the terms of version 2 of the GNU General Public License as @@ -20,6 +20,10 @@ SUBDIRS += appInfo SUBDIRS += gdp SUBDIRS += guestStore + SUBDIRS += componentMgr +endif +if ENABLE_CONTAINERINFO + SUBDIRS += containerInfo endif if ENABLE_SDMP SUBDIRS += serviceDiscovery diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/resolutionSet/resolutionCommon.c open-vm-tools-12.1.5/open-vm-tools/services/plugins/resolutionSet/resolutionCommon.c --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/resolutionSet/resolutionCommon.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/resolutionSet/resolutionCommon.c 2022-11-29 21:17:22.000000000 +0000 @@ -37,7 +37,8 @@ /* The DRM device we are looking for */ #define RESOLUTION_VENDOR "0x15ad" -#define RESOLUTION_DEVICE "0x0405" +#define RESOLUTION_SVGA2_DEVICE "0x0405" +#define RESOLUTION_SVGA3_DEVICE "0x0406" #define RESOLUTION_KERNELNAME "vmwgfx" /* Required DRM version for resolutionKMS */ @@ -121,8 +122,9 @@ if (!vendor || !device) goto skipCheck; - if (strcmp(vendor, RESOLUTION_VENDOR) || - strcmp(device, RESOLUTION_DEVICE)) + if (strcmp(vendor, RESOLUTION_VENDOR) != 0 || + (strcmp(device, RESOLUTION_SVGA2_DEVICE) != 0 && + strcmp(device, RESOLUTION_SVGA3_DEVICE) != 0)) goto skipCheck; devNode = udev_device_get_devnode(dev); diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/serviceDiscovery/get-versions.sh open-vm-tools-12.1.5/open-vm-tools/services/plugins/serviceDiscovery/get-versions.sh --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/serviceDiscovery/get-versions.sh 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/serviceDiscovery/get-versions.sh 2022-11-29 21:17:22.000000000 +0000 @@ -1,12 +1,13 @@ #!/bin/sh -# Copyright (C) 2020 VMware, Inc. All rights reserved. +# Copyright (c) 2021-2022 VMware, Inc. All rights reserved. # check if necesary commands exist command -v ss >/dev/null 2>&1 || { echo >&2 "ss doesn't exist"; exit 1; } command -v grep >/dev/null 2>&1 || { echo >&2 "grep doesn't exist"; exit 1; } command -v sort >/dev/null 2>&1 || { echo >&2 "sort doesn't exist"; exit 1; } command -v ps >/dev/null 2>&1 || { echo >&2 "ps doesn't exist"; exit 1; } +command -v awk>/dev/null 2>&1 || { echo >&2 "awk doesn't exist"; exit 1; } space_separated_pids=$(ss -lntup | grep -Eo "pid=[0-9]+" | grep -Eo "[0-9]*" | sort -u) @@ -82,6 +83,33 @@ command -v tcserver >/dev/null 2>&1 && { tcserver version 2>/dev/null; } } +get_cassandra_version() { + PATTERN="/usr/lib/.*apache-cassandra" + for p in $space_separated_pids + do + CASSANDRA_CMD=$(get_command_line $p | grep -Eo "$PATTERN") + CASSANDRA_INSTALL_PATH=`echo $CASSANDRA_CMD | awk 'match($0,/\/usr\/lib\/[a-zA-Z-]*\/[a-zA-Z\/]*\/apache-cassandra-[0-9.]*\//) {print substr($0,RSTART,RLENGTH)}'` + if [ ! -z "$CASSANDRA_INSTALL_PATH" ] + then + IS_LI_CASSANDRA=`echo $CASSANDRA_INSTALL_PATH | grep "loginsight"` + [ ! -z "$IS_LI_CASSANDRA" ] && export CASSANDRA_CONF="/storage/core/loginsight/cidata/cassandra/config" + echo VERSIONSTART cassandra_version "$("${CASSANDRA_INSTALL_PATH}/bin/cassandra" -v 2>/dev/null)" VERSIONEND + else + CASSANDRA_CMD=$(get_command_line $p | grep -Eo "CassandraDaemon") + [ ! -z "$CASSANDRA_CMD" ] && echo VERSIONSTART cassandra_version $($(which cassandra) 2>/dev/null -v) VERSIONEND + fi + done +} + +get_vrli_version() { + FILE_PATH_TEMPLATE=/storage/core/loginsight/config/loginsight-config.xml# + FILE_NAMES=$(ls /storage/core/loginsight/config/ 2>/dev/null | grep -o "[0-9].*") + [ ! -z "$FILE_NAMES" ] && LATEST_FILE_NUM=$(printf '%s\n' "${FILE_NAMES[@]}" | awk '$1 > m || NR == 1 { m = $1 } END { print m }') + VERSION_FILE_NAME="$FILE_PATH_TEMPLATE$LATEST_FILE_NUM" + VERSION=$(cat $VERSION_FILE_NAME 2>/dev/null | grep 'strata-version value=' | grep -oE "[0-9.]+" | head -1) + [ ! -z "$VERSION" ] && echo VERSIONSTART vrli_version $VERSION VERSIONEND +} + echo VERSIONSTART "vcops_version" "$(get_vcops_version)" VERSIONEND echo VERSIONSTART "srm_mgt_server_version" "$(get_srm_mgt_server_version)" VERSIONEND echo VERSIONSTART "vcenter_appliance_version" "$(get_vcenter_appliance_version)" VERSIONEND @@ -98,4 +126,6 @@ get_vcloud_director_version get_weblogic_version get_apache_tomcat_version -get_jboss_version \ No newline at end of file +get_jboss_version +get_cassandra_version +get_vrli_version diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/serviceDiscovery/serviceDiscovery.c open-vm-tools-12.1.5/open-vm-tools/services/plugins/serviceDiscovery/serviceDiscovery.c --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/serviceDiscovery/serviceDiscovery.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/serviceDiscovery/serviceDiscovery.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2020 VMware, Inc. All rights reserved. + * Copyright (C) 2020-2021 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 @@ -20,7 +20,7 @@ * serviceDiscovery.c -- * * Captures the information about services inside the guest - * and writes it to Namespace DB. + * and writes it to either host-side gdp daemon or Namespace DB */ #include @@ -48,7 +48,6 @@ #define NSDB_PRIV_GET_VALUES_CMD "namespace-priv-get-values" #define NSDB_PRIV_SET_KEYS_CMD "namespace-priv-set-keys" - #if defined (_WIN32) #define SCRIPT_EXTN ".bat" @@ -63,6 +62,7 @@ SCRIPT_EXTN #define SERVICE_DISCOVERY_WIN_SCRIPT_NET "net-share" SCRIPT_EXTN #define SERVICE_DISCOVERY_WIN_SCRIPT_IIS_PORTS "get-iis-ports-info" SCRIPT_EXTN +#define SERVICE_DISCOVERY_WIN_SCRIPT_SHAREPOINT_PORTS "get-sharepoint-ports-info" SCRIPT_EXTN #else @@ -74,6 +74,9 @@ */ #define SERVICE_DISCOVERY_SCRIPT_PERFORMANCE_METRICS \ "get-listening-process-perf-metrics" SCRIPT_EXTN + +#define _get_errno(p) (*p = errno) + #endif /* @@ -108,10 +111,55 @@ #define SERVICE_DISCOVERY_RPC_WAIT_TIME 100 /* + * Defines the configuration to cache data in gdp plugin + */ +#define CONFNAME_SERVICEDISCOVERY_CACHEDATA "cache-data" + +#define SERVICE_DISCOVERY_CONF_DEFAULT_CACHEDATA TRUE + +#define SERVICE_DISCOVERY_TOPIC_PREFIX "serviceDiscovery" + +#if defined(VMX86_DEBUG) +/* + * Defines the configuration to identify whether is in GDP debug mode + * + * Tools daemon restart is required to apply this setting's cahnge + */ +#define CONFNAME_SERVICEDISCOVERY_GDP_DEBUG "gdp-debug" + +/* + * Defines the configuration to customize polling interval for GDP debug + * + * Tools daemon restart is required to apply this setting's cahnge + */ +#define CONFNAME_SERVICEDISCOVERY_GDP_POLL_INTERVAL "poll-interval" + +/* + * Default polling interval of service discovery plugin for GDP debug in seconds + */ +#define SERVICE_DISCOVERY_CONF_GDP_DEBUG_POLL_INTERVAL 15 + +/* + * Minimum polling interval of service discovery plugin for GDP debug in seconds + */ +#define SERVICE_DISCOVERY_CONF_MIN_POLL_INTERVAL 1 + +static Bool isGDPDebug = FALSE; +#endif + +/* * Maximum number of keys that can be deleted by one operation */ #define SERVICE_DISCOVERY_DELETE_CHUNK_SIZE 25 +/* + * GdpError message table. + */ +#define GDP_ERR_ITEM(a, b) b, +static const char * const gdpErrMsgs[] = { +GDP_ERR_LIST +}; +#undef GDP_ERR_ITEM typedef struct { gchar *keyName; @@ -130,6 +178,8 @@ SERVICE_DISCOVERY_WIN_SCRIPT_RELATIONSHIP }, { SERVICE_DISCOVERY_WIN_KEY_IIS_PORTS, SERVICE_DISCOVERY_WIN_SCRIPT_IIS_PORTS }, + { SERVICE_DISCOVERY_WIN_KEY_SHAREPOINT_PORTS, + SERVICE_DISCOVERY_WIN_SCRIPT_SHAREPOINT_PORTS }, { SERVICE_DISCOVERY_WIN_KEY_NET, SERVICE_DISCOVERY_WIN_SCRIPT_NET }, #endif }; @@ -138,8 +188,14 @@ static gint64 gLastWriteTime = 0; static GArray *gFullPaths = NULL; -static volatile Bool gTaskSubmitted = FALSE; +static Atomic_Bool gTaskSubmitted = { FALSE }; // Task has been submitted. + +static size_t readBytesPerCycle = 0; +static size_t cycle = 0; +static Bool isGDPWriteReady = TRUE; +static Bool isNDBWriteReady = TRUE; +static Bool gSkipThisTask = FALSE; // Skip this task on some gdp errors. /* ***************************************************************************** @@ -158,6 +214,37 @@ return g_get_real_time() / 1000; } +#if defined(VMX86_DEBUG) +/* + ***************************************************************************** + * GetGDPPollInterval -- + * + * @brief Get poll interval from tools config for debugging the GDP + * + * @param[in] ctx The application context + * + * @retval Poll interval in milli-seconds. + * + ***************************************************************************** + */ + +static gint +GetGDPPollInterval(ToolsAppCtx *ctx) +{ + gint pollInterval = + VMTools_ConfigGetInteger(ctx->config, + CONFGROUPNAME_SERVICEDISCOVERY, + CONFNAME_SERVICEDISCOVERY_GDP_POLL_INTERVAL, + SERVICE_DISCOVERY_CONF_GDP_DEBUG_POLL_INTERVAL); + if (pollInterval < SERVICE_DISCOVERY_CONF_MIN_POLL_INTERVAL) { + g_info("%s: Service discovery minimum poll interval is enforced.\n", + __FUNCTION__); + pollInterval = SERVICE_DISCOVERY_CONF_MIN_POLL_INTERVAL; + } + + return pollInterval * 1000; +} +#endif /* ***************************************************************************** @@ -205,7 +292,7 @@ */ if (!status && result != NULL && strcmp(*result, RPCCHANNEL_SEND_PERMISSION_DENIED) == 0) { - g_debug("%s: Retrying RPC send", __FUNCTION__); + g_debug("%s: Retrying RPC send\n", __FUNCTION__); free(*result); g_usleep(SERVICE_DISCOVERY_RPC_WAIT_TIME * 1000); status = RpcChannel_SendOneRawPriv(msg, msgLen, result, resultLen); @@ -215,6 +302,118 @@ return status; } +/* + ***************************************************************************** + * SendData -- + * + * Sends guest data to host-side gdp daemon. + * + * @param[in] ctx The application context + * @param[in] createTime Data create time + * @param[in] topic Data topic + * @param[in] data Service data + * @param[in] len Service data len + * + * @retval TRUE On success. + * @retval FALSE Failed. + * + ***************************************************************************** + */ + +Bool +SendData(ToolsAppCtx *ctx, + gint64 createTime, + const char *topic, + const char *data, + const int len) +{ + GdpError gdpErr; + Bool status = FALSE; + Bool cacheData = VMTools_ConfigGetBoolean(ctx->config, + CONFGROUPNAME_SERVICEDISCOVERY, + CONFNAME_SERVICEDISCOVERY_CACHEDATA, + SERVICE_DISCOVERY_CONF_DEFAULT_CACHEDATA); + + gdpErr = ToolsPluginSvcGdp_Publish(ctx, + createTime, + topic, + NULL, + NULL, + data, + len, + cacheData); + if (gdpErr != GDP_ERROR_SUCCESS) { + g_info("%s: ToolsPluginSvcGdp_Publish error: %s\n", + __FUNCTION__, gdpErrMsgs[gdpErr]); + if (gdpErr == GDP_ERROR_STOP || + gdpErr == GDP_ERROR_UNREACH || + gdpErr == GDP_ERROR_TIMEOUT) { + gSkipThisTask = TRUE; + } + } else { + status = TRUE; + } + + return status; +} + +/* + ***************************************************************************** + * fread_safe -- + * + * A wrapper of C runtime library fread() with almost same signature except + * the item size is always 1 byte. It ensures that when the returned number + * of bytes is less than the input buffer size in bytes, an error has occured + * or the end of the file is encountered. + * + * @param [out] buf Pointer to a block of memory with a size of at least + * (size) bytes, converted to a void*. + * @param [in] size Size, in bytes, of each element to be read. + * @param [in] stream Pointer to a FILE object that specifies an input stream. + * @param [out] eof Indicates whether end of file is reached. + * + * @retval The total number of elements successfully read is returned. + * + ***************************************************************************** + */ + +static size_t +fread_safe(void *buf, + size_t size, + FILE *stream, + Bool *eof) +{ + size_t readBytes = 0; + + while (readBytes < size) { + size_t localReadBytes; + + /* + * fread is a blocking call. + */ + localReadBytes = fread((char *)buf + readBytes, 1, + size - readBytes, stream); + + if (ferror(stream)) { + int error_code = 0; + _get_errno(&error_code); + g_info("%s: fread returned %"FMTSZ"u with errno=%d\n", + __FUNCTION__, localReadBytes, error_code); + break; + } + + readBytes += localReadBytes; + + if (feof(stream)) { + g_debug("%s: fread reached end of file\n", + __FUNCTION__); + *eof = TRUE; + break; + } + } + + return readBytes; +} /* ***************************************************************************** @@ -371,6 +570,40 @@ return status; } +/* + ***************************************************************************** + * DepleteReadFromStream -- + * + * Reads from stream and appends to the output dynamic buffer + * + * @param[in] s Stream + * @param[out] out Output buffer + * + ***************************************************************************** + */ + +void +DepleteReadFromStream(FILE *s, + DynBuf *out) +{ + for (;;) { + size_t readBytes; + char buf[SERVICE_DISCOVERY_VALUE_MAX_SIZE]; + + readBytes = fread(buf, 1, sizeof(buf), s); + + g_debug("%s: readBytes = %"FMTSZ"u\n", __FUNCTION__, readBytes); + + if (readBytes > 0) { + DynBuf_Append(out, buf, readBytes); + } + + if (readBytes < sizeof(buf)) { + break; + } + } +} + /* ***************************************************************************** @@ -448,6 +681,110 @@ return status; } +/* + ***************************************************************************** + * SendScriptOutput -- + * + * Reads script child process stdout stream, sends output to + * host-side gdp daemon and/or namespace DB. + * + * Stream output data are cut into chunks with chunk size of 16K for namespace + * DB and 48K for gdp daemon. If there are multiple chunks of data, each chunk + * is sent to gdp daemon/namespace db separately with its chunk number in the + * topic. + * + * @param[in] ctx The application context + * @param[in] key Script name + * @param[in] childStdout Stream to read child process stdout + * + * @retval TRUE Successfully sent output. + * @retval FALSE Otherwise. + * + ***************************************************************************** + */ + +Bool +SendScriptOutput(ToolsAppCtx *ctx, + const char *key, + FILE* childStdout) +{ + Bool status = TRUE; + Bool gdp_status = TRUE; + int i = 0; + size_t totalReadBytes = 0; + gint64 createTime = g_get_real_time(); + size_t ndbBufSize = SERVICE_DISCOVERY_VALUE_MAX_SIZE * sizeof(char); + for (;;) { + size_t readBytes; + char buf[GDP_USER_DATA_LEN]; + Bool eof = FALSE; + readBytes = fread_safe(buf, sizeof(buf), childStdout, &eof); + + totalReadBytes += readBytes; + g_debug("%s: DB readBytes = %"FMTSZ"u\n", __FUNCTION__, + readBytes); + if (isGDPWriteReady && gdp_status && readBytes > 0) { + g_debug("%s:%s Write to GDP readBytes = %"FMTSZ"u\n", + __FUNCTION__, key, readBytes); + gchar* topic; + + if (eof || readBytes < sizeof(buf)) { + topic = g_strdup_printf(SERVICE_DISCOVERY_TOPIC_PREFIX ".%s.%"FMTSZ + "u.%"FMTSZ"u", key, cycle, totalReadBytes); + } else { + topic = g_strdup_printf(SERVICE_DISCOVERY_TOPIC_PREFIX ".%s.%"FMTSZ + "u", key, cycle); + } + gdp_status = SendData(ctx, createTime, topic, buf, (int)readBytes); + readBytesPerCycle += readBytes; + g_free(topic); + } + + if (isNDBWriteReady) { + size_t ndbReadBytes = 0; + size_t j; + for (j = 0; j < readBytes; j += ndbReadBytes) { + if (j + ndbBufSize > readBytes) { + ndbReadBytes = readBytes - j; + } else { + ndbReadBytes = ndbBufSize; + } + if (status && ndbReadBytes > 0) { + g_debug("%s:%s Write to Namespace DB readBytes = %"FMTSZ"u\n", + __FUNCTION__, key, ndbReadBytes); + + gchar* msg = g_strdup_printf("%s-%d", key, ++i); + status = WriteData(ctx, msg, buf + j, ndbReadBytes); + if (!status) { + g_warning("%s: Failed to store data\n", __FUNCTION__); + } + g_free(msg); + } + } + } + + /* + * Exit the loop only after childStdout is not readable any more. + * Otherwise, the child process may be blocked in writing its stdout + * and hang. + */ + if (eof || readBytes < sizeof(buf)) { + break; + } + + } + + if (isNDBWriteReady && status) { + gchar *chunkCount = g_strdup_printf("%d", i); + status = WriteData(ctx, key, chunkCount, strlen(chunkCount)); + if (status) { + g_debug("%s: Written key %s chunks %s\n", __FUNCTION__, key, chunkCount); + } + g_free(chunkCount); + } + + return status && gdp_status; +} /* ***************************************************************************** @@ -571,54 +908,77 @@ ServiceDiscoveryTask(ToolsAppCtx *ctx, void *data) { - Bool status = FALSE; int i; - gint64 previousWriteTime = gLastWriteTime; + Bool status = FALSE; + Atomic_WriteBool(&gTaskSubmitted, TRUE); + if (isGDPWriteReady) { + gSkipThisTask = FALSE; + } + if (isNDBWriteReady) { + gint64 previousWriteTime = gLastWriteTime; - gTaskSubmitted = TRUE; - /* - * We are going to write to Namespace DB, update glastWriteTime - */ - gLastWriteTime = GetGuestTimeInMillis(); + /* + * We are going to write to Namespace DB, update glastWriteTime + */ + gLastWriteTime = GetGuestTimeInMillis(); - /* - * Reset "ready" flag to stop readers until all data is written - */ - status = WriteData(ctx, SERVICE_DISCOVERY_KEY_READY, "FALSE", 5); - if (!status) { - gLastWriteTime = previousWriteTime; - g_warning("%s: Failed to reset %s flag", __FUNCTION__, - SERVICE_DISCOVERY_KEY_READY); - goto out; - } + /* + * Reset "ready" flag to stop readers until all data is written + */ + status = WriteData(ctx, SERVICE_DISCOVERY_KEY_READY, "FALSE", 5); + if (!status) { + gLastWriteTime = previousWriteTime; + g_warning("%s: Failed to reset %s flag", __FUNCTION__, + SERVICE_DISCOVERY_KEY_READY); + if (!isGDPWriteReady) { + Atomic_WriteBool(&gTaskSubmitted, FALSE); + return; + } + } - /* - * Remove chunks written to DB in the previous iteration - */ - CleanupNamespaceDB(ctx); + /* + * Remove chunks written to DB in the previous iteration + */ + CleanupNamespaceDB(ctx); + } + readBytesPerCycle = 0; + cycle++; for (i = 0; i < gFullPaths->len; i++) { KeyNameValue tmp = g_array_index(gFullPaths, KeyNameValue, i); - if (!PublishScriptOutputToNamespaceDB(ctx, tmp.keyName, tmp.val)) { - g_debug("%s: PublishScriptOutputToNamespaceDB failed for script %s\n", - __FUNCTION__, tmp.val); + if (!ExecuteScript(ctx, tmp.keyName, tmp.val)) { + g_debug("%s: ExecuteScript failed for script %s\n", + __FUNCTION__, tmp.val); + if (isGDPWriteReady && gSkipThisTask && !isNDBWriteReady) { + break; + } } } + if (isGDPWriteReady && !gSkipThisTask) { + gchar* readyData = g_strdup_printf("%"FMTSZ"u", readBytesPerCycle); + g_debug("%s: Sending ready flag with number of read bytes :%s\n", + __FUNCTION__, readyData); + gchar* topic = g_strdup_printf(SERVICE_DISCOVERY_TOPIC_PREFIX ".%s.%" + FMTSZ"u", "ready", cycle); + SendData(ctx, g_get_real_time(), topic, readyData, strlen(readyData)); + g_free(topic); + g_free(readyData); + } - /* - * Update ready flag - */ - status = WriteData(ctx, SERVICE_DISCOVERY_KEY_READY, "TRUE", 4); - if (!status) { - g_warning("%s: Failed to update ready flag", __FUNCTION__); + if (isNDBWriteReady) { + /* + * Update ready flag + */ + status = WriteData(ctx, SERVICE_DISCOVERY_KEY_READY, "TRUE", 4); + if (!status) { + g_warning("%s: Failed to update ready flag", __FUNCTION__); + } } -out: - gTaskSubmitted = FALSE; + Atomic_WriteBool(&gTaskSubmitted, FALSE); } - /* ***************************************************************************** * checkForWrite -- @@ -632,16 +992,17 @@ * Second check - checks if time greater than interval read from Namespace DB * has elapsed since the last write operation. * - * @param[in] ctx The application context. + * @param[in] ctx The application context. + * @param[in] signalKey Signal key to check the write redinness of Namespace DB or gdp. * - * @retval TRUE Execute scripts and write service data to Namespace DB. + * @retval TRUE Execute scripts and write service data to Namespace DB or gdp * @retval FALSE Omit this cycle wihtout any script running. * ***************************************************************************** */ static Bool -checkForWrite(ToolsAppCtx *ctx) +checkForWrite(ToolsAppCtx *ctx, const char *signalKey) { char *signal = NULL; size_t signalLen = 0; @@ -650,7 +1011,7 @@ /* * Read signal from Namespace DB */ - if (!ReadData(ctx, SERVICE_DISCOVERY_KEY_SIGNAL, &signal, &signalLen)) { + if (!ReadData(ctx, signalKey, &signal, &signalLen)) { g_debug("%s: Failed to read necessary information from Namespace DB\n", __FUNCTION__); } else { @@ -705,13 +1066,12 @@ return result; } - /* ***************************************************************************** * ServiceDiscoveryThread -- * - * Creates a new thread that collects all the desired application related - * information and updates the Namespace DB. + * Creates a new task thread that gathers discovered services' data and + * publishes the data to either Namespace DB or host-side gdp daemon. * * @param[in] data The application context. * @@ -724,15 +1084,29 @@ ServiceDiscoveryThread(gpointer data) { ToolsAppCtx *ctx = data; + #if defined(VMX86_DEBUG) + if (isGDPDebug) { + isGDPWriteReady = TRUE; + isNDBWriteReady = FALSE; + } else { + isGDPWriteReady = checkForWrite(ctx, SERVICE_DISCOVERY_KEY_GDP_SIGNAL); + isNDBWriteReady = checkForWrite(ctx, SERVICE_DISCOVERY_KEY_SIGNAL); + } + #else + isGDPWriteReady = checkForWrite(ctx, SERVICE_DISCOVERY_KEY_GDP_SIGNAL); + isNDBWriteReady = checkForWrite(ctx, SERVICE_DISCOVERY_KEY_SIGNAL); + #endif /* * First check for taskSubmitted, if it is true automatically omit this * cycle even without checking for write to avoid resetting last write * time. */ - if (gTaskSubmitted || !checkForWrite(ctx)) { - g_debug("%s: Data should not be written taskSubmitted = %s\n", - __FUNCTION__, gTaskSubmitted ? "True" : "False"); + if (Atomic_ReadBool(&gTaskSubmitted)) { + g_debug("%s: Previously submitted task is not completed\n", __FUNCTION__); + } else if (!isNDBWriteReady && !isGDPWriteReady) { + g_debug("%s: Neither Namespace DB nor GDP is ready for writing\n", + __FUNCTION__); } else { g_debug("%s: Submitting task to write\n", __FUNCTION__); if (!ToolsCorePool_SubmitTask(ctx, ServiceDiscoveryTask, NULL, NULL)) { @@ -760,8 +1134,21 @@ TweakDiscoveryLoop(ToolsAppCtx *ctx) { if (gServiceDiscoveryTimeoutSource == NULL) { + gint pollInterval = SERVICE_DISCOVERY_POLL_INTERVAL; + #if defined(VMX86_DEBUG) + isGDPDebug = + VMTools_ConfigGetBoolean(ctx->config, + CONFGROUPNAME_SERVICEDISCOVERY, + CONFNAME_SERVICEDISCOVERY_GDP_DEBUG, + FALSE); + if (isGDPDebug) { + pollInterval = GetGDPPollInterval(ctx); + g_info("%s: GDP Debug is enabled with %d ms polling interval\n", + __FUNCTION__, pollInterval); + } + #endif gServiceDiscoveryTimeoutSource = - g_timeout_source_new(SERVICE_DISCOVERY_POLL_INTERVAL); + g_timeout_source_new(pollInterval); VMTOOLSAPP_ATTACH_SOURCE(ctx, gServiceDiscoveryTimeoutSource, ServiceDiscoveryThread, ctx, NULL); g_source_unref(gServiceDiscoveryTimeoutSource); diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/serviceDiscovery/serviceDiscoveryInt.h open-vm-tools-12.1.5/open-vm-tools/services/plugins/serviceDiscovery/serviceDiscoveryInt.h --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/serviceDiscovery/serviceDiscoveryInt.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/serviceDiscovery/serviceDiscoveryInt.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2020 VMware, Inc. All rights reserved. + * Copyright (C) 2020-2021 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 @@ -28,21 +28,39 @@ #define G_LOG_DOMAIN "serviceDiscovery" #include +#include #include "vm_basic_types.h" +#include "vm_atomic.h" +#include "dynbuf.h" #include "vmware/tools/plugin.h" +#include "vmware/tools/gdp.h" /* * Maximum length of the data (either key or value) written to Namespace DB */ #define SERVICE_DISCOVERY_VALUE_MAX_SIZE (1024*15) -Bool PublishScriptOutputToNamespaceDB(ToolsAppCtx *ctx, - const char *key, - const char *script); Bool WriteData(ToolsAppCtx *ctx, const char *key, const char *data, const size_t len); +void DepleteReadFromStream(FILE *stream, + DynBuf *out); + +Bool SendData(ToolsAppCtx *ctx, + gint64 createTime, + const char *key, + const char *data, + const int len); + +Bool SendScriptOutput(ToolsAppCtx *ctx, + const char *key, + FILE *childStdout); + +Bool ExecuteScript(ToolsAppCtx *ctx, + const char *key, + const char *script); + #endif /* _SERVICEDISCOVERYINT_H_ */ diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/serviceDiscovery/serviceDiscoveryPosix.c open-vm-tools-12.1.5/open-vm-tools/services/plugins/serviceDiscovery/serviceDiscoveryPosix.c --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/serviceDiscovery/serviceDiscoveryPosix.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/serviceDiscovery/serviceDiscoveryPosix.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2020 VMware, Inc. All rights reserved. + * Copyright (C) 2020-2021 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 @@ -62,21 +62,7 @@ __FUNCTION__, errno); } } else { - for (;;) { - size_t readBytes; - char buf[SERVICE_DISCOVERY_VALUE_MAX_SIZE]; - readBytes = fread(buf, 1, sizeof(buf), f); - g_debug("%s: readBytes = %" G_GSSIZE_FORMAT "\n", __FUNCTION__, - readBytes); - - if (readBytes > 0) { - DynBuf_Append(out, buf, readBytes); - } - - if (readBytes < sizeof(buf)) { - break; - } - } + DepleteReadFromStream(f, out); if (fclose(f) != 0) { g_warning("%s: Failed to close file stream, errno=%d", __FUNCTION__, errno); @@ -84,126 +70,103 @@ } } - /* ***************************************************************************** - * PublishScriptOutputToNamespaceDB -- - * - * Spawns child process for script, reads stdout from pipe, writes - * generated chunks to Namespace DB. + * ExecuteScript -- * - * Chunk count will be written to Namespace DB using received - * "key" (ie. get-listening-process-info). + * Spawns child process for script, reads child process stdout stream and + * sends data to Namespace DB and/or host-side gdp daemon. * - * Chunks will be written to Namespace DB with keys constructed by "key-[i]" - * template (ie. get-listening-process-info-1, get-listening-process-info-2) - * - * @param[in] ctx Application context. - * @param[in] key Key used for chunk count + * @param[in] ctx The application context + * @param[in] key Script name * @param[in] script Script to be executed * - * @retval TRUE Script execution and Namespace DB write over RPC succeeded. - * @retval FALSE Either of script execution or Namespace DB write failed. + * @retval TRUE Successfully executed script and sent output to gdp daemon. + * @retval FALSE Otherwise. * ***************************************************************************** */ Bool -PublishScriptOutputToNamespaceDB(ToolsAppCtx *ctx, - const char *key, - const char *script) +ExecuteScript(ToolsAppCtx *ctx, + const char *key, + const char *script) { - Bool status = FALSE; - GPid pid; + Bool status; gchar *command = g_strdup(script); gchar *cmd[] = { command, NULL }; gint child_stdout = -1; gint child_stderr = -1; - FILE* child_stdout_f; + FILE *child_stdout_f; GError *p_error = NULL; DynBuf err; - int i = 0; - status = g_spawn_async_with_pipes(NULL, cmd, NULL, G_SPAWN_DEFAULT, NULL, - NULL, &pid, NULL, &child_stdout, &child_stderr, - &p_error); + status = g_spawn_async_with_pipes(NULL, // const gchar *working_directory + cmd, // gchar **argv + NULL, // gchar **envp + G_SPAWN_DEFAULT, // GSpawnFlags flags + NULL, // GSpawnChildSetupFunc child_setup + NULL, // gpointer user_data + NULL, // GPid *child_pid + NULL, // gint *standard_input + &child_stdout, // gint *standard_output + &child_stderr, // gint *standard_error + &p_error); // GError **error if (!status) { if (p_error != NULL) { - g_warning("%s: Error during script exec %s\n", __FUNCTION__, - p_error->message); - g_error_free(p_error); + g_warning("%s: Error during script exec %s\n", + __FUNCTION__, p_error->message); + g_clear_error(&p_error); } else { g_warning("%s: Command not run\n", __FUNCTION__); } + + /* + * If an error occurs, child_pid, standard_input, standard_output, + * and standard_error will not be filled with valid values. + */ g_free(command); return status; } g_debug("%s: Child process spawned for %s\n", __FUNCTION__, key); + status = FALSE; + child_stdout_f = fdopen(child_stdout, "r"); if (child_stdout_f == NULL) { g_warning("%s: Failed to create file stream for child stdout, errno=%d", - __FUNCTION__, errno); - status = FALSE; + __FUNCTION__, errno); goto out; } - for (;;) { - char buf[SERVICE_DISCOVERY_VALUE_MAX_SIZE]; - size_t readBytes = fread(buf, 1, sizeof(buf), child_stdout_f); - - g_debug("%s: readBytes = %" G_GSSIZE_FORMAT " status = %s\n", - __FUNCTION__, readBytes, status ? "TRUE" : "FALSE"); - // At first iteration we are sure that status is true - if (status && readBytes > 0) { - gchar* msg = g_strdup_printf("%s-%d", key, ++i); - status = WriteData(ctx, msg, buf, readBytes); - if (!status) { - g_warning("%s: Failed to store data\n", __FUNCTION__); - } - g_free(msg); - } - - if (readBytes < sizeof(buf)) { - if (!status) { - g_warning("%s: Data read finished but failed to store\n", __FUNCTION__); - } - break; - } - } - - if (status) { - gchar *chunkCount = g_strdup_printf("%d", i); - status = WriteData(ctx, key, chunkCount, strlen(chunkCount)); - if (status) { - g_debug("%s: Written key %s chunks %s\n", __FUNCTION__, key, chunkCount); - } - g_free(chunkCount); - } + status = SendScriptOutput(ctx, key, child_stdout_f); DynBuf_Init(&err); ReadFromHandle(child_stderr, &err); child_stderr = -1; if (DynBuf_GetSize(&err) != 0) { DynBuf_AppendString(&err, ""); - g_debug("%s: stderr=%s\n", __FUNCTION__, (const char *) DynBuf_Get(&err)); + g_debug("%s: stderr=%s\n", + __FUNCTION__, (const char *) DynBuf_Get(&err)); } DynBuf_Destroy(&err); + out: - g_free(command); if (child_stdout_f != NULL) { if (fclose(child_stdout_f) != 0) { g_warning("%s: Failed to close child stdout file stream, errno=%d", - __FUNCTION__, errno); + __FUNCTION__, errno); } } else if (close(child_stdout) != 0) { g_warning("%s: Failed to close child stdout handle, errno=%d", - __FUNCTION__, errno); + __FUNCTION__, errno); } if (child_stderr != -1 && close(child_stderr) != 0) { g_warning("%s: Failed to close child process stderr handle, errno=%d", - __FUNCTION__, errno); + __FUNCTION__, errno); } + + g_free(command); return status; } diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/timeSync/timeSync.c open-vm-tools-12.1.5/open-vm-tools/services/plugins/timeSync/timeSync.c --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/timeSync/timeSync.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/timeSync/timeSync.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2008-2021 VMware, Inc. All rights reserved. + * Copyright (C) 2008-2022 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 @@ -410,9 +410,7 @@ int64 before; int64 after; - if (vmx86_debug) { - TimeSync_GetCurrentTime(&before); - } + TimeSync_GetCurrentTime(&before); /* Stepping invalidates the current slew, reset to nominal. */ TimeSyncSetSlewState(data, FALSE); @@ -421,21 +419,19 @@ return FALSE; } - /* + /* * Tell timetracker to stop trying to catch up, since we have corrected - * both the guest OS error and the apparent time error. + * both the guest OS error and the apparent time error. */ bp.in.cx.halfs.low = BDOOR_CMD_STOPCATCHUP; Backdoor(&bp); - if (vmx86_debug) { - TimeSync_GetCurrentTime(&after); - - g_debug("Time changed by %"FMT64"dus from %"FMT64"d.%06"FMT64"d -> " - "%"FMT64"d.%06"FMT64"d\n", adjustment, - before / US_PER_SEC, before % US_PER_SEC, - after / US_PER_SEC, after % US_PER_SEC); - } + TimeSync_GetCurrentTime(&after); + + g_debug("Time changed by %"FMT64"dus from %"FMT64"d.%06"FMT64"d -> " + "%"FMT64"d.%06"FMT64"d\n", adjustment, + before / US_PER_SEC, before % US_PER_SEC, + after / US_PER_SEC, after % US_PER_SEC); return TRUE; } diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/vix/vixTools.c open-vm-tools-12.1.5/open-vm-tools/services/plugins/vix/vixTools.c --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/vix/vixTools.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/vix/vixTools.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2007-2021 VMware, Inc. All rights reserved. + * Copyright (C) 2007-2022 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 @@ -4386,7 +4386,7 @@ #ifdef __FreeBSD__ /* * We should check the original envp for all vars except - * a few whitelisted ones that we set/unset on impersonate + * a few allowlisted ones that we set/unset on impersonate * user start/stop. for them we need to do getenv() */ if (!strcmp(names, "USER") || diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/vmbackup/nullProvider.c open-vm-tools-12.1.5/open-vm-tools/services/plugins/vmbackup/nullProvider.c --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/vmbackup/nullProvider.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/vmbackup/nullProvider.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2010-2016 VMware, Inc. All rights reserved. + * Copyright (C) 2010-2016, 2022 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 @@ -243,6 +243,32 @@ return TRUE; } + +/* + ****************************************************************************** + * VmBackupNullUndo -- */ /** + * + * Update the state machine state with the currentOpName. + * + * Can be called when snapshot times out. See PR2993571 and PR3003917. + * + * @param[in] state the backup state + * @param[in] clientData client data + * + * @return TRUE + * + ****************************************************************************** + */ + +static Bool +VmBackupNullUndo(VmBackupState *state, + void *clientData) +{ + g_debug("*** %s\n", __FUNCTION__); + VmBackup_SetCurrentOp(state, NULL, NULL, __FUNCTION__); + return TRUE; +} + #endif /* @@ -281,6 +307,9 @@ provider = g_new(VmBackupSyncProvider, 1); provider->start = VmBackupNullStart; +#if !defined(_WIN32) + provider->undo = VmBackupNullUndo; +#endif provider->snapshotDone = VmBackupNullSnapshotDone; provider->release = VmBackupNullRelease; provider->clientData = NULL; diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/plugins/vmbackup/stateMachine.c open-vm-tools-12.1.5/open-vm-tools/services/plugins/vmbackup/stateMachine.c --- open-vm-tools-11.3.5/open-vm-tools/services/plugins/vmbackup/stateMachine.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/plugins/vmbackup/stateMachine.c 2022-11-29 21:17:22.000000000 +0000 @@ -115,6 +115,31 @@ /** + * Returns the configured timeout value. + * + * @param[in] config Config file to read from. + * @param[in] defValue Default value if the timeout key is not found or error. + * + * @return value of the timeout key if read successfully, + * defValue otherwise. + */ + +static gint +VmBackupGetTimeout(GKeyFile *config, + const gint defValue) +{ + gint timeout = VMBACKUP_CONFIG_GET_INT(config, "timeout", defValue); + if (timeout < 0 || timeout > (G_MAXINT / 1000)) { + g_warning("Invalid timeout %d. Using default %us.", + timeout, defValue); + timeout = defValue; + } + + return timeout; +} + + +/** * Returns a string representation of the given state machine state. * * @param[in] state State of interest. @@ -1081,8 +1106,8 @@ * See bug 506106. */ if (gBackupState->timeout == 0) { - gBackupState->timeout = VMBACKUP_CONFIG_GET_INT(ctx->config, "timeout", - GUEST_QUIESCE_DEFAULT_TIMEOUT_IN_SEC); + gBackupState->timeout = VmBackupGetTimeout(ctx->config, + GUEST_QUIESCE_DEFAULT_TIMEOUT_IN_SEC); } /* Treat "0" as no timeout. */ @@ -1167,8 +1192,7 @@ gBackupState->scriptArg = VMBACKUP_CONFIG_GET_STR(ctx->config, "scriptArg", NULL); - gBackupState->timeout = VMBACKUP_CONFIG_GET_INT(ctx->config, - "timeout", 0); + gBackupState->timeout = VmBackupGetTimeout(ctx->config, 0); gBackupState->vssUseDefault = VMBACKUP_CONFIG_GET_BOOL(ctx->config, "vssUseDefault", TRUE); diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/vmtoolsd/mainLoop.c open-vm-tools-12.1.5/open-vm-tools/services/vmtoolsd/mainLoop.c --- open-vm-tools-11.3.5/open-vm-tools/services/vmtoolsd/mainLoop.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/vmtoolsd/mainLoop.c 2022-11-29 21:17:22.000000000 +0000 @@ -1182,11 +1182,6 @@ GMainContext *gctx; ToolsServiceProperty ctxProp = { TOOLS_CORE_PROP_CTX }; - /* - * Useful for debugging purposes. Log the vesion and build information. - */ - g_message("Tools Version: %s (%s)\n", TOOLS_VERSION_EXT_CURRENT_STR, BUILD_NUMBER); - /* Initializes the app context. */ gctx = g_main_context_default(); state->ctx.version = TOOLS_CORE_API_V1; diff -Nru open-vm-tools-11.3.5/open-vm-tools/services/vmtoolsd/mainPosix.c open-vm-tools-12.1.5/open-vm-tools/services/vmtoolsd/mainPosix.c --- open-vm-tools-11.3.5/open-vm-tools/services/vmtoolsd/mainPosix.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/services/vmtoolsd/mainPosix.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2008-2020 VMware, Inc. All rights reserved. + * Copyright (C) 2008-2020,2022 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 @@ -178,8 +178,6 @@ * Check that environment is a VM */ if (!VmCheck_IsVirtualWorld()) { - g_printerr("Error: %s must be run inside a virtual machine" - " on a VMware hypervisor product.\n", argv[0]); goto exit; } diff -Nru open-vm-tools-11.3.5/open-vm-tools/tests/testVmblock/Makefile.am open-vm-tools-12.1.5/open-vm-tools/tests/testVmblock/Makefile.am --- open-vm-tools-11.3.5/open-vm-tools/tests/testVmblock/Makefile.am 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/tests/testVmblock/Makefile.am 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ ################################################################################ -### Copyright (c) 2009-2016,2020 VMware, Inc. All rights reserved. +### Copyright (c) 2009-2016,2020-2021 VMware, Inc. All rights reserved. ### ### This program is free software; you can redistribute it and/or modify ### it under the terms of version 2 of the GNU General Public License as @@ -15,12 +15,14 @@ ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ################################################################################ + noinst_PROGRAMS = if HAVE_FUSE - noinst_PROGRAMS = vmware-testvmblock-fuse + noinst_PROGRAMS += vmware-testvmblock-fuse + noinst_PROGRAMS += vmware-testvmblock-manual-fuse +endif +if HAVE_FUSE3 + noinst_PROGRAMS += vmware-testvmblock-fuse noinst_PROGRAMS += vmware-testvmblock-manual-fuse -else - noinst_PROGRAMS = vmware-testvmblock-legacy - noinst_PROGRAMS += vmware-testvmblock-manual-legacy endif AM_CFLAGS = @@ -30,10 +32,6 @@ AM_LDFLAGS = AM_LDFLAGS += -lpthread -vmware_testvmblock_legacy_SOURCES = vmblocktest.c - -vmware_testvmblock_manual_legacy_SOURCES = manual-blocker.c - vmware_testvmblock_fuse_CFLAGS = $(AM_CFLAGS) -Dvmblock_fuse vmware_testvmblock_fuse_SOURCES = vmblocktest.c diff -Nru open-vm-tools-11.3.5/open-vm-tools/toolbox/l10n/de.vmsg open-vm-tools-12.1.5/open-vm-tools/toolbox/l10n/de.vmsg --- open-vm-tools-11.3.5/open-vm-tools/toolbox/l10n/de.vmsg 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/toolbox/l10n/de.vmsg 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ ########################################################## -# Copyright (C) 2010-2017,2020-2021 VMware, Inc. All rights reserved. +# Copyright (C) 2010-2017,2020-2022 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 diff -Nru open-vm-tools-11.3.5/open-vm-tools/toolbox/l10n/es.vmsg open-vm-tools-12.1.5/open-vm-tools/toolbox/l10n/es.vmsg --- open-vm-tools-11.3.5/open-vm-tools/toolbox/l10n/es.vmsg 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/toolbox/l10n/es.vmsg 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ ########################################################## -# Copyright (C) 2010-2017,2020-2021 VMware, Inc. All rights reserved. +# Copyright (C) 2010-2017,2020-2022 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 diff -Nru open-vm-tools-11.3.5/open-vm-tools/toolbox/l10n/fr.vmsg open-vm-tools-12.1.5/open-vm-tools/toolbox/l10n/fr.vmsg --- open-vm-tools-11.3.5/open-vm-tools/toolbox/l10n/fr.vmsg 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/toolbox/l10n/fr.vmsg 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ ########################################################## -# Copyright (C) 2010-2017,2020-2021 VMware, Inc. All rights reserved. +# Copyright (C) 2010-2017,2020-2022 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 @@ -76,7 +76,7 @@ disk.wipe.ignoreFreeSpaceWarnings = "Ignorez tout avertissement relatif à l'espace disque pour la durée du processus d'effacement.\n" -disk.wiper.file.error = "Erreur, impossible de créer un fichier d'effacement .\n" +disk.wiper.file.error = "Erreur, impossible de créer un fichier d'effacement.\n" disk.wiper.progress = "\rProgression : %1$d" diff -Nru open-vm-tools-11.3.5/open-vm-tools/toolbox/l10n/it.vmsg open-vm-tools-12.1.5/open-vm-tools/toolbox/l10n/it.vmsg --- open-vm-tools-11.3.5/open-vm-tools/toolbox/l10n/it.vmsg 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/toolbox/l10n/it.vmsg 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ ########################################################## -# Copyright (C) 2010-2017,2020-2021 VMware, Inc. All rights reserved. +# Copyright (C) 2010-2017,2020-2022 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 diff -Nru open-vm-tools-11.3.5/open-vm-tools/toolbox/l10n/ja.vmsg open-vm-tools-12.1.5/open-vm-tools/toolbox/l10n/ja.vmsg --- open-vm-tools-11.3.5/open-vm-tools/toolbox/l10n/ja.vmsg 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/toolbox/l10n/ja.vmsg 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ ########################################################## -# Copyright (C) 2010-2017,2020-2021 VMware, Inc. All rights reserved. +# Copyright (C) 2010-2017,2020-2022 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 diff -Nru open-vm-tools-11.3.5/open-vm-tools/toolbox/l10n/ko.vmsg open-vm-tools-12.1.5/open-vm-tools/toolbox/l10n/ko.vmsg --- open-vm-tools-11.3.5/open-vm-tools/toolbox/l10n/ko.vmsg 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/toolbox/l10n/ko.vmsg 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ ########################################################## -# Copyright (C) 2010-2017,2020-2021 VMware, Inc. All rights reserved. +# Copyright (C) 2010-2017,2020-2022 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 diff -Nru open-vm-tools-11.3.5/open-vm-tools/toolbox/l10n/zh_CN.vmsg open-vm-tools-12.1.5/open-vm-tools/toolbox/l10n/zh_CN.vmsg --- open-vm-tools-11.3.5/open-vm-tools/toolbox/l10n/zh_CN.vmsg 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/toolbox/l10n/zh_CN.vmsg 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ ########################################################## -# Copyright (C) 2010-2017,2020-2021 VMware, Inc. All rights reserved. +# Copyright (C) 2010-2017,2020-2022 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 diff -Nru open-vm-tools-11.3.5/open-vm-tools/toolbox/l10n/zh_TW.vmsg open-vm-tools-12.1.5/open-vm-tools/toolbox/l10n/zh_TW.vmsg --- open-vm-tools-11.3.5/open-vm-tools/toolbox/l10n/zh_TW.vmsg 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/toolbox/l10n/zh_TW.vmsg 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ ########################################################## -# Copyright (C) 2010-2017,2020-2021 VMware, Inc. All rights reserved. +# Copyright (c) 2010-2017,2020-2022 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 @@ -104,7 +104,7 @@ help.hint = "如需詳細資訊,請嘗試「%1$s%2$s%3$s%4$s」。\n" -help.info = "%1$s: 更新主機上的客體資訊\n使用方式: %2$s %3$s update <資訊類別>\n\n子命令:\n update <資訊類別>: 更新依 <資訊類別> 識別之資訊\n<資訊類別> 可為「network」\n" +help.info = "%1$s: 更新主機上的客體資訊\n用法: %2$s %3$s update <資訊類別>\n\n子命令:\n update <資訊類別>: 更新依 <資訊類別> 識別之資訊\n<資訊類別> 可為「network」\n" help.logging = "%1$s: 修改工具記錄\n用法: %2$s %3$s 層級 <子命令> <服務名稱> <層級>\n\n子命令:\n get <服務名稱>: 顯示目前層級\n 備註: 如果 tools.conf 中未顯示,則其\n 在全域組態中的值會在顯示時傳回\n set <服務名稱> <層級>: 設定目前層級\n\n<服務名稱> 可為任何受支援的服務,例如 vmsvc 或 vmusr\n<層級> 可為錯誤、嚴重、警告、資訊、訊息、偵錯之一\n 預設為 %4$s\n" @@ -112,7 +112,7 @@ help.script = "%1$s: 控制指令碼執行以回應電源作業\n用法: %2$s %3$s <子命令> [args]\n\n子命令:\n enable: 啟用指定指令碼,並將其路徑還原為預設值\n disable: 停用指定指令碼\n set : 將指定指令碼設定為指定路徑\n default: 列印指定指令碼的預設路徑\n current: 列印指定指令碼的目前路徑\n 備註: 如果 tools.conf 中未顯示路徑,則其\n 在全域組態中的值會在顯示時傳回\n" -help.stat = "%1$s: 列印實用的客體和主機資訊\n使用方式: %2$s %3$s <子命令>\n\n子命令:\n hosttime: 列印主機時間\n speed: 列印 CPU 速度 (MHz)\n僅 ESX 客體子命令:\n sessionid: 列印目前的工作階段識別碼\n balloon: 列印記憶體佔用資訊\n swap: 列印記憶體交換資訊\n memlimit: 列印記憶體限制資訊\n memres: 列印記憶體保留區資訊\n cpures: 列印 CPU 保留區資訊\n cpulimit: 列印 CPU 限制資訊\n raw [<代碼> <統計名称>]: 列印原始統計資訊\n <代碼> 可為「text」、「json」、「xml」、「yaml」其中之一。\n <統計名称> 包含「session」、「host」、「resources」、「vscsi」和\n vnet」(某些狀態如 vscsi 為兩個字,例如「vscsi scsi0:0」)。\n 如果並未指定引數 <代碼> 和 <統計名称>\n 則列印可用的統計資料。\n" +help.stat = "%1$s: 列印實用的客體和主機資訊\n用法: %2$s %3$s <子命令>\n\n子命令:\n hosttime: 列印主機時間\n speed: 列印 CPU 速度 (MHz)\n僅 ESX 客體子命令:\n sessionid: 列印目前的工作階段識別碼\n balloon: 列印記憶體佔用資訊\n swap: 列印記憶體交換資訊\n memlimit: 列印記憶體限制資訊\n memres: 列印記憶體保留區資訊\n cpures: 列印 CPU 保留區資訊\n cpulimit: 列印 CPU 限制資訊\n raw [<代碼> <統計名称>]: 列印原始統計資訊\n <代碼> 可為「text」、「json」、「xml」、「yaml」其中之一。\n <統計名称> 包含「session」、「host」、「resources」、「vscsi」和\n vnet」(某些狀態如 vscsi 為兩個字,例如「vscsi scsi0:0」)。\n 如果並未指定引數 <代碼> 和 <統計名称>\n 則列印可用的統計資料。\n" help.timesync = "%1$s: 用於控制客體作業系統時間同步的功能\n用法: %2$s %3$s \n\n子命令:\n enable: 啟用時間同步\n disable: 停用時間同步\n status: 列印時間同步狀態\n" diff -Nru open-vm-tools-11.3.5/open-vm-tools/tools.conf open-vm-tools-12.1.5/open-vm-tools/tools.conf --- open-vm-tools-11.3.5/open-vm-tools/tools.conf 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/tools.conf 2022-11-29 21:17:22.000000000 +0000 @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2021 VMware, Inc. All rights reserved. +# Copyright (c) 2019-2022 VMware, Inc. All rights reserved. # "CAUTION: tools.conf is highly syntax sensitive file. Use extreme caution # while editing it. If modified, it is automatically re-loaded by @@ -245,6 +245,44 @@ # whether to include reserved space in diskInfo space metrics on Linux #diskinfo-include-reserved=false +[globalconf] + +# The GlobalConf feature provides an ability for the vSphere administrators +# to distribute a 'VMware Tools Configuration File' (tools.conf) via the +# GuestStore for multiple VMs at scale. + +# Defines the configuration to enable/disable the GlobalConf module. +# Set to true to enable the module. +# Set to false to disable the module. Default false. +#enabled=false + +# Defines a custom GlobalConf poll interval (in seconds). +# Default 3600 seconds. Minimum 1800 seconds. +#poll-interval=3600 + +# Defines the global configuration resource in GuestStore. +# Windows guests +#resource=/vmware/configurations/vmtools/windows/tools.conf +# +# Linux guests +#resource=/vmware/configurations/vmtools/linux/tools.conf + +[componentmgr] + +# This plugin manages the known and enabled components add/remove status. +# The plugin polls at regular interval and triggers action add/remove for +# all the known and enabled components in the componentMgr plugin. + +# Default and minimum polling interval in seconds (0 => polling disabled) +#poll-interval=180 + +# Comma separated list of components managed by the plugin. If not specified, +# default value is all, which means all components are enabled by default. +# A special value of none means no component, which is equivalent to disabling +# the plugin completely. Value is parsed left to right and parsing stops at +# first occurrence of all or none or end of line. +#included=all + [appinfo] # This plugin collects info about running applications in guest OS. @@ -259,6 +297,35 @@ # version info, otherwise native Win32 API is used. #useWMI=false +# Whether to remove the duplicate applications information in the +# guestinfo variable. +#remove-duplicates=true + +[containerinfo] + +# This plugin collects info about running containers in guest OS. + +# User-defined poll interval in seconds. Set to 0 to disable the plugin. +#poll-interval=21600 + +# Maximum number of containers to be retrieved per namespace. +#max-containers=256 + +# Whether to remove the duplicate containers information in the +# guestinfo variable. +#remove-duplicates=true + +# Unix socket to use to communicate with the docker daemon. +#docker-unix-socket=/var/run/docker.sock + +# The unix socket to connect to communicate with containerd grpc server +# for retrieving the list of running containers. +#containerd-unix-socket=/run/containerd/containerd.sock + +# List of namespaces to be queried for the running containers. +# The value for this key is a comman separated list. +#allowed-namespaces=moby,k8s.io,default + [servicediscovery] # This plugin provides admins with additional info for better VM management. @@ -369,22 +436,37 @@ [autoupgrade] -# The autoupgrade plugin is only available for Windows. - # The "allow-upgrade" option controls whether automatic upgrades (or reinstalls) -# are allowed. The two options "allow-add-feature" and "allow-remove-feature" -# control whether adding or removing a feature will be allowed. The two latter -# ones only affect Windows tools. - +# are allowed. #allow-upgrade=true + +# The autoupgrade plugin is only available for Windows. +# The "allow-add-feature" and "allow-remove-feature" control whether adding +# or removing a feature will be allowed. +# The allow-msi-transforms option controls whether TRANSFORMS property is +# allowed. + #allow-add-feature=true #allow-remove-feature=true +#allow-msi-transforms=false [deployPkg] # to disable guest customization #enable-customization=false +# This "wait-cloudinit-timeout" option controls how long does guest +# customization wait for cloud-init execution done when it detects cloud-init +# is available in guest. +# Guest customization will continue executing as soon as it detects cloud-init +# execution done within this option's value in seconds. +# If cloud-init is still running beyond this option's value in seconds, guest +# customization will continue executing regardless cloud-init execution status. +# Minimum valid value is 0 second, set to 0 to disable waiting. +# Maximum valid value is 1800 seconds (30 minutes). +# Default value is 30 seconds. +#wait-cloudinit-timeout=30 + [cbhelper] # The carbonblack helper plugin is only available for Windows. diff -Nru open-vm-tools-11.3.5/open-vm-tools/vgauth/cli/l10n/de.vmsg open-vm-tools-12.1.5/open-vm-tools/vgauth/cli/l10n/de.vmsg --- open-vm-tools-11.3.5/open-vm-tools/vgauth/cli/l10n/de.vmsg 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/vgauth/cli/l10n/de.vmsg 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ ########################################################## -# Copyright (C) 2011-2017,2020 VMware, Inc. All rights reserved. +# Copyright (C) 2011-2017,2020-2022 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 diff -Nru open-vm-tools-11.3.5/open-vm-tools/vgauth/cli/l10n/es.vmsg open-vm-tools-12.1.5/open-vm-tools/vgauth/cli/l10n/es.vmsg --- open-vm-tools-11.3.5/open-vm-tools/vgauth/cli/l10n/es.vmsg 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/vgauth/cli/l10n/es.vmsg 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ ########################################################## -# Copyright (C) 2011-2017,2020 VMware, Inc. All rights reserved. +# Copyright (C) 2011-2017,2020-2022 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 diff -Nru open-vm-tools-11.3.5/open-vm-tools/vgauth/cli/l10n/fr.vmsg open-vm-tools-12.1.5/open-vm-tools/vgauth/cli/l10n/fr.vmsg --- open-vm-tools-11.3.5/open-vm-tools/vgauth/cli/l10n/fr.vmsg 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/vgauth/cli/l10n/fr.vmsg 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ ########################################################## -# Copyright (C) 2011-2017,2020 VMware, Inc. All rights reserved. +# Copyright (C) 2011-2017,2020-2022 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 diff -Nru open-vm-tools-11.3.5/open-vm-tools/vgauth/cli/l10n/it.vmsg open-vm-tools-12.1.5/open-vm-tools/vgauth/cli/l10n/it.vmsg --- open-vm-tools-11.3.5/open-vm-tools/vgauth/cli/l10n/it.vmsg 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/vgauth/cli/l10n/it.vmsg 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ ########################################################## -# Copyright (C) 2011-2017,2020 VMware, Inc. All rights reserved. +# Copyright (c) 2011-2017,2020-2022 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 @@ -82,9 +82,9 @@ removeall.success = "%1$s: tutti gli alias sono stati rimossi\n" -removealloptions.subject = "Oggetto SAML" +removealloptions.subject = "L'oggetto SAML" removealloptions.username = "Utente da cui viene rimosso l'archivio certificati" -removealloptions.verbose = "Operazione dettagliata" +removealloptions.verbose = "Operazione Verbose" vgauth.init.failed = "Impossibile inizializzare VGAuth" diff -Nru open-vm-tools-11.3.5/open-vm-tools/vgauth/cli/l10n/ja.vmsg open-vm-tools-12.1.5/open-vm-tools/vgauth/cli/l10n/ja.vmsg --- open-vm-tools-11.3.5/open-vm-tools/vgauth/cli/l10n/ja.vmsg 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/vgauth/cli/l10n/ja.vmsg 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ ########################################################## -# Copyright (c) 2011-2017,2020-2021 VMware, Inc. All rights reserved. +# Copyright (C) 2011-2017,2020-2022 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 diff -Nru open-vm-tools-11.3.5/open-vm-tools/vgauth/cli/l10n/ko.vmsg open-vm-tools-12.1.5/open-vm-tools/vgauth/cli/l10n/ko.vmsg --- open-vm-tools-11.3.5/open-vm-tools/vgauth/cli/l10n/ko.vmsg 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/vgauth/cli/l10n/ko.vmsg 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ ########################################################## -# Copyright (C) 2011-2017,2020 VMware, Inc. All rights reserved. +# Copyright (C) 2011-2017,2020-2022 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 diff -Nru open-vm-tools-11.3.5/open-vm-tools/vgauth/cli/l10n/zh_CN.vmsg open-vm-tools-12.1.5/open-vm-tools/vgauth/cli/l10n/zh_CN.vmsg --- open-vm-tools-11.3.5/open-vm-tools/vgauth/cli/l10n/zh_CN.vmsg 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/vgauth/cli/l10n/zh_CN.vmsg 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ ########################################################## -# Copyright (c) 2011-2017,2020-2021 VMware, Inc. All rights reserved. +# Copyright (C) 2011-2017,2020-2022 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 diff -Nru open-vm-tools-11.3.5/open-vm-tools/vgauth/cli/l10n/zh_TW.vmsg open-vm-tools-12.1.5/open-vm-tools/vgauth/cli/l10n/zh_TW.vmsg --- open-vm-tools-11.3.5/open-vm-tools/vgauth/cli/l10n/zh_TW.vmsg 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/vgauth/cli/l10n/zh_TW.vmsg 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ ########################################################## -# Copyright (c) 2011-2017,2020-2021 VMware, Inc. All rights reserved. +# Copyright (C) 2011-2017,2020-2022 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 diff -Nru open-vm-tools-11.3.5/open-vm-tools/vgauth/common/certverify.c open-vm-tools-12.1.5/open-vm-tools/vgauth/common/certverify.c --- open-vm-tools-11.3.5/open-vm-tools/vgauth/common/certverify.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/vgauth/common/certverify.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2011-2016, 2018-2019, 2021 VMware, Inc. All rights reserved. + * Copyright (C) 2011-2016, 2018-2019, 2021-2022 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 @@ -93,11 +93,23 @@ const char *data; const char *file; unsigned long code; - +#if OPENSSL_VERSION_NUMBER >= 0X30000000L + const char *func; +#endif + +#if OPENSSL_VERSION_NUMBER >= 0X30000000L + code = ERR_get_error_all(&file, &line, &func, &data, &flags); +#else code = ERR_get_error_line_data(&file, &line, &data, &flags); +#endif while (code) { +#if OPENSSL_VERSION_NUMBER >= 0X30000000L + g_warning("SSL error: %lu (%s) in %s func %s line %d\n", + code, ERR_error_string(code, NULL), file, func, line); +#else g_warning("SSL error: %lu (%s) in %s line %d\n", code, ERR_error_string(code, NULL), file, line); +#endif if (data && (flags & ERR_TXT_STRING)) { g_warning("SSL error data: %s\n", data); } @@ -107,7 +119,11 @@ * until the SSL error buffer starts getting reused and a double * free happens. */ +#if OPENSSL_VERSION_NUMBER >= 0X30000000L + code = ERR_get_error_all(&file, &line, &func, &data, &flags); +#else code = ERR_get_error_line_data(&file, &line, &data, &flags); +#endif } } @@ -146,12 +162,15 @@ X509_NAME_oneline(X509_get_subject_name(curCert), nameBuf, sizeof(nameBuf) - 1); nameBuf[sizeof(nameBuf)-1] = '\0'; } else { + /* Ignore return, returns length of the source string */ + /* coverity[check_return] */ g_strlcpy(nameBuf, "", sizeof nameBuf); } - g_debug("%s: name: %s ok: %d error %d at %d depth lookup:%s\n", + g_debug("%s: name: %s ok: %d error '%s' (%d) at %d depth lookup:%s\n", __FUNCTION__, nameBuf, ok, + X509_verify_cert_error_string(certErr), certErr, X509_STORE_CTX_get_error_depth(ctx), X509_verify_cert_error_string(certErr)); @@ -165,7 +184,9 @@ ret = 1; break; default: - g_warning("%s: error %d treated as failure\n", __FUNCTION__, certErr); + g_warning("%s: error '%s' (%d) treated as failure\n", + __FUNCTION__, X509_verify_cert_error_string(certErr), + certErr); break; } } diff -Nru open-vm-tools-11.3.5/open-vm-tools/vgauth/common/vmxlog.c open-vm-tools-12.1.5/open-vm-tools/vgauth/common/vmxlog.c --- open-vm-tools-11.3.5/open-vm-tools/vgauth/common/vmxlog.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/vgauth/common/vmxlog.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2018-2021 VMware, Inc. All rights reserved. + * Copyright (C) 2018-2022 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 @@ -17,464 +17,29 @@ *********************************************************/ /* - * @file logvmx.c + * @file vmxlog.c * * Simple guest->VMX RPC log support that assumes VMCI is available. * - * Doesn't share any Tools code or headers; key bits that can't change - * are copied from vmci_sockets.h - * */ -#include "vmxlog.h" #include +#include "vmxrpc.h" +#include "vmxlog.h" -#include -#ifdef _WIN32 -#include -#else -#include -#include -#include -#include -#include -#endif -#include -#include -#include -#include -#include -#include -#include - -/* - * VMX listening address - */ -const int VMX_CID = 0; -const int RPCI_PORT = 976; -#define VMADDR_PORT_ANY ((unsigned int) -1) - -static int gAddressFamily = -1; #define LOG_RPC_CMD "log" #define LOG_RPC_CMD_NEW "guest.log.text" static gboolean gDisableVMXLogging = TRUE; /* - * Error codes for SendString() and SendRpciPacket() + * Error codes for SendLogString() */ #define VMX_RPC_OK 1 // success #define VMX_RPC_UNKNOWN 0 // RPC disabled or not supported #define VMX_RPC_ERROR -1 // failed to send RPC #define VMXLOG_SERVICE_NAME "[vgauthservice]" -/* - * Some typedefs for portability. - */ -#ifdef _WIN32 -/* still have to care about pre-C++11 so use the old instead of stdint.h */ -typedef unsigned __int32 uint32; -typedef unsigned __int64 uint64; - -#endif -#ifdef __linux__ -typedef __uint32_t uint32; -typedef __uint64_t uint64; - -#define SOCKET int -#endif -#ifdef sun -typedef uint32_t uint32; -typedef uint64_t uint64; - -#define SOCKET int -#endif - -#if defined(_WIN32) -typedef unsigned short sa_family_t; -#endif // _WIN32 - - -/* - * Wrapper for socket errnos - */ -static int -GetSocketErrCode(void) -{ -#ifdef _WIN32 - return WSAGetLastError(); -#else - return errno; -#endif -} - - -/* - * start code cut&paste from vmci_sockets.h - * - * This is the subset from vmci_sockets.h required for our purposes. - * this results in a few refs to other parts of the file that were - * left out. - */ - -#ifdef _WIN32 -# include -# define VMCI_SOCKETS_DEVICE L"\\\\.\\VMCI" -# define VMCI_SOCKETS_VERSION 0x81032058 -# define VMCI_SOCKETS_GET_AF_VALUE 0x81032068 -# define VMCI_SOCKETS_GET_LOCAL_CID 0x8103206c -# define VMCI_SOCKETS_UUID_2_CID 0x810320a4 - -static unsigned int -__VMCISock_DeviceIoControl(DWORD cmd) -{ - unsigned int val = (unsigned int)-1; - HANDLE device = CreateFileW(VMCI_SOCKETS_DEVICE, GENERIC_READ, 0, NULL, - OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); - if (INVALID_HANDLE_VALUE != device) { - DWORD ioReturn; - DeviceIoControl(device, cmd, &val, sizeof val, &val, sizeof val, - &ioReturn, NULL); - CloseHandle(device); - device = INVALID_HANDLE_VALUE; - } - return val; -} -#endif //_WIN32 - - -/** - * \brief Address structure for vSockets. - * - * The address family should be set to whatever VMCISock_GetAFValueFd() - * returns. The structure members should all align on their natural - * boundaries without resorting to compiler packing directives. The total - * size of this structure should be exactly the same as that of \c struct - * \c sockaddr. - * - * \see VMCISock_GetAFValueFd() - */ - -struct sockaddr_vm { -#if defined(__APPLE__) || defined(__FreeBSD__) - unsigned char svm_len; -#endif // __APPLE__ || __FreeBSD__ - - /** \brief Address family. \see VMCISock_GetAFValueFd() */ - sa_family_t svm_family; - - /** \cond PRIVATE */ - unsigned short svm_reserved1; - /** \endcond */ - - /** \brief Port. \see VMADDR_PORT_ANY */ - unsigned int svm_port; - - /** \brief Context ID. \see VMADDR_CID_ANY */ - unsigned int svm_cid; - - /** \cond PRIVATE */ - unsigned char svm_zero[sizeof(struct sockaddr) - -#if defined(__APPLE__) - sizeof(unsigned char) - -#endif // __APPLE__ - sizeof(sa_family_t) - - sizeof(unsigned short) - - sizeof(unsigned int) - - sizeof(unsigned int)]; - /** \endcond */ -}; -/* end code copied from vmci_sockets.h */ - - -/* - * Local version of htonll() which is missing in many environments. - * Assumes the host is little-endian. - */ -static uint64 -_vmxlog_htonll(uint64 s) -{ - uint64 out; - unsigned char *buf = (unsigned char *) &out; - - buf[0] = s >> 56 & 0xff; - buf[1] = s >> 48 & 0xff; - buf[2] = s >> 40 & 0xff; - buf[3] = s >> 32 & 0xff; - buf[4] = s >> 24 & 0xff; - buf[5] = s >> 16 & 0xff; - buf[6] = s >> 8 & 0xff; - buf[7] = s >> 0 & 0xff; - - return out; -} - - -/* - ****************************************************************************** - * MakePacket -- */ /** - * - * Takes 'cmd' and builds an RPC packet out of it, putting in the - * length and header info (properly byte swapped). - * - * See bora-vmsoft/lib/rpcChannel/simpleSocket.c:Socket_PackSendData() - * - * retPacket contains the new packet, which must be g_free()d. - * Returns the size of the new packet. - * - * Returns -1 on failure, size of packet on success. - * - ****************************************************************************** - */ - -static int -MakePacket(const char *cmd, - char **retPacket) -{ - int len; - int tlen; - uint32 plen; - uint32 slen; - char *packet = NULL; - char *p; - struct { - uint32 type; - uint32 fieldId; - uint64 value; - } hdr; - struct { - uint32 type; - uint32 fieldId; - uint64 value; - } flags; - struct { - uint32 type; - uint32 fieldId; - uint32 len; - } payload; - - *retPacket = NULL; - if (cmd == NULL) { - return -1; - } - - len = (int) strlen(cmd); - - /* network byte order is important here */ - hdr.type = htonl(1); // DMFIELDTYPE_INT64 - hdr.fieldId = htonl(1); // GUESTRPCPKT_FIELD_TYPE - hdr.value = _vmxlog_htonll(1); // GUESTRPCPKT_TYPE_DATA - - /* - * Adding the fast_close flag GUESTRPCPKT_FIELD_FAST_CLOSE in the packet - * to indicate vmx to close the channel as soon as the response is sent. - */ - flags.type = htonl(1); // DMFIELDTYPE_INT64 - flags.fieldId = htonl(3); // GUESTRPCPKT_FIELD_FAST_CLOSE - flags.value = _vmxlog_htonll(1); // GUESTRPCPKT_TYPE_DATA - - /* - * this part of the data doesn't seem to care about network byte - * order, but do it anyways. - */ - payload.type = htonl(2); // DMFIELDTYPE_STRING - payload.fieldId = htonl(2); // GUESTRPCPKT_FIELD_PAYLOAD - payload.len = htonl(len); // length of 'cmd' - - plen = sizeof(hdr) + sizeof(flags) + sizeof(payload) + len; - - tlen = plen + sizeof(int); - packet = (char *) g_malloc(tlen); - p = packet; - - /* use network byte order overall length */ - slen = htonl(plen); - memcpy(p, (char *)&slen, sizeof slen); - p += sizeof(uint32); - - memcpy(p, &hdr, sizeof hdr); - p += sizeof hdr; - memcpy(p, &flags, sizeof flags); - p += sizeof flags; - memcpy(p, &payload, sizeof payload); - p += sizeof payload; - memcpy(p, cmd, len); - - *retPacket = packet; - - return tlen; -} - - -/* - ****************************************************************************** - * GetAddressFamily -- */ /** - * - * Returns the vsock socket family on success, -1 on failure. - * - * This assumes modern vsock is in the kernel. - ****************************************************************************** - */ - -int -GetAddressFamily(void) -{ -#ifdef _WIN32 - return __VMCISock_DeviceIoControl(VMCI_SOCKETS_GET_AF_VALUE); -#else - const int AF_VSOCK_LOCAL = 40; - int s = socket(AF_VSOCK_LOCAL, SOCK_DGRAM, 0); - if (s != -1) { - close(s); - return AF_VSOCK_LOCAL; - } - - return -1; -#endif -} - - -/* - ****************************************************************************** - * CreateVMCISocket -- */ /** - * - * Creates, binds and connects a socket to the VMX. - * - * Returns a new socket that should be close()d or -1 on failure. - * - ****************************************************************************** - */ - -static SOCKET -CreateVMCISocket(void) -{ - struct sockaddr_vm localAddr; - struct sockaddr_vm addr; - int ret; - SOCKET fd = socket(gAddressFamily, SOCK_STREAM, 0); - if (fd < 0) { - g_warning("%s: socket() failed %d\n", __FUNCTION__, GetSocketErrCode()); - return -1; - } - - /* bind to a priviledged port */ - memset(&localAddr, 0, sizeof localAddr); - localAddr.svm_family = gAddressFamily; -#ifdef _WIN32 - localAddr.svm_cid = __VMCISock_DeviceIoControl(VMCI_SOCKETS_GET_LOCAL_CID); -#else - localAddr.svm_cid = -1; -#endif - localAddr.svm_port = VMADDR_PORT_ANY; - ret = bind(fd, (struct sockaddr *)&localAddr, sizeof localAddr); - if (ret != 0) { - g_warning("%s: bind() failed %d\n", __FUNCTION__, GetSocketErrCode()); - goto err; - } - - /* connect to destination */ - memset(&addr, 0, sizeof addr); - addr.svm_family = gAddressFamily; - addr.svm_cid = VMX_CID; - addr.svm_port = RPCI_PORT; - - ret = connect(fd, (struct sockaddr *)&addr, sizeof addr); - if (ret < 0) { - g_warning("%s: connect() failed %d\n", __FUNCTION__, GetSocketErrCode()); - goto err; - } - - return fd; -err: -#ifdef _WIN32 - closesocket(fd); -#else - close(fd); -#endif - - return -1; -} - - -/* - ****************************************************************************** - * SendRpciPacket -- */ /** - * - * Sends RPC packet to the VMX. Reads but ignores any response. - * - * @param[in] packet RPC packet. - * @param[in] packetLen Length of packet. - * - * Returns VMX_RPC_ERROR on failure, VMX_RPC_OK on success, VMX_RPC_UNKNOWN - * if RPC failed (doesn't exist or disabled). - * - ****************************************************************************** - */ - -static int -SendRpciPacket(const char *packet, - int packetLen) -{ - SOCKET sock; - char buf[1024]; - char *reply; - int ret; - int retVal = VMX_RPC_OK; - - /* - * Its inefficient to create/destroy the socket each time, but - * there's potential to run the VMX out of connections if we hold it open. - * Since performance isn't a major concern, play it safe. - */ - sock = CreateVMCISocket(); - if (sock < 0) { - g_warning("%s: failed to create VMCI socket\n", __FUNCTION__); - return VMX_RPC_ERROR; - } - ret = send(sock, packet, packetLen, 0); - if (ret != packetLen) { - g_warning("%s: failed to send packet (%d)\n", - __FUNCTION__, GetSocketErrCode()); - retVal = VMX_RPC_ERROR; - goto done; - } - - /* - * Read the answer to see if the RPC went through. - */ - ret = recv(sock, buf, sizeof buf, 0); - /* - * Cheat a bit here -- just get to the text and ignore the header. - * The string data starts 19 chars into the buffer. - * - * XXX should this only happen on 'Unknown'? If the VMX - * level changes on the fly, this can start working. - * - * Possible optimization -- every N minutes, retry the new RPC. - */ - if (ret >= 18 && ret < sizeof buf) { - buf[ret] = '\0'; - reply = &buf[18]; - g_debug("%s: RPC returned '%s'\n", __FUNCTION__, reply); - if (g_strcmp0(reply, "disabled") == 0 || - g_strcmp0(reply, "Unknown") == 0) { - g_warning("%s: RPC unknown or disabled\n", __FUNCTION__); - retVal = VMX_RPC_UNKNOWN; - } - } else { - g_warning("%s: recv() returned %d\n", __FUNCTION__, ret); - retVal = VMX_RPC_ERROR; - } - -done: -#ifdef _WIN32 - closesocket(sock); -#else - close(sock); -#endif - - return retVal; -} /* @@ -491,24 +56,8 @@ int VMXLog_Init(void) { -#ifdef _WIN32 - int ret; - WSADATA wsaData; - - ret = WSAStartup(MAKEWORD(2,0), &wsaData); - if (ret != 0) { - g_warning("%s: Failed to init winsock (%d)\n", __FUNCTION__, ret); - return -1; - } -#endif - gAddressFamily = GetAddressFamily(); - if (gAddressFamily < 0) { - g_warning("%s: Failed to set up VMX logging\n", __FUNCTION__); - return -1; - } - gDisableVMXLogging = FALSE; - return 1; + return VMXRPC_Init(); } @@ -525,15 +74,14 @@ VMXLog_Shutdown(void) { gDisableVMXLogging = TRUE; - gAddressFamily = -1; } /* ****************************************************************************** - * SendString -- */ /** + * SendLogString -- */ /** * - * Formats a message as an RPC and sends it to the VMX. + * Sends a Log message to the VMX. * * @param[in] cmd The message to send. * @@ -543,25 +91,26 @@ */ static int -SendString(const gchar *cmd) +SendLogString(const gchar *cmd) { - gchar *packet = NULL; - int packetLen; + gchar *reply = NULL; int ret; + int retVal = VMX_RPC_OK; - packetLen = MakePacket(cmd, &packet); - if (packetLen <= 0) { - g_warning("%s: failed to build RPC packet\n", __FUNCTION__); - return VMX_RPC_ERROR; - } - - ret = SendRpciPacket(packet, packetLen); - if (ret == VMX_RPC_ERROR) { + ret = VMXRPC_SendRpc(cmd, FALSE, &reply); + if (ret >= 0) { + if (g_strcmp0(reply, "disabled") == 0 || + g_strcmp0(reply, "Unknown command") == 0) { + g_warning("%s: RPC unknown or disabled\n", __FUNCTION__); + retVal = VMX_RPC_UNKNOWN; + } + } else { g_warning("%s: failed to send RPC packet\n", __FUNCTION__); + retVal = VMX_RPC_ERROR; } - g_free(packet); - return ret; + g_free(reply); + return retVal; } @@ -586,7 +135,11 @@ gchar *msg = NULL; gchar *cmd = NULL; int ret; - static gboolean useNewRpc = TRUE; + // static gboolean useNewRpc = TRUE; + // XXX the new RPC can quietly no-op on virtual hw < 17 + // is this fixable somehow, or should we just give up + // on the new RPC completely? + static gboolean useNewRpc = FALSE; static gboolean rpcBroken = FALSE; /* @@ -611,7 +164,7 @@ cmd = g_strdup_printf("%s " VMXLOG_SERVICE_NAME " %s", LOG_RPC_CMD, msg); } - ret = SendString(cmd); + ret = SendLogString(cmd); g_free(cmd); cmd = NULL; if ((ret == VMX_RPC_UNKNOWN) && useNewRpc) { diff -Nru open-vm-tools-11.3.5/open-vm-tools/vgauth/common/vmxrpc.c open-vm-tools-12.1.5/open-vm-tools/vgauth/common/vmxrpc.c --- open-vm-tools-11.3.5/open-vm-tools/vgauth/common/vmxrpc.c 1970-01-01 00:00:00.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/vgauth/common/vmxrpc.c 2022-11-29 21:17:22.000000000 +0000 @@ -0,0 +1,639 @@ +/********************************************************* + * Copyright (C) 2022 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 + * by the Free Software Foundation version 2.1 and no later version. + * + * 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 Lesser GNU General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + *********************************************************/ + +/* + * @file vmxrpc.c + * + * Simple guest->VMX RPC support. + * + * Doesn't share any Tools code or headers; key bits that can't change + * are copied from vmci_sockets.h + * + */ + +#include +#include "vmxrpc.h" + +#include +#ifdef _WIN32 +#include +#else +#include +#include +#include +#include +#include +#endif +#include +#include +#include +#include +#include +#include +#include + +/* + * VMX listening address + */ +const int VMX_CID = 0; +const int RPCI_PORT = 976; +#define VMADDR_PORT_ANY ((unsigned int) -1) + +#define PRIVILEGED_PORT_MAX 1023 +#define PRIVILEGED_PORT_MIN 1 + +static int gAddressFamily = -1; + +/* + * Some typedefs for portability. + */ +#ifdef _WIN32 +/* still have to care about pre-C++11 so use the old instead of stdint.h */ +typedef unsigned __int32 uint32; +typedef unsigned __int64 uint64; + +#endif +#ifdef __linux__ +typedef __uint32_t uint32; +typedef __uint64_t uint64; + +#define SOCKET int +#endif +#ifdef sun +typedef uint32_t uint32; +typedef uint64_t uint64; + +#define SOCKET int +#endif + +#if defined(_WIN32) +typedef unsigned short sa_family_t; +#endif // _WIN32 + +#ifdef _WIN32 +#define SYSERR_ECONNRESET WSAECONNRESET +#define SYSERR_EADDRINUSE WSAEADDRINUSE +#else +#define SYSERR_ECONNRESET ECONNRESET +#define SYSERR_EADDRINUSE EADDRINUSE +#endif + + +/* + * Wrapper for socket errnos + */ +static int +GetSocketErrCode(void) +{ +#ifdef _WIN32 + return WSAGetLastError(); +#else + return errno; +#endif +} + + +/* + * Wrapper for socket close + */ +static void +Socket_Close(SOCKET fd) +{ +#ifdef _WIN32 + closesocket(fd); +#else + close(fd); +#endif +} + + +/* + * start code cut&paste from vmci_sockets.h + * + * This is the subset from vmci_sockets.h required for our purposes. + * this results in a few refs to other parts of the file that were + * left out. + */ + +#ifdef _WIN32 +# include +# define VMCI_SOCKETS_DEVICE L"\\\\.\\VMCI" +# define VMCI_SOCKETS_VERSION 0x81032058 +# define VMCI_SOCKETS_GET_AF_VALUE 0x81032068 +# define VMCI_SOCKETS_GET_LOCAL_CID 0x8103206c +# define VMCI_SOCKETS_UUID_2_CID 0x810320a4 + +static unsigned int +__VMCISock_DeviceIoControl(DWORD cmd) +{ + unsigned int val = (unsigned int)-1; + HANDLE device = CreateFileW(VMCI_SOCKETS_DEVICE, GENERIC_READ, 0, NULL, + OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); + if (INVALID_HANDLE_VALUE != device) { + DWORD ioReturn; + DeviceIoControl(device, cmd, &val, sizeof val, &val, sizeof val, + &ioReturn, NULL); + CloseHandle(device); + device = INVALID_HANDLE_VALUE; + } + return val; +} +#endif //_WIN32 + + +/** + * \brief Address structure for vSockets. + * + * The address family should be set to whatever VMCISock_GetAFValueFd() + * returns. The structure members should all align on their natural + * boundaries without resorting to compiler packing directives. The total + * size of this structure should be exactly the same as that of \c struct + * \c sockaddr. + * + * \see VMCISock_GetAFValueFd() + */ + +struct sockaddr_vm { +#if defined(__APPLE__) || defined(__FreeBSD__) + unsigned char svm_len; +#endif // __APPLE__ || __FreeBSD__ + + /** \brief Address family. \see VMCISock_GetAFValueFd() */ + sa_family_t svm_family; + + /** \cond PRIVATE */ + unsigned short svm_reserved1; + /** \endcond */ + + /** \brief Port. \see VMADDR_PORT_ANY */ + unsigned int svm_port; + + /** \brief Context ID. \see VMADDR_CID_ANY */ + unsigned int svm_cid; + + /** \cond PRIVATE */ + unsigned char svm_zero[sizeof(struct sockaddr) - +#if defined(__APPLE__) + sizeof(unsigned char) - +#endif // __APPLE__ + sizeof(sa_family_t) - + sizeof(unsigned short) - + sizeof(unsigned int) - + sizeof(unsigned int)]; + /** \endcond */ +}; +/* end code copied from vmci_sockets.h */ + + +/* + * Local version of htonll() which is missing in many environments. + * Assumes the host is little-endian. + */ +static uint64 +_vmxlog_htonll(uint64 s) +{ + uint64 out; + unsigned char *buf = (unsigned char *) &out; + + buf[0] = s >> 56 & 0xff; + buf[1] = s >> 48 & 0xff; + buf[2] = s >> 40 & 0xff; + buf[3] = s >> 32 & 0xff; + buf[4] = s >> 24 & 0xff; + buf[5] = s >> 16 & 0xff; + buf[6] = s >> 8 & 0xff; + buf[7] = s >> 0 & 0xff; + + return out; +} + + +/* + ****************************************************************************** + * VMXRPC_MakePacket -- */ /** + * + * Takes 'cmd' and builds an RPC packet out of it, putting in the + * length and header info (properly byte swapped). + * + * See bora-vmsoft/lib/rpcChannel/simpleSocket.c:Socket_PackSendData() + * + * retPacket contains the new packet, which must be g_free()d. + * Returns the size of the new packet. + * + * Returns -1 on failure, size of packet on success. + * + ****************************************************************************** + */ + +static int +VMXRPC_MakePacket(const char *cmd, + char **retPacket) +{ + int len; + int tlen; + uint32 plen; + uint32 slen; + char *packet = NULL; + char *p; + struct { + uint32 type; + uint32 fieldId; + uint64 value; + } hdr; + struct { + uint32 type; + uint32 fieldId; + uint64 value; + } flags; + struct { + uint32 type; + uint32 fieldId; + uint32 len; + } payload; + + *retPacket = NULL; + if (cmd == NULL) { + return -1; + } + + len = (int) strlen(cmd); + + /* network byte order is important here */ + hdr.type = htonl(1); // DMFIELDTYPE_INT64 + hdr.fieldId = htonl(1); // GUESTRPCPKT_FIELD_TYPE + hdr.value = _vmxlog_htonll(1); // GUESTRPCPKT_TYPE_DATA + + /* + * Adding the fast_close flag GUESTRPCPKT_FIELD_FAST_CLOSE in the packet + * to indicate vmx to close the channel as soon as the response is sent. + */ + flags.type = htonl(1); // DMFIELDTYPE_INT64 + flags.fieldId = htonl(3); // GUESTRPCPKT_FIELD_FAST_CLOSE + flags.value = _vmxlog_htonll(1); // GUESTRPCPKT_TYPE_DATA + + /* + * this part of the data doesn't seem to care about network byte + * order, but do it anyways. + */ + payload.type = htonl(2); // DMFIELDTYPE_STRING + payload.fieldId = htonl(2); // GUESTRPCPKT_FIELD_PAYLOAD + payload.len = htonl(len); // length of 'cmd' + + plen = sizeof(hdr) + sizeof(flags) + sizeof(payload) + len; + + tlen = plen + sizeof(int); + packet = (char *) g_malloc(tlen); + p = packet; + + /* use network byte order overall length */ + slen = htonl(plen); + memcpy(p, &slen, sizeof slen); + p += sizeof slen; + + memcpy(p, &hdr, sizeof hdr); + p += sizeof hdr; + memcpy(p, &flags, sizeof flags); + p += sizeof flags; + memcpy(p, &payload, sizeof payload); + p += sizeof payload; + memcpy(p, cmd, len); + + *retPacket = packet; + + return tlen; +} + + +/* + ****************************************************************************** + * GetAddressFamily -- */ /** + * + * Returns the vsock socket family on success, -1 on failure. + * + * This assumes modern vsock is in the kernel. + ****************************************************************************** + */ + +static int +GetAddressFamily(void) +{ +#ifdef _WIN32 + return __VMCISock_DeviceIoControl(VMCI_SOCKETS_GET_AF_VALUE); +#else + const int AF_VSOCK_LOCAL = 40; + int s = socket(AF_VSOCK_LOCAL, SOCK_DGRAM, 0); + if (s != -1) { + close(s); + return AF_VSOCK_LOCAL; + } + + return -1; +#endif +} + + +/* + ****************************************************************************** + * CreateVMCISocket -- */ /** + * + * Creates, binds and connects a socket to the VMX. + * + * @param[in] useSecure If TRUE, use bind to a reserved port locally to allow + * for a secure channel. + * + * Returns a new socket that should be close()d or -1 on failure. + * + ****************************************************************************** + */ + +static SOCKET +CreateVMCISocket(gboolean useSecure) +{ + struct sockaddr_vm localAddr; + struct sockaddr_vm addr; + int ret; + int errCode; + unsigned int localPort = PRIVILEGED_PORT_MAX; + SOCKET fd; + +again: + fd = socket(gAddressFamily, SOCK_STREAM, 0); + if (fd < 0) { + g_warning("%s: socket() failed %d\n", __FUNCTION__, GetSocketErrCode()); + return -1; + } + + memset(&localAddr, 0, sizeof localAddr); + localAddr.svm_family = gAddressFamily; +#ifdef _WIN32 + localAddr.svm_cid = __VMCISock_DeviceIoControl(VMCI_SOCKETS_GET_LOCAL_CID); +#else + localAddr.svm_cid = -1; +#endif + + if (useSecure) { + while (localPort >= PRIVILEGED_PORT_MIN) { + localAddr.svm_port = localPort; + ret = bind(fd, (struct sockaddr *)&localAddr, sizeof localAddr); + if (ret != 0) { + errCode = GetSocketErrCode(); + if (errCode == SYSERR_EADDRINUSE) { + g_debug("%s: bind() failed w/ ADDRINUSE, trying another port\n", + __FUNCTION__); + --localPort; + continue; /* Try next port */ + } else { + // unexpected failure, bail + g_warning("%s: bind() failed %d\n", __FUNCTION__, errCode); + goto err; + } + } else { + g_debug("%s: bind() worked for port %d\n", __FUNCTION__, localPort); + goto bound; + } + } + g_warning("%s: failed to find a bindable port\n", __FUNCTION__); + goto err; + } else { + localAddr.svm_port = VMADDR_PORT_ANY; + ret = bind(fd, (struct sockaddr *)&localAddr, sizeof localAddr); + if (ret != 0) { + g_warning("%s: bind() failed %d\n", __FUNCTION__, GetSocketErrCode()); + goto err; + } + } + +bound: + /* connect to destination */ + memset(&addr, 0, sizeof addr); + addr.svm_family = gAddressFamily; + addr.svm_cid = VMX_CID; + addr.svm_port = RPCI_PORT; + + ret = connect(fd, (struct sockaddr *)&addr, sizeof addr); + if (ret < 0) { + errCode = GetSocketErrCode(); + if (errCode == SYSERR_ECONNRESET) { + /* + * VMX might be slow releasing a port pair + * when another client closed the client side end. + * Simply try next port. + */ + g_debug("%s: connect() failed with RESET, trying another port\n", + __FUNCTION__); + localPort--; + Socket_Close(fd); + goto again; + } + g_warning("%s: connect() failed %d\n", __FUNCTION__, GetSocketErrCode()); + goto err; + } + + return fd; +err: + Socket_Close(fd); + + return -1; +} + + + +/* + ****************************************************************************** + * VMXRPC_Init -- */ /** + * + * Initializes VMX secure RPCs. + * + * Returns -1 on error, 1 on success. + * + ****************************************************************************** + */ + +int +VMXRPC_Init(void) +{ + if (gAddressFamily != -1) { + // already initted + return 1; + } +#ifdef _WIN32 + int ret; + WSADATA wsaData; + + ret = WSAStartup(MAKEWORD(2,0), &wsaData); + if (ret != 0) { + g_warning("%s: Failed to init winsock (%d)\n", __FUNCTION__, ret); + return -1; + } +#endif + gAddressFamily = GetAddressFamily(); + if (gAddressFamily < 0) { + g_warning("%s: Failed to set up VMX logging\n", __FUNCTION__); + return -1; + } + + return 1; +} + + +/* + ****************************************************************************** + * VMXRPC_SendRpc -- */ /** + * + * Sends RPC packet to the VMX. Returns any response if retBuf is + * non-NULL. + * + * @param[in] cmd RPC command + * @param[in] useSecure If TRUE, use bind to a reserved port locally to allow + * for a secure channel. + * @param[out] retBuf RPC reply. + * + * Returns -1 on failure, or the length of the returned reply on success (0 if + * retBuf is NULL). + * + ****************************************************************************** + */ + +int +VMXRPC_SendRpc(const gchar *cmd, + gboolean useSecure, + gchar **retBuf) +{ + SOCKET sock; + char *fullReply = NULL; + char *bp; + uint32 repLen; + uint32 curLen; + int ret; + int retVal = 0; + gchar *packet = NULL; + int packetLen; + struct { + uint32 len; + } hdr; + // bytes into the DataMap stream where the reply starts +#define REPLY_OFFSET 14 + + if (VMXRPC_Init() != 1) { + g_warning("%s: couldn't get VMCI address family\n", __FUNCTION__); + return -1; + } + + sock = CreateVMCISocket(useSecure); + if (sock < 0) { + g_warning("%s: failed to create VMCI socket\n", __FUNCTION__); + return -1; + } + + packetLen = VMXRPC_MakePacket(cmd, &packet); + if (packetLen <= 0) { + g_warning("%s: failed to build RPC packet\n", __FUNCTION__); + retVal = -1; + goto done; + } + + ret = send(sock, packet, packetLen, 0); + if (ret != packetLen) { + g_warning("%s: failed to send packet (%d)\n", + __FUNCTION__, GetSocketErrCode()); + retVal = -1; + goto done; + } + + // get the header, which is the length of the rest of the reply + ret = recv(sock, (char *) &hdr, sizeof hdr, 0); + if (ret != sizeof(hdr)) { + g_warning("%s: failed to read reply length (wanted %d, got %d) (%d)\n", + __FUNCTION__, (int) sizeof(hdr), ret, GetSocketErrCode()); + retVal = -1; + goto done; + } + repLen = ntohl(hdr.len); + g_debug("%s: reply len: %u\n", __FUNCTION__, repLen); + if (repLen < REPLY_OFFSET) { + g_warning("%s: reply len too small (%u)\n", + __FUNCTION__, repLen); + retVal = -1; + goto done; + } + // +1 to ensure a NUL at the end + fullReply = g_malloc0((sizeof(char) * repLen) + 1); + curLen = 0; + bp = fullReply; + // handle the case it somehow gets chopped up + while (curLen < repLen) { + ret = recv(sock, bp, repLen - curLen, 0); + if (ret < 0) { + g_warning("%s: failed to read reply packet (%d)\n", + __FUNCTION__, GetSocketErrCode()); + retVal = -1; + goto done; + } else if (ret == 0) { // unexpected EOF, fail + g_warning("%s: unexpected EOF, failing\n", __FUNCTION__); + retVal = -1; + goto done; + } + curLen += ret; + bp += ret; + } + +done: +#ifdef _WIN32 + closesocket(sock); +#else + close(sock); +#endif + if (retVal >= 0 && retBuf != NULL) { + // the useful part starts at REPLY_OFFSET after the DataMaps + *retBuf = g_strdup(fullReply + REPLY_OFFSET); + retVal = repLen - REPLY_OFFSET; + } + g_free(fullReply); + g_free(packet); + + return retVal; +} + + +#ifdef TEST +/* build test app with + * $ gcc -g -DTEST -I/usr/include/glib-2.0 \ + * -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -o /tmp/vmxrpc-test \ + * vmxrpc.c -lglib-2.0 + */ +int +main(int argc, char **argv) +{ + char *reply; + int ret; + + if (argc < 2) { + fprintf(stderr, "%s: needs an RPC arg\n", argv[0]); + exit(-1); + } + ret = VMXRPC_SendRpc(argv[1], TRUE, &reply); + if (ret < 0) { + fprintf(stderr, "%s: failed to send RPC\n", argv[0]); + exit(-1); + } else { + puts(reply); + g_free(reply); + } + exit(0); +} +#endif // TEST diff -Nru open-vm-tools-11.3.5/open-vm-tools/vgauth/common/vmxrpc.h open-vm-tools-12.1.5/open-vm-tools/vgauth/common/vmxrpc.h --- open-vm-tools-11.3.5/open-vm-tools/vgauth/common/vmxrpc.h 1970-01-01 00:00:00.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/vgauth/common/vmxrpc.h 2022-11-29 21:17:22.000000000 +0000 @@ -0,0 +1,33 @@ +/********************************************************* + * Copyright (C) 2022 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 + * by the Free Software Foundation version 2.1 and no later version. + * + * 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 Lesser GNU General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + *********************************************************/ + +#ifndef _VMXRPC_H_ +#define _VMXRPC_H_ + + +/* + * @file vmxrpc.h + * + * Support for RPCs to the VMX. + */ + +int VMXRPC_SendRpc(const gchar *cmd, gboolean useSecure, gchar **retBuf); + +int VMXRPC_Init(void); + +#endif // _VMXRPC_H_ diff -Nru open-vm-tools-11.3.5/open-vm-tools/vgauth/lib/netPosix.c open-vm-tools-12.1.5/open-vm-tools/vgauth/lib/netPosix.c --- open-vm-tools-11.3.5/open-vm-tools/vgauth/lib/netPosix.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/vgauth/lib/netPosix.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2011-2016,2019 VMware, Inc. All rights reserved. + * Copyright (C) 2011-2016,2019,2022 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 @@ -74,6 +74,8 @@ return VGAUTH_E_COMM; } + /* Ignore return, returns the length of the source string */ + /* coverity[check_return] */ g_strlcpy(sockaddr.sun_path, ctx->comm.pipeName, UNIX_PATH_MAX); do { diff -Nru open-vm-tools-11.3.5/open-vm-tools/vgauth/service/Makefile.am open-vm-tools-12.1.5/open-vm-tools/vgauth/service/Makefile.am --- open-vm-tools-11.3.5/open-vm-tools/vgauth/service/Makefile.am 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/vgauth/service/Makefile.am 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ ################################################################################ -### Copyright (C) 2014-2020 VMware, Inc. All rights reserved. +### Copyright (C) 2014-2020, 2022 VMware, Inc. All rights reserved. ### ### This program is free software; you can redistribute it and/or modify ### it under the terms of version 2 of the GNU General Public License as @@ -47,6 +47,7 @@ VGAuthService_SOURCES += ../common/VGAuthLog.c VGAuthService_SOURCES += ../common/VGAuthUtil.c VGAuthService_SOURCES += ../common/vmxlog.c +VGAuthService_SOURCES += ../common/vmxrpc.c VGAuthServicedir = /etc/vmware-tools/vgauth/schemas VGAuthService_SCRIPTS = diff -Nru open-vm-tools-11.3.5/open-vm-tools/vgauth/serviceImpl/netPosix.c open-vm-tools-12.1.5/open-vm-tools/vgauth/serviceImpl/netPosix.c --- open-vm-tools-11.3.5/open-vm-tools/vgauth/serviceImpl/netPosix.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/vgauth/serviceImpl/netPosix.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2011-2017, 2019-2021 VMware, Inc. All rights reserved. + * Copyright (C) 2011-2017, 2019-2022 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 @@ -151,8 +151,14 @@ sockaddr.sun_family = PF_UNIX; - g_unlink(conn->pipeName); + ret = g_unlink(conn->pipeName); + if (ret < 0 && errno != ENOENT) { + Warning("%s: unlink(%s) failed, %d - continuing\n", __FUNCTION__, + conn->pipeName, errno); + } + /* Ignore return, returns the length of the source string */ + /* coverity[check_return] */ g_strlcpy(sockaddr.sun_path, conn->pipeName, UNIX_PATH_MAX); ret = bind(sock, (struct sockaddr *) &sockaddr, sizeof sockaddr); @@ -304,6 +310,7 @@ void ServiceNetworkRemoveListenPipe(ServiceConnection *conn) { + /* coverity[check_return] */ ServiceFileUnlinkFile(conn->pipeName); } diff -Nru open-vm-tools-11.3.5/open-vm-tools/vgauth/serviceImpl/proto.c open-vm-tools-12.1.5/open-vm-tools/vgauth/serviceImpl/proto.c --- open-vm-tools-11.3.5/open-vm-tools/vgauth/serviceImpl/proto.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/vgauth/serviceImpl/proto.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2011-2016,2019-2021 VMware, Inc. All rights reserved. + * Copyright (C) 2011-2016,2019-2022 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 @@ -1201,6 +1201,10 @@ VGAuthError err; gboolean isSecure = ServiceNetworkIsConnectionPrivateSuperUser(conn); + if (conn->isPublic && req->reqType != PROTO_REQUEST_SESSION_REQ) { + return VGAUTH_E_PERMISSION_DENIED; + } + switch (req->reqType) { /* * This comes over the public connection; alwsys let it through. diff -Nru open-vm-tools-11.3.5/open-vm-tools/vgauth/serviceImpl/saml-xmlsec1.c open-vm-tools-12.1.5/open-vm-tools/vgauth/serviceImpl/saml-xmlsec1.c --- open-vm-tools-11.3.5/open-vm-tools/vgauth/serviceImpl/saml-xmlsec1.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/vgauth/serviceImpl/saml-xmlsec1.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2016-2021 VMware, Inc. All rights reserved. + * Copyright (C) 2016-2022 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 @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include #include @@ -53,6 +55,60 @@ #define CATALOG_FILENAME "catalog.xml" #define SAML_SCHEMA_FILENAME "saml-schema-assertion-2.0.xsd" + +/* + ****************************************************************************** + * UserXmlFileOpen -- */ /** + * + * User defined version of libxml2 export xmlFileOpen. + * + * This function opens a file with its unescaped name only. + * + * xmlInitParser() calls xmlRegisterDefaultInputCallbacks() which calls + * xmlRegisterInputCallbacks(xmlFileMatch, xmlFileOpen, + * xmlFileRead, xmlFileClose) + * + * UserXmlFileOpen is registered at the end of the xmlInputCallback table by + * xmlRegisterInputCallbacks(xmlFileMatch, UserXmlFileOpen, + * xmlFileRead, xmlFileClose) + * + * Based on libxml2 xmlIO.c, precedence is given to user defined handlers. + * + * @param[in] filename The URI file name. + * + * @return A handler or NULL in case of failure. + ****************************************************************************** + */ + +static void * +UserXmlFileOpen(const char *filename) +{ + char *unescaped; + void *retval = NULL; + + g_debug("%s: Incoming file name is \"%s\"\n", __FUNCTION__, filename); + + unescaped = xmlURIUnescapeString(filename, 0, NULL); + if (unescaped != NULL) { + g_debug("%s: Opening file \"%s\"\n", __FUNCTION__, unescaped); + retval = xmlFileOpen(unescaped); + xmlFree(unescaped); + } + + if (retval == NULL) { + g_warning("%s: Failed to open file \"%s\"\n", __FUNCTION__, filename); + /* + * Do not retry xmlFileOpen(filename) here. + * Calling system API to open escaped file paths is risky. This can + * cause unexpected not-secured paths being accessed and expose + * privilege escalation vulnerabilities. + */ + } + + return retval; +} + + /* * Hack to test expired tokens and by-pass the time checks. * @@ -204,9 +260,9 @@ catalogPath = g_build_filename(schemaDir, CATALOG_FILENAME, NULL); schemaPath = g_build_filename(schemaDir, SAML_SCHEMA_FILENAME, NULL); - xmlInitializeCatalog(); - /* + * Skip calling xmlInitializeCatalog(). + * * xmlLoadCatalog() just adds to the default catalog, and won't return an * error if it doesn't exist so long as a default catalog is set. * @@ -355,6 +411,12 @@ xmlSetGenericErrorFunc(NULL, XmlErrorHandler); /* + * Register user defined UserXmlFileOpen + */ + xmlRegisterInputCallbacks(xmlFileMatch, UserXmlFileOpen, + xmlFileRead, xmlFileClose); + + /* * Load schemas */ if (!LoadCatalogAndSchema()) { diff -Nru open-vm-tools-11.3.5/open-vm-tools/vgauth/serviceImpl/schemas/saml-schema-assertion-2.0.xsd open-vm-tools-12.1.5/open-vm-tools/vgauth/serviceImpl/schemas/saml-schema-assertion-2.0.xsd --- open-vm-tools-11.3.5/open-vm-tools/vgauth/serviceImpl/schemas/saml-schema-assertion-2.0.xsd 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/vgauth/serviceImpl/schemas/saml-schema-assertion-2.0.xsd 2022-11-29 21:17:22.000000000 +0000 @@ -1,283 +1,283 @@ - - - - - - - Document identifier: saml-schema-assertion-2.0 - Location: http://docs.oasis-open.org/security/saml/v2.0/ - Revision history: - V1.0 (November, 2002): - Initial Standard Schema. - V1.1 (September, 2003): - Updates within the same V1.0 namespace. - V2.0 (March, 2005): - New assertion schema for SAML V2.0 namespace. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + Document identifier: saml-schema-assertion-2.0 + Location: http://docs.oasis-open.org/security/saml/v2.0/ + Revision history: + V1.0 (November, 2002): + Initial Standard Schema. + V1.1 (September, 2003): + Updates within the same V1.0 namespace. + V2.0 (March, 2005): + New assertion schema for SAML V2.0 namespace. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -Nru open-vm-tools-11.3.5/open-vm-tools/vmblock-fuse/fsops.c open-vm-tools-12.1.5/open-vm-tools/vmblock-fuse/fsops.c --- open-vm-tools-11.3.5/open-vm-tools/vmblock-fuse/fsops.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/vmblock-fuse/fsops.c 2022-11-29 21:17:22.000000000 +0000 @@ -65,6 +65,14 @@ static vmblockSpecialDirEntry notifyDirEntry = { NOTIFY_DIR "/*", S_IFREG | 0444, 1, 0 }; +#if FUSE_MAJOR_VERSION == 3 +#define CALL_FUSE_FILLER(buf, name, stbuf, off, flags) \ + filler(buf, name, stbuf, off, flags) +#else +#define CALL_FUSE_FILLER(buf, name, stbuf, off, flags) \ + filler(buf, name, stbuf, off) +#endif + /* *----------------------------------------------------------------------------- * @@ -248,9 +256,16 @@ *----------------------------------------------------------------------------- */ +#if FUSE_MAJOR_VERSION == 3 +int +VMBlockGetAttr(const char *path, // IN: File to get attributes of. + struct stat *statBuf, // OUT: Where to put the attributes. + struct fuse_file_info *fi) // IN: Ignored +#else int VMBlockGetAttr(const char *path, // IN: File to get attributes of. struct stat *statBuf) // OUT: Where to put the attributes. +#endif { vmblockSpecialDirEntry *dirEntry; ASSERT(path != NULL); @@ -362,7 +377,7 @@ errno = 0; while ((dentry = readdir(dir)) != NULL) { - status = filler(buf, dentry->d_name, &statBuf, 0); + status = CALL_FUSE_FILLER(buf, dentry->d_name, &statBuf, 0, 0); if (status == 1) { break; } @@ -408,6 +423,17 @@ *----------------------------------------------------------------------------- */ +#if FUSE_MAJOR_VERSION == 3 +int +VMBlockReadDir(const char *path, // IN: Directory to read. + void *buf, // OUT: Where to put directory + // listing. + fuse_fill_dir_t filler, // IN: Function to add an entry + // to buf. + off_t offset, // IN: Ignored. + struct fuse_file_info *fileInfo, // IN: Ignored. + enum fuse_readdir_flags flags) // IN: Ignored. +#else int VMBlockReadDir(const char *path, // IN: Directory to read. void *buf, // OUT: Where to put directory @@ -416,6 +442,7 @@ // to buf. off_t offset, // IN: Ignored. struct fuse_file_info *fileInfo) // IN: Ignored. +#endif { struct stat fileStat; struct stat dirStat; @@ -433,11 +460,11 @@ dirStat.st_mode = S_IFDIR; if (strcmp(path, "/") == 0) { - (void)(filler(buf, ".", &dirStat, 0) || - filler(buf, "..", &dirStat, 0) || - filler(buf, VMBLOCK_DEVICE_NAME, &fileStat, 0) || - filler(buf, REDIRECT_DIR_NAME, &dirStat, 0) || - filler(buf, NOTIFY_DIR_NAME, &dirStat, 0)); + (void)(CALL_FUSE_FILLER(buf, ".", &dirStat, 0, 0) || + CALL_FUSE_FILLER(buf, "..", &dirStat, 0, 0) || + CALL_FUSE_FILLER(buf, VMBLOCK_DEVICE_NAME, &fileStat, 0, 0) || + CALL_FUSE_FILLER(buf, REDIRECT_DIR_NAME, &dirStat, 0, 0) || + CALL_FUSE_FILLER(buf, NOTIFY_DIR_NAME, &dirStat, 0, 0)); return 0; } else if ( (strcmp(path, REDIRECT_DIR) == 0) || (strcmp(path, NOTIFY_DIR) == 0)) { @@ -764,8 +791,19 @@ *----------------------------------------------------------------------------- */ +#if FUSE_MAJOR_VERSION == 3 +void * +VMBlockInit(struct fuse_conn_info *conn, + struct fuse_config *config) +#else +#if FUSE_USE_VERSION < 26 void * VMBlockInit(void) +#else +void * +VMBlockInit(struct fuse_conn_info *conn) +#endif +#endif { BlockInit(); return NULL; diff -Nru open-vm-tools-11.3.5/open-vm-tools/vmblock-fuse/fsops.h open-vm-tools-12.1.5/open-vm-tools/vmblock-fuse/fsops.h --- open-vm-tools-11.3.5/open-vm-tools/vmblock-fuse/fsops.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/vmblock-fuse/fsops.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2008-2018 VMware, Inc. All rights reserved. + * Copyright (C) 2008-2018,2021 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 @@ -31,12 +31,18 @@ #define _VMBLOCK_FUSE_H_ /* + * FUSE_USE_VERSION must be set before the fuse or fuse3 headers are + * included. If undefined, fall back to previous default used. + */ +#ifndef FUSE_USE_VERSION +/* * FUSE_USE_VERSION sets the version of the FUSE API that will be exported. * Version 25 is the newest version supported by the libfuse in our toolchain * as of 2008-07. */ - #define FUSE_USE_VERSION 25 +#endif + #include #include "vmblock.h" @@ -55,9 +61,18 @@ */ int VMBlockReadLink(const char *path, char *buf, size_t bufSize); + +#if FUSE_MAJOR_VERSION == 3 +int VMBlockGetAttr(const char *path, struct stat *statBuf, + struct fuse_file_info *fi); +int VMBlockReadDir(const char *path, void *buf, fuse_fill_dir_t filler, + off_t offset, struct fuse_file_info *fileInfo, + enum fuse_readdir_flags); +#else int VMBlockGetAttr(const char *path, struct stat *statBuf); int VMBlockReadDir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fileInfo); +#endif int VMBlockOpen(const char *path, struct fuse_file_info *fileInfo); int VMBlockWrite(const char *path, const char *buf, size_t size, off_t offset, struct fuse_file_info *fileInfo); diff -Nru open-vm-tools-11.3.5/open-vm-tools/vmblock-fuse/main.c open-vm-tools-12.1.5/open-vm-tools/vmblock-fuse/main.c --- open-vm-tools-11.3.5/open-vm-tools/vmblock-fuse/main.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/vmblock-fuse/main.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2008-2016 VMware, Inc. All rights reserved. + * Copyright (C) 2008-2016,2021 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 @@ -66,5 +66,9 @@ LOGLEVEL_THRESHOLD = 4; } } +#if FUSE_USE_VERSION < 26 return fuse_main(argc, argv, &vmblockOperations); +#else + return fuse_main(argc, argv, &vmblockOperations, NULL); +#endif } diff -Nru open-vm-tools-11.3.5/open-vm-tools/vmblock-fuse/Makefile.am open-vm-tools-12.1.5/open-vm-tools/vmblock-fuse/Makefile.am --- open-vm-tools-11.3.5/open-vm-tools/vmblock-fuse/Makefile.am 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/vmblock-fuse/Makefile.am 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ ################################################################################ -### Copyright (C) 2008-2016 VMware, Inc. All rights reserved. +### Copyright (c) 2008-2016,2021 VMware, Inc. All rights reserved. ### ### This program is free software; you can redistribute it and/or modify ### it under the terms of version 2 of the GNU General Public License as @@ -29,12 +29,14 @@ AM_CFLAGS += -DUSERLEVEL AM_CFLAGS += -D_FILE_OFFSET_BITS=64 AM_CFLAGS += @FUSE_CPPFLAGS@ +AM_CFLAGS += @FUSE3_CPPFLAGS@ AM_CFLAGS += @GLIB2_CPPFLAGS@ AM_CFLAGS += -I$(top_srcdir)/modules/shared/vmblock AM_CFLAGS += -I$(srcdir) vmware_vmblock_fuse_LDADD = vmware_vmblock_fuse_LDADD += @FUSE_LIBS@ +vmware_vmblock_fuse_LDADD += @FUSE3_LIBS@ vmware_vmblock_fuse_LDADD += @GLIB2_LIBS@ vmware_vmblock_fuse_SOURCES = diff -Nru open-vm-tools-11.3.5/open-vm-tools/vmhgfs-fuse/config.c open-vm-tools-12.1.5/open-vm-tools/vmhgfs-fuse/config.c --- open-vm-tools-11.3.5/open-vm-tools/vmhgfs-fuse/config.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/vmhgfs-fuse/config.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2015-2018 VMware, Inc. All rights reserved. + * Copyright (C) 2015-2018,2021 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 @@ -22,6 +22,7 @@ */ #include "module.h" +#include #include #ifdef VMX86_DEVEL @@ -76,8 +77,10 @@ VMHGFS_OPT("-l %i", logLevel, 4), #endif /* We will change the default value, unless it is specified explicitly. */ +#if FUSE_MAJOR_VERSION != 3 FUSE_OPT_KEY("big_writes", KEY_BIG_WRITES), FUSE_OPT_KEY("nobig_writes", KEY_NO_BIG_WRITES), +#endif FUSE_OPT_KEY("-V", KEY_VERSION), FUSE_OPT_KEY("--version", KEY_VERSION), @@ -131,8 +134,13 @@ #define LIB_MODULEPATH "/lib/modules" #define MODULES_DEP "modules.dep" +#if FUSE_MAJOR_VERSION == 3 +#define FUSER_MOUNT_BIN "/bin/fusermount3" +#define FUSER_MOUNT_USR_BIN "/usr/bin/fusermount3" +#else #define FUSER_MOUNT_BIN "/bin/fusermount" #define FUSER_MOUNT_USR_BIN "/usr/bin/fusermount" +#endif #define PROC_FILESYSTEMS "/proc/filesystems" #define FUSER_KERNEL_FS "fuse" @@ -406,7 +414,9 @@ int key, // IN struct fuse_args *outargs) // OUT { +#if FUSE_MAJOR_VERSION != 3 struct vmhgfsConfig *config = data; +#endif switch (key) { case FUSE_OPT_KEY_NONOPT: @@ -434,6 +444,7 @@ } return 1; +#if FUSE_MAJOR_VERSION != 3 case KEY_BIG_WRITES: config->addBigWrites = TRUE; return 0; @@ -441,11 +452,18 @@ case KEY_NO_BIG_WRITES: config->addBigWrites = FALSE; return 0; +#endif case KEY_HELP: Usage(outargs->argv[0]); +#if FUSE_MAJOR_VERSION != 3 fuse_opt_add_arg(outargs, "-ho"); fuse_main(outargs->argc, outargs->argv, NULL, NULL); +#else + fprintf(stdout, "FUSE options:\n"); + fuse_cmdline_help(); + fuse_lib_help(outargs); +#endif exit(1); case KEY_ENABLED_FUSE: { @@ -496,8 +514,8 @@ #ifdef VMX86_DEVEL config.logLevel = LOGLEVEL_THRESHOLD; #endif -#ifdef __APPLE__ - /* osxfuse does not have option 'big_writes'. */ +#if defined(__APPLE__) || FUSE_MAJOR_VERSION == 3 + /* osxfuse and fuse3 does not have option 'big_writes'. */ config.addBigWrites = FALSE; #else config.addBigWrites = TRUE; diff -Nru open-vm-tools-11.3.5/open-vm-tools/vmhgfs-fuse/dir.c open-vm-tools-12.1.5/open-vm-tools/vmhgfs-fuse/dir.c --- open-vm-tools-11.3.5/open-vm-tools/vmhgfs-fuse/dir.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/vmhgfs-fuse/dir.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2013,2019 VMware, Inc. All rights reserved. + * Copyright (C) 2013,2019,2021 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 @@ -396,7 +396,11 @@ st.st_size = attr.size; st.st_ino = ino; st.st_mode = d_type << 12; +#if FUSE_MAJOR_VERSION == 3 + result = filldir(vfsDirent, escName, &st, 0, 0); +#else result = filldir(vfsDirent, escName, &st, 0); +#endif if (result) { /* diff -Nru open-vm-tools-11.3.5/open-vm-tools/vmhgfs-fuse/main.c open-vm-tools-12.1.5/open-vm-tools/vmhgfs-fuse/main.c --- open-vm-tools-11.3.5/open-vm-tools/vmhgfs-fuse/main.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/vmhgfs-fuse/main.c 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2013 VMware, Inc. All rights reserved. + * Copyright (C) 2013,2021 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 @@ -22,10 +22,6 @@ * Main entry points for fuse file operations for HGFS */ -#if FUSE_USE_VERSION >= 26 -#define HAVE_UTIMENSAT 1 -#endif - #include "module.h" #include "cache.h" #include "filesystem.h" @@ -119,9 +115,16 @@ *---------------------------------------------------------------------- */ +#if FUSE_MAJOR_VERSION == 3 +static int +hgfs_getattr(const char *path, //IN: path of a file/directory + struct stat *stbuf, //IN/OUT: file/directoy attribute + struct fuse_file_info *fi) //IN/OUT: Unused +#else static int hgfs_getattr(const char *path, //IN: path of a file/directory struct stat *stbuf) //IN/OUT: file/directoy attribute +#endif { HgfsHandle fileHandle = HGFS_INVALID_HANDLE; HgfsAttrInfo newAttr = {0}; @@ -365,12 +368,22 @@ *---------------------------------------------------------------------- */ +#if FUSE_MAJOR_VERSION == 3 +static int +hgfs_readdir(const char *path, //IN: path to a directory + void *buf, //OUT: buffer to fill the dir entry + fuse_fill_dir_t filler, //IN: function pointer to fill buf + off_t offset, //IN: offset to read the dir + struct fuse_file_info *fi, //IN: file info set by open call + enum fuse_readdir_flags flags) //IN: unused +#else static int hgfs_readdir(const char *path, //IN: path to a directory void *buf, //OUT: buffer to fill the dir entry fuse_fill_dir_t filler, //IN: function pointer to fill buf off_t offset, //IN: offset to read the dir struct fuse_file_info *fi) //IN: file info set by open call +#endif { char *abspath = NULL; int res = 0; @@ -602,9 +615,16 @@ *---------------------------------------------------------------------- */ +#if FUSE_MAJOR_VERSION == 3 +static int +hgfs_rename(const char *from, //IN: from path name + const char *to, //IN: to path name + unsigned int flags) //IN: unused +#else static int hgfs_rename(const char *from, //IN: from path name const char *to) //IN: to path name +#endif { char *absfrom = NULL; char *absto = NULL; @@ -695,9 +715,16 @@ *---------------------------------------------------------------------- */ +#if FUSE_MAJOR_VERSION == 3 +static int +hgfs_chmod(const char *path, //IN: path to a file + mode_t mode, //IN: mode to set + struct fuse_file_info *fi) //IN/OUT: unused +#else static int hgfs_chmod(const char *path, //IN: path to a file mode_t mode) //IN: mode to set +#endif { char *abspath = NULL; int res; @@ -760,10 +787,18 @@ *---------------------------------------------------------------------- */ +#if FUSE_MAJOR_VERSION == 3 +static int +hgfs_chown(const char *path, //IN: Path to a file + uid_t uid, //IN: User id + gid_t gid, //IN: Group id + struct fuse_file_info *fi) //IN/OUT: unused +#else static int hgfs_chown(const char *path, //IN: Path to a file uid_t uid, //IN: User id gid_t gid) //IN: Group id +#endif { HgfsHandle fileHandle = HGFS_INVALID_HANDLE; HgfsAttrInfo newAttr = {0}; @@ -823,9 +858,16 @@ *---------------------------------------------------------------------- */ +#if FUSE_MAJOR_VERSION == 3 +static int +hgfs_truncate(const char *path, //IN: path to a file + off_t size, //IN: new size + struct fuse_file_info *fi) //IN/OUT: unused +#else static int hgfs_truncate(const char *path, //IN: path to a file off_t size) //IN: new size +#endif { HgfsHandle fileHandle = HGFS_INVALID_HANDLE; HgfsAttrInfo newAttr = {0}; @@ -884,14 +926,15 @@ *---------------------------------------------------------------------- */ -#ifdef HAVE_UTIMENSAT +#if FUSE_MAJOR_VERSION == 3 static int hgfs_utimens(const char *path, //IN: path to a file - const struct timespec ts[2]) //IN: new time + const struct timespec ts[2], //IN: new time + struct fuse_file_info *fi) //IN/OUT: unused #else static int -hgfs_utime(const char *path, //IN: path to a file - struct utimbuf *times) //IN: new time +hgfs_utimens(const char *path, //IN: path to a file + const struct timespec ts[2]) //IN: new time #endif { HgfsHandle fileHandle = HGFS_INVALID_HANDLE; @@ -936,17 +979,10 @@ attr->mask = (HGFS_ATTR_VALID_WRITE_TIME | HGFS_ATTR_VALID_ACCESS_TIME); -#ifdef HAVE_UTIMENSAT accessTimeSec = ts[0].tv_sec; accessTimeNsec = ts[0].tv_nsec; writeTimeSec = ts[1].tv_sec; writeTimeNsec = ts[1].tv_nsec; -#else - accessTimeSec = times->actime; - accessTimeNsec = 0; - writeTimeSec = times->modtime; - writeTimeNsec = 0; -#endif attr->accessTime = HgfsConvertToNtTime(accessTimeSec, accessTimeNsec); attr->writeTime = HgfsConvertToNtTime(writeTimeSec, writeTimeNsec); @@ -1249,8 +1285,14 @@ *---------------------------------------------------------------------- */ +#if FUSE_MAJOR_VERSION == 3 +static void* +hgfs_init(struct fuse_conn_info *conn, // IN: unused + struct fuse_config *cfg) // IN/OUT: unused +#else static void* hgfs_init(struct fuse_conn_info *conn) // IN: unused +#endif { pthread_t purgeCacheThread; int dummy; @@ -1335,11 +1377,7 @@ .chmod = hgfs_chmod, .chown = hgfs_chown, .truncate = hgfs_truncate, -#ifdef HAVE_UTIMENSAT .utimens = hgfs_utimens, -#else // HAVE_UTIMENSAT - .utime = hgfs_utime, -#endif // defined HAVE_UTIMENSAT .open = hgfs_open, .read = hgfs_read, .write = hgfs_write, diff -Nru open-vm-tools-11.3.5/open-vm-tools/vmhgfs-fuse/Makefile.am open-vm-tools-12.1.5/open-vm-tools/vmhgfs-fuse/Makefile.am --- open-vm-tools-11.3.5/open-vm-tools/vmhgfs-fuse/Makefile.am 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/vmhgfs-fuse/Makefile.am 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ ################################################################################ -### Copyright (C) 2015-2016 VMware, Inc. All rights reserved. +### Copyright (c) 2015-2016,2021 VMware, Inc. All rights reserved. ### ### This program is free software; you can redistribute it and/or modify ### it under the terms of version 2 of the GNU General Public License as @@ -19,10 +19,12 @@ AM_CFLAGS = AM_CFLAGS += @FUSE_CPPFLAGS@ +AM_CFLAGS += @FUSE3_CPPFLAGS@ AM_CFLAGS += @GLIB2_CPPFLAGS@ vmhgfs_fuse_LDADD = vmhgfs_fuse_LDADD += @FUSE_LIBS@ +vmhgfs_fuse_LDADD += @FUSE3_LIBS@ vmhgfs_fuse_LDADD += @GLIB2_LIBS@ vmhgfs_fuse_LDADD += @VMTOOLS_LIBS@ diff -Nru open-vm-tools-11.3.5/open-vm-tools/vmhgfs-fuse/module.h open-vm-tools-12.1.5/open-vm-tools/vmhgfs-fuse/module.h --- open-vm-tools-11.3.5/open-vm-tools/vmhgfs-fuse/module.h 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/vmhgfs-fuse/module.h 2022-11-29 21:17:22.000000000 +0000 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2013 VMware, Inc. All rights reserved. + * Copyright (C) 2013,2021 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 @@ -25,7 +25,13 @@ #ifndef _VMHGFS_FUSE_MODULE_H_ #define _VMHGFS_FUSE_MODULE_H_ -#define FUSE_USE_VERSION 29 +/* + * FUSE_USE_VERSION must be set before the fuse or fuse3 headers are + * included. If undefined, fall back to previous default used. + */ +#ifndef FUSE_USE_VERSION +# define FUSE_USE_VERSION 29 +#endif #include #include "hgfsUtil.h" diff -Nru open-vm-tools-11.3.5/open-vm-tools/vmwgfxctrl/main.c open-vm-tools-12.1.5/open-vm-tools/vmwgfxctrl/main.c --- open-vm-tools-11.3.5/open-vm-tools/vmwgfxctrl/main.c 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/open-vm-tools/vmwgfxctrl/main.c 2022-11-29 21:17:22.000000000 +0000 @@ -59,7 +59,8 @@ /* The DRM device we are looking for */ #define VMWGFXCTRL_VENDOR "0x15ad" -#define VMWGFXCTRL_DEVICE "0x0405" +#define VMWGFXCTRL_SVGA2_DEVICE "0x0405" +#define VMWGFXCTRL_SVGA3_DEVICE "0x0406" #define VMWGFXCTRL_KERNELNAME "vmwgfx" /* Required DRM version for resolutionKMS */ @@ -136,7 +137,8 @@ } if (strcmp(vendor, VMWGFXCTRL_VENDOR) != 0 || - strcmp(device, VMWGFXCTRL_DEVICE) != 0) { + (strcmp(device, VMWGFXCTRL_SVGA2_DEVICE) != 0 && + strcmp(device, VMWGFXCTRL_SVGA3_DEVICE) != 0)) { goto skipCheck; } diff -Nru open-vm-tools-11.3.5/README.md open-vm-tools-12.1.5/README.md --- open-vm-tools-11.3.5/README.md 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/README.md 2022-11-29 21:17:22.000000000 +0000 @@ -90,11 +90,68 @@ sudo ldconfig ``` +### Service Discovery (sdmp) plugin To build the optional sdmp (Service Discovery) plugin use the `--enable-servicediscovery` option to invoke the configure script: ``` ./configure --enable-servicediscovery ``` +### The open-vm-tools 12.0.0 release introduces an optional setup script and two plugins (one optional) + + * Salt Minion Setup + * Component Manager plugin + * ContainerInfo plugin (optional) + +### Salt Minion Setup +The Salt support on Linux consists of a single bash script to setup Salt Minion on VMware virtual machines. The script requires the "curl" and "awk" commands to be available on the system. + +Linux providers supplying open-vm-tools packages are recommended to provide Salt Minion support in a separate optional package - "open-vm-tools-salt-minion". + +To include the Salt Minion Setup in the open-vm-tools build use the `--enable-salt-minion` option when invoking the configure script. +``` +./configure --enable-salt-minion +``` + +### Component Manager (componentMgr) plugin +The component Manager manages a preconfigured set of components available from VMware that can be made available on the Linux guest. Currently the only component that can be managed is the Salt Minion Setup. + +### ContainerInfo (containerInfo) plugin +The optional containerInfo plugin retrieves a list of the containers running on a Linux guest and publishes the list to the guest variable "**guestinfo.vmtools.containerinfo**" in JSON format. The containerInfo plugin communicates with the containerd daemon using gRPC to retrieve the desired information. For containers that are managed by Docker, the plugin uses libcurl to communicate with the Docker daemon and get the names of the containers. + +Since this plugin requires additional build and runtime dependencies, Linux vendors are recommended to release it in a separate, optional package - "open-vm-tools-containerinfo". This avoids unnecessary dependencies for customers not using the feature. + +#### Canonical, Debian, Ubuntu Linux +| Build Dependencies | Runtime | +|:------------------------:|:----------------:| +| `libcurl4-openssl-dev` | `curl` | +| `protobuf-compiler` | `protobuf` | +| `libprotobuf-dev` | `grpc++` | +| `protobuf-compiler-grpc` | +| `libgrpc++-dev` | +| `golang-github-containerd-containerd-dev` | +| `golang-github-gogo-protobuf-dev` | + +#### Fedora, Red Hat Enterprise Linux, ... +| Build Dependencies | Runtime | +|:------------------------:|:----------------:| +| `libcurl-devel` | `curl` | +| `protobuf-compiler` | `protobuf` | +| `protobuf-devel` | `grpc-cpp` | +| `grpc-plugins` | +| `grpc-devel` | +| `containerd-devel` | + + +#### Configuring the build for the ContainerInfo plugin +The configure script defaults to building the ContainerInfo when all the needed dependencies are available. ContainerInfo will not be built if there are missing dependencies. Invoke the configure script with `--enable-containerinfo=no` to explicitly inhibit building the plugin. +``` +./configure --enable-containerinfo=no +``` +If the configure script is given the option `--enable-containerinfo=yes` and any necessary dependency is not available, the configure script will terminate with an error. +``` +./configure --enable-containerinfo=yes +``` + ## Getting configure options and help If you are looking for help or additional settings for the building of this project, the following configure command will display a list of help options: ``` @@ -118,6 +175,9 @@ * Oracle Linux 7 and later * Fedora 19 and later releases * openSUSE 11.x and later releases + * Flatcar Container Linux, all releases + * Rocky 8 and later releases + * AlmaLinux OS 8 and later releases ## Will external developers be allowed to become committers to the project? Yes. Initially, VMware engineers will be the only committers. As we roll out our development infrastructure, we will be looking to add external committers to the project as well. @@ -137,6 +197,21 @@ Scan and email it to oss-queries_at_vmware.com Agreement: http://open-vm-tools.sourceforge.net/files/vca.pdf +## My version of Linux is not recognized. How do I add my Linux name to the known list? + +The open-vm-tools source contains a table mapping the guest distro name to the officially recognized short name. __Please do not submit pull requests altering this table and associated code.__ Any changes here must be accompanied by additional changes in the VMware host. Values that are not recognized by the VMware host will be ignored. + + +Use the appropriate generic Linux designation when configuring a VM for your Linux version. The selection available will vary by virtual hardware version being used. +- Other 5.x or later Linux (64-bit) +- Other 5.x or later Linux (32-bit) +- Other 4.x Linux (64-bit) +- Other 4.x Linux (32-bit) +- Other 3.x Linux (64-bit) +- Other 3.x Linux (32-bit) +- Other Linux (64-bit) +- Other Linux (32-bit) + # Compatibilty ## What Operating Systems are supported for customization? diff -Nru open-vm-tools-11.3.5/ReleaseNotes.md open-vm-tools-12.1.5/ReleaseNotes.md --- open-vm-tools-11.3.5/ReleaseNotes.md 2021-09-24 04:19:18.000000000 +0000 +++ open-vm-tools-12.1.5/ReleaseNotes.md 2022-11-29 21:17:22.000000000 +0000 @@ -1,8 +1,8 @@ -# Open-vm-tools 11.3.5 Release Notes +# open-vm-tools 12.1.5 Release Notes -Updated on: 23 SEP 2021 +Updated on: 29th NOV 2022 -Open-vm-tools | 23 SEP 2021 | Build 18557794 +open-vm-tools | 29th NOV 2022 | Build 20735119 Check back for additions and updates to these release notes. @@ -10,95 +10,74 @@ The release notes cover the following topics: -* [What's New](#whatsnew) -* [Internationalization](#internationalization) -* [End of Feature Support Notice](#endoffeaturesupport) -* [Guest Operating System Customization Support](#guestop) -* [Interoperability Matrix](#interop) -* [Resolved Issues](#resolved-issues) -* [Known Issues](#known-issues) +* [What's New](#whatsnew) +* [Internationalization](#i18n) +* [End of Feature Support Notice](#endoffeaturesupport) +* [Guest Operating System Customization Support](#guestop) +* [Interoperability Matrix](#interop) +* [Resolved Issues](#resolvedissues) +* [Known Issues](#knownissues) ## What's New -* **For issues resolved in this release, see [Resolved Issues](#resolved-issues) section.** +There are no new features in the open-vm-tools 12.1.5 release. This is primarily a maintenance release that addresses a few critical problems. -* **Added a configurable logging capability to the `network` script.** +* Please see the [Resolved Issues](#resolvedissues) and [Known Issues](#knownissues) sections below. - The `network` script has been updated to: - - use `vmware-toolbox-cmd` to query any network logging configuration from the `tools.conf` file. - - use `vmtoolsd --cmd "log ..."` to log a message to the vmx logfile when the logging handler is configured to "vmx" or when the logfile is full or is not writeable. +* A complete list of the granular changes in the open-vm-tools 12.1.5 release is available at: -* **The hgfsmounter (`mount.vmhgfs`) command has been removed from open-vm-tools.** + [open-vm-tools ChangeLog](https://github.com/vmware/open-vm-tools/blob/stable-12.1.5/open-vm-tools/ChangeLog) - The hgfsmounter (`mount.vmhgfs`) command is no longer used in Linux open-vm-tools. It has been replaced by hgfs-fuse. Therefore, removing all references to the hgfsmounter in Linux builds. +## Internationalization -## Internationalization +open-vm-tools 12.1.5 is available in the following languages: -Open-vm-tools 11.3.5 is available in the following languages: +* English +* French +* German +* Spanish +* Italian +* Japanese +* Korean +* Simplified Chinese +* Traditional Chinese -* English -* French -* German -* Spanish -* Italian -* Japanese -* Korean -* Simplified Chinese -* Traditional Chinese - -## End of Feature Support Notice - -* The tar tools (linux.iso) and OSPs shipped with VMware Tools 10.3.x release will continue to be supported. However, releases after VMware Tools 10.3.5 will only include critical and security fixes. No new feature support will be provided in these types of VMware Tools (tar tools and OSP's). It is recommended that customers use open-vm-tools for those operating systems that support open-vm-tools. For more information on different types of VMware Tools, see [https://blogs.vmware.com/vsphere/2016/02/understanding-the-three-types-of-vm-tools.html](https://blogs.vmware.com/vsphere/2016/02/understanding-the-three-types-of-vm-tools.html) +## Interoperability Matrix -## Guest Operating System Customization Support +The [VMware Product Interoperability Matrix](http://partnerweb.vmware.com/comp_guide2/sim/interop_matrix.php) provides details about the compatibility of current and earlier versions of VMware Products.  -The [Guest OS Customization Support Matrix](http://partnerweb.vmware.com/programs/guestOS/guest-os-customization-matrix.pdf) provides details about the guest operating systems supported for customization. +## Resolved Issues -## Interoperability Matrix +* **A number of Coverity reported issues have been addressed.** -The [VMware Product Interoperability Matrix](http://partnerweb.vmware.com/comp_guide2/sim/interop_matrix.php) provides details about the compatibility of current and earlier versions of VMware Products. +* **The deployPkg plugin may prematurely reboot the guest VM before cloud-init has completed user data setup.** -## Resolved Issues + If both the Perl based Linux customization script and cloud-init run when the guest VM boots, the deployPkg plugin may reboot the guest before cloud-init has finished. The deployPkg plugin has been updated to wait for a running cloud-init process to finish before the guest VM reboot is initiated. -* **Customization: Retry the Linux reboot if `telinit` is a soft link to systemctl -.** + This issue is fixed in this release. - Issues have been reported on some newer versions of Linux where the VM failed to reboot at the end of a traditional customization. The command '/sbin/telinit 6' exited abnormally due to SIGTERM sent by systemd and where `telinit` is a symlink to systemctl. +* **A SIGSEGV may be encountered when a non-quiesing snapshot times out.** - This issue is fixed in the 11.3.5 open-vm-tools release. + This issue is fixed in this release. -* **Open-vm-tools commands would hang if configured with "--enable-valgrind".** +* **Unwanted vmtoolsd service error message if not on a VMware hypervisor.** - The "backdoor" touch test cannot be handled by Valgrind. + When open-vm-tools comes preinstalled in a base Linux release, the vmtoolsd services are started automatically at system start and desktop login. If running on physical hardware or in a non-VMware hypervisor, the services will emit an error message to the Systemd's logging service before stopping. - This issue is fixed in the 11.3.5 open-vm-tools release. + This issue is fixed in this release. -## Known Issues +## Known Issues -**Open-vm-tools Issues in VMware Workstation or Fusion** * **Shared Folders mount is unavailable on Linux VM.** If the **Shared Folders** feature is enabled on a Linux VM while it is powered off, the shared folders mount is not available on restart. - Note: This issue is applicable to open-vm-tools running on Workstation and Fusion. + Note: This issue is applicable to open-vm-tools running on VMware Workstation and VMware Fusion. Workaround: - If the VM is powered on, disable and enable the **Shared Folders** feature from the interface. For resolving the issue permanently, edit **/etc/fstab** and add an entry to mount the Shared Folders automatically on boot. - - For example, add the line: + If the VM is powered on, disable and enable the **Shared Folders** feature from the interface. For resolving the issue permanently, edit **/etc/fstab** and add an entry to mount the Shared Folders automatically on boot. For example, add the line: vmhgfs-fuse /mnt/hgfs fuse defaults,allow_other 0 0 -* **Drag functionality fails to work in Ubuntu.** - - Drag functionality fails to work in Ubuntu 16.04.4 32-bit virtual machines installed using Easy Install. Also, failure of the copy and paste functionality is observed in the same systems. - - Note: This issue is applicable to open-vm-tools running on Workstation and Fusion. - - Workaround: - - * Add the modprobe.blacklist=vmwgfx linux kernel boot option. - * To gain access to larger resolutions, remove svga.guestBackedPrimaryAware = "TRUE" option from the VMX file. -