]> git.ipfire.org Git - thirdparty/open-vm-tools.git/log
thirdparty/open-vm-tools.git
6 years agoCommon header file change not applicable to open-vm-tools.
Oliver Kurth [Fri, 20 Dec 2019 20:25:49 +0000 (12:25 -0800)] 
Common header file change not applicable to open-vm-tools.

6 years agoAvoid vmtoolsd crash in HostInfo.
Oliver Kurth [Wed, 11 Dec 2019 18:19:09 +0000 (10:19 -0800)] 
Avoid vmtoolsd crash in HostInfo.

The guest identification code causes vmtoolsd to crash in certain
versions of some distros.  The crash is caused by recent changes to
the lsb_release command.  Previously, if the command existed, all
of its options worked.  Now, some of the options no longer exist.

Change the code to check for an lsb_release failure whenever it is
invoked.

Fix for: https://github.com/vmware/open-vm-tools/issues/390

6 years agodndUIX11.cpp::GetLastDirName() Remove a trailing slash in a directory pathname.
Oliver Kurth [Wed, 11 Dec 2019 18:19:09 +0000 (10:19 -0800)] 
dndUIX11.cpp::GetLastDirName() Remove a trailing slash in a directory pathname.

6 years agoConfigurable environment for vmtoolsd.
Oliver Kurth [Wed, 11 Dec 2019 18:19:09 +0000 (10:19 -0800)] 
Configurable environment for vmtoolsd.

If a user wants to override(*) an environment variable e.g.
TMPDIR for vmtoolsd, the only choices for the user are:
1. Change system environment variable, that may affect more
than vmtoolsd
2. Change vmtoolsd service startup scripts on Linux.
Some of these methods, especially #2 gets overwritten by
upgrades and user is forced to re-apply the change on every
upgrade of VMTools. Also, #2 is somewhat complex due to
different type of VMTools installations and differences
in Linux distros.

We can't override the environment completely from within
service but we can configure the environment to a large
extent once vmtoolsd comes up and reads tools.conf.

*=> "override" term here applies to setting, modifying and/or
unsetting an environment variable.

This is mainly required for system service vmsvc, but
given that vmusr shares code with vmsvc, we can provide
this functionality for both.

Updated example tools.conf with the new configuration.

6 years agonicinfo: report real nameservers used when using systemd-resolved
Oliver Kurth [Wed, 11 Dec 2019 18:19:09 +0000 (10:19 -0800)] 
nicinfo: report real nameservers used when using systemd-resolved

If systemd-resolved is used, report the external DNS server, not the
locally installed one.  This is detected by checking if /etc/resolv.conf
is a link to /run/systemd/resolve/stub-resolv.conf.  In that case,
/run/systemd/resolve/resolv.conf will hold the actual DNS server.  See
https://www.freedesktop.org/software/systemd/man/systemd-resolved.service.html

6 years agoFix Coverity reported issue in dndUIX11.cpp
Oliver Kurth [Wed, 11 Dec 2019 18:19:09 +0000 (10:19 -0800)] 
Fix Coverity reported issue in dndUIX11.cpp

- unsigned_compare: This greater-than-or-equal-to-zero comparison of an
  unsigned value is always true. end >= 0UL.
 Function: GetLastDirName

6 years ago[open-vm-tools Coverity] Fix Coverity scan reported issues in copyPasteUIX11.cpp
Oliver Kurth [Wed, 11 Dec 2019 18:19:09 +0000 (10:19 -0800)] 
[open-vm-tools Coverity] Fix Coverity scan reported issues in copyPasteUIX11.cpp

- Non-static class member mHGGetListTime is not initialized in this constructor
 solution: add it into init list of constructor

- unsigned_compare: This greater-than-or-equal-to-zero comparison of an
  unsigned value is always true. end >= 0UL.
 Function: GetLastDirName

6 years agoRemove residual data when the DNS nameserver configuration changes.
Oliver Kurth [Wed, 11 Dec 2019 18:19:08 +0000 (10:19 -0800)] 
Remove residual data when the DNS nameserver configuration changes.

If the list of DNS nameservers available should shorten or both IPv4 and
IPv6 entries are present, residual data can still be available for display.
This change to nicInfoPosix.c corrects the problem.

6 years agoTools-11.0.5 - Trim trailing whitespace from log params in /etc/tools.conf.
Oliver Kurth [Wed, 11 Dec 2019 18:19:08 +0000 (10:19 -0800)] 
Tools-11.0.5 - Trim trailing whitespace from log params in /etc/tools.conf.

Remove trailing whitespace from pathnames and parameters in
tools.conf.

6 years agoAvoid securing disk device info for ZFS pools (at this time)
Oliver Kurth [Wed, 11 Dec 2019 18:19:08 +0000 (10:19 -0800)] 
Avoid securing disk device info for ZFS pools (at this time)

ZFS filesystem pools device names can appear as single directory name
at the root directory.  The current logic to locate the
/sys/class/blocks/<device> PCI structure based on typical device name
format will fail for ZFS pools.  As an immediate fix to the SIGSEGV,
avoid attempting to locate the PCI info; keep vmtoolsd running.

Addresses https://github.com/vmware/open-vm-tools/issues/378

6 years agoAvoid vmtoolsd crash in HostInfo.
Oliver Kurth [Thu, 5 Dec 2019 19:34:43 +0000 (11:34 -0800)] 
Avoid vmtoolsd crash in HostInfo.

The guest identification code causes vmtoolsd to crash in certain
versions of some distros.  The crash is caused by recent changes to
the lsb_release command.  Previously, if the command existed, all
of its options worked.  Now, some of the options no longer exist.

Change the code to check for an lsb_release failure whenever it is
invoked.

Fix for: https://github.com/vmware/open-vm-tools/issues/390

