Oliver Kurth [Tue, 17 Mar 2020 21:36:57 +0000 (14:36 -0700)]
bora/lib/unicode: fix leak on exit
The hashtable used for encoding name -> IANA table index
lookups was not getting freed.
Also, HashTable_AllocOnce() incorrectly instructs
the hashtable to clear its clientData, which contains
an integer index and not a pointer, using "free".
Oliver Kurth [Tue, 17 Mar 2020 21:36:57 +0000 (14:36 -0700)]
Fix a Coverity-reported overrun.
A Coverity scan of open-vm-tools reports a buffer overrun in
Escape_Unescape. The problem is that Escape_Unescape uses
sizeof('\0') to specify the size of a buffer that consists of
a single character in the variable nulByte (previously named
nullbyte). However, character literals in C are ints, so
sizeof('\0') is equivalent to sizeof int rather than sizeof char.
Use "sizeof nulByte" instead.
Oliver Kurth [Tue, 17 Mar 2020 21:36:56 +0000 (14:36 -0700)]
LOG variadic: remove LOGLEVEL_VARIADIC [1 of 2]
Mass conversion is complete. It's time to remove the intermediate state.
[1/2]: remove LOGLEVEL_VARIADIC from loglevel_defs.h. This removes the
backwards-compat path.
Oliver Kurth [Wed, 4 Mar 2020 20:07:13 +0000 (12:07 -0800)]
Mapping the deployPkg log error level to g_log warning level.
g_error() is always fatal, resulting in terminating the application. In
this case the guest customization will fail. So mapping the deployPkg log
error level to g_log warning level to avoid application termination.
Oliver Kurth [Wed, 4 Mar 2020 20:07:13 +0000 (12:07 -0800)]
Send GUESTRPCPKT_FIELD_FAST_CLOSE when doing one-off RPC via vsock
To work around a vsock/vmci/VMX issue with vsock cleanup, send a special
command that tells the VXM to immediately close a vsock after completing
an RPC. This minimizes delays/timeouts when sending one-off RPCs rapdily.
Can still run out of vsockets, but they clean up pretty quickly,
so add logic to sleep a bit and retry if ENOBUFS is returned
by connect().
Oliver Kurth [Wed, 4 Mar 2020 20:07:12 +0000 (12:07 -0800)]
Misc. Appinfo plugin cleanup.
- Used 'g' prefix for the global variables.
- Added '%s' at the beginning of each log message.
- Renamed a non-static function with the proper naming convention.
- Fixed documentation for few functions.
- Added '.' at the end of each log message to maintain consistency.
- Used proper '// IN' comments for each function argument.
Oliver Kurth [Wed, 4 Mar 2020 20:07:12 +0000 (12:07 -0800)]
Replace VixTools_ConfigGetBoolean with VMTools_ConfigGetBoolean
Initially came up with a utility function named VixTools_ConfigGetBoolean
to retrieve the boolean value from the config dictionary. This function
was designed as local/specific to VIX plugin. Later, VMTools_ConfigGetBoolean
function was designed with the same functionality and is being used everywhere
in the Tools repository.
This changeset gets rid of VixTools_ConfigGetBoolean and replaces
all those occurrences with VMTools_ConfigGetBoolean.
Oliver Kurth [Wed, 4 Mar 2020 20:07:12 +0000 (12:07 -0800)]
Common source file changes not directly applicable to open-vm-tools.
Fix procMgr library for Windows.
- For windows, to retrieve the command line for a target process,
the procMgr library creates a remote thread in the target process
and executes GetCommandLine function. This approach is OK. But for
few applications that are not built with proper flags, creating a
remote thread may crash the application. In order to avoid any
issues, it was decided not use the 'remote thread' approach by DEFAULT.
- Refactored the procMgr APIs to take an input argument from the
user if the 'remote thread' approach needs to be used.
- Refactored the procMgr APIs to conditionally use the WMI for
retrieving the command line for a target process.
- New options are provided to the user if the 'remote thread'
and 'WMI' approaches need to be forced. Modified the VIX tools plugin
to read and honor the new flags from tools.conf
The following are the new flags under guestoperations group.
useRemoteThreadForProcessCommandLine
useWMIForProcessCommandLine
The default value for the above new flags is false. User can set them
to true if needed.
- Re-factored some code in appInfo plugin that calls procMgr library.
The appinfo plugin doesn't really use the commandline. So, modified the
appinfo plugin to just use the API that doesn't use the complicated
approaches for the listing down the processes.
Oliver Kurth [Wed, 4 Mar 2020 20:07:12 +0000 (12:07 -0800)]
Arm64 backdoor: Disable USE_HYPERCALL for Arm64 tools build.
Undefine USE_HYPERCALL on ESXi-Arm to force the backdoor interface type
to BACKDOOR_INTERFACE_IO. This is necessary to fix the Arm64 tools build.
This change does not affect x86 (open-vm-tools).
Oliver Kurth [Wed, 4 Mar 2020 20:07:12 +0000 (12:07 -0800)]
FreeBSD has removed some vnops flags that have never been used.
Two flags that were being tested in the nullfs vnops.c source have
never actually been used by any filesystem layer on top of the nullfs.
FreeBSD is doing a little house cleaning and the VDESC_NOMAP_VPP and
VDESC_VPP_WILLRELE defines are being removed from the source base.
FreeBSD has provided source code changes for the FreeBSD vmblock
driver as they have made in identical nullfs code in the FreeBSD
base code.
Oliver Kurth [Wed, 4 Mar 2020 20:07:12 +0000 (12:07 -0800)]
Add hypercall to bora/lib/backdoor.
Use vmcall or vmmcall when they are available.
Removed #include <string.h>, it was added in an earlier version
but is not needed in the current code.
Limit HostinfoBackdoorGetInterface to x86 architecture.
Fix some indents.
Oliver Kurth [Wed, 4 Mar 2020 20:07:11 +0000 (12:07 -0800)]
Handle LSI Logic Parallel and BusLogic SCSI on PCI bus 0.
When a LSI Logic Parallel or BusLogic SCSI controller appears on PCI
bus 0, the disk device controller name is not present; the "label" file
is missing. Adding logic to check if disk device is attached to a
SCSI controller on bus 0 (0000:00:10.0) if a "label" file cannot be
found. If that is the case, setting the device name to "scsi0.n"
where "n" is the device unit number previously determined.
Oliver Kurth [Wed, 4 Mar 2020 20:07:11 +0000 (12:07 -0800)]
Fix broken PowerCLI Invoke-VMScript cmdtlet by an earlier change.
Also fixed a handle leak in VixToolsGetTokenHandleFromTicketID.
Note: Credential type VIX_USER_CREDENTIAL_TICKETED_SESSION, started by
VIX_COMMAND_ACQUIRE_CREDENTIALS, is not built upon VGAuth lib
VGAuth_GenerateSSPIChallenge/VGAuth_ValidateSSPIResponse, impersonation is
done via lib/impersonate/impersonate.c::Impersonate_Do, the loaded user
profile is designed to be unloaded after 5 minutes, but because vix.dll is
linked with stub lib poll whose Poll_CB_RTime() does not do anything, the
profile is never unloaded.
Oliver Kurth [Wed, 4 Mar 2020 20:07:11 +0000 (12:07 -0800)]
Handle Photon's "/dev/root" mount point when doing disk device mapping
Photon EFI boot VMs have the root disc mounted long before the various
PCI controllers are initialized and the attached devices enumerated.
When looking through the /proc/mounts, the root filesystem mounted
at '/' is displayed as if on device /dev/root/ But there is no "root"
device in /dev, nor in the PCI device tree at /sys/class/block. Later
Photon builds fabricate a block device at "/dev/root" but again nothing
in the /sys/class/block PCI tree.
For this situation, it is necessary to use the pseudo device's major and
minor number to access the PCI device tree through /sys/dev/block.
The major and minor device number can be extracted from the contents of
/proc/self/mountinfo.
Oliver Kurth [Wed, 4 Mar 2020 20:07:11 +0000 (12:07 -0800)]
Rectify a log spew in vmsvc logging (vmware-vmsvc-root.log)
When a LSI Logic Parallel SCSI controller sits in PCI bus 0
(SCSI controller 0), the Linux disk device enumeration does not provide
a "label" file with the controller name. This results in messages like
'GuestInfoGetDiskDevice: Missing disk device name; VMDK mapping
unavailable for "/var/log", fsName: "/dev/sda2"'
repeatedly appearing in the vmsvc logging. The patch converts what
previously was a warning message to a debug message and thus avoids
the log spew.
This patch has been made available for open-vm-tools 11.0.x on the
open-vm-tools github repo.
Oliver Kurth [Thu, 13 Feb 2020 00:49:09 +0000 (16:49 -0800)]
lib/file: memory leak in File_WalkDirectoryNext
During a sequence of POSIX readdir calls it is possible for a directory
to be rearranged and a file that was previously reported may be found
again. The code that protects the caller from seeing this isn't freeing
the file name string if a duplicate is discovered. Fix this.
Oliver Kurth [Mon, 6 Jan 2020 23:46:20 +0000 (15:46 -0800)]
Changes to common header files.
Make ALIGNED() functional for 64-bit Windows
The current implementation of ALIGNED in vm_basic_types.h only
works for compilers that are, or pretend to be, GCC. However,
it is reasonable to conclude that data specifically aligned
for one OS / compiler should be aligned the same way when built
with other tools or for OSes.
This change updates the ALIGNED macro to correctly function when
building on 64-bit Windows. If not using GCC-alike, or Windows,
the macro continues to expand to nothing.
The MSVC __declspec construct accepts a limited syntax, basically
requiring an integer literal (see pciPassthruInfo_public.h). It
must be a prefix operation.
The GCC __attribute__ is more expressive and can be postfix or
prefix, so it is moved to be prefix.
The bulk of the change moves the use of ALIGNED to be prefix in
all places that compile for the Workstation product on Windows.
Oliver Kurth [Mon, 6 Jan 2020 23:46:20 +0000 (15:46 -0800)]
Tools: More support for "VMware Tools for Linux-arm64"
Preliminary touch-ups in the main branch to support the upcoming upstreaming
of the "VMware Tools for Linux-arm64" build code.
bora-vmsoft/vgauth/service/servicePosix.c:
The glibc on arm64 does not have <sys/io.h>. It makes sense because I/O
ports are an x86-ism (for more details, sees
https://bugzilla.redhat.com/show_bug.cgi?id=1116162#c1 ). Instead of
making the inclusion conditions more complex, It was noticed that none
of the symbols defined in <sys/io.h> and <sys/sysinfo.h> are used in
this C file. So these inclusions are not necessary.
Oliver Kurth [Fri, 20 Dec 2019 20:25:51 +0000 (12:25 -0800)]
Changes to common source files not directly applicable to open-vm-tools.
Depriv the file locking code, part 1
This is the first change in a series of changes toward removing the
need to be root to use the file locking code. Here, doing some cleanup
and separate the file locking code from the device locking code.
Another later change will depriv the file locking code.
Oliver Kurth [Fri, 20 Dec 2019 20:25:50 +0000 (12:25 -0800)]
[Dynbuf] Rename DynBuf_GrowToFit to DynBuf_EnsureMinSize
As suggested, GrowToFit isn't a verb, suggest renaming the function to
DynBuf_EnsureMinSize, and change the description as "Ensure that the
size of the DynBuf is at least 'size'"
Change all references of DynBuf_GrowToFit to DynBuf_EnsureMinSize.
Oliver Kurth [Fri, 20 Dec 2019 20:25:50 +0000 (12:25 -0800)]
[Dynbuf] Fix minor bug in DynBuf_GrowToFit
DynBuf_GrowToFit tries to provide a dynbuf with size greater than the
given size. However, the second argument passed to DynBuf_Enlarge doesn't
match the intention. The size should be directly passed, not the
difference between the target and current size.