Browse Source

New upstream version 10.3.0

tags/upstream/10.3.0^0
Bernd Zeimetz 2 years ago
parent
commit
6fd496d8c8
100 changed files with 38766 additions and 10845 deletions
  1. +0
    -1
      README.md
  2. +47
    -16
      ReleaseNotes.md
  3. +11
    -0
      open-vm-tools/AUTHORS
  4. +36198
    -8792
      open-vm-tools/ChangeLog
  5. +5
    -27
      open-vm-tools/LICENSE
  6. +3
    -124
      open-vm-tools/README
  7. +1
    -1
      open-vm-tools/common-agent/Cpp/Framework/Framework/include/BaseDefines.h
  8. +8
    -1
      open-vm-tools/common-agent/Cpp/Framework/Framework/include/Exception/CCafException.h
  9. +7
    -3
      open-vm-tools/common-agent/Cpp/Framework/Framework/include/Memory/DynamicArray/TDynamicArray.h
  10. +2
    -2
      open-vm-tools/common-agent/Cpp/Framework/Framework/src/Common/CApplicationContext.cpp
  11. +2
    -1
      open-vm-tools/common-agent/Cpp/Framework/Framework/src/Integration/Core/CDocument.cpp
  12. +2
    -1
      open-vm-tools/common-agent/Cpp/Framework/Framework/src/Integration/Core/CIntMessage.cpp
  13. +2
    -1
      open-vm-tools/common-agent/Cpp/Framework/Subsystems/Integration/src/CRecipientListRouterInstance.cpp
  14. +8
    -3
      open-vm-tools/common-agent/Cpp/ManagementAgent/Subsystems/MaIntegration/src/CMonitorListener.cpp
  15. +2
    -4
      open-vm-tools/common-agent/Cpp/ManagementAgent/Subsystems/MaIntegration/src/CMonitorListener.h
  16. +116
    -40
      open-vm-tools/configure.ac
  17. +1
    -3
      open-vm-tools/lib/appUtil/appUtil.c
  18. +191
    -55
      open-vm-tools/lib/asyncsocket/asyncsocket.c
  19. +11
    -4
      open-vm-tools/lib/auth/authPosix.c
  20. +8
    -2
      open-vm-tools/lib/dynxdr/Makefile.am
  21. +10
    -6
      open-vm-tools/lib/dynxdr/dynxdr.c
  22. +88
    -72
      open-vm-tools/lib/file/file.c
  23. +18
    -10
      open-vm-tools/lib/file/fileIO.c
  24. +81
    -23
      open-vm-tools/lib/file/fileIOPosix.c
  25. +37
    -12
      open-vm-tools/lib/file/fileLockPrimitive.c
  26. +31
    -7
      open-vm-tools/lib/file/filePosix.c
  27. +2
    -2
      open-vm-tools/lib/file/fileStandAlone.c
  28. +57
    -17
      open-vm-tools/lib/file/fileTemp.c
  29. +230
    -171
      open-vm-tools/lib/file/fileTempPosix.c
  30. +9
    -9
      open-vm-tools/lib/guestApp/guestApp.c
  31. +7
    -1
      open-vm-tools/lib/guestRpc/Makefile.am
  32. +88
    -8
      open-vm-tools/lib/hashMap/hashMap.c
  33. +2
    -2
      open-vm-tools/lib/hgfs/hgfsEscape.c
  34. +79
    -92
      open-vm-tools/lib/hgfsServer/hgfsServer.c
  35. +2
    -2
      open-vm-tools/lib/hgfsServer/hgfsServerInt.h
  36. +74
    -74
      open-vm-tools/lib/hgfsServer/hgfsServerParameters.c
  37. +2
    -2
      open-vm-tools/lib/hgfsServer/hgfsServerParameters.h
  38. +6
    -1
      open-vm-tools/lib/include/asyncsocket.h
  39. +7
    -3
      open-vm-tools/lib/include/backdoor_def.h
  40. +6
    -6
      open-vm-tools/lib/include/buildNumber.h
  41. +23
    -1
      open-vm-tools/lib/include/conf.h
  42. +4
    -3
      open-vm-tools/lib/include/config.h
  43. +1
    -28
      open-vm-tools/lib/include/cpuid_info.h
  44. +30
    -2
      open-vm-tools/lib/include/deployPkg/linuxDeployment.h
  45. +12
    -4
      open-vm-tools/lib/include/err.h
  46. +12
    -23
      open-vm-tools/lib/include/file.h
  47. +11
    -1
      open-vm-tools/lib/include/fileIO.h
  48. +22
    -1
      open-vm-tools/lib/include/ghIntegrationCommon.h
  49. +70
    -5
      open-vm-tools/lib/include/guestStats.h
  50. +4
    -7
      open-vm-tools/lib/include/guest_os.h
  51. +10
    -6
      open-vm-tools/lib/include/guest_os_tables.h
  52. +2
    -1
      open-vm-tools/lib/include/hashMap.h
  53. +71
    -47
      open-vm-tools/lib/include/hgfsProto.h
  54. +0
    -226
      open-vm-tools/lib/include/hgfsTransport.h
  55. +6
    -5
      open-vm-tools/lib/include/hostinfo.h
  56. +19
    -13
      open-vm-tools/lib/include/libExport.hh
  57. +4
    -3
      open-vm-tools/lib/include/loglevel_user.h
  58. +4
    -2
      open-vm-tools/lib/include/nicInfo.h
  59. +8
    -1
      open-vm-tools/lib/include/poll.h
  60. +2
    -1
      open-vm-tools/lib/include/posix.h
  61. +7
    -1
      open-vm-tools/lib/include/rpcvmx.h
  62. +0
    -187
      open-vm-tools/lib/include/safetime.h
  63. +3
    -3
      open-vm-tools/lib/include/slashProc.h
  64. +9
    -30
      open-vm-tools/lib/include/str.h
  65. +2
    -1
      open-vm-tools/lib/include/strutil.h
  66. +1
    -4
      open-vm-tools/lib/include/system.h
  67. +6
    -2
      open-vm-tools/lib/include/unicodeBase.h
  68. +4
    -1
      open-vm-tools/lib/include/util.h
  69. +12
    -14
      open-vm-tools/lib/include/uuid.h
  70. +284
    -192
      open-vm-tools/lib/include/vm_atomic.h
  71. +3
    -3
      open-vm-tools/lib/include/vm_basic_asm.h
  72. +5
    -7
      open-vm-tools/lib/include/vm_basic_asm_x86_common.h
  73. +16
    -59
      open-vm-tools/lib/include/vm_basic_defs.h
  74. +84
    -141
      open-vm-tools/lib/include/vm_basic_types.h
  75. +7
    -2
      open-vm-tools/lib/include/vm_device_version.h
  76. +6
    -5
      open-vm-tools/lib/include/vm_legal.h
  77. +7
    -12
      open-vm-tools/lib/include/vm_product.h
  78. +49
    -34
      open-vm-tools/lib/include/vm_product_versions.h
  79. +24
    -3
      open-vm-tools/lib/include/vm_tools_version.h
  80. +3
    -1
      open-vm-tools/lib/include/vmblock.h
  81. +5
    -2
      open-vm-tools/lib/include/vmware/guestrpc/deploypkg.h
  82. +16
    -15
      open-vm-tools/lib/include/vmware/tools/guestrpc.h
  83. +3
    -1
      open-vm-tools/lib/include/vmware/tools/plugin.h
  84. +4
    -1
      open-vm-tools/lib/include/vmware/tools/utils.h
  85. +107
    -85
      open-vm-tools/lib/include/x86cpuid.h
  86. +2
    -2
      open-vm-tools/lib/include/x86vendor.h
  87. +20
    -11
      open-vm-tools/lib/include/xdrutil.h
  88. +1
    -2
      open-vm-tools/lib/lock/ulInt.h
  89. +8
    -6
      open-vm-tools/lib/misc/hostinfoPosix.c
  90. +34
    -1
      open-vm-tools/lib/misc/posixPwd.c
  91. +42
    -3
      open-vm-tools/lib/misc/strutil.c
  92. +3
    -3
      open-vm-tools/lib/misc/timeutil.c
  93. +171
    -2
      open-vm-tools/lib/misc/utilMem.c
  94. +4
    -4
      open-vm-tools/lib/misc/util_misc.c
  95. +6
    -6
      open-vm-tools/lib/misc/vmstdio.c
  96. +6
    -4
      open-vm-tools/lib/misc/vthreadBase.c
  97. +7
    -1
      open-vm-tools/lib/netUtil/Makefile.am
  98. +7
    -7
      open-vm-tools/lib/nicInfo/Makefile.am
  99. +8
    -4
      open-vm-tools/lib/nicInfo/nicInfo.c
  100. +4
    -2
      open-vm-tools/lib/nicInfo/nicInfoInt.h

+ 0
- 1
README.md View File

@@ -113,7 +113,6 @@ You can get involved today in several different ways:
* Oracle Linux 7 and later
* Fedora 19 and later releases
* openSUSE 11.x and later releases
* FreeBSD 10.x and later releases
## Will external developers be allowed to become committers to the project?
Yes. Initially, VMware engineers will be the only committers. As we roll out our development infrastructure, we will be looking to add external committers to the project as well.


+ 47
- 16
ReleaseNotes.md View File

@@ -1,6 +1,9 @@
**Updated on: 29 MAR 2018**
open-vm-tools 10.3.0 Release Notes
==================================

open-vm-tools | 29 MAR 2018 | Build 8068406
**Updated on: 12 JUL 2018**

open-vm-tools | 12 JUL 2018 | Build 8931395

Check for additions and updates to these release notes.

@@ -19,16 +22,15 @@ The release notes cover the following topics:
What's New
----------

