]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
merge -X theirs stable-10.2.x, remove files that were deleted in stable-10.2.x
authorOliver Kurth <okurth@vmware.com>
Mon, 8 Jan 2018 20:53:58 +0000 (12:53 -0800)
committerOliver Kurth <okurth@vmware.com>
Mon, 8 Jan 2018 20:54:11 +0000 (12:54 -0800)
1  2 
open-vm-tools/configure.ac
open-vm-tools/lib/asyncsocket/asyncsocket.c
open-vm-tools/lib/include/asyncsocket.h
open-vm-tools/lib/include/productState.h
open-vm-tools/lib/include/x86cpuid.h
open-vm-tools/lib/misc/strutil.c
open-vm-tools/lib/nicInfo/nicInfoPosix.c
open-vm-tools/lib/syncDriver/syncDriverLinux.c
open-vm-tools/libDeployPkg/linuxDeployment.c
open-vm-tools/modules/solaris/vmxnet3/vmxnet3_tx.c

index 1c5962f5c9faeeb2c7737545c6885c4f4e658bd0,6ba126eedd170fa2fde21ae29170864ca0c33e9d..3531a8c3533a6d3c061d8859a56516469d3ed8b4
@@@ -569,11 -645,11 +645,14 @@@ els
                      [],
                      [],
                      [],
-                     [AC_VMW_LIB_ERROR([XMLSECURITY], [xml-security-c])])
+                     [AC_VMW_LIB_ERROR([XMLSECURITY], [xmlsecurity])])
+ fi
+ else
+    enable_caf=no
  fi
 +else
 +   enable_caf=no
 +fi
  
  #
  # Check for CUnit and disable test code if not available.
index 7806e62f293b7129515aea4d39d0cc47c0f617b3,13908679b4ac0685256eda13373dc93d3b855429..44b5e83906b039dd2311222a8f39908568c9fd4f
@@@ -1920,34 -1979,7 +1979,9 @@@ AsyncTCPSocketConnect(struct sockaddr_s
        goto error;
     }
  
