Oliver Kurth [Fri, 2 Aug 2019 18:07:20 +0000 (11:07 -0700)]
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 [Sun, 21 Jul 2019 00:15:19 +0000 (17:15 -0700)]
Make DEBUG_ONLY work with toplevel commas (Change part 3)
Now that all the C pre-processors in use support variadic macros, make
DEBUG_ONLY work with toplevel commas (i.e. commas which are outside of
any parentheses pair). This is useful in at least 2 ways:
In C code, to easily pass debug arguments to functions in debug builds
without any overhead in non-debug builds.
void
foo(DEBUG_ONLY(int debugArg,) // IN
int nonDebugArg) // IN
{
ASSERT(DebugFunc(debugArg));
NonDebugFunc(nonDebugArg);
}
Oliver Kurth [Sun, 21 Jul 2019 00:15:19 +0000 (17:15 -0700)]
Use two new inline functions to replace most of the uses of
HGFS_LARGE_IO_MAX and HGFS_LARGE_PACKET_MAX macros.
In preparation to bump up HGFS_LARGE_IO_MAX and HGFS_LARGE_PACKET_MAX,
replace most uses of the two macro constants with inline functions that
can return either the new limits or the older defaults based on the
configuration.
Oliver Kurth [Sun, 21 Jul 2019 00:15:18 +0000 (17:15 -0700)]
Avoid emitting a trailing comma in the GuestInfoSendDiskInfoV1 JSON RPC
Although currently accepted by the JSMN library that we are using
in VMX, that superfluous comma is strictly invalid according to the
JSON standard - ECMA-404.
Oliver Kurth [Sun, 21 Jul 2019 00:03:42 +0000 (17:03 -0700)]
Avoid emitting a trailing comma in the GuestInfoSendDiskInfoV1 JSON RPC
Although currently accepted by the JSON library that we are using
in VMX, that superfluous comma is strictly invalid according to the
JSON standard - ECMA-404.
Oliver Kurth [Wed, 3 Jul 2019 21:28:56 +0000 (14:28 -0700)]
Fix process command name for special linux processes.
While listing down the processes in a linux guest, the existing
procMgr library reads /proc/<PID>/cmdline file and parses the
content. While reading this, an assumption is made that there is
a null terminating character at the end of the file content.
This holds true for most of the processes. But for few special processes,
the cmdline file doesn't have the terminating null character.
Oliver Kurth [Wed, 3 Jul 2019 21:28:56 +0000 (14:28 -0700)]
Fix the command name for few linux processes.
ProcMgr library publishes the 'command name' attribute for
each process while listing down all the processes. For doing this,
the commandline is first parsed from /proc/<PID>/cmdline file
and the part starting from the right-most '/' is considered as the
command name. This is OK only if we have an absolute path for the
command binary. Other wise, this may result in incorrect results.
For example:
sshd: root@pts/1
gdm-session-worker [pam/gdm-autologin]
Fixed the code to ignore the parsing if we do not have an absolute
path.
Note: There are two ways how the command name is retrieved for each
process.
1. /proc/<PID>/cmdline is parsed.
If (1) fails for some reason, then
2. /proc/<PID>/status is parsed.
There is no issue with (2). This changeset fixes the parsing issue only
with (1) approach mentioned above.
Oliver Kurth [Wed, 3 Jul 2019 21:28:56 +0000 (14:28 -0700)]
Add support for NVMe disks; IDE and SATA disk devices in 3.x Linux kernels
Support has been added for virtual disks attached to an NVMe
controller. The device "label" will provide the "nvme<n>" for the
controller. The disk unit is provided in the device "nsid" file.
An earlier implementation (Linux 2.6 kernels) provided the unit
number as the final digit group in the device node name.
The Linux 3.x kernel has some differences in the layout of IDE and
SATA disk devices in the sysfs filesystem. The differences from the
sysfs in a 2.6 Linux kernel are:
- The IDE "class" file and SATA "class" and "label" files are in a
different directory.
- IDE controller and SATA device nodes begin with "ata" where "host"
was used in earlier kernel sysfs filesystems.
GuestInfoGetDevClass() has been modfied to check in two possible
locations for the "class" file. The directory located will also
contain the "label" file for SCSI, SAS, and SATA disk devices.
GuestInfoGetIdeSataDev() has been modified to search for either
ata<n> or host<n> directories in the sysfs tree for the disk device.
Oliver Kurth [Wed, 3 Jul 2019 21:26:55 +0000 (14:26 -0700)]
Truncate oversize partition names
Truncate disk partition names if they are too large, rather than just
skipping all the disk information for the guest. Closes
https://github.com/vmware/open-vm-tools/issues/346 .
This patch aims to fix an issue found by Coverity Scan.
This issue is a False Positive, the outBuf is only freed in specific
scenario, so there is no 'BAD FREE'. But it's better to reconstruct the
related code to clear the SCA error.
Oliver Kurth [Mon, 17 Jun 2019 18:41:38 +0000 (11:41 -0700)]
linuxDeployment.c: Suppress the telinit error if the first telinit commands
has made VM reboot.
The code executes '/sbin/telinit 6' repeatedly to reboot VM. VM will be
rebooting if the telinit command executed successfully(exitcode==0).
Observed the repeated telinit command might get error(exitcode==1) on some
GOSes, ex: Ubuntu18.04, RHEL7.4/7.5 and Fedora 29.
Observed no such error on older GOSes, ex: Ubuntu14.04, RHEL6.6
The error telinit log is confusing, actually it does NOT mean customization
failed.
This change does NOT log telinit error, and returns deployPkg status to
make sure the log is consistent with customization result when the first
'telinit 6' succeeded but one of the following 'telinit 6' command failed.
The following actions are unchanged with or without this change:
1. log telinit error, stop loop and exit 127 if the first 'telinit 6' fails.
2. repeatedly execute 'telinit 6' if previous one executed successfully
(exitcode==0).
Fix coverity uninitialized variable "requestId" by zeroing it
in HgfsServerGetRequest before passing to the request packet
HgfsUnpackPacketParams extraction function which will use it
in a log message.
Also moved an assert useful for testing protocol changes which was
incorrect in its placement.
Oliver Kurth [Mon, 17 Jun 2019 18:41:37 +0000 (11:41 -0700)]
Determine Linux OS disk devices associated with mounted filesystems.
For each filesystem for which disk guestInfo is currently collected,
determine the virtual hardware device being used. This is currently
represented as <cntrl class><cntrl #>:<device #>, eg. scsi0:0,
scsi1:0, ide0:0 or sata1:4 and matches the virtual device label seen
in VMX.
A Linux logical volume based filesystem can reside on multiple disks.
In order to handle LVMs, the disk devices for each filesystem are
maintained as a variable array of disk device names.
For Linux guests, disk device names are passed as a json array.
Oliver Kurth [Mon, 17 Jun 2019 18:41:37 +0000 (11:41 -0700)]
Fix 'Using uninitialized value' issue reported by Coverity.
* In a error code path, 'exitCode' variable is used without
any initialization. This issue was reported by the Coverity.
Fixed it by initializing the 'exitCode' to -1.
* While fixing this, moved the variables to the if block where
they are acutally used.
Oliver Kurth [Mon, 17 Jun 2019 18:41:36 +0000 (11:41 -0700)]
Improvements for ProcMgr library.
* This changeset fixes various issues related to ProcMgr library.
== Retrieve the absolute path of the image for each process ==
* When listing down the processes, it is useful to retrieve the
absolute path of the process binary.
=== For Linux ===:
* In /proc filesystem, /proc/{PID}/exe is a symlink to the binary
and we can make use of it to figure out the absolute path.
* If /proc/{PID}/exe is not a valid symlink, then the 'cmdline'
is parsed and aboslute path is calculated accordingly.
* Note: This changeset tries its best to figure out the absolute path.
If it can't, then the attribute is set to NULL.
== Misc issues fixed. ==
=== Linux ===
* Fixed a memory leak with 'procCmdName' while looping through the
/proc/ directory entries.
* Fixed another memory leak with cmdLineTemp and cmdStatTemp variables
while listing down the processes in linux guests.
* In few cases, /proc/{PID}/cmdline file contains multiple NUL
characters at the end. In that case, the existing code converts them
into 'whitespaces'. Fixed the code to chop of all the trailing
whitespaces in the command line.
Oliver Kurth [Mon, 3 Jun 2019 20:39:45 +0000 (13:39 -0700)]
Fix memory leak in SNEBuildHash function.
In a specific code path, if a key already exists in the hashtable,
the memory allocated for 'value' variable is not being freed. This
leads to a memory leak. Fixed.
Oliver Kurth [Mon, 3 Jun 2019 20:39:44 +0000 (13:39 -0700)]
Crash during File_WalkDirectoryNext
In the rewrite of File_WalkDirectoryNext, a bug was introduced in the
invalid Unicode path. Invalid Unicode occurs very rarely... and the
bug finally turned up. Fix this... the bug is rather obvious.
Oliver Kurth [Mon, 3 Jun 2019 20:39:44 +0000 (13:39 -0700)]
Fix asianux identification.
Add asianux to distroArray and change how asianux releases 7 and 8
are identified.
This came in as a pull request on github for open-vm-tools:
https://github.com/vmware/open-vm-tools/pull/325 . Apparently
the OS identification in /etc/asianux-release changed with Asianux
7, and as a result tools does not identify it correctly.
Oliver Kurth [Mon, 3 Jun 2019 20:39:44 +0000 (13:39 -0700)]
Update to common source code; does not affect open-vm-tools.
Allow an asyncWebSocket to connect through an existing socket descriptor
Because Windows does not allow unprivileged processes to specify
DSCP (formerly ToS) values on TCP traffic, in order to support
DSCP for Blast WebSockets we must obtain a preconfigured socket
descriptor from a privileged process and then build the WebSocket
connection over that socket.
This changeset extends the asyncWebSocket API by adding a Connect
function that can accept and use an existing socket descriptor in
addition to the usual collection of WebSocket Connect parameters.
Because the asyncWebSocket is built over an asyncTCPSocket, this
change ripples down into the asyncTCPSocket API which also gets a
new Connect variant with a socket descriptor parameter.
To avoid duplicating existing logic, the old Connect variants
are modified to do their work by invoking the new API with
a distinguished socket descriptor value of -1. This value
indicates that no existing socket descriptor is provided and
that a new socket should be created and used for the connection.
In this changeset, passing in an existing socket is supported
only on the Windows platform. The feature is not required on
other platforms, where unprivileged processes are permitted to
define DSCP values for their connections. Attempting to create
a connection over an existing socket on other platforms will
result in a Connect failure.
Oliver Kurth [Mon, 3 Jun 2019 20:39:44 +0000 (13:39 -0700)]
Round out Log functions to all levels
Logs would be measurably more useful for debugging if the available
levels were used correctly and consistently. As a step towards
encouraging such use, define Log_Warning() and Log_Info() as synonyms
for Warning() and Log() (which, for historical reasons, are not
declared in log.h). Also remove all the conflicting private definitions.