* **Quiesced snapshots**: Ability to exclude specific file systems from quiesced snapshots on Linux guest operating systems. This configuration can be set in the tools configuration file. For more details, see the VMware Tools [Documentation](https://docs.vmware.com/en/VMware-Tools/index.html) page.
* **Disable display mode setting**: A configuration option is introduced to disable normal display mode setting functionality using open-vm-tools. For more details, see [KB 53572](https://kb.vmware.com/s/article/53572).
* **Resolved Issues: **This release of open-vm-tools resolves few issues which are documented in the [Resolved Issues](#resolvedissues) section of this release notes.
* Starting with 10.3.0, open-vm-tools builds with xmlsec1 by default (instead of building with xml-security). To revert to the old behavior and build with xml-security, use the option
'--enable-xmlsecurity' for the ./configure command.

Before You Begin
----------------

Important note about upgrading to ESXi 5.5 Update 3b or later
**Important note about upgrading to ESXi 5.5 Update 3b or later**

Resolution on incompatibility and general guidelines: While upgrading ESXi hosts to ESXi 5.5 Update 3b or ESXi 6.0 Update 1 or later, and using older versions of Horizon View Agent, refer to the knowledge base articles:
General guidelines: While upgrading ESXi hosts to ESXi 5.5 Update 3b or ESXi 6.0 Update 1 or later, and using older versions of Horizon View Agent, refer to the knowledge base articles:

* [Connecting to View desktops with Horizon View Agent 5.3.5 or earlier hosted on ESXi 5.5 Update 3b or later fails with a black screen.](http://kb.vmware.com/kb/2144438)
* [Connecting to View desktops with Horizon View Agent 6.0.x or 6.1.x hosted on ESXi 5.5 Update 3b or later fails with a black screen.](http://kb.vmware.com/kb/2144518)
@@ -37,7 +39,7 @@ Resolution on incompatibility and general guidelines: While upgrading ESXi hosts
Internationalization
--------------------

open-vm-tools 10.2.5 is available in the following languages:
open-vm-tools 10.3.0 is available in the following languages:

* English
* French
@@ -52,25 +54,54 @@ open-vm-tools 10.2.5 is available in the following languages:
Compatibility Notes
-------------------

* open-vm-tools 10.2.5 is compatible with supported versions of VMware vSphere ESXi 5.5 and later, VMware Workstation 14.0 and VMware Fusion 10.0. See [VMware Compatibility Guide](http://www.vmware.com/resources/compatibility/search.php) for more information.
* Starting with open-vm-tools version 10.2.0, Perl script-based open-vm-tools installation for FreeBSD has been discontinued. FreeBSD systems are supported only through the open-vm-tools packages directly available from FreeBSD package repositories. FreeBSD packages for open-vm-tools 10.1.0 and later are available from FreeBSD package repositories.
* As of tools release 10.2.0, FreeBSD guests are supported only by open-vm-tools; support for the VM Tools binary package supplied directly by VMware has been discontinued for FreeBSD. Binary packages for open-vm-tools 10.1.0 and later are available from FreeBSD package repositories.

### Guest Operating System Customization Support

The [Guest OS Customization Support Matrix](http://partnerweb.vmware.com/programs/guestOS/guest-os-customization-matrix.pdf) provides details about the guest operating systems supported for customization.
The [Guest OS Customization Support Matrix](http://partnerweb.vmware.com/programs/guestOS/guest-os-customization-matrix.pdf) provides details about the guest operating systems supported for customization.


Resolved Issues
---------------

* **open-vm-tools 10.2.0 does not recognize UFS filesystem partitions**
* **The open-vm-tools process might take a long time and consume 100% CPU of a core in a Linux OS with many IPv6 routes**
open-vm-tools 10.2.0 has dropped UFS from the list of known file system type. As a result, the default filesystem of Solaris and FreeBSD is not recognized. open-vm-tools Services in the GuestInfo for the virtual machine do not report these filesystems. You might not be able to monitor the disk usage of UFS filesystems with vRealize Operations or vCenter Managed Object Browser.
Prior to open-vm-tools 10.3.0, gathering network adapter information in a Linux guest OS with many IPv6 routes was a time-consuming process with 100% use of the CPU of a core. The exported data contained only a maximum of 100 routes. IPv4 routes took precedence over IPv6, leading to data loss in reporting IPv6 routes. If there were more than 100 IPv4 routes, IPv6 routes were not reported.
This performance issue has been resolved in this release. The default routes gathering behavior can be overridden by configuring the values in the /etc/vmware-tools/tools.conf file:
\[guestinfo\]
max-ipv4-routes=0
max-ipv6-routes=0
Note: If they are not manually set, or an invalid value (over 100 or less than 0) is set, 'max-ipv4-routes' and 'max-ipv6-routes' are set to 100 by default. They can be set to 0 to disable the data collection.
This issue is resolved in this release.
* **Information about non-existing device mounted to a file system was not reported**
* **Installation of the libvmtools package might fail the installation of VMware Tools**
Few Linux guest operating systems might have a non-existing device mounted to a filesystem. For example /dev/root/. open-vm-tools does not report this information.
When the package "libvmtools0" is installed in SUSE Linux 12 and open-vm-tools is not installed, the VMware Tools installer fails. This is done to prevent an incomplete installation. Users have to uninstall both open-vm-tools and libvmtools0 packages to install VMware Tools.
This issue is resolved in this release.
Known Issues
------------

* **Drag and Drop functionality fails to work in Ubuntu**
Drag and Drop functionality fails to work in Ubuntu 16.04.4 32-bit virtual machines installed using easy install. Also, failure of copy and paste functionality is observed in the same system.
Workaround:
* Add the modprobe.blacklist=vmwgfx linux kernel boot option.
* To gain access to larger resolutions, remove svga.guestBackedPrimaryAware = "TRUE" option from the VMX file.

* **Shared Folders mount is unavailable on Linux VM**
If the **Shared Folders** feature is enabled on a Linux VM while it is powered off, shared folders mount is not available upon restart.
Workaround: If the VM is powered on, disable and enable the **Shared Folders** feature from the interface.
For resolving the issue permanently, edit **/etc/fstab** and add an entry to mount the Shared Folders automatically on boot.
For example, add the line:
vmhgfs-fuse /mnt/hgfs fuse defaults,allow_other 0 0

+ 11
- 0
open-vm-tools/AUTHORS View File

@@ -25,3 +25,14 @@ Mike Latimer Restrict udev rules to disk devices only

Thomas Mueller Ignore ENXIO errors with SyncDriver
- https://github.com/vmware/open-vm-tools/pull/218

Germán M. Bravo FreeBSD: Improper use of sysconf() for getpwent buffer size
leads to vmtoolsd crash.
- https://github.com/vmware/open-vm-tools/pull/238

Ed Schouten Use standard SYSCTL_ADD_OID() macro to access the
sysctl_add_oid() function across supported FreeBSD releases.
- https://github.com/vmware/open-vm-tools/pull/125

Steve Wills Fix vmmemctl.ko driver build for supported FreeBSD releases.
- https://github.com/vmware/open-vm-tools/pull/140

+ 36198
- 8792
open-vm-tools/ChangeLog
File diff suppressed because it is too large
View File


+ 5
- 27
open-vm-tools/LICENSE View File

@@ -1,10 +1,10 @@
LICENSE

Open-vm-tools v10.2.5
Open-vm-tools v10.3.0

The Linux kernel modules are released under the GPL v2, a majority of the user level components are released under the LGPL v2.1, and the SVGA and mouse drivers are released under the X11 license.

Copyright © 2007-2018 VMware, Inc. All rights reserved.
Copyright © 2007-2018 VMware, Inc. All rights reserved.

=========================================================================
GNU GENERAL PUBLIC LICENSE
@@ -231,7 +231,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI

========

Open-vm-tools v10.2.5 includes a number of subcomponents with separate copyright notices and license terms. Your use of the source code for these subcomponents is subject to the terms and conditions of the following licenses.
Open-vm-tools v10.3.0 includes a number of subcomponents with separate copyright notices and license terms. Your use of the source code for these subcomponents is subject to the terms and conditions of the following licenses.


SECTION 1: BSD-STYLE, MIT-STYLE, OR SIMILAR STYLE LICENSES
@@ -243,11 +243,10 @@ SECTION 1: BSD-STYLE, MIT-STYLE, OR SIMILAR STYLE LICENSES
===================================================


--------------- SECTION 1: BSD-STYLE, MIT-STYLE, OR SIMILAR STYLE LICENSES ----------
--------------- SECTION 1: BSD-STYLE, MIT-STYLE, OR SIMILAR STYLE LICENSES ----------

BSD-STYLE, MIT-STYLE, OR SIMILAR STYLE LICENSES are applicable to the following component(s).


>>> freebsd-base64-4.8

base64.c -- routines to encode/decode base64 data
@@ -348,26 +347,5 @@ THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,

Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in these Data Files or Software without prior written authorization of the copyright holder.



===========================================================================

To the extent any open source components are licensed under the
GPL and/or LGPL, or other similar licenses that require the
source code and/or modifications to source code to be made
available (as would be noted above), you may obtain a copy of
the source code corresponding to the binaries for such open
source components and modifications thereto, if any, (the
"Source Files"), by downloading the Source Files from VMware's website at
http://www.vmware.com/download/open_source.html, or by sending a request, with
your name and address to: VMware, Inc., 3401 Hillview Avenue,
Palo Alto, CA 94304,United States of America. All such
requests should clearly specify: OPEN SOURCE FILES REQUEST,
Attention General Counsel. VMware shall mail a copy of the
Source Files to you on a CD or equivalent physical medium. This
offer to obtain a copy of the Source Files is valid for three
years from the date you acquired this Software product. Alternatively,
the Source Files may accompany the VMware product.

[OPENVMTOOLS1025GAVS022118]
[OPENVMTOOLS1030GANV061518]


+ 3
- 124
open-vm-tools/README View File

@@ -1,126 +1,5 @@
Project information:
This file is no longer distributed with open-vm-tools.

open-vm-tools <http://open-vm-tools.sourceforge.net/>
For current project information and release notes, please refer to
README.md and ReleaseNotes.md at https://github.com/vmware/open-vm-tools

These are the release notes for the open-vm-tools. Read them carefully, as
they explain how to build this project for different platforms and various
different Linux distributions.

================================================================================
General information:

(*)What are the open-vm-tools?
The open-vm-tools are a subset of the VMware Tools, currently composed of
kernel modules for Linux and user-space programs for all VMware supported Unix
like guest operating systems.

(*)Where do I find documentation for the open-vm-tools beyond this README?
Please refer to the main project web site for all the latest documentation
at: <http://open-vm-tools.sourceforge.net/>

(*)How do I build the open-vm-tools?
The open-vm-tools uses the GNU Automake tool for generating Makefiles to
build all sources. More information about Automake can be found here:
<http://sources.redhat.com/automake/>

For more information on building this project see the "Project build
information" section of this document.

================================================================================
Project build information:

(*)Getting configure options & help:
If you are looking for help or additional settings for the building of this
project the following configure command will display a list of help options:
"./configure --help"

(*)Using configure:
When using configure in the steps below it is only necessary to call
"./configure" once unless there was a problem after the first invocation.

(*)Building Unix user-space programs:
1) "./configure"
2) Run "make" to build Unix userland programs
3) Run "make modules" to build kernel modules

(*)Packaging:
If you are interested in creating a Tools package, please see
<https://sourceforge.net/apps/mediawiki/open-vm-tools/index.php?title=Packaging>
for more information.

================================================================================
Build suggestions:
Each Linux distribution puts binaries, libraries and development headers in
different locations. This leads to having to setup different paths for the
compiler and linker for the Automake system. Below is a list of known
configurations to build for platforms that do not "just work" out of the box
or the tar-ball as the case may be.

General Build note:
Please make note that the "--disable-multimon" flag should only be used when
there are no libXinerama libraries installed, or you do not want to enable multi
monitor support.

Your operating system version will influence which kernel
modules can be built. Here are the minimum OS versions for each
module:

|------------------------------------------------------------------------------|
| vmsync | vmblock | vmxnet | vmmemctl | vmhgfs |
|---------------|----------------|--------------|----------------|-------------|
| Linux 2.6.6 | Linux 2.4.0 | Linux 2.2.0 | Linux 2.2.0 | Linux 2.4.0 |
| FreeBSD N/A | FreeBSD 6.0 | FreeBSD 4.9 | FreeBSD 3.2 | |
|------------------------------------------------------------------------------|

(*)Suse Enterprise 10.1 (i386 & x86_64):
i386:
./configure LDFLAGS="-L/opt/gnome/lib"

x86_64:
./configure LDFLAGS="-L/opt/gnome/lib64"

(*)OpenSolaris "Nevada" (i386 & x86_64):
Before building open-vm-tools on Solaris, you will need to make
sure that libdnet (http://libdnet.sourceforge.net/) is installed and
that the 'dnet-config' script is on your shell's PATH.

Make sure that the GNU tools are in your shell's PATH. The
default GNU tools location on OpenSolaris is: "/usr/sfw/bin". Once the
PATH is set in your build shell then the following configure command
should work:

./configure --disable-multimon

(*)FreeBSD 6.2 (i386 & x86_64):
./configure LDFLAGS="-L/usr/local/lib"

================================================================================
Other resources:
There are also open-source video & mouse drivers for Xorg/XFree86 that
provide better performance and additional features to Linux, Solaris, and BSD
derivatives guests running X11.

The drivers 'xf86-input-vmmouse' and 'xf86-video-vmware' are included with
recent Xorg releases, and it shouldn't be necessary to do anything extra to
obtain them. If you want to obtain them separately, they can be downloaded at:
<http://xorg.freedesktop.org/releases/individual/driver/>

================================================================================
Guest operating systems used to test on this release:

(*)Fedora Core 8 (i386 & x86_64)
(*)Redhat 9.0 (i386)
(*)Redhat Enterprise 4 U5 (i386 & x86_64)
(*)Redhat Enterprise 5 (i386 & x86_64)
(*)FreeBSD 5.4 (i386 & x86_64)
(*)FreeBSD 6.2 (i386 & x86_64)
(*)OpenSolaris 10 "Nevada" (i386 & x86_64)
(*)Open SuSE 10.3 (i386 & x86_64)
(*)Ubuntu 6.04 (i386 & x86_64)
(*)Ubuntu 7.10 (i386 & x86_64)

===============================================================================
Known issues:


===============================================================================

+ 1
- 1
open-vm-tools/common-agent/Cpp/Framework/Framework/include/BaseDefines.h View File

@@ -2,7 +2,7 @@
* Author: mdonahue
* Created: Jan 12, 2011
*
* Copyright (C) 2011-2016 VMware, Inc. All rights reserved. -- VMware Confidential
* Copyright (C) 2011-2018 VMware, Inc. All rights reserved. -- VMware Confidential
*/

#ifndef SYS_INC_BASEDEFINES_H_


+ 8
- 1
open-vm-tools/common-agent/Cpp/Framework/Framework/include/Exception/CCafException.h View File

@@ -2,12 +2,19 @@
* Author: mdonahue
* Created: Jan 13, 2011
*
* Copyright (C) 2011-2016 VMware, Inc. All rights reserved. -- VMware Confidential
* Copyright (C) 2011-2018 VMware, Inc. All rights reserved. -- VMware Confidential
*/

#ifndef CCAFEXCEPTION_H_
#define CCAFEXCEPTION_H_

#ifdef WIN32
/*
* * Disable the 'std::basic_string<> needs to have dll-interface to be used by
* * clients of class 'Caf::CCafException' warning.
* */
#pragma warning(disable : 4251)
#endif

#include "ICafObject.h"



+ 7
- 3
open-vm-tools/common-agent/Cpp/Framework/Framework/include/Memory/DynamicArray/TDynamicArray.h View File

@@ -35,13 +35,17 @@
//
// Created: Wednesday, August 07, 2002 2:27:39 PM
//
// Copyright (C) 2011-2016 VMware, Inc. All rights reserved. -- VMware Confidential
// Copyright (C) 2011-2018 VMware, Inc. All rights reserved. -- VMware Confidential
// -- VMware Confidential
//
//////////////////////////////////////////////////////////////////////////////
#ifndef _TDynamicArray_H_
#define _TDynamicArray_H_

#ifdef WIN32
#pragma warning( disable : 4244 ) //Disabling unnecessary conversion warning
#endif

#include <string.h>
#include "Exception/CCafException.h"

@@ -906,7 +910,7 @@ private:
_sentinelBits = reinterpret_cast<const uint64>(_data)
^ gs_ulDynamicArraySentinelBitPattern;
#else
_sentinelBits = reinterpret_cast<const uint32>(_data) ^ gs_ulDynamicArraySentinelBitPattern;
_sentinelBits = reinterpret_cast<const uintptr_t>(_data) ^ gs_ulDynamicArraySentinelBitPattern;
#endif

// Initialize the new buffer.
@@ -1003,7 +1007,7 @@ protected:
if ((_sentinelBits ^ reinterpret_cast<const uint64>(_data))
!= gs_ulDynamicArraySentinelBitPattern)
#else
if ((_sentinelBits ^ reinterpret_cast<const uint32>(_data)) !=
if ((_sentinelBits ^ reinterpret_cast<const uintptr_t>(_data)) !=
gs_ulDynamicArraySentinelBitPattern)
#endif
{


+ 2
- 2
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Common/CApplicationContext.cpp View File

@@ -2,11 +2,11 @@
* Author: bwilliams
* Created: Jul 2009
*
* Copyright (C) 2009-2016 VMware, Inc. All rights reserved. -- VMware Confidential
* Copyright (C) 2009-2018 VMware, Inc. All rights reserved. -- VMware Confidential
*/

#include "stdafx.h"
#include <iterator>
#include "Common/IAppContext.h"
#include "IBean.h"
#include "Xml/XmlUtils/CXmlElement.h"


+ 2
- 1
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Integration/Core/CDocument.cpp View File

@@ -2,10 +2,11 @@
* Author: bwilliams
* Created: Oct 20, 2011
*
* Copyright (C) 2011-2016 VMware, Inc. All rights reserved. -- VMware Confidential
* Copyright (C) 2011-2018 VMware, Inc. All rights reserved. -- VMware Confidential
*/

#include "stdafx.h"
#include <iterator>

#include "Integration/IDocument.h"
#include "Xml/XmlUtils/CXmlElement.h"


+ 2
- 1
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Integration/Core/CIntMessage.cpp View File

@@ -2,10 +2,11 @@
* Author: bwilliams
* Created: Oct 22, 2010
*
* Copyright (C) 2010-2016 VMware, Inc. All rights reserved. -- VMware Confidential
* Copyright (C) 2010-2018 VMware, Inc. All rights reserved. -- VMware Confidential
*/

#include "stdafx.h"
#include <iterator>

#include "ICafObject.h"
#include "IVariant.h"


+ 2
- 1
open-vm-tools/common-agent/Cpp/Framework/Subsystems/Integration/src/CRecipientListRouterInstance.cpp View File

@@ -2,10 +2,11 @@
* Created on: Aug 9, 2012
* Author: mdonahue
*
* Copyright (C) 2012-2016 VMware, Inc. All rights reserved. -- VMware Confidential
* Copyright (C) 2012-2018 VMware, Inc. All rights reserved. -- VMware Confidential
*/

#include "stdafx.h"
#include <iterator>

#include "Common/IAppContext.h"
#include "IVariant.h"


+ 8
- 3
open-vm-tools/common-agent/Cpp/ManagementAgent/Subsystems/MaIntegration/src/CMonitorListener.cpp View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2010-2017 VMware, Inc. All rights reserved. -- VMware Confidential
* Copyright (C) 2010-2018 VMware, Inc. All rights reserved. -- VMware Confidential
*/

#include "stdafx.h"
@@ -189,6 +189,11 @@ void CMonitorListener::listenerPreConfigured(
FileSystemUtils::saveTextFile(_listenerPreConfiguredPath, reason);
}



bool CMonitorListener::isListenerPreConfigured() {
// Invalidate the flag
if (!_listenerPreConfigured) {
_listenerPreConfigured = FileSystemUtils::doesFileExist(_listenerPreConfiguredPath);
}
return _listenerPreConfigured;
}


+ 2
- 4
open-vm-tools/common-agent/Cpp/ManagementAgent/Subsystems/MaIntegration/src/CMonitorListener.h View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017 VMware, Inc. All rights reserved. -- VMware Confidential
* Copyright (C) 2017-2018 VMware, Inc. All rights reserved. -- VMware Confidential
*/

#ifndef _MaIntegration_CMonitorListener_h_
@@ -23,9 +23,7 @@ public:

bool preConfigureListener();

bool isListenerPreConfigured() {
return _listenerPreConfigured;
}
bool isListenerPreConfigured();

bool followTunnel(std::string& listenerStartupType);



+ 116
- 40
open-vm-tools/configure.ac View File

@@ -35,10 +35,10 @@
### Initialization
###

TOOLS_VERSION="10.2.5"
TOOLS_VERSION="10.3.0"
AC_INIT(
[open-vm-tools],
[10.2.5],
[10.3.0],
[open-vm-tools-devel@lists.sourceforge.net])

# In order to make this configure script auto-detect situations where
@@ -402,7 +402,7 @@ if test "$enable_deploypkg" = "yes"; then
[],
[0.0.20040308alpha],
[mspack.h],
[],
[mspack_version],
[],
[AC_MSG_ERROR([mspack >= 0.0.20040308alpha is required.])])
fi
@@ -426,39 +426,39 @@ AC_VMW_CHECK_LIB([glib-2.0],
[GLIB2],
[glib-2.0],
[],
[2.14.0],
[2.34.0],
[glib.h],
[g_key_file_new],
[],
[AC_MSG_ERROR([glib2 >= 2.14.0 is required.])])
[AC_MSG_ERROR([glib2 >= 2.34.0 is required.])])

AC_VMW_CHECK_LIB([gmodule-2.0],
[GMODULE],
[gmodule-2.0],
[],
[2.14.0],
[],
[2.34.0],
[],
[g_module_open],
[],
[AC_MSG_ERROR([gmodule >= 2.14.0 is required.])])
[AC_MSG_ERROR([gmodule >= 2.34.0 is required.])])
AC_VMW_CHECK_LIB([gobject-2.0],
[GOBJECT],
[gobject-2.0],
[],
[2.14.0],
[2.34.0],
[glib-object.h],
[g_object_new],
[],
[],
[AC_MSG_ERROR([gobject >= 2.14.0 is required.])])
[AC_MSG_ERROR([gobject >= 2.34.0 is required.])])
AC_VMW_CHECK_LIB([gthread-2.0],
[GTHREAD],
[gthread-2.0],
[],
[2.14.0],
[2.34.0],
[],
[g_thread_new],
[],
[],
[AC_MSG_ERROR([glib >= 2.14.0 is required.])])
[AC_MSG_ERROR([gthread >= 2.34.0 is required.])])
AC_CHECK_PROG([have_genmarshal],
[glib-genmarshal],
[yes],
@@ -509,27 +509,27 @@ AC_ARG_ENABLE([vgauth],
[do not build vgauth.])],
[
enable_vgauth="$enableval"
use_xmlsec1=no
use_xmlsec1=yes
],
[
if test "$os" = "linux"; then
enable_vgauth=yes
use_xmlsec1=no
use_xmlsec1=yes
else
enable_vgauth=no
use_xmlsec1=no
use_xmlsec1=yes
fi
])

AC_ARG_ENABLE([xmlsec1],
[AS_HELP_STRING([--enable-xmlsec1],
[build vgauth with xmlsec1 instead of xml-security-c (off by default).])],
[build vgauth with xmlsec1 instead of xml-security-c (on by default).])],
[use_xmlsec1="$enableval"],
[use_xmlsec1=no])
[use_xmlsec1=yes])

