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.
Oliver Kurth [Thu, 3 Oct 2019 00:48:34 +0000 (17:48 -0700)]
Move /etc/vmware-tools/vm-support to /usr/bin/ in open-vm-tools.
Change scripts/Makefile.am to know about the new location.
This fix requires the following updates to the vendor scripts:
The rules files have "chmod /etc/vmware-tools/vm-support".
The spec files have "mv /etc/vmware-tools/vm-support /usr/bin".
Oliver Kurth [Mon, 30 Sep 2019 23:24:27 +0000 (16:24 -0700)]
Add a Coverity annotation to lib/vmGuestLib/vmGuestLib.c
A previous change adding Coverity annotations to vmGuestLib.c
omitted one. Adding for completeness although it does not actually
affect Coverity results.
Oliver Kurth [Mon, 30 Sep 2019 23:24:27 +0000 (16:24 -0700)]
Fix potential overflow in timeSync reported by Coverity
Issue: Potentially overflowing expression: data->timeSyncPeriod * 1000000U
is evaluated using 32-bit arithmetic, and then used in a context
that expects an expression of type uint64.
Fix: explict type conversion.
Oliver Kurth [Mon, 9 Sep 2019 18:23:49 +0000 (11:23 -0700)]
Fix Misc. issues in vmtoolsLog.c
* g_malloc0 aborts the application if the specificed amount of memory
cannot be allocated. Hence, no need to have a NULL check for the
return value of g_malloc0.
* Removed one if block in VMToolsLogInt since the if check will never
be TRUE.
* g_strdup returns NULL if the input argument is NULL. Removed
the unnecessary NULL checks for the input argument to g_strdup at few
places.
Oliver Kurth [Mon, 9 Sep 2019 18:23:49 +0000 (11:23 -0700)]
[AppInfo] OVT Coverity fixes.
The return value of Str_Snprintf is not being checked for negative
values and is directly passed to DynBuf_Append which accepts only
positive values. This may cause issues if Str_Snprintf fails. Added
a trivial check.
Oliver Kurth [Mon, 9 Sep 2019 18:23:49 +0000 (11:23 -0700)]
[AppInfo] OVT Coverity fixes.
The return value of Str_Snprintf is not being checked for negative
values and is directly passed to DynBuf_Append which accepts only
positive values. This may cause issues if Str_Snprintf fails. Added
a trivial check.
Oliver Kurth [Mon, 9 Sep 2019 18:23:49 +0000 (11:23 -0700)]
Fix the deployPkg status files when privateTmp is enabled
Currently, deployPkg status file path is hardcoded to /tmp. When
privateTmp is enabled in the guest VM, /tmp is hidden from the rest
of the system and is wiped on reboot. So need use different path to
save the status file.
This change is changing deployPkg status file path from /tmp to /var/log
Oliver Kurth [Mon, 9 Sep 2019 18:23:48 +0000 (11:23 -0700)]
More Coverity annotations for open-vm-tools issues.
Add annotations for additional Coverity-reported issues so that
Coverity scans of ovt will automatically classify these issues
as "intentional." Such annotations are useful both for internal
use as well as for partners who run Coverity scans of open-vm-tools.