6 years agoRemove an unused variable from the "VMware Tools for Linux-Arm" build
Oliver Kurth [Thu, 5 Dec 2019 19:34:43 +0000 (11:34 -0800)] 
Remove an unused variable from the "VMware Tools for Linux-Arm" build

The gHvVendor variable is unused when building for arm64.  So move the
variable declaration next to the only x86 code which uses the variable,
and rename the variable since it is no longer global.

6 years agoIntroduce Clang SA-specific assert
Oliver Kurth [Thu, 5 Dec 2019 19:34:43 +0000 (11:34 -0800)] 
Introduce Clang SA-specific assert

Introduce an assert which would only be generated during clang SA
execution.  With it we would avoid generating extra code from
assertations which might be needed specifically for Clang SA's correct
working (even with enabled analyzer, binary wouldn't grow, as
__clang_analyzer__ is only defined while the analyzer is parsing
the files for analysis, and not during Clang's compilation).

Cases in which might be used is for example before a statement which
we are fine just to fail or to possibly silence a false positive.

A real example where we would require such assertion is for the attached
report in the review.  There seem to be a bug with the analyzer where it
will falsely ignore branches if we assert a parent class pointer before
using dynamic_cast as it will evaluate both pointers to be same.

To show more precisely, we would use helper functions from debug checker
ExprInspection.

Example 1:
745 void
746 DvsKeeper::GetMethodFault(Exception *e, Ref<MethodFault>& fault)
747 {
748    MethodFault::Exception *mfe = dynamic_cast<MethodFault::Exception *>(e);
749    clang_analyzer_warnIfReached();
750    if (mfe != nullptr) {
751       clang_analyzer_warnIfReached();
752       fault = mfe->GetFault();
753    } else {
754       clang_analyzer_warnIfReached();
755       fault = new SystemError(e->what());
756    }
757    clang_analyzer_warnIfReached();
758 }

This would generate the following warnings:
bora/vpx/vpxd/dvs/core/dvsKeeper.cpp:749:4: warning: REACHABLE
clang_analyzer_warnIfReached();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bora/vpx/vpxd/dvs/core/dvsKeeper.cpp:751:7: warning: REACHABLE
clang_analyzer_warnIfReached();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bora/vpx/vpxd/dvs/core/dvsKeeper.cpp:754:7: warning: REACHABLE
clang_analyzer_warnIfReached();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bora/vpx/vpxd/dvs/core/dvsKeeper.cpp:755:31: warning: Called C++ object pointer is null
fault = new SystemError(e->what());
^~~~~~~~~
bora/vpx/vpxd/dvs/core/dvsKeeper.cpp:757:4: warning: REACHABLE
clang_analyzer_warnIfReached();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 warnings generated.

Example 2:
745 void
746 DvsKeeper::GetMethodFault(Exception *e, Ref<MethodFault>& fault)
747 {
748    ASSERT(e != nullptr);
749    MethodFault::Exception *mfe = dynamic_cast<MethodFault::Exception *>(e);
750    clang_analyzer_warnIfReached();
751    if (mfe != nullptr) {
752       clang_analyzer_warnIfReached();
753       fault = mfe->GetFault();
754    } else {
755       clang_analyzer_warnIfReached();
756       fault = new SystemError(e->what());
757    }
758    clang_analyzer_warnIfReached();
759 }
Result:
bora/vpx/vpxd/dvs/core/dvsKeeper.cpp:750:4: warning: REACHABLE
clang_analyzer_warnIfReached();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bora/vpx/vpxd/dvs/core/dvsKeeper.cpp:752:7: warning: REACHABLE
clang_analyzer_warnIfReached();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bora/vpx/vpxd/dvs/core/dvsKeeper.cpp:758:4: warning: REACHABLE
clang_analyzer_warnIfReached();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 warnings generated.

When we do that, the whole else branch is unreachable by the analyzer,
which shouldn't be the case.

Example 3:
745 void
746 DvsKeeper::GetMethodFault(Exception *e, Ref<MethodFault>& fault)
747 {
748    ASSERT(e != nullptr);
749    MethodFault::Exception *mfe = dynamic_cast<MethodFault::Exception *>(e);
750    ASSERT(mfe == nullptr);
751    clang_analyzer_warnIfReached();
752    if (mfe != nullptr) {
753       clang_analyzer_warnIfReached();
754       fault = mfe->GetFault();
755    } else {
756       clang_analyzer_warnIfReached();
757       fault = new SystemError(e->what());
758    }
759    clang_analyzer_warnIfReached();
760 }

No warnings are generated, and 'mfe' can be null if the cast fails.

Example 4:
746 void
747 DvsKeeper::GetMethodFault(Exception *e, Ref<MethodFault>& fault)
748 {
749    ASSERT(e != nullptr);
750    MethodFault::Exception *mfe = dynamic_cast<MethodFault::Exception *>(e);
751    clang_analyzer_eval(e == mfe);
752    clang_analyzer_warnIfReached();
753    if (mfe != nullptr) {
754       clang_analyzer_warnIfReached();
755       fault = mfe->GetFault();
756    } else {
757       clang_analyzer_warnIfReached();
758       fault = new SystemError(e->what());
759    }
760    clang_analyzer_warnIfReached();
761 }
bora/vpx/vpxd/dvs/core/dvsKeeper.cpp:751:4: warning: TRUE
clang_analyzer_eval(e == mfe);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bora/vpx/vpxd/dvs/core/dvsKeeper.cpp:752:4: warning: REACHABLE
clang_analyzer_warnIfReached();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bora/vpx/vpxd/dvs/core/dvsKeeper.cpp:754:7: warning: REACHABLE
clang_analyzer_warnIfReached();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bora/vpx/vpxd/dvs/core/dvsKeeper.cpp:760:4: warning: REACHABLE
clang_analyzer_warnIfReached();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 warnings generated.

Even knowing 'e' is not a nullptr, the analyzer falsely evaluates 'e'
and 'mfe' to be the same, which leads to many other wrong assumptions.

Example 5 (What would be best way to work around this bug with least
           analyzer impact):
745 void
746 DvsKeeper::GetMethodFault(Exception *e, Ref<MethodFault>& fault)
747 {
748    MethodFault::Exception *mfe = dynamic_cast<MethodFault::Exception *>(e);
749    clang_analyzer_warnIfReached();
750    if (mfe != nullptr) {
751       clang_analyzer_warnIfReached();
752       fault = mfe->GetFault();
753    } else {
754       clang_analyzer_warnIfReached();
755       ASSERT(e != nullptr);
756       clang_analyzer_warnIfReached();
757       fault = new SystemError(e->what());
758    }
759    clang_analyzer_warnIfReached();
760 }
bora/vpx/vpxd/dvs/core/dvsKeeper.cpp:749:4: warning: REACHABLE
clang_analyzer_warnIfReached();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bora/vpx/vpxd/dvs/core/dvsKeeper.cpp:751:7: warning: REACHABLE
clang_analyzer_warnIfReached();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bora/vpx/vpxd/dvs/core/dvsKeeper.cpp:754:7: warning: REACHABLE
clang_analyzer_warnIfReached();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bora/vpx/vpxd/dvs/core/dvsKeeper.cpp:759:4: warning: REACHABLE
clang_analyzer_warnIfReached();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 warnings generated.

In such cases, we could look into the problem as both real and analyzer
issue and other ways to "fix" it either don't work, or impact the further
work of the analyzer, which we would like to be as minimal as possible.

6 years agoLinuxDeployment.c: Temp directories are not cleaned up in the case of error.
Oliver Kurth [Thu, 5 Dec 2019 19:34:43 +0000 (11:34 -0800)] 
LinuxDeployment.c: Temp directories are not cleaned up in the case of error.

Clean up the created temporary directory if an error happens.

6 years agoAdd arm64 support in open-vm-tools
Oliver Kurth [Thu, 5 Dec 2019 19:34:43 +0000 (11:34 -0800)] 
Add arm64 support in open-vm-tools

This adds the required files and fixes to be able to build
the open-vm-tools for arm64.

One major change is the update of autoconf from 2.61 to 2.69,
with automake.  The autoconf update forced to add the libtool
include path to properly run autoreconf on the tools.  I don't
know if these AUTOCONF/AUTORECONF variables are used anywhere
else.

The open-vm-tools have been tested on debian 10 and fedora 31
VMs (thanks to Andreas Scherr).

Also fixed Hostinfo_TouchVirtualPC() which was incorrectly
testing if vm_x86_64 was defined.  It is always defined, to
either to 0 or 1.

6 years agoClean up some code in hostinfo.
Oliver Kurth [Thu, 5 Dec 2019 19:34:41 +0000 (11:34 -0800)] 
Clean up some code in hostinfo.

Remove duplicate declarations in hostinfo.h
Re-indent some lines in hostinfoPosix.c

6 years agoChange to common header file not applicable to open-vm-tools.
Oliver Kurth [Fri, 22 Nov 2019 22:52:35 +0000 (14:52 -0800)] 
Change to common header file not applicable to open-vm-tools.

6 years agoChange to common header file not applicable to open-vm-tools.
Oliver Kurth [Fri, 22 Nov 2019 22:52:35 +0000 (14:52 -0800)] 
Change to common header file not applicable to open-vm-tools.

6 years agoFix a resource leak issue in deployPkg
Oliver Kurth [Fri, 22 Nov 2019 22:52:35 +0000 (14:52 -0800)] 
Fix a resource leak issue in deployPkg

Variable file going out of scope in error path leaks the storage it
points to.  Added fclose before return when malloc failed.

6 years agoCommon header file change not applicable to open-vm-tools.
Oliver Kurth [Fri, 22 Nov 2019 22:52:35 +0000 (14:52 -0800)] 
Common header file change not applicable to open-vm-tools.

6 years agoCommon header file change not applicable to open-vm-tools.
Oliver Kurth [Fri, 22 Nov 2019 22:52:35 +0000 (14:52 -0800)] 
Common header file change not applicable to open-vm-tools.

6 years agoAdd Coverity annotations to bora/lib/file/file.
Oliver Kurth [Fri, 22 Nov 2019 22:52:35 +0000 (14:52 -0800)] 
Add Coverity annotations to bora/lib/file/file.

Add annotations for Coverity-reported false positives in filePosix.c
and fileIOPosix.c.

6 years agoCode clean up in lib/file/filePosix.c
Oliver Kurth [Fri, 22 Nov 2019 22:52:35 +0000 (14:52 -0800)] 
Code clean up in lib/file/filePosix.c

Consolidate identical code in File_GetCapacity() and File_GetFreeSpace().

6 years agoAddress two Coverity-reported issues in hostinfoPosix.c.
Oliver Kurth [Fri, 22 Nov 2019 22:52:35 +0000 (14:52 -0800)] 
Address two Coverity-reported issues in hostinfoPosix.c.

Rework some code with the intent of making it more straightfoward,
which also eliminates a false positive.

Check the return value from PosixUnlink and log a warning on error.

6 years agoFix a potential NULL pointer dereference in the vmbackup plugin.
Oliver Kurth [Fri, 22 Nov 2019 22:52:35 +0000 (14:52 -0800)] 
Fix a potential NULL pointer dereference in the vmbackup plugin.

In some circumtances, VmBackupAsyncCallback might dereference
gBackupState after calling VmBackupDoAbort even though the
latter function can potentially set gBackupState to NULL.  Add
a check to prevent the potential NULL pointer dereference.

6 years agoLOG() calls changed to variadic form.
Oliver Kurth [Fri, 22 Nov 2019 22:52:35 +0000 (14:52 -0800)] 
LOG() calls changed to variadic form.

6 years agoMore LOG() calls changed to variadic form.
Oliver Kurth [Fri, 22 Nov 2019 22:52:35 +0000 (14:52 -0800)] 
More LOG() calls changed to variadic form.

6 years agoEnable appinfo plugin for hosted products.
Oliver Kurth [Fri, 22 Nov 2019 22:52:34 +0000 (14:52 -0800)] 
Enable appinfo plugin for hosted products.

Currently, with TOT code, appInfo plugin is loaded only when
the VM is managed by VMware ESX server.  In this changeset, that
limitation is removed and the plugin will be loaded for hosted
products also.

6 years agodndUIX11.cpp::GetLastDirName() Remove a trailing slash in a directory pathname.
Oliver Kurth [Fri, 22 Nov 2019 22:52:34 +0000 (14:52 -0800)] 
dndUIX11.cpp::GetLastDirName() Remove a trailing slash in a directory pathname.

6 years agoFix Coverity reported issue time of check to time of use (TOCTOU) in deployPkg
Oliver Kurth [Fri, 22 Nov 2019 22:52:34 +0000 (14:52 -0800)] 
Fix Coverity reported issue time of check to time of use (TOCTOU) in deployPkg

Change to call mkdir directly, then check and log the error.

6 years agoLOG() calls changed to variadic form.
Oliver Kurth [Fri, 22 Nov 2019 22:52:34 +0000 (14:52 -0800)] 
LOG() calls changed to variadic form.

6 years agoAdd Coverity annotations in services/plugins/dndcp/dndGuest/rpcV4Util.cpp.
Oliver Kurth [Fri, 22 Nov 2019 22:52:34 +0000 (14:52 -0800)] 
Add Coverity annotations in services/plugins/dndcp/dndGuest/rpcV4Util.cpp.

Add Coverity annotations for false positives reported by a scan of
open-vm-tools.

6 years agoChanges to common header file not applicable to open-vm-tools.
Oliver Kurth [Fri, 22 Nov 2019 22:52:34 +0000 (14:52 -0800)] 
Changes to common header file not applicable to open-vm-tools.

6 years agoBackout previous change to lib/file/filePosix.c.
Oliver Kurth [Fri, 22 Nov 2019 22:52:31 +0000 (14:52 -0800)] 
Backout previous change to lib/file/filePosix.c.

6 years agoCommon source file change not applicable to open-vm-tools.
Oliver Kurth [Tue, 12 Nov 2019 02:12:24 +0000 (18:12 -0800)] 
Common source file change not applicable to open-vm-tools.

6 years agoopen-vm-tools: Do not build the appInfo plugin on FreeBSD
Oliver Kurth [Tue, 12 Nov 2019 02:12:23 +0000 (18:12 -0800)] 
open-vm-tools: Do not build the appInfo plugin on FreeBSD

The appInfo plugin is supported only on Linux and Windows guests.
Modify the bora-vmsoft/install/Source/services/plugins/Makefile.am
to only include appInfo in the build if OVT is being built for a Linux
guest.

6 years agoMore LOG() calls changed to variadic form.
Oliver Kurth [Tue, 12 Nov 2019 02:12:23 +0000 (18:12 -0800)] 
More LOG() calls changed to variadic form.

6 years agoMore LOG() calls changed to variadic form.
Oliver Kurth [Tue, 12 Nov 2019 02:12:23 +0000 (18:12 -0800)] 
More LOG() calls changed to variadic form.

6 years agoMore LOG() calls changed to variadic form - dndcp plugin.
Oliver Kurth [Tue, 12 Nov 2019 02:12:23 +0000 (18:12 -0800)] 
More LOG() calls changed to variadic form - dndcp plugin.

6 years agoMore LOG() calls changed to variadic form - hgfsServer.
Oliver Kurth [Tue, 12 Nov 2019 02:12:23 +0000 (18:12 -0800)] 
More LOG() calls changed to variadic form - hgfsServer.

6 years agoCommon source file change not applicable to open-vm-tools.
Oliver Kurth [Tue, 12 Nov 2019 02:12:23 +0000 (18:12 -0800)] 
Common source file change not applicable to open-vm-tools.

6 years agoCommon header file change not applicable to open-vm-tools.
Oliver Kurth [Tue, 12 Nov 2019 02:12:23 +0000 (18:12 -0800)] 
Common header file change not applicable to open-vm-tools.

6 years agoMore LOG() calls changed to variadic form.
Oliver Kurth [Tue, 12 Nov 2019 02:12:23 +0000 (18:12 -0800)] 
More LOG() calls changed to variadic form.

6 years agoMore LOG() calls changed to variadic form.
Oliver Kurth [Tue, 12 Nov 2019 02:12:22 +0000 (18:12 -0800)] 
More LOG() calls changed to variadic form.

6 years agoCommon header file change not applicable to open-vm-tools
Oliver Kurth [Tue, 12 Nov 2019 02:12:22 +0000 (18:12 -0800)] 
Common header file change not applicable to open-vm-tools

6 years agoCommon header file change not applicable to open-vm-tools.
Oliver Kurth [Tue, 12 Nov 2019 02:12:22 +0000 (18:12 -0800)] 
Common header file change not applicable to open-vm-tools.

6 years agoCommon header file change not applicable to open-vm-tools.
Oliver Kurth [Tue, 12 Nov 2019 02:12:22 +0000 (18:12 -0800)] 
Common header file change not applicable to open-vm-tools.

6 years agoFix a potentisl memory leak in an error situation; reported by Coverity.
Oliver Kurth [Tue, 12 Nov 2019 02:12:22 +0000 (18:12 -0800)] 
Fix a potentisl memory leak in an error situation; reported by Coverity.

6 years agoFix issues of unchecked return value reported by Coverity.
Oliver Kurth [Tue, 12 Nov 2019 02:12:22 +0000 (18:12 -0800)] 
Fix issues of unchecked return value reported by Coverity.

CID 80926 (#2 of 2): Unchecked return value (CHECKED_RETURN)
8. check_return: Calling ForkExecAndWaitCommand without checking return value

CID 80934 (#2 of 2): Unchecked return value from library (CHECKED_RETURN)
3. check_return: Calling lseek(pkgFd, 512L, 0) without checking return value.
This library function may fail and return an error code.

CID 80927 (#4 of 4): Unchecked return value from library (CHECKED_RETURN)
5. check_return: Calling fcntl(p->stdoutFd, 4, flags | 0x800) without
checking return value. This library function may fail and return an error
code.

6 years agoUse malloc everywhere in linux deploypkg plugin code
Oliver Kurth [Tue, 12 Nov 2019 02:12:22 +0000 (18:12 -0800)] 
Use malloc everywhere in linux deploypkg plugin code

This change is replacing Util_SafeMalloc() by malloc() in Linux
deploypkg plugin code.  Also changing if statement to == NULL
or != NULL for char* type.

6 years agoConfigurable environment for vmtoolsd.
Oliver Kurth [Tue, 12 Nov 2019 02:12:22 +0000 (18:12 -0800)] 
Configurable environment for vmtoolsd.

If a user wants to override(*) an environment variable e.g.
TMPDIR for vmtoolsd, the only choices for the user are:
1. Change system environment variable, that may affect more
than vmtoolsd
2. Change vmtoolsd service startup scripts on Linux.
Some of these methods, especially #2 gets overwritten by
upgrades and user is forced to re-apply the change on every
upgrade of VMTools. Also, #2 is somewhat complex due to
different type of VMTools installations and differences
in Linux distros.

We can't override the environment completely from within
service but we can configure the environment to a large
extent once vmtoolsd comes up and reads tools.conf.

*=> "override" term here applies to setting, modifying and/or
unsetting an environment variable.

This is mainly required for system service vmsvc, but
given that vmusr shares code with vmsvc, we can provide
this functionality for both.

Updated example tools.conf with the new configuration.

6 years agoBack out previous change for configurable environment for vmtoolsd.
Oliver Kurth [Tue, 12 Nov 2019 02:12:22 +0000 (18:12 -0800)] 
Back out previous change for configurable environment for vmtoolsd.

Changed checked in with commented code by mistake.
Will re-submit after uncommenting.

6 years agoConfigurable environment for vmtoolsd.
Oliver Kurth [Tue, 12 Nov 2019 02:12:22 +0000 (18:12 -0800)] 
Configurable environment for vmtoolsd.

If a user wants to override(*) an environment variable e.g.
TMPDIR for vmtoolsd, the only choices for the user are:
1. Change system environment variable, that may affect more
than vmtoolsd
2. Change vmtoolsd service startup scripts on Linux.
Some of these methods, especially #2 gets overwritten by
upgrades and user is forced to re-apply the change on every
upgrade of VMTools. Also, #2 is somewhat complex due to
different type of VMTools installations and differences
in Linux distros.

We can't override the environment completely from within
service but we can configure the environment to a large
extent once vmtoolsd comes up and reads tools.conf.

*=> "override" term here applies to setting, modifying and/or
unsetting an environment variable.

This is mainly required for system service vmsvc, but
given that vmusr shares code with vmsvc, we can provide
this functionality for both.

Updated example tools.conf with the new configuration.

6 years agoMake pollGtk resetable.
Oliver Kurth [Tue, 12 Nov 2019 02:12:22 +0000 (18:12 -0800)] 
Make pollGtk resetable.

A simple poll implementation built on top of GLib, pollGtk can only be
inited once in a program's lifetime.  This works for product but not
testcases.

This patch changes the function static variable "inited" to be file static,
and can be reset this variable in PollGtkExit().

6 years agoCommon header file change not applicable to open-vm-tools.
Oliver Kurth [Tue, 12 Nov 2019 02:12:22 +0000 (18:12 -0800)] 
Common header file change not applicable to open-vm-tools.

6 years agoAddress Coverity reported issues in the DnD plugin.
Oliver Kurth [Tue, 12 Nov 2019 02:12:22 +0000 (18:12 -0800)] 
Address Coverity reported issues in the DnD plugin.
  - uninitialized non-static class members.
  - memory leak.
  - potential NULL pointer dereference.

6 years agoCommon header file change not applicable to open-vm-tools.
Oliver Kurth [Tue, 12 Nov 2019 02:12:22 +0000 (18:12 -0800)] 
Common header file change not applicable to open-vm-tools.

6 years agoCommon header file change not applicable to open-vm-tools.
Oliver Kurth [Tue, 12 Nov 2019 02:12:21 +0000 (18:12 -0800)] 
Common header file change not applicable to open-vm-tools.

6 years agoAddress some issues reported by the Coverity scan of open-vm-tools.
Oliver Kurth [Tue, 12 Nov 2019 02:12:21 +0000 (18:12 -0800)] 
Address some issues reported by the Coverity scan of open-vm-tools.

Fix or annotate issues reported in the Coverity scan of open-vm-tools,
as follows:

(1) Fix NULL pointer de-reference in failure case of
CopyStringListEntry.

(2) Add NULL pointer checks before dereferences in
VixMsg_DeObfuscateNamePassword.

(3) Annotate a false positive in VixMsg_EncodeString.

(4) Annotate and add an ASSERT to a false positive in
StrUtil_GetLongestLineLength.

6 years agonicinfo: report real nameservers used when using systemd-resolved
Oliver Kurth [Tue, 12 Nov 2019 02:12:21 +0000 (18:12 -0800)] 
nicinfo: report real nameservers used when using systemd-resolved

If systemd-resolved is used, report the external DNS server, not the
locally installed one.  This is detected by checking if /etc/resolv.conf
is a link to /run/systemd/resolve/stub-resolv.conf.  In that case,
/run/systemd/resolve/resolv.conf will hold the actual DNS server.  See
https://www.freedesktop.org/software/systemd/man/systemd-resolved.service.html

6 years agoCommon source file change not directly applicable to open-vm-tools.
Oliver Kurth [Wed, 30 Oct 2019 18:21:53 +0000 (11:21 -0700)] 
Common source file change not directly applicable to open-vm-tools.

6 years agostop systemd-243 udev complaints #371
Oliver Kurth [Wed, 30 Oct 2019 18:21:53 +0000 (11:21 -0700)] 
stop systemd-243 udev complaints #371

Address issues from pull request #371 on github:
- fix substiution variables for systemd-243
- fix permissions of rules file
See https://github.com/vmware/open-vm-tools/pull/371

6 years agoSuppress a couple of coverity false alarms in FileLoggerOpen().
Oliver Kurth [Wed, 30 Oct 2019 18:21:53 +0000 (11:21 -0700)] 
Suppress a couple of coverity false alarms in FileLoggerOpen().

The stat() system call is used to determine whether to rotate logs.
There is no danger of time-of-check vs. time-of-use because the rotation
decision still holds even under the very-unlikely condition that the existing
log file size changes.

When rotating the logs, the service should not stop when a rename() fails
on an old file.  The process ignores the rename() return code intentionally.
The error condition cannot be logged because the process is already in the
log handling context and would either crash or risk a recursion loop
otherwise.  In addition, writing to stdout/stderr is useless, since the
process is running as a service and the stdout/stderr is reopened on /dev/null.

Therefore, the above two coverity issues are suppressed in the code.

6 years agoBump the VMware Tools version to 11.0.5 on vmtools-prod-cpd.
Oliver Kurth [Wed, 30 Oct 2019 18:21:53 +0000 (11:21 -0700)] 
Bump the VMware Tools version to 11.0.5 on vmtools-prod-cpd.

Update bora/public/vm_tools_version.h to set the current tools version
to 11.0.5

TOOLS_VERSION_SLEDGEHAMMER_UPDATE1  --> 11.0.5

6 years agoFix issue reported by Coverity scan in deployPkg
Oliver Kurth [Wed, 30 Oct 2019 18:18:23 +0000 (11:18 -0700)] 
Fix issue reported by Coverity scan in deployPkg

rand() should not be used for security-related applications, because
linear congruential algorithms are too easy to break.  Use a compliant
random number generator, such as /dev/random or /dev/urandom on
Unix-like systems, and CNG (Cryptography API: Next Generation) on Windows.

6 years agoAvoid securing disk device info for ZFS pools (at this time)
Oliver Kurth [Wed, 30 Oct 2019 18:18:23 +0000 (11:18 -0700)] 
Avoid securing disk device info for ZFS pools (at this time)

ZFS filesystem pools device names can appear as single directory name
at the root directory.  The current logic to locate the
/sys/class/blocks/<device> PCI structure based on typical device name
format will fail for ZFS pools.  As an immediate fix to the SIGSEGV,
avoid attempting to locate the PCI info; keep vmtoolsd running.

Addresses https://github.com/vmware/open-vm-tools/issues/378

6 years agoTrim trailing whitespace from log params in /etc/tools.conf.
Oliver Kurth [Wed, 30 Oct 2019 18:18:23 +0000 (11:18 -0700)] 
Trim trailing whitespace from log params in /etc/tools.conf.

Remove trailing whitespace from pathnames and parameters in
tools.conf.

6 years agoCommon header file change not applicable to open-vm-tools.
Oliver Kurth [Wed, 30 Oct 2019 18:18:23 +0000 (11:18 -0700)] 
Common header file change not applicable to open-vm-tools.

6 years agoA LOG goes variadic change in asyncsocket.c
Oliver Kurth [Wed, 30 Oct 2019 18:18:23 +0000 (11:18 -0700)] 
A LOG goes variadic change in asyncsocket.c

6 years agoFix Coverity reported issue in dndUIX11.cpp
Oliver Kurth [Wed, 30 Oct 2019 18:18:23 +0000 (11:18 -0700)] 
Fix Coverity reported issue in dndUIX11.cpp

- unsigned_compare: This greater-than-or-equal-to-zero comparison of an
  unsigned value is always true. end >= 0UL.
 Function: GetLastDirName

6 years agoRemove dead code in dndCommon.c reported by Coverity.
Oliver Kurth [Wed, 30 Oct 2019 18:18:23 +0000 (11:18 -0700)] 
Remove dead code in dndCommon.c reported by Coverity.

6 years ago[open-vm-tools Coverity] Fix Coverity scan reported issues in copyPasteUIX11.cpp
Oliver Kurth [Wed, 30 Oct 2019 18:18:23 +0000 (11:18 -0700)] 
[open-vm-tools Coverity] Fix Coverity scan reported issues in copyPasteUIX11.cpp

- Non-static class member mHGGetListTime is not initialized in this constructor
 solution: add it into init list of constructor

- unsigned_compare: This greater-than-or-equal-to-zero comparison of an
  unsigned value is always true. end >= 0UL.
 Function: GetLastDirName

6 years ago[open-vm-tools Coverity] Fix sign extension issue reported by Coverity.
Oliver Kurth [Wed, 30 Oct 2019 18:18:22 +0000 (11:18 -0700)] 
[open-vm-tools Coverity] Fix sign extension issue reported by Coverity.

- sign_extension: Suspicious implicit sign extension: x with type uint16
  (16 bits, unsigned) is promoted in (x << 16) | y to type int (32 bits,
  signed), then sign-extended to type unsigned long (64 bits, unsigned).
  If (x << 16) | y is greater than 0x7FFFFFFF, the upper bits of the
  result will all be 1.
 File: bora-vmsoft/services/plugins/dndcp/pointer.cpp
 Function: PointerSetPos

6 years agoChanges to common source files not directly applicable to open-vm-tools.
Oliver Kurth [Wed, 30 Oct 2019 18:18:22 +0000 (11:18 -0700)] 
Changes to common source files not directly applicable to open-vm-tools.

6 years agoCorrect several uninitialied varialbles reported by Coverity in dnd/cp code.
Oliver Kurth [Wed, 30 Oct 2019 18:18:22 +0000 (11:18 -0700)] 
Correct several uninitialied varialbles reported by Coverity in dnd/cp code.

- uninit_member: Non-static class member mRpc is not initialized in this
  constructor nor in any functions that it calls.
 File: bora/lib/dnd/rpcutil/rpcV3Util.cpp
 Function: RpcV3Util

- uninit_member: Non-static class member field mRpcChanCBList.xdrInSize is
  not initialized in this constructor nor in any functions that it calls.
 File: bora/vmx/tools/dndCPTransportGuestRpc.cpp
 Function: DnDCPTransportGuestRpc

- uninit_member: Non-static class member mGHDnDDropOccurred is not initialized
  in this constructor nor in any functions that it calls.
 File: bora-vmsoft/lib/dndGuestBase/dndUIX11.cpp
 Function: DnDUIX11

- uninit_member: Non-static class member m_main is not initialized in this
  constructor nor in any functions that it calls.
 File: bora-vmsoft/services/plugins/dndcp/copyPasteDnDX11.cpp
 Function: CopyPasteDnDX11

- uninit_member: Non-static class member mToolsAppCtx is not initialized in
  this constructor nor in any functions that it calls.
 File: bora-vmsoft/lib/dndGuest/vmGuestDnDCPMgr.hh
 Function: VMGuestDnDCPMgr

- uninit_member: Non-static class member mRpc is not initialized in this
  constructor nor in any functions that it calls.
 File: bora-vmsoft/lib/dndGuestBase/guestDnDSrc.cc
 Function: GuestDnDSrc

- uninit_member: Non-static class member mMsgSrc is not initialized in this
  constructor nor in any functions that it calls.
 File: bora/lib/dnd/rpcutil/rpcV4Util.cpp
 Function: RpcV4Util

- uninit_member: Non-static class member mIsActive is not initialized in this
  constructor nor in any functions that it calls.
 File: bora-vmsoft/lib/dndGuest/guestCopyPasteDest.cc
 Function: GuestCopyPasteDest

6 years agoCommon header file change not applicable to open-vm-tools.
Oliver Kurth [Wed, 30 Oct 2019 18:18:22 +0000 (11:18 -0700)] 
Common header file change not applicable to open-vm-tools.

6 years agoAddress issues from Coverity scan of open-vm-tools.
Oliver Kurth [Wed, 30 Oct 2019 18:18:22 +0000 (11:18 -0700)] 
Address issues from Coverity scan of open-vm-tools.

Fix two issues reported by the Coverity scan of open-vm-tools
and annotate a third:

* Validate siginfo read from a pipe in order to address
a tainted data issue reported in signalSource.c.

* Add a "Fall through" comment to address a missing break
reported in panic.c.

* Annotate an intentional NULL-dereference in guestSDKLog.c.

6 years agoFix misc. warnings related to strncpy usage.
Oliver Kurth [Wed, 30 Oct 2019 18:18:21 +0000 (11:18 -0700)] 
Fix misc. warnings related to strncpy usage.

For few files bundled in open-vm-tools package, one of the code
scanners reported the following warning.

" Easily used incorrectly; doesn't always \0-terminate or check for
invalid pointers"

Checked the files and modified the code to pass 'sizeof dest - 1'
as the third argument to avoid any warnings.

In one of the VGAUTH library functions, added a check for the input buffer
size and return a valid error.

6 years agoCommon header file change not applicable to open-vm-tools.
Oliver Kurth [Wed, 30 Oct 2019 18:18:21 +0000 (11:18 -0700)] 
Common header file change not applicable to open-vm-tools.

6 years agoSuppress a couple of coverity false alarms in FileLoggerOpen().
Oliver Kurth [Wed, 30 Oct 2019 18:18:21 +0000 (11:18 -0700)] 
Suppress a couple of coverity false alarms in FileLoggerOpen().

The stat() system call is used to determine whether to rotate logs.
There is no danger of time-of-check vs. time-of-use because the rotation
decision still holds even under the very-unlikely condition that the existing
log file size changes.

When rotating the logs, the service should not stop when a rename() fails
on an old file.  The process ignores the rename() return code intentionally.
The error condition cannot be logged because the process is already in the
log handling context and would either crash or risk a recursion loop
otherwise.  In addition, writing to stdout/stderr is useless, since the
process is running as a service and the stdout/stderr is reopened on /dev/null.

Therefore, the above two coverity issues are suppressed in the code.

6 years agoCommon header file change not applicable to open-vm-tools.
Oliver Kurth [Wed, 30 Oct 2019 18:18:21 +0000 (11:18 -0700)] 
Common header file change not applicable to open-vm-tools.

6 years agoFix misc. warnings in base64.c
Oliver Kurth [Wed, 30 Oct 2019 18:18:20 +0000 (11:18 -0700)] 
Fix misc. warnings in base64.c

At few places in the code, %ld is being used as the format specifier for
printing the variables of size_t datatype. Changed it to %FMTSZu.

6 years agostop systemd-243 udev complaints #371
Oliver Kurth [Mon, 28 Oct 2019 23:12:42 +0000 (16:12 -0700)] 
stop systemd-243 udev complaints #371

Address issues from pull request #371 on github:
- fix substiution variables for systemd-243
- fix permissions of rules file
See https://github.com/vmware/open-vm-tools/pull/371

6 years agoCommon header file change not applicable to open-vm-tools.
Oliver Kurth [Mon, 28 Oct 2019 23:12:42 +0000 (16:12 -0700)] 
Common header file change not applicable to open-vm-tools.

6 years agoCommon header file change not applicable to open-vm-tools.
Oliver Kurth [Mon, 28 Oct 2019 23:12:42 +0000 (16:12 -0700)] 
Common header file change not applicable to open-vm-tools.

6 years agoCommon source file changes not directly applicable to open-vm-tools.
Oliver Kurth [Mon, 28 Oct 2019 23:12:42 +0000 (16:12 -0700)] 
Common source file changes not directly applicable to open-vm-tools.

6 years agoFix 'variable scope can be reduced' warnings.
Oliver Kurth [Mon, 28 Oct 2019 23:12:42 +0000 (16:12 -0700)] 
Fix 'variable scope can be reduced' warnings.

One of the code quality checkers (Codacy) reported the following
issue for a bunch of files bundled in 'open-vm-tools'.

"""
Fix 'The scope of the variable 'var' can be reduced.'
"""

Checked all applicable files and removed the variable initialization
where it's really not necessary.

This is really not a major issue but it's no harm fixing.

6 years agoLOG goes variadic in dndCPTransportGuestRpc.cpp
Oliver Kurth [Mon, 28 Oct 2019 23:12:41 +0000 (16:12 -0700)] 
LOG goes variadic in dndCPTransportGuestRpc.cpp

6 years agoCommon header file change not applicable to open-vm-tools.
Oliver Kurth [Mon, 28 Oct 2019 23:12:41 +0000 (16:12 -0700)] 
Common header file change not applicable to open-vm-tools.

6 years agoCommon header file change not applicable to open-vm-tools.
Oliver Kurth [Mon, 28 Oct 2019 23:12:41 +0000 (16:12 -0700)] 
Common header file change not applicable to open-vm-tools.

6 years agoCode clean up in common source files.
Oliver Kurth [Mon, 28 Oct 2019 23:12:41 +0000 (16:12 -0700)] 
Code clean up in common source files.

Fix macros so they work in the world of Log Facility newlining.

The Log Facility no longer accepts appending calls into a single
line.  As such, some macros need to be "fixed up".

6 years agoRecord new tools patch and update versions in vm_tools_version.h.
Oliver Kurth [Mon, 28 Oct 2019 23:12:40 +0000 (16:12 -0700)] 
Record new tools patch and update versions in vm_tools_version.h.

6 years agoBack out previous code clean up changes.
Oliver Kurth [Mon, 28 Oct 2019 23:12:40 +0000 (16:12 -0700)] 
Back out previous code clean up changes.

6 years agoCode clean up in common source files.
Oliver Kurth [Mon, 28 Oct 2019 23:12:40 +0000 (16:12 -0700)] 
Code clean up in common source files.

Fix macros so they work in the world of Log Facility newlining.

The Log Facility no longer accepts appending calls into a single
line.  As such, some macros need to be "fixed up".

6 years agoFix a minor issue reported by Codacy code scanner.
Oliver Kurth [Mon, 28 Oct 2019 23:12:40 +0000 (16:12 -0700)] 
Fix a minor issue reported by Codacy code scanner.

One of the code quality checkers (Codacy) reported the following
issue for a bunch of files bundled in 'open-vm-tools'.

"""
Fix 'variable has been re-assigned before it's value has been used'
"""

Checked all applicable files and removed the variable initialization
where it's really not necessary.

This is really not a major issue but it's no harm fixing.

6 years agoFix minor NULL check in DataMap_Copy function.
Oliver Kurth [Mon, 28 Oct 2019 23:12:39 +0000 (16:12 -0700)] 
Fix minor NULL check in DataMap_Copy function.

One of the code scanners identified the following issue in
DataMap_Copy function.

"""
Either the condition 'src==NULL' is redundant or there is possible null pointer dereference: src.
"""

Fixed the issue by moving the NULL check to the top of the function.

6 years agoCommon header file change not directly applicable to open-vm-tools.
Oliver Kurth [Mon, 28 Oct 2019 23:12:39 +0000 (16:12 -0700)] 
Common header file change not directly applicable to open-vm-tools.

6 years agoVariadic LOG macros and fewer trailing newlines
Oliver Kurth [Mon, 28 Oct 2019 23:12:39 +0000 (16:12 -0700)] 
Variadic LOG macros and fewer trailing newlines

It's (long past) time we started using variadic LOG macros
and stopped requiring a newline at the end of every format
string.  A previous removed the newline requirement recently.

-   LOG(N, ("format string\n", arg1, arg2))
+   LOG(N, "format string", arg1, arg2)

The important parts of this change are buried in macro madness.
The key bit is the LOG_BYNAME macro, which now can be written
to be variadic.

To support both styles simultaneously, this change adds a macro
LOGLEVEL_VARIADIC which switches the definition of LOG_BYNAME to
variadic (e.g. remove extra parens).

Following this change, we can convert files to the variadic version
and set LOGLEVEL_VARIADIC.

6 years agoAssertion after use fix - lib/file/standalone.c
Oliver Kurth [Mon, 28 Oct 2019 23:12:39 +0000 (16:12 -0700)] 
Assertion after use fix - lib/file/standalone.c

One of the code scanners caught this one.

6 years agoCommon header file change not applicable to open-vm-tools.
Oliver Kurth [Mon, 28 Oct 2019 23:12:39 +0000 (16:12 -0700)] 
Common header file change not applicable to open-vm-tools.