AC_ARG_ENABLE([xmlsecurity],
[AS_HELP_STRING([--enable-xmlsecurity],
[build vgauth with xml-security-c instead of xmlsec1 (on by default).])],
[build vgauth with xml-security-c instead of xmlsec1 (off by default).])],
[
if test "$enableval" = "yes"; then
use_xmlsec1="no"
@@ -586,6 +586,11 @@ AC_ARG_WITH([xml2],
[enable_vgauth=no],
[with_xml2=yes])

AC_ARG_WITH([tirpc],
[AS_HELP_STRING([--without-tirpc],
[compiles with/without libtirpc.])],
[],
[with_tirpc=auto])

# Make sure we are building with openssl 1.0.1 and above so that
# we use only TLSv1_2.
@@ -627,7 +632,7 @@ if test "$enable_vgauth" = "yes"; then
[xmlsec1-config],
[],
[xmlsec/xmlsec.h],
[xmlSecCheckVersion],
[xmlSecCheckVersionExt],
[XMLSEC1_CPPFLAGS="$XMLSEC1_CPPFLAGS -DXMLSEC_NO_SIZE_T"],
[AC_VMW_LIB_ERROR([XMLSEC1], [xmlsec1])])

@@ -782,9 +787,9 @@ else
[GDK_PIXBUF_XLIB2],
[gdk-pixbuf-xlib-2.0],
[],
[],
[2.21.0],
[gdk-pixbuf-xlib/gdk-pixbuf-xlib.h],
[],
[gdk_pixbuf_xlib_init],
[],
[AC_MSG_ERROR([gdk-pixbuf-xlib-2.0 not found. Please configure without X11 (using --without-x) or install the gdk-pixbuf-xlib-2.0 devel package.])])