-    return AsyncSocketConnectWithAsock(asock, addr, addrLen, connectFn,
-                                       clientData, AsyncSocketConnectCallback,
-                                       pollParams, outError);
- error:
-    if (outError) {
-       *outError = error;
-    }
-    return NULL;
- }
- AsyncSocket *
- AsyncSocketConnectWithAsock(AsyncSocket *asock,
-                             struct sockaddr_storage *addr,
-                             socklen_t addrLen,
-                             AsyncSocketConnectFn connectFn,
-                             void *clientData,
-                             PollerFunction internalConnectFn,
-                             AsyncSocketPollParams *pollParams,
-                             int *outError)
- {
-    VMwareStatus pollStatus;
-    int sysErr;
-    int error = ASOCKERR_GENERIC;
  
 +   ASSERT(internalConnectFn != NULL);
 +
     /*
      * Call connect(), which can either succeed immediately or return an error
      * indicating that the connection is in progress. In the latter case, we
@@@ -4531,19 -4411,19 +4413,30 @@@ AsyncTCPSocketClose(AsyncSocket *base
        Bool removed;
        AsyncSocketState oldState;
  
-       isListener = FALSE;
+       /* Flush output if requested via AsyncTCPSocket_SetCloseOptions(). */
+       if (asock->flushEnabledMaxWaitMsec &&
+           AsyncTCPSocketGetState(asock) == AsyncSocketConnected &&
+           !asock->base.errorSeen) {
+          int ret = AsyncTCPSocketFlush(BaseSocket(asock),
+                                        asock->flushEnabledMaxWaitMsec);
+          if (ret != ASOCKERR_SUCCESS) {
+             TCPSOCKWARN(asock,
+                         ("AsyncTCPSocket_Flush failed: %s. Closing now.\n",
+                          AsyncSocket_Err2String(ret)));
+          }
+       }
  
 +      /* Flush output if requested via AsyncSocket_SetCloseOptions(). */
 +      if (asock->flushEnabledMaxWaitMsec &&
 +          asock->state == AsyncSocketConnected &&
 +          !asock->errorSeen) {
 +         int ret = AsyncSocket_Flush(asock, asock->flushEnabledMaxWaitMsec);
 +         if (ret != ASOCKERR_SUCCESS) {
 +            ASOCKWARN(asock, ("AsyncSocket_Flush failed: %s. Closing now.\n",
 +                              AsyncSocket_Err2String(ret)));
 +         }
 +      }
 +
        /*
         * Set the new state to closed, and then check the old state and do the
         * right thing accordingly
@@@ -5878,19 -5474,19 +5487,22 @@@ AsyncTCPSocketSslAcceptCallback(void *c
     VMwareStatus pollStatus;
  
     ASSERT(asock);
-    ASSERT(asock->pollParams.iPoll == NULL);
-    ASSERT(AsyncSocketIsLocked(asock));
+    ASSERT(AsyncTCPSocketPollParams(asock)->iPoll == NULL);
+    ASSERT(AsyncTCPSocketIsLocked(asock));
+    AsyncTCPSocketAddRef(asock);
  
-    AsyncSocketAddRef(asock);
+    /* Only set if poll callback is registered */
+    asock->sslPollFlags = 0;
  
 +   /* Only set if poll callback is registered */
 +   asock->sslPollFlags = 0;
 +
     sslOpCode = SSL_TryCompleteAccept(asock->sslSock);
     if (sslOpCode > 0) {
-       (*asock->sslAcceptFn)(TRUE, asock, asock->clientData);
+       (*asock->sslAcceptFn)(TRUE, BaseSocket(asock), asock->clientData);
     } else if (sslOpCode < 0) {
-       (*asock->sslAcceptFn)(FALSE, asock, asock->clientData);
+       (*asock->sslAcceptFn)(FALSE, BaseSocket(asock), asock->clientData);
     } else {
        asock->sslPollFlags = SSL_WantRead(asock->sslSock) ?
                              POLL_FLAG_READ : POLL_FLAG_WRITE;
@@@ -6073,51 -5910,13 +5926,55 @@@ AsyncSocket_ListenSocketUDS(const char 
   *-----------------------------------------------------------------------------
   */
  
- void
- AsyncSocketSetSendLowLatencyMode(AsyncSocket *asock,  // IN
-                                  Bool enable)         // IN
+ static void
+ AsyncTCPSocketListenerError(int error,           // IN
+                             AsyncSocket *asock,  // IN
+                             void *clientData)    // IN
  {
-    asock->sendLowLatency = enable;
+    AsyncSocket *s = clientData;
+    ASSERT(s);
+    AsyncSocketHandleError(s, error);
  }
 +
 +
 +#ifndef _WIN32
 +/*
 + *-----------------------------------------------------------------------------
 + *
 + * AsyncSocket_ListenSocketUDS --
 + *
 + *      Listens on the specified unix domain socket, and accepts new socket
 + *      connections. Fires the connect callback with new AsyncSocket object for
 + *      each connection.
 + *
 + * Results:
 + *      New AsyncSocket in listening state or NULL on error
 + *
 + * Side effects:
 + *      Creates new Unix domain socket, binds and listens.
 + *
 + *-----------------------------------------------------------------------------
 + */
 +
 +AsyncSocket *
 +AsyncSocket_ListenSocketUDS(const char *pipeName,               // IN
 +                            AsyncSocketConnectFn connectFn,     // IN
 +                            void *clientData,                   // IN
 +                            AsyncSocketPollParams *pollParams,  // IN
 +                            int *outError)                      // OUT
 +{
 +   struct sockaddr_un addr;
 +
 +   memset(&addr, 0, sizeof addr);
 +   addr.sun_family = AF_UNIX;
 +   Str_Strcpy(addr.sun_path, pipeName, sizeof addr.sun_path);
 +
 +   Log(ASOCKPREFIX "creating new socket listening on %s\n", pipeName);
 +
 +   return AsyncSocketListenImpl((struct sockaddr_storage *)&addr,
 +                                sizeof addr,
 +                                connectFn, clientData, pollParams, FALSE,
 +                                FALSE, NULL, outError);
 +}
 +#endif
index 63a145313d64de032c0dfcf1366f6a0739330450,524147ea9ca259b9f77de9b444f2a9cf1d7c2c22..7982a52c099c62ef89b9f5d7e22374ed940457f3
@@@ -445,26 -657,12 +657,26 @@@ int AsyncSocket_SetErrorFn(AsyncSocket 
                             void *clientData);
  
  /*
-  * Set socket level recv/send buffer sizes if they are less than given sizes.
+  * Set optional AsyncSocket_Close() behaviors.
   */
- Bool AsyncSocket_SetBufferSizes(AsyncSocket *asock,  // IN
-                                 int sendSz,    // IN
-                                 int recvSz);   // IN
+ int AsyncSocket_SetCloseOptions(AsyncSocket *asock,
+                                 int flushEnabledMaxWaitMsec,
+                                 AsyncSocketCloseFn closeCb);
  
 +/*
 + * Set optional AsyncSocket_Close() behaviors.
 + */
 +void AsyncSocket_SetCloseOptions(AsyncSocket *asock,
 +                                 int flushEnabledMaxWaitMsec,
 +                                 AsyncSocketCloseCb closeCb);
 +
 +/*
 + * Send websocket close frame.
 + */
 +int
 +AsyncSocket_SendWebSocketCloseFrame(AsyncSocket *asock,
 +                                    uint16 closeStatus);
 +
  /*
   * Close the connection and destroy the asock.
   */
index dbb241ae9189328fc45d8660320c3191fcb8bf37,327a33f05fbf4e8f383f66d84d3b57681fe2ac65..e4ed2f1d8d38a6adb6133f47168015287b322df3
@@@ -79,39 -64,48 +64,51 @@@ typedef enum 
   * Public functions.
   *
   * PR 567850
-  * ProductState_Set should only be called once. Subsequent calls will be ignored.
+  * ProductState_Set should only be called once. Subsequent calls will be
+  * ignored.
   */
  
- void ProductState_Set(Product product, const char *name, const char *version,
-                       unsigned int buildNumber, ProductCaps capabilities,
-                       const char *licenseName, const char *licenseVersion,
+ void ProductState_Set(Product product,
+                       const char *name,
+                       const char *version,
+                       unsigned int buildNumber,
+                       ProductCaps capabilities,
+                       const char *licenseName,
+                       const char *licenseVersion,
                        const char *bundleIdentifier);
  
- Product ProductState_GetProduct(void);
+ unsigned int  ProductState_GetBuildNumber(void);
+ const char   *ProductState_GetBuildNumberString(void);
+ const char   *ProductState_GetBundleIdentifier(void);
+ ProductCaps   ProductState_GetCapabilities(void);
+ const char   *ProductState_GetCompilationOption(void);
+ const char   *ProductState_GetConfigName(void);
+ const char   *ProductState_GetFullVersion(void);
+ void          ProductState_GetHelp(Product *helpProduct,
+                                    const char **helpVersion);
+ const char   *ProductState_GetLicenseName(void);
+ const char   *ProductState_GetLicenseVersion(void);
+ const char   *ProductState_GetName(void);
+ Product       ProductState_GetProduct(void);
+ const char   *ProductState_GetRegistryPath(void);
+ char         *ProductState_GetRegistryPathForProduct(const char *productName);
+ const char   *ProductState_GetVersion(void);
+ void          ProductState_GetVersionNumber(unsigned int *major,
+                                             unsigned int *minor,
+                                             unsigned int *patchLevel);
  Bool ProductState_IsProduct(ProductMask product);
  Bool ProductState_AllowUnlicensedVMX(void);
- const char *ProductState_GetName(void);
- const char *ProductState_GetVersion(void);
- unsigned int ProductState_GetBuildNumber(void);
- ProductCaps ProductState_GetCapabilities(void);
- const char *ProductState_GetLicenseName(void);
- const char *ProductState_GetLicenseVersion(void);
  void ProductState_SetConfigName(const char *configName);
- const char *ProductState_GetConfigName(void);
  /* etc */
  
- const char *ProductState_GetCompilationOption(void);
- const char *ProductState_GetFullVersion(void);
- const char *ProductState_GetBuildNumberString(void);
- const char *ProductState_GetRegistryPath(void);
- char *ProductState_GetRegistryPathForProduct(const char *productName);
- const char *ProductState_GetBundleIdentifier(void);
- void ProductState_GetVersionNumber(unsigned int *major, unsigned int *minor,
-                                    unsigned int *patchLevel);
+ void ProductState_SetHelp(Product helpProduct,
+                           const char *helpVersion);
  
 +void ProductState_SetHelp(Product helpProduct, const char *helpVersion);
 +void ProductState_GetHelp(Product *helpProduct, const char **helpVersion);
 +
  char *ProductState_Serialize(ProductStateSerializationFlags flags);
  ProductStateSerializationFlags ProductState_Deserialize(const char *state);
  
index a0b839d908032575f9158b2c763de174760a694a,596664ffdbab4aa4484dd748169e9ec0dfeaccf2..7731ba9afb95fceae581bcee5a1405387e783280
@@@ -1531,8 -1800,23 +1800,25 @@@ CPUID_MODEL_IS_IVYBRIDGE(uint32 v) // I
  }
  
  
 +
 +
+ static INLINE Bool
+ CPUID_MODEL_IS_KNIGHTS_LANDING(uint32 v) // IN: %eax from CPUID with %eax=1.
+ {
+    /* Assumes the CPU manufacturer is Intel. */
+    return CPUID_FAMILY_IS_P6(v) &&
+           CPUID_EFFECTIVE_MODEL(v) == CPUID_MODEL_KNL_57;
+ }
+ static INLINE Bool
+ CPUID_MODEL_IS_KNIGHTS_MILL(uint32 v) // IN: %eax from CPUID with %eax=1.
+ {
+    /* Assumes the CPU manufacturer is Intel. */
+    return CPUID_FAMILY_IS_P6(v) &&
+           CPUID_EFFECTIVE_MODEL(v) == CPUID_MODEL_KNM_85;
+ }
  static INLINE Bool
  CPUID_FAMILY_IS_K7(uint32 eax)
  {
index 18684b0867b57a116ea1c0bc2e960d103b1cbeac,27f230bd133e3cc144d1d81ea18294ae09ae9009..6b5dabfe6c2e3e4c0ad7bd5b91e2a07588feb6cd
  #include "vm_ctype.h"
  #include "util.h"
  
+ #ifndef SIZE_MAX /* SIZE_MAX is new in C99 */
+ #define SIZE_MAX ((size_t) -1)
+ #endif
++/*
++ *-----------------------------------------------------------------------------
++ *
++ * StrUtil_IsEmpty --
++ *
++ *      Test if a non-NULL string is empty.
++ *
++ * Results:
++ *      TRUE if the string has length 0, FALSE otherwise.
++ *
++ * Side effects:
++ *      None
++ *
++ *-----------------------------------------------------------------------------
++ */
++
++#ifdef VMX86_DEBUG
++static INLINE Bool
++StrUtil_IsEmpty(const char *str)  // IN:
++{
++   ASSERT(str != NULL);
++   return str[0] == '\0';
++}
++#endif
 +
  /*
   *-----------------------------------------------------------------------------
   *
index c5f7917ac62a3ba640a43aeb87cbb523a91f6ce7,818e61e723c03e37a6bf1ce237de2e23efc4948e..e818e1c175d58e113720e16a1378afd11f00b0ba
@@@ -517,9 -644,91 +644,95 @@@ ReadInterfaceDetails(const struct intf_
     return 0;
  }
  
 +#endif // !NO_DNET
 +
 +
++#ifdef USE_RESOLVE
+ /*
+  ******************************************************************************
+  * ReadInterfaceDetailsPrimary --                                        */ /**
+  *
+  * @brief Callback function called by libdnet when iterating over all the NICs
+  * on the host. Calls ReadInterfaceDetails with the priority param set to
+  * NICINFO_PRIORITY_PRIMARY.
+  *
+  * @param[in]  entry     Current interface entry.
+  * @param[in]  arg       Pointer to NicInfoV3 container.
+  *
+  * @note New GuestNicV3 structures are added to the NicInfoV3 structure.
+  *
+  * @retval 0    Success.
+  * @retval -1   Failure.
+  *
+  ******************************************************************************
+  */
+ static int
+ ReadInterfaceDetailsPrimary(const struct intf_entry *entry,
+                             void *arg)
+ {
+    return ReadInterfaceDetails(entry, arg, NICINFO_PRIORITY_PRIMARY);
+ }
+ /*
+  ******************************************************************************
+  * ReadInterfaceDetailsNormal --                                      */ /**
+  *
+  * @brief Callback function called by libdnet when iterating over all the NICs
+  * on the host. Calls ReadInterfaceDetails with the priority param set to
+  * NICINFO_PRIORITY_NORMAL.
+  *
+  * @param[in]  entry     Current interface entry.
+  * @param[in]  arg       Pointer to NicInfoV3 container.
+  *
+  * @note New GuestNicV3 structures are added to the NicInfoV3 structure.
+  *
+  * @retval 0    Success.
+  * @retval -1   Failure.
+  *
+  ******************************************************************************
+  */
+ static int
+ ReadInterfaceDetailsNormal(const struct intf_entry *entry,
+                            void *arg)
+ {
+    return ReadInterfaceDetails(entry, arg, NICINFO_PRIORITY_NORMAL);
+ }
+ /*
+  ******************************************************************************
+  * ReadInterfaceDetailsLowPriority --                                    */ /**
+  *
+  * @brief Callback function called by libdnet when iterating over all the NICs
+  * on the host. Calls ReadInterfaceDetails with the priority param set to
+  * NICINFO_PRIORITY_LOW.
+  *
+  * @param[in]  entry     Current interface entry.
+  * @param[in]  arg       Pointer to NicInfoV3 container.
+  *
+  * @note New GuestNicV3 structures are added to the NicInfoV3 structure.
+  *
+  * @retval 0    Success.
+  * @retval -1   Failure.
+  *
+  ******************************************************************************
+  */
+ static int
+ ReadInterfaceDetailsLowPriority(const struct intf_entry *entry,
+                                 void *arg)
+ {
+    return ReadInterfaceDetails(entry, arg, NICINFO_PRIORITY_LOW);
+ }
+ #endif // !NO_DNET
  #ifdef USE_RESOLVE
  
  /*
index da0a8cb6e554f456f7776ec783f2db886ddfa689,db042da4fea991d21e97c3a60982f9ae50fdb3df..3671c9aaab654fdafd98845b3ae7baccdc2456c4
@@@ -159,12 -182,13 +182,18 @@@ LinuxDriver_Freeze(const GSList *paths
  
     sync->driver.thaw = LinuxFiThaw;
     sync->driver.close = LinuxFiClose;
+    sync->driver.getattr = LinuxFiGetAttr;
+    /*
+     * Ensure we did not get an empty list
+     */
+    VERIFY(paths != NULL);
  
 +   /*
 +    * Ensure we did not get an empty list
 +    */
 +   VERIFY(paths != NULL);
 +
     /*
      * Iterate through the requested paths. If we get an error for the first
      * path, and it's not EPERM, assume that the ioctls are not available in
index 8e536a972020170e54a62ef9cb9b45dac9c3d1b0,023d41f1141aac27ee2aedd4fa2485a721db4975..9a86d92f5abd258b6b9cbc8f2d7184b744d10465
@@@ -1002,6 -1035,75 +1035,103 @@@ CopyFileToDirectory(const char* srcPath
     return true;
  }
  
+ //......................................................................................
++static bool
++CopyFileToDirectory(const char* srcPath, const char* destPath,
++                    const char* fileName)
++{
++   char command[1024];
++   int forkExecResult;
++   snprintf(command, sizeof(command), "/bin/cp %s/%s %s/%s.tmp", srcPath,
++            fileName, destPath, fileName);
++   command[sizeof(command) - 1] = '\0';
++   forkExecResult = ForkExecAndWaitCommand(command);
++   if (forkExecResult != 0) {
++      SetDeployError("Error while copying file %s: %s", fileName,
++                     strerror(errno));
++      return false;
++   }
++   snprintf(command, sizeof(command), "/bin/mv -f %s/%s.tmp %s/%s", destPath,
++            fileName, destPath, fileName);
++   command[sizeof(command) - 1] = '\0';
++
++   forkExecResult = ForkExecAndWaitCommand(command);
++   if (forkExecResult != 0) {
++      SetDeployError("Error while renaming temp file %s: %s", fileName,
++                     strerror(errno));
++      return false;
++   }
++   return true;
++}
++
+ /**
+  *----------------------------------------------------------------------------
+  *
+  * UseCloudInitWorkflow --
+  *
+  * Function which checks if cloud-init should be used for customization.
+  * Essentially it checks if
+  * - customization specificaion file (cust.cfg) is present.
+  * - cloud-init is installed
+  * - cloud-init is enabled.
+  *
+  * @param   [IN]  dirPath  Path where the package is extracted.
+  * @returns true if cloud-init should be used for guest customization.
+  *
+  *----------------------------------------------------------------------------
+  * */
+ static bool
+ UseCloudInitWorkflow(const char* dirPath)
+ {
+    char *cfgFullPath = NULL;
+    int cfgFullPathSize;
+    static const char cfgName[] = "cust.cfg";
+    static const char cloudInitConfigFilePath[] = "/etc/cloud/cloud.cfg";
+    static const char cloudInitCommand[] = "/usr/bin/cloud-init -v";
+    int forkExecResult;
+    if (NULL == dirPath) {
+       return false;
+    }
+    sLog(log_debug, "Check if cust.cfg exists.");
+    cfgFullPathSize = strlen(dirPath) + 1 /* For '/' */ + sizeof(cfgName);
+    cfgFullPath = (char *) malloc(cfgFullPathSize);
+    if (cfgFullPath == NULL) {
+       sLog(log_error, "Failed to allocate memory. (%s)", strerror(errno));
+       return false;
+    }
+    snprintf(cfgFullPath, cfgFullPathSize, "%s/%s", dirPath, cfgName);
+    cfgFullPath[cfgFullPathSize - 1] = '\0';
+    if (access(cfgFullPath, R_OK) != 0) {
+       sLog(log_info, "cust.cfg is missing in '%s' directory. Error: (%s)",
+            dirPath, strerror(errno));
+       free(cfgFullPath);
+       return false;
+    } else {
+       sLog(log_info, "cust.cfg is found in '%s' directory.", dirPath);
+    }
+    forkExecResult = ForkExecAndWaitCommand(cloudInitCommand);
+    if (forkExecResult != 0) {
+       sLog(log_info, "cloud-init is not installed");
+       free(cfgFullPath);
+       return false;
+    } else {
+       sLog(log_info, "cloud-init is installed");
+    }
+    free(cfgFullPath);
+    return IsCloudInitEnabled(cloudInitConfigFilePath);
+ }
  /**
   *
   * Core function which takes care of deployment in Linux.
@@@ -1037,13 -1136,12 +1164,18 @@@ Deploy(const char* packageName
     SetCustomizationStatusInVmx(TOOLSDEPLOYPKG_RUNNING,
                                 TOOLSDEPLOYPKG_ERROR_SUCCESS,
                                 NULL);
+    tmpDirPath = mkdtemp((char *)Util_SafeStrdup(TMP_DIR_PATH_PATTERN));
+    if (tmpDirPath == NULL) {
+       SetDeployError("Error creating tmp dir: %s", strerror(errno));
+       return DEPLOY_ERROR;
+    }
  
 +   tmpDirPath = mkdtemp((char *)Util_SafeStrdup(TMP_DIR_PATH_PATTERN));
 +   if (tmpDirPath == NULL) {
 +      SetDeployError("Error creating tmp dir: %s", strerror(errno));
 +      return DEPLOY_ERROR;
 +   }
 +
     sLog(log_info, "Reading cabinet file %s. \n", packageName);
  
     // Get the command to execute