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.
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.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
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
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.
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.
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.
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
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
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.
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
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.
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.