@@ -827,7 +832,7 @@ else
[gtkmm-3.0],
[],
[3.0.0],
[],
[gtkmm.h],
[],
[GTKMM_CPPFLAGS="$GTKMM_CPPFLAGS -DHAVE_GTKMM"],
[AC_MSG_ERROR([gtkmm3 library not found. Please install the libgtkmm devel package(s), or re-configure using --without-gtkmm3.])])
@@ -899,14 +904,14 @@ if test "$os" = "freebsd" -a "$osVersion" -ge 600000; then
AC_CHECK_LIB(
[thr],
[pthread_mutex_init],
[THREAD_LIB=-lthr],
[THREAD_LIBS=-lthr],
[AC_MSG_ERROR(
[Unable to locate required threading library libthr.])])
else
AC_CHECK_LIB(
[pthread],
[pthread_mutex_init],
[THREAD_LIB=-lpthread],
[THREAD_LIBS=-lpthread],
[AC_MSG_ERROR(
[libpthread not found. Please install the libc/libpthread devel package(s).])])
fi
@@ -1066,10 +1071,74 @@ if test "$enable_caf" = "yes"; then

fi

if test "$with_tirpc" != "no"; then
AC_VMW_CHECK_LIB([libtirpc],
[TIRPC],
[libtirpc],
[],
[],
[],
[],
[have_tirpc="yes"],
[have_tirpc="no"])
fi

if test "$with_tirpc" != "yes"; then
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include <rpc/types.h>
#include <rpc/xdr.h>

int main()
{
struct xdr_ops xdr;
#if defined(__GLIBC__)
xdr.x_putint32(NULL, NULL);
#endif
return 0;
}
]])], [need_tirpc="no"], [need_tirpc="yes"])
AC_MSG_NOTICE([tirpc is needed: $need_tirpc])
fi

if test "$with_tirpc" = "no"; then
if test "$need_tirpc" = "yes"; then
AC_MSG_ERROR([libtirpc is required but it is disabled.])
fi
use_tirpc="no"
elif test "$with_tirpc" = "auto"; then
if test "$need_tirpc" = "yes" -a "$have_tirpc" = "no"; then
AC_MSG_ERROR([cannot find libtirpc but it is required.])
fi
use_tirpc=$need_tirpc
elif test "$with_tirpc" = "yes"; then
if test "$have_tirpc" = "no"; then
AC_MSG_ERROR([cannot build with libtirpc because it cannot be found.])
fi
use_tirpc="yes"
fi

XDR_LIBS=
XDR_CPPFLAGS=
if test "$use_tirpc" = "yes"; then
AC_MSG_NOTICE([building with libtirpc])
XDR_LIBS="$TIRPC_LIBS"
XDR_CPPFLAGS="-DUSE_TIRPC $TIRPC_CPPFLAGS"
else
AC_MSG_NOTICE([building without libtirpc])
# In Solaris, the XDR-related functions are not in libc like in Linux and
# FreeBSD, so binaries need to be linked to some extra libraries.
if test "$os" = "solaris"; then
XDR_LIBS="-lnsl -lrpcsvc"
fi
fi

AC_PATH_PROG(
[RPCGEN],
[rpcgen],
[ AC_MSG_ERROR([rpcgen not found. Please install the libc devel package.]) ])
[not_found])
if test "$RPCGEN" == "not_found"; then
AC_MSG_ERROR([rpcgen not found.])
fi

###
### Headers
@@ -1095,6 +1164,13 @@ AC_CHECK_HEADERS([sys/user.h],
])
AC_CHECK_HEADERS([sys/vfs.h])
AC_CHECK_HEADERS([syslimits.h])

# On Freebsd, the unwind.h header file is available in the libunwind
# package, but the necessary functions are only available if __GNU_SOURCE
# is defined to enable "all" GCC extensions.
if test "$os" = "freebsd"; then
ac_cv_header_unwind_h="no"
fi
AC_CHECK_HEADERS([unwind.h])

AC_CHECK_HEADER(
@@ -1144,6 +1220,12 @@ AC_C_VOLATILE
CFLAGS="$CFLAGS -Wall"
CFLAGS="$CFLAGS -Werror"

# Suppress warnings from clang when taking the address of packed struct
# member fields when compiling hgfsServer.c
if $CC --version | $GREP -i "clang" > /dev/null; then
CFLAGS="$CFLAGS -Wno-address-of-packed-member"
fi

# -Wno-unknown-pragmas is due to gcc not understanding '#pragma ident'
# in Xlib.h on OpenSolaris.
# Glib2 keep changing mutex APIs so we also need to disable 'deprecated'
@@ -1257,8 +1339,8 @@ if test "$os" = "linux"; then
if test "$osVersion" -lt 303000; then
MODULES="$MODULES vmxnet"
fi
# See if we need vmhgfs module. Starting with 4.0.0 we use FUSE
if test "$osVersion" -lt 400000; then
# See if we need vmhgfs module. Starting with 3.10.0 we use FUSE
if test "$osVersion" -lt 310000; then
MODULES="$MODULES vmhgfs"
fi
# See if we need vmci and vsock modules. Starting with 3.9 they made
@@ -1389,7 +1471,6 @@ AM_CONDITIONAL(HAVE_XSM, test "$have_xsm" = "yes")
AM_CONDITIONAL(HAVE_XCOMPOSITE, test "$have_xcomposite" = "yes")
AM_CONDITIONAL(ENABLE_TESTS, test "$have_cunit" = "yes")
AM_CONDITIONAL(WITH_ROOT_PRIVILEGES, test "$with_root_privileges" = "yes")
AM_CONDITIONAL(HAVE_DNET, test "$have_dnet" = "yes")
AM_CONDITIONAL(HAVE_DOXYGEN, test "$have_doxygen" = "yes")
AM_CONDITIONAL(HAVE_FUSE, test "$have_fuse" = "yes")
AM_CONDITIONAL(HAVE_GNU_LD, test "$with_gnu_ld" = "yes")
@@ -1434,8 +1515,8 @@ if test "$HAVE_CRYPT" = "yes"; then
fi


LIBVMTOOLS_LIBADD="$LIBVMTOOLS_LIBADD $THREAD_LIB"
VIX_LIBADD="$VIX_LIBADD $THREAD_LIB"
LIBVMTOOLS_LIBADD="$LIBVMTOOLS_LIBADD $THREAD_LIBS"
VIX_LIBADD="$VIX_LIBADD $THREAD_LIBS"

### Core Services definitions.

@@ -1445,14 +1526,7 @@ VMTOOLS_LIBS="$BUILDDIR/libvmtools/libvmtools.la $GLIB2_LIBS"
VMTOOLS_CPPFLAGS="-DVMTOOLS_USE_GLIB $GLIB2_CPPFLAGS"

PLUGIN_CPPFLAGS="$VMTOOLS_CPPFLAGS $PLUGIN_CPPFLAGS"
PLUGIN_LDFLAGS="-Wl,-z,defs -Wl,-lc -shared -module -avoid-version"

# In Solaris, the XDR-related functions are not in libc like in Linux and
# FreeBSD, so binaries need to be linked to some extra libraries.
XDR_LIBS=
if test "$os" = "solaris"; then
XDR_LIBS="-lnsl -lrpcsvc"
fi
PLUGIN_LDFLAGS="-Wl,-z,defs -Wl,-lc -Wl,--as-needed -shared -module -avoid-version"

# Installation directories for core services plugins.
TEST_PLUGIN_INSTALLDIR=$datadir/open-vm-tools/tests
@@ -1491,8 +1565,10 @@ AC_SUBST([PLUGIN_CPPFLAGS])
AC_SUBST([PLUGIN_LDFLAGS])
AC_SUBST([VMTOOLS_CPPFLAGS])
AC_SUBST([VMTOOLS_LIBS])
AC_SUBST([THREAD_LIBS])
AC_SUBST([RPCGENFLAGS])
AC_SUBST([XDR_LIBS])
AC_SUBST([XDR_CPPFLAGS])
AC_SUBST([TEST_PLUGIN_INSTALLDIR])
AC_SUBST([COMMON_PLUGIN_INSTALLDIR])
AC_SUBST([VMSVC_PLUGIN_INSTALLDIR])


+ 1
- 3
open-vm-tools/lib/appUtil/appUtil.c View File

@@ -1,5 +1,5 @@
/*********************************************************
* Copyright (C) 2008-2016 VMware, Inc. All rights reserved.
* Copyright (C) 2008-2018 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
@@ -22,12 +22,10 @@
* Utility functions for guest applications.
*/

#include "appUtil.h"

#include <stdlib.h>
#include <string.h>

#include "vmware.h"
#include "appUtil.h"
#include "debug.h"
#include "rpcout.h"


+ 191
- 55
open-vm-tools/lib/asyncsocket/asyncsocket.c View File

@@ -1,5 +1,5 @@
/*********************************************************
* Copyright (C) 2003-2017 VMware, Inc. All rights reserved.
* Copyright (C) 2003-2018 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
@@ -93,6 +93,7 @@
#include "util.h"
#include "msg.h"
#include "posix.h"
#include "vm_basic_asm.h"
#include "vmci_sockets.h"
#ifndef VMX86_TOOLS
#include "vmdblib.h"
@@ -219,7 +220,6 @@ typedef struct AsyncTCPSocket {

uint8 inIPollCb;
Bool inRecvLoop;
Bool inDoOneMsg;
uint32 inBlockingRecv;

struct AsyncTCPSocket *listenAsock4;
@@ -2046,7 +2046,7 @@ AsyncTCPSocketConnect(struct sockaddr_storage *addr, // IN
asock->clientData = clientData;

/* Store a copy of the sockaddr_storage so we can look it up later. */
asock->remoteAddr = *addr;
memcpy(&(asock->remoteAddr), addr, addrLen);
asock->remoteAddrLen = addrLen;

AsyncTCPSocketUnlock(asock);
@@ -2410,7 +2410,7 @@ AsyncTCPSocketRecv(AsyncSocket *base, // IN:
return ASOCKERR_NOTCONNECTED;
}

if (asock->inBlockingRecv) {
if (asock->inBlockingRecv && !asock->inRecvLoop) {
TCPSOCKWARN(asock, ("Recv called while a blocking recv is pending.\n"));
return ASOCKERR_INVAL;
}
@@ -3310,10 +3310,13 @@ AsyncTCPSocketFillRecvBuffer(AsyncTCPSocket *s) // IN
s->base.recvPos,
needed);
}
TCPSOCKLOG(3, s, ("need\t%d\trecv\t%d\tremain\t%d\n", needed, recvd,
needed - recvd));

