Oliver Kurth [Wed, 16 Jan 2019 22:53:06 +0000 (14:53 -0800)]
Add WarningToHost() and WarningToGuest() functions
This change is needed to address the privacy and security changes that
are required so that vmware library warnings can be forwarded to the
host side selectively.
For instance, if a warning message is sent to VMX, the user name must be
stripped from the message.
Oliver Kurth [Wed, 16 Jan 2019 22:53:05 +0000 (14:53 -0800)]
Bail out of vmtoolsd early when there are RPC errors.
VMX state machine could give up quiescing operation for various
reasons when vmtoolsd is busy performing necessary state transitions.
Once VMX gives up quiescing operation, there is no point in
vmtoolsd continuing with it. vmtoolsd should also give up the
operation asap. The vmtoolsd process can detect VMX state machine
change when it gets errors sending VMBACKUP_PROTOCOL_EVENT_SET RPC.
RPC errors are only used as a trigger to abort the operation.
We ignore the RPC errors that might occur after aborting the
operation.
Oliver Kurth [Wed, 16 Jan 2019 22:53:05 +0000 (14:53 -0800)]
Don't send a backup manifest when aborting a Linux quiesced snapshot.
When taking a Linux quiesced snapshot, communication failures between
VMX and VMTools may result in VMTools sending a genericManifest event
message after the quiesced snapshot operation has been aborted. If
this happens, VMX will send an error back to VMTools, which in turn
causes VMTools not to send genericManifest messages on subsequent
quiesced snapshots even if the host supports such messages.
One aspect of the implementation that gives rise to this behavior is
the use of the sync provider's snapshotDone function to undo a
quiescing operation. Specifically, if VMTools aborts a quiesced
snapshot when the file system is quiesced, the quiescing must be
undone. Currently, this is handled by calling the sync provider's
snapshotDone function. This is the same function that is called to
complete the quiescing snapshot protocol when it is successful. In
some respects this makes sense, since in either case snapshotDone
unquiesces the file system. However, architecturally and conceptually,
it seems useful to distinguish between the action to be taken in the
successful case versus the aborting case. It's also useful to do so
in practice, because the successful case sends the genericManifest
event to notify the host there is a backup manifest file, while the
aborting case should not do that.
To address the issue, add an "undo" function for the Linux sync
provider. The undo function is called instead of snapshotDone as
part of aborting a quiesced snapshot in which the file system is
quiesced at the time of the abort.
Recent discussions about setting "errno" to ENOENT when either
getpwuid_r() or getpwnam_r() return 0 (success) if there is no passwd
entry for the user have vacillated.
Since none of the current callers of the routines in procMgrPosix.c
query the contents of "errno", the current consensus is to simply log
a warning message along with reason for the failure.
Oliver Kurth [Tue, 18 Dec 2018 21:19:48 +0000 (13:19 -0800)]
General code clean-up.
bora/lib/misc/posixPosix.c:
Treat local variables "len" consistently as "size_t" type in
Posix_Getmntent_r()
bora-vmsoft/apps/toolbox-cmd/toolboxcmd-shrink.c:
Improve readability of error handling logic in ShrinkDoWipeAndShrink()
and remove another line of dead code.
Both gcc and clang (on Mac) warn for pointer-incompatible
assignments. It appears that gcc's -Wwarn-strings isn't working
properly, because it produces no warnings for the following
assignment:
char *potentialSegV = ".rodata-based string";
However, clang does.
This change addresses three problems in bora/lib that produce build
failures when -Wincompatible-pointer-types-discards-qualifiers is
enabled when using clang (one wonders how many other such potential
problems exist?)
o bsd_vsnprintf.c
The 'cp' pointer is assigned the address of a constant string.
Since there are writes through 'cp', the quickest solution is to
declare a local, non-const, array variable that holds the string
"(null)".
o unicodeSimpleTypes.c
This change, the easiest of the three, marks the 'char *' field as
'const'.
Oliver Kurth [Tue, 18 Dec 2018 21:19:47 +0000 (13:19 -0800)]
Fix NULL pointer dereference and remove three lines of dead code.
QbitLogic has run [Code]Ai on the open-vm-tools source code and
and notified VMware of a potential NULL pointer reference and four
pieces of dead code.
See https://github.com/vmware/open-vm-tools/pull/247
bora-vmsoft/services/vmtoolsd/pluginMgr.c
The proposed fix conditionally emitted a log message. That fix has
been reworked to consistently emit a log message with conditional
content.
bora/lib/misc/posixPosix.c
bora-vmsoft/apps/toolbox-cmd/toolboxcmd-shrink.c
Remove one line of dead code from each source file.
bora-vmsoft/lib/procMgr/procMgrPosix.c:
Suggested dead code fix actually pointed to a bug where errno
was not getting updated as intended.
bora-vmsoft/services/plugins/guestInfo/perfMonLinux.c:
Suggested dead code is no longer dead; change not applicable.
Oliver Kurth [Tue, 18 Dec 2018 21:19:46 +0000 (13:19 -0800)]
lib/file: Improve File_ListDirectory and File_WalkDirectory*
The File_WalkDirectory implementation has an initial latency (before
file names are available) that is unnecessary. Using the unicode
library, when not necessary, adds a huge amount of memory usage and
wastes CPU time.
These routines duplicate quite a bit of code.
Rewrite File_ListDirectory to use File_WalkDirectory*.
Rewrite File_WalkDirectory*:
- Return files as they are discovered, not after the entire directory
contents are parsed. If one decides to stop early, they don't have
to pay the price for the entire directory contents.
- Preserve the protection from duplicate file names. While Windows
locks a directory during a content tranverse, POSIXen does nott. Code
is here in the lib/file for quite some time so that the numerous
callers do not have to handle dealing with dups.
- Avoid using the unicode library on platforms where we can, this avoid
most of the eggregious memory usage.
- Don't use Dynbuf... Handling things directly is more efficient.
Oliver Kurth [Fri, 9 Nov 2018 22:59:39 +0000 (14:59 -0800)]
Adding the libappmonitor source to the open-vm-tools distribution.
In response to customer requests that the libappmonitor library from
the VMwares Guest SDK be opensourced, the libappmonitor code has been
bundled in open-vm-tools.
Oliver Kurth [Fri, 2 Nov 2018 22:28:26 +0000 (15:28 -0700)]
Hide static function declaration for Linux from FreeBSD and Solaris OVT
A recent change introduced a new static function
HgfsInvalidateParentsChildren() in bora-vmsoft/hgfs/fuse/cache.c. That
function is defined and called only in Linux builds.
The static function declaration should not be visible on FreeBSD OVT
builds.
Oliver Kurth [Fri, 2 Nov 2018 22:28:25 +0000 (15:28 -0700)]
GuestMapper: Detailed data fixes
The guestInfo detailed data for Photon was being reported incorrectly,
sometimes adding trailing whitespace when not needed.
The problem was how the release file was processed. It was being
processed (open/read/code/close) multiple times, and wasn't separating
each of the fields as it should. Fixed this.
Adding logging of what is sent by the guest; how things are mapped.
Oliver Kurth [Fri, 2 Nov 2018 22:28:25 +0000 (15:28 -0700)]
VIGOR and RPCI definitions for the tools hang detector events.
Define an array of ToolsHealthEvent to record the last N tools hang
events. By keeping a list of historical events since the power on,
we help ourselves trouble shooting guest/toolsd issues.
Use the first array element for the latest event. This simplifies
implementation as the DynArray can be easily capped by setting the
array count. This requires us to add a PushFront function to add
new element to the front of the DynArray.
Added the RPCI handler for the tools hang detector RPCI messages.
Oliver Kurth [Fri, 2 Nov 2018 22:28:20 +0000 (15:28 -0700)]
Common source file changes not directly applicable to open-vm-tools.
On Windows, the CDR tmp files under folder "VMwareDnD" will be kept
permanently in some cases after drag & drop.
Root cause: The existing strategy is to delete the folder before next reboot
of the machine, which is implemented through writing Windows HKLM registry.
However, for the non-administrator user, that user has no permission to
write the registry which in turn results in the temp files not being removed.
Solution: The temp files will be removed when the user disconnect the remote
desktop/app. The details are:
1. Client will remove the temp folder when remote desktop/app is disconnected
(rmks exits). Server will remove the temp folder when mksvchServer plugin
gets "Not Ready" notification which means mksvchanServer is disconnected
from the mksvchanClient.
2. Use prefix "Horizon_xxxx(pid)-" to distinguish if the temp folder is
being used by DnD or not. For Client, the pid is the rmks process id,
for Server, the pid is Clipboard pid.