/*
* Do NOT make any system call directly or indirectly here
* unless you can preserve the system error number
*/
if (recvd > 0) {
TCPSOCKLOG(3, s, ("need\t%d\trecv\t%d\tremain\t%d\n", needed, recvd,
needed - recvd));
s->sslConnected = TRUE;
s->base.recvPos += recvd;
if (AsyncSocketCheckAndDispatchRecv(&s->base, &result)) {
@@ -3478,10 +3481,13 @@ AsyncTCPSocketWriteBuffers(AsyncTCPSocket *s) // IN

sent = SSL_Write(s->sslSock,
(uint8 *) head->buf + s->sendPos, left);

TCPSOCKLOG(3, s, ("left\t%d\tsent\t%d\tremain\t%d\n",
left, sent, left - sent));
/*
* Do NOT make any system call directly or indirectly here
* unless you can preserve the system error number
*/
if (sent > 0) {
TCPSOCKLOG(3, s, ("left\t%d\tsent\t%d\tremain\t%d\n",
left, sent, left - sent));
s->sendBufFull = FALSE;
s->sslConnected = TRUE;
if ((s->sendPos += sent) == sizeToSend) {
@@ -3889,10 +3895,12 @@ out:
* Results:
* ASOCKERR_SUCCESS if it worked, ASOCKERR_GENERIC on system call
* failures
* ASOCKERR_BUSY if another thread is in the read callback.
* ASOCKERR_TIMEOUT if nothing happened in the allotted time.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------------
*/

@@ -3934,7 +3942,6 @@ AsyncTCPSocketDoOneMsg(AsyncSocket *base, // IN

s->inBlockingRecv++;
retVal = AsyncTCPSocketPoll(s, read, timeoutMS, &asock);
s->inBlockingRecv--;
if (retVal != ASOCKERR_SUCCESS) {
if (retVal == ASOCKERR_GENERIC) {
TCPSOCKWARN(s, ("%s: failed to poll on the socket during read.\n",
@@ -3942,10 +3949,9 @@ AsyncTCPSocketDoOneMsg(AsyncSocket *base, // IN
}
} else {
ASSERT(asock == s);
s->inDoOneMsg = TRUE;
retVal = AsyncTCPSocketFillRecvBuffer(s);
s->inDoOneMsg = FALSE;
}
s->inBlockingRecv--;

/*
* If socket got closed in AsyncTCPSocketFillRecvBuffer, we
@@ -3963,6 +3969,8 @@ AsyncTCPSocketDoOneMsg(AsyncSocket *base, // IN
s->recvCb = FALSE; /* For re-registering the poll callback. */
if (retVal == ASOCKERR_SUCCESS || retVal == ASOCKERR_TIMEOUT) {
retVal = AsyncTCPSocketRegisterRecvCb(s);
Log("SOCKET reregister recvCb after DoOneMsg (ref %d)\n",
BaseSocket(s)->refCount);
}
if (retVal != ASOCKERR_SUCCESS) {
s->base.recvBuf = NULL;
@@ -3988,6 +3996,142 @@ AsyncTCPSocketDoOneMsg(AsyncSocket *base, // IN
}


/*
*----------------------------------------------------------------------------
*
* AsyncSocket_TCPDrainRecv --
*
* This function can be used to drain all the messages from a socket
* disconnected on the remote end. It spins a socket until the specified
* amount of time has elapsed or an error is encountered, with backoff
* between read attempts if there is a conflict with another thread. The
* recv callback is restored at the end of this only if not all the
* messages have been read, the socket is still connected and recv callack
* has not been cancelled.
*
* Results:
* ASOCKERR_SUCCESS if all messages are have been read, or if the callback
* has canceled the recv, or if the socket is closed
* ASOCKERR_GENERIC on system call failures
* ASOCKERR_TIMEOUT if there may still be unread messages at the end of
* the speccified time.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------------
*/

int
AsyncSocket_TCPDrainRecv(AsyncSocket *base, // IN
int timeoutMS) // IN
{
AsyncTCPSocket *s = TCPSocket(base);
int retVal;
Bool cbRemoved = FALSE;
Bool releaseLock = FALSE;
unsigned count = 0;
VmTimeType startMS = Hostinfo_SystemTimerMS();
VmTimeType nowMS;

ASSERT(AsyncTCPSocketGetState(s) == AsyncSocketConnected);
ASSERT(s->recvCb); /* We are supposed to call someone... */

if (!AsyncTCPSocketIsLocked(s) || !Poll_LockingEnabled()) {
AsyncTCPSocketLock(s);
releaseLock = TRUE;
}
AsyncTCPSocketAddRef(s);

while (TRUE) {
AsyncTCPSocket *asock = NULL;

count++;
if (s->inRecvLoop) {
/*
* The recv loop would read the data if there is any and it is
* not safe to proceed and race with the recv loop.
*/
TCPSOCKLG0(s, ("busy: another thread in recv loop\n"));
retVal = ASOCKERR_BUSY;
/* Add a bit of backoff. */
AsyncTCPSocketUnlock(s);
Util_Usleep(MIN(100 << (mssb32(count) / 2), timeoutMS));
AsyncTCPSocketLock(s);
goto retry;
}

if (!cbRemoved) {
/*
* Cancel the recv callback, but pretend that it is still registered
* so we know if the callback cancel recv.
*/
AsyncTCPSocketCancelRecvCb(s);
s->recvCb = TRUE;
cbRemoved = TRUE;
}

s->inBlockingRecv++;
retVal = AsyncTCPSocketPoll(s, TRUE, 0, &asock);
if (retVal != ASOCKERR_SUCCESS) {
if (retVal == ASOCKERR_GENERIC) {
TCPSOCKWARN(s, ("%s: failed to poll on the socket during read.\n",
__FUNCTION__));
}
} else if (AsyncTCPSocketGetState(s) == AsyncSocketConnected) {
ASSERT(asock == s);
retVal = AsyncTCPSocketFillRecvBuffer(s);
}
s->inBlockingRecv--;

retry:
if (retVal == ASOCKERR_REMOTE_DISCONNECT ||
AsyncTCPSocketGetState(s) == AsyncSocketClosed ||
!s->recvCb) {
/* No more messages to recv. */
retVal = ASOCKERR_SUCCESS;
break;
}
if (retVal == ASOCKERR_GENERIC) {
break;
}

nowMS = Hostinfo_SystemTimerMS();
if (nowMS >= startMS + timeoutMS) {
retVal = ASOCKERR_TIMEOUT;
break;
}
timeoutMS -= nowMS - startMS;
startMS = nowMS;
ASSERT(AsyncTCPSocketGetState(s) == AsyncSocketConnected && s->recvCb);
}

if (cbRemoved) {
s->recvCb = FALSE;
/*
* If AsyncTCPSocketPoll or AsyncTCPSocketFillRecvBuffer fails, do not
* add the recv callback as it may never fire.
*/
if (retVal == ASOCKERR_TIMEOUT) {
ASSERT(AsyncTCPSocketGetState(s) == AsyncSocketConnected);
ASSERT(s->base.refCount > 1); /* We better not be the last user */
retVal = AsyncTCPSocketRegisterRecvCb(s);
Log("SOCKET reregister recvCb after DrainRecv (ref %d)\n",
BaseSocket(s)->refCount);
}
}
if (!s->recvCb) {
s->base.recvBuf = NULL;
}

AsyncTCPSocketRelease(s);
if (releaseLock) {
AsyncTCPSocketUnlock(s);
}
return retVal;
}


/*
*----------------------------------------------------------------------------
*
@@ -4167,7 +4311,7 @@ AsyncTCPSocketCancelRecvCb(AsyncTCPSocket *asock) // IN:
removed = AsyncTCPSocketPollRemove(asock, TRUE,
POLL_FLAG_READ | POLL_FLAG_PERIODIC,
asock->internalRecvFn);
VERIFY(removed || AsyncTCPSocketPollParams(asock)->iPoll);
ASSERT(removed || AsyncTCPSocketPollParams(asock)->iPoll);
asock->recvCb = FALSE;
}
}
@@ -4247,7 +4391,7 @@ AsyncTCPSocketCancelCbForClose(AsyncSocket *base) // IN:
asock->internalRecvFn);
/* Callback might be temporarily removed in AsyncSocket_DoOneMsg. */
ASSERT_NOT_TESTED(removed ||
asock->inDoOneMsg ||
asock->inBlockingRecv ||
AsyncTCPSocketPollParams(asock)->iPoll);

asock->recvCb = FALSE;
@@ -4755,38 +4899,34 @@ AsyncTCPSocketIPollRecvCallback(void *clientData) // IN:

AsyncTCPSocketLock(asock);
if (asock->recvCbTimer) {
/* IVmdbPoll only has periodic callbacks. */
/* IVmdbPoll only has periodic timer callbacks. */
AsyncTCPSocketIPollRemove(asock, FALSE, 0, asock->internalRecvFn);
asock->recvCbTimer = FALSE;
}
asock->inIPollCb |= IN_IPOLL_RECV;
lock = AsyncTCPSocketPollParams(asock)->lock;
if (asock->recvCb && asock->inBlockingRecv == 0) {
asock->inIPollCb |= IN_IPOLL_RECV;
AsyncTCPSocketRecvCallback(clientData);
asock->inIPollCb &= ~IN_IPOLL_RECV;
/*
* There is no need to take a reference here -- the fact that this
* callback is running means AsyncsocketIPollRemove would not release a
* reference if it is called.
* Re-register the callback if it has not been canceled. Lock may have
* been dropped to fire recv callback so re-check inBlockingRecv.
*/
int error = AsyncTCPSocketFillRecvBuffer(asock);

if (error == ASOCKERR_GENERIC || error == ASOCKERR_REMOTE_DISCONNECT) {
AsyncTCPSocketHandleError(asock, error);
if (asock->recvCb && asock->inBlockingRecv == 0) {
AsyncTCPSocketIPollAdd(asock, TRUE, POLL_FLAG_READ,
asock->internalRecvFn, asock->fd);
}
} else {
TCPSOCKLG0(asock, ("Skip recv because %s\n",
asock->recvCb ? "blocking recv is in progress"
: "recv callback is cancelled"));
}

asock->inIPollCb &= ~IN_IPOLL_RECV;
if (asock->recvCb) {
AsyncTCPSocketUnlock(asock);
} else {
/*
* Callback has been unregistered. Per above, we need to release the
* reference explicitly.
*/
AsyncTCPSocketRelease(asock);
AsyncTCPSocketUnlock(asock);
if (lock != NULL) {
MXUser_DecRefRecLock(lock);
}
/* This is a one-shot callback so we always release the reference taken. */
AsyncTCPSocketRelease(asock);
AsyncTCPSocketUnlock(asock);
if (lock != NULL) {
MXUser_DecRefRecLock(lock);
}
#endif
}
@@ -4894,21 +5034,15 @@ AsyncTCPSocketIPollSendCallback(void *clientData) // IN:
AsyncTCPSocketLock(s);
s->inIPollCb |= IN_IPOLL_SEND;
lock = AsyncTCPSocketPollParams(s)->lock;
if (s->sendCbTimer) {
/* IVmdbPoll only has periodic timer callback. */
AsyncTCPSocketIPollRemove(s, FALSE, 0, AsyncTCPSocketIPollSendCallback);
s->sendCbTimer = FALSE;
}
if (s->sendCb) {
/*
* Unregister this callback as we want the non-periodic behavior. There
* is no need to take a reference here -- the fact that this callback is
* running means AsyncsocketIPollRemove would not release a reference.
* We would release that reference at the end.
*/
if (s->sendCbTimer) {
AsyncTCPSocketIPollRemove(s, FALSE, 0, AsyncTCPSocketIPollSendCallback);
} else {
AsyncTCPSocketIPollRemove(s, TRUE, POLL_FLAG_WRITE,
AsyncTCPSocketIPollSendCallback);
}

AsyncTCPSocketSendCallback(s);
} else {
TCPSOCKLG0(s, ("cancelled send callback fired\n"));
}

s->inIPollCb &= ~IN_IPOLL_SEND;
@@ -5062,8 +5196,9 @@ AsyncTCPSocketIPollAdd(AsyncTCPSocket *asock, // IN
poll = AsyncTCPSocketPollParams(asock)->iPoll;

if (socket) {
int pollFlags = (flags & POLL_FLAG_READ) != 0 ? VMDB_PRF_READ
: VMDB_PRF_WRITE;
int pollFlags = VMDB_PRF_ONE_SHOT |
((flags & POLL_FLAG_READ) != 0 ? VMDB_PRF_READ
: VMDB_PRF_WRITE);

ret = poll->Register(poll, pollFlags, callback, asock, info);
} else {
@@ -5121,8 +5256,9 @@ AsyncTCPSocketIPollRemove(AsyncTCPSocket *asock, // IN
poll = AsyncTCPSocketPollParams(asock)->iPoll;

if (socket) {
int pollFlags = (flags & POLL_FLAG_READ) != 0 ? VMDB_PRF_READ
: VMDB_PRF_WRITE;
int pollFlags = VMDB_PRF_ONE_SHOT |
((flags & POLL_FLAG_READ) != 0 ? VMDB_PRF_READ
: VMDB_PRF_WRITE);

ret = poll->Unregister(poll, pollFlags, callback, asock);
} else {
@@ -5189,7 +5325,7 @@ AsyncTCPSocketCancelRecv(AsyncSocket *base, // IN
return ASOCKERR_INVAL;
}

if (asock->inBlockingRecv) {
if (asock->inBlockingRecv && !asock->inRecvLoop) {
Warning(ASOCKPREFIX "Cannot cancel request while a blocking recv is "
"pending.\n");
return ASOCKERR_INVAL;


+ 11
- 4
open-vm-tools/lib/auth/authPosix.c View File

@@ -1,5 +1,5 @@
/*********************************************************
* Copyright (C) 2003-2017 VMware, Inc. All rights reserved.
* Copyright (C) 2003-2018 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <unistd.h> // for access, crypt, etc.
#if !defined USE_PAM && !defined __APPLE__
#include <shadow.h>
@@ -262,8 +263,8 @@ static struct pam_conv PAM_conversation = {
static AuthTokenInternal *
AuthAllocateToken(void)
{
long bufSize;
AuthTokenInternal *ati;
size_t bufSize;

/*
* We need to get the maximum size buffer needed by getpwuid_r from
@@ -271,9 +272,15 @@ AuthAllocateToken(void)
* by the Posix_Get*_r() wrappers.
*/

bufSize = (size_t) sysconf(_SC_GETPW_R_SIZE_MAX) * 4;
errno = 0;
bufSize = sysconf(_SC_GETPW_R_SIZE_MAX);
if ((errno != 0) || (bufSize <= 0)) {
bufSize = 16 * 1024; // Unlimited; pick something reasonable
}

bufSize *= 4;

ati = Util_SafeMalloc(sizeof *ati + bufSize);
ati = Util_SafeMalloc(sizeof *ati + (size_t) bufSize);
ati->bufSize = bufSize;

return ati;


+ 8
- 2
open-vm-tools/lib/dynxdr/Makefile.am View File

@@ -1,5 +1,5 @@
################################################################################
### Copyright (C) 2008-2016 VMware, Inc. All rights reserved.
### Copyright (C) 2008-2018 VMware, Inc. All rights reserved.
###
### This program is free software; you can redistribute it and/or modify
### it under the terms of version 2 of the GNU General Public License as
@@ -17,7 +17,13 @@

noinst_LTLIBRARIES = libDynxdr.la

libDynxdr_la_SOURCES =
libDynxdr_la_SOURCES =
libDynxdr_la_SOURCES += dynxdr.c
libDynxdr_la_SOURCES += xdrutil.c

libDynxdr_la_CPPFLAGS =
libDynxdr_la_CPPFLAGS += @XDR_CPPFLAGS@

libDynxdr_la_LIBADD =
libDynxdr_la_LIBADD += @XDR_LIBS@


+ 10
- 6
open-vm-tools/lib/dynxdr/dynxdr.c View File

@@ -1,5 +1,5 @@
/*********************************************************
* Copyright (C) 2008-2017 VMware, Inc. All rights reserved.
* Copyright (C) 2008-2018 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
@@ -55,7 +55,7 @@ typedef struct DynXdrData {
* Mac OS X, FreeBSD and Solaris don't take a const parameter to the
* "x_getpostn" function.
*/
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(sun)
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(sun) || defined(USE_TIRPC)
# define DYNXDR_GETPOS_CONST
#else
# define DYNXDR_GETPOS_CONST const
@@ -172,7 +172,11 @@ DynXdrSetPos(XDR *xdrs, // IN
}


#if defined(__GLIBC__) || (defined(sun) && (defined(_LP64) || defined(_KERNEL)))
#if !defined(USE_TIRPC) && \
defined(__GLIBC__) || \
(defined(sun) && \
(defined(_LP64) || \
defined(_KERNEL)))
/*
*-----------------------------------------------------------------------------
*
@@ -322,11 +326,11 @@ DynXdr_Create(XDR *in) // IN
DynXdrSetPos, /* x_setpostn */
DynXdrInline, /* x_inline */
NULL, /* x_destroy */
#if defined(__GLIBC__)
#if defined(__APPLE__) || defined(USE_TIRPC)
NULL, /* x_control */
#elif defined(__GLIBC__)
NULL, /* x_getint32 */
DynXdrPutInt32, /* x_putint32 */
#elif defined(__APPLE__)
NULL, /* x_control */
#elif defined(sun) && (defined(_LP64) || defined(_KERNEL))
NULL, /* x_control */
NULL, /* x_getint32 */


+ 88
- 72
open-vm-tools/lib/file/file.c View File

@@ -1,5 +1,5 @@
/*********************************************************
* Copyright (C) 1998-2017 VMware, Inc. All rights reserved.
* Copyright (C) 1998-2018 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
@@ -35,7 +35,6 @@
#include <stdlib.h>
#include <ctype.h>
#include <errno.h>
#include "safetime.h"
#if defined(_WIN32)
#include <io.h>
#define S_IXUSR 0100
@@ -44,6 +43,7 @@
#include <unistd.h>
#endif
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>

@@ -85,6 +85,8 @@
* uses the effective uid, but it's too risky to fix right now.
* See PR 459242.
*
* Errno/GetLastError is available upon failure.
*
* Results:
* TRUE file is accessible with the process' real uid
* FALSE file doesn't exist or an error occured
@@ -109,6 +111,8 @@ File_Exists(const char *pathName) // IN: May be NULL.
*
* If the given file exists, unlink it.
*
* Errno/GetLastError is available upon failure.
*
* Results:
* Return 0 if the unlink is successful or if the file did not exist.
* Otherwise return -1.
@@ -169,6 +173,8 @@ File_SupportsMandatoryLock(const char *pathName) // IN: file to be locked
*
* Check if specified file is a directory or not.
*
* Errno/GetLastError is available upon failure.
*
* Results:
* TRUE is a directory
* FALSE is not a directory or an error occured
@@ -196,6 +202,8 @@ File_IsDirectory(const char *pathName) // IN:
*
* Return the read / write / execute permissions of a file.
*
* Errno/GetLastError is available upon failure.
*
* Results:
* TRUE if success, FALSE otherwise.
*
@@ -246,6 +254,8 @@ File_GetFilePermissions(const char *pathName, // IN:
* followed.
* WINDOWS: No symbolic links so no link following.
*
* Errno/GetLastError is available upon failure.
*
* Results:
* Return 0 if the unlink is successful. Otherwise, returns -1.
*
@@ -271,6 +281,8 @@ File_Unlink(const char *pathName) // IN:
* On Windows, there are no symbolic links so this is the same as
* File_Unlink
*
* Errno/GetLastError is available upon failure.
*
* Results:
* Return 0 if the unlink is successful. Otherwise, returns -1.
*
@@ -330,37 +342,6 @@ File_UnlinkRetry(const char *pathName, // IN:
}


/*
*----------------------------------------------------------------------
*
* FileCreateDirectoryEx --
*
* Creates the specified directory with the specified permissions.
*
* Results:
* True if the directory is successfully created, false otherwise.
*
* Side effects:
* Creates the directory on disk.
*
*----------------------------------------------------------------------
*/

static int
FileCreateDirectoryEx(const char *pathName, // IN:
int mask) // IN:
{
int err = FileCreateDirectory(pathName, mask);

if (err != 0) {
Log(LGPFX" %s: Failed to create %s. Error = %d\n",
__FUNCTION__, pathName, err);
}

return err;
}


/*
*----------------------------------------------------------------------
*
@@ -368,8 +349,13 @@ FileCreateDirectoryEx(const char *pathName, // IN:
*
* Creates the specified directory with the specified permissions.
*
* Errno/GetLastError is available upon failure.
*
* Results:
* True if the directory is successfully created, false otherwise.
* TRUE Directory was created
* FALSE Directory creation failed.
* See File_EnsureDirectoryEx for dealing with directories that
* may exist.
*
* Side effects:
* Creates the directory on disk.
@@ -379,9 +365,9 @@ FileCreateDirectoryEx(const char *pathName, // IN:

Bool
File_CreateDirectoryEx(const char *pathName, // IN:
int mask) // IN:
int mode) // IN:
{
int err = FileCreateDirectoryEx(pathName, mask);
int err = FileCreateDirectory(pathName, mode);

return err == 0;
}
@@ -394,8 +380,13 @@ File_CreateDirectoryEx(const char *pathName, // IN:
*
* Creates the specified directory with 0777 permissions.
*
* Errno/GetLastError is available upon failure.
*
* Results:
* True if the directory is successfully created, false otherwise.
* TRUE Directory was created
* FALSE Directory creation failed.
* See File_EnsureDirectory for dealing with directories that
* may exist.
*
* Side effects:
* Creates the directory on disk.
@@ -406,7 +397,9 @@ File_CreateDirectoryEx(const char *pathName, // IN:
Bool
File_CreateDirectory(const char *pathName) // IN:
{
return File_CreateDirectoryEx(pathName, 0777);
int err = FileCreateDirectory(pathName, 0777);

return err == 0;
}


@@ -418,6 +411,8 @@ File_CreateDirectory(const char *pathName) // IN:
* If the directory doesn't exist, creates it. If the directory
* already exists, do nothing and succeed.
*
* Errno/GetLastError is available upon failure.
*
* Results:
* See above.
*
@@ -429,17 +424,28 @@ File_CreateDirectory(const char *pathName) // IN:

Bool
File_EnsureDirectoryEx(const char *pathName, // IN:
int mask) // IN:
int mode) // IN:
{
int err = FileCreateDirectory(pathName, mask);
Bool success = ((err == 0) || (err == EEXIST));
int err = FileCreateDirectory(pathName, mode);

if (!success) {
Log(LGPFX" %s: Failed to create %s. Error = %d\n",
__FUNCTION__, pathName, err);
if (err == EEXIST) {
FileData fileData;

err = FileAttributes(pathName, &fileData);

if (err == 0) {
if (fileData.fileType != FILE_TYPE_DIRECTORY) {
err = ENOTDIR;
errno = ENOTDIR;

#if defined(_WIN32)
SetLastError(ERROR_DIRECTORY);
#endif
}
}
}

return success;
return err == 0;
}


@@ -451,6 +457,8 @@ File_EnsureDirectoryEx(const char *pathName, // IN:
* If the directory doesn't exist, creates it. If the directory
* already exists, do nothing and succeed.
*
* Errno/GetLastError is available upon failure.
*
* Results:
* See above.
*
@@ -939,8 +947,8 @@ File_CopyFromFdToFd(FileIODescriptor src, // IN:
* for File_CopyTree.
*
* Results:
* TRUE on success
* FALSE on failure: Error messages are appended.
* TRUE Success.
* FALSE Failure. Error messages appended
*
* Side effects:
* None.
@@ -1051,8 +1059,8 @@ FileCopyTree(const char *srcName, // IN:
* optionally overwriting any files.
*
* Results:
* TRUE on success
* FALSE on failure: Error messages are appended.
* TRUE Success.
* FALSE Failure. Error messages appended
*
* Side effects:
* None.
@@ -1103,8 +1111,8 @@ File_CopyTree(const char *srcName, // IN:
* decides whether to overwrite the existing file or not.
*
* Results:
* TRUE on success
* FALSE on failure: Messages are appended
* TRUE Success.
* FALSE Failure. Error messages appended
*
* Side effects:
* None
@@ -1181,8 +1189,8 @@ File_CopyFromFd(FileIODescriptor src, // IN:
* decides whether to overwrite the existing file or not.
*
* Results:
* TRUE on success
* FALSE on failure: Messages are appended
* TRUE Success.
* FALSE Failure. Error messages appended
*
* Side effects:
* None
@@ -1251,7 +1259,7 @@ File_Copy(const char *srcName, // IN:
* purposes copying only results if the native rename ability fails.
*
* Results:
* TRUE succeeded
* TRUE success
* FALSE otherwise
*
* Side effects:
@@ -1310,8 +1318,8 @@ File_Move(const char *oldFile, // IN:
* reason. In that event we will append error messages.
*
* Results:
* TRUE - on success
* FALSE - on failure with error messages appended
* TRUE Success.
* FALSE Failure. Error messages appended
*
* Side effects:
* - Deletes the originating directory
@@ -1671,7 +1679,8 @@ FileFirstSlashIndex(const char *pathName, // IN:
* to remove it after in case later operations fail.
*
* Results:
* TRUE on success, FALSE on failure.
* TRUE Success.
* FALSE Failure.
*
* If topmostCreated is not NULL, it returns the result of the hierarchy
* creation. If no directory was created, *topmostCreated is set to NULL.
@@ -1688,7 +1697,7 @@ FileFirstSlashIndex(const char *pathName, // IN:

Bool
File_CreateDirectoryHierarchyEx(const char *pathName, // IN:
int mask, // IN:
int mode, // IN:
char **topmostCreated) // OUT/OPT:
{
char *volume;
@@ -1724,7 +1733,7 @@ File_CreateDirectoryHierarchyEx(const char *pathName, // IN:
}

/*
* Iterate parent directories, splitting on appropriate dir separators.
* Iterate directory path, creating directories as necessary.
*/

while (TRUE) {
@@ -1739,11 +1748,11 @@ File_CreateDirectoryHierarchyEx(const char *pathName, // IN:

/*
* If we check if the directory already exists and then we create it,
* there is a race between these two operations - that might cause this
* operation to fail with no reason.
* This is why we reverse the attempt and the check.
* there is a race between these two operations. Any failure can be
* confusing. We avoid this by attempting to create the directory before
* checking the type.
*/
err = FileCreateDirectoryEx(temp, mask);
err = FileCreateDirectory(temp, mode);

if (err == 0) {
if (topmostCreated != NULL && *topmostCreated == NULL) {
@@ -1751,9 +1760,9 @@ File_CreateDirectoryHierarchyEx(const char *pathName, // IN:
temp = NULL;
}
} else {
FileData fileData;

if (err == EEXIST) {
FileData fileData;

err = FileAttributes(temp, &fileData);

if (err == 0) {
@@ -1769,6 +1778,11 @@ File_CreateDirectoryHierarchyEx(const char *pathName, // IN:
}
}

if (err != 0) {
Log(LGPFX" %s: Failure on '%s'. Error = %d\n",
__FUNCTION__, temp, err);
}

Posix_Free(temp);

if (err != 0) {
@@ -1959,9 +1973,9 @@ FileDeleteDirectoryTree(const char *pathName, // IN: directory to delete
* it can but will return FALSE.
*
* Results:
* TRUE the entire content was deleted or there were no files and the
* directoy was empty
* FALSE otherwise.
* TRUE the entire contents were deleted or there were no files and the
* directory was empty
* FALSE otherwise
*
* Side effects:
* Deletes the directory content from disk.
@@ -2011,7 +2025,8 @@ File_DeleteDirectoryTree(const char *pathName) // IN: directory to delete
* searchPath must be ';' delimited.
*
* Results:
* TRUE if a file is found. FALSE otherwise.
* TRUE file was found
* FALSE otherwise.
*
* Side effects:
* If result is non Null allocate a string for the filename found.
@@ -2143,7 +2158,8 @@ done:
* the named directory is writeable.
*
* Results:
* NULL if error, the expanded path otherwise.
* NULL error
* !NULL the expanded path otherwise.
*
* Side effects:
* The result is allocated.
@@ -2618,8 +2634,8 @@ File_GetFSMountInfo(const char *pathName,
* Check if the specified file path contains symbolic link.
*
* Results:
* return TRUE if pathName contains a symlink,
* return FALSE if pathName is not a symlink or error.
* TRUE pathName contains a symlink,
* FALSE pathName is not a symlink nor contains a symlink, or error.
*
* Side effects:
* None


+ 18
- 10
open-vm-tools/lib/file/fileIO.c View File

@@ -1,5 +1,5 @@
/*********************************************************
* Copyright (C) 1998-2017 VMware, Inc. All rights reserved.
* Copyright (C) 1998-2018 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
@@ -849,11 +849,12 @@ FileIO_AtomicUpdateEx(FileIODescriptor *newFD, // IN/OUT: file IO descriptor

if (HostType_OSIsVMK()) {
#if defined(VMX86_SERVER)
FS_SwapFilesArgsUW *args = NULL;
FS_SwapFilesArgsUW args = { 0 };
char *dirName = NULL;
char *fileName = NULL;
char *dstDirName = NULL;
char *dstFileName = NULL;
Bool isSame;

currPath = File_FullPath(FileIO_Filename(currFD));
if (currPath == NULL) {
@@ -875,14 +876,22 @@ FileIO_AtomicUpdateEx(FileIODescriptor *newFD, // IN/OUT: file IO descriptor
File_GetPathName(currPath, &dstDirName, &dstFileName);

ASSERT(dirName != NULL);
ASSERT(fileName && *fileName);
ASSERT(fileName != NULL && *fileName != '\0');
ASSERT(dstDirName != NULL);
ASSERT(dstFileName && *dstFileName);
ASSERT(File_IsSameFile(dirName, dstDirName));
ASSERT(dstFileName != NULL && *dstFileName != '\0');

args = Util_SafeCalloc(1, sizeof *args);
args->fd = currFD->posix;
if (ioctl(newFD->posix, IOCTLCMD_VMFS_SWAP_FILES, args) != 0) {
errno = 0;
isSame = File_IsSameFile(dirName, dstDirName);
if (errno == 0) {
ASSERT(isSame);
} else {
savedErrno = errno;
Log("%s: File_IsSameFile failed (errno = %d).\n", __FUNCTION__, errno);
goto swapdone;
}

args.fd = currFD->posix;
if (ioctl(newFD->posix, IOCTLCMD_VMFS_SWAP_FILES, &args) != 0) {
savedErrno = errno;
if (errno != ENOSYS && errno != ENOTTY) {
Log("%s: ioctl failed %d.\n", __FUNCTION__, errno);
@@ -932,7 +941,6 @@ FileIO_AtomicUpdateEx(FileIODescriptor *newFD, // IN/OUT: file IO descriptor
}

swapdone:
Posix_Free(args);
Posix_Free(dirName);
Posix_Free(fileName);
Posix_Free(dstDirName);
@@ -1027,7 +1035,7 @@ swapdone:
*