From: Oliver Kurth Date: Mon, 8 Jan 2018 20:53:58 +0000 (-0800) Subject: merge -X theirs stable-10.2.x, remove files that were deleted in stable-10.2.x X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dd736d23750701ce20f6c16a209bbb094fc5ce04;p=thirdparty%2Fopen-vm-tools.git merge -X theirs stable-10.2.x, remove files that were deleted in stable-10.2.x --- dd736d23750701ce20f6c16a209bbb094fc5ce04 diff --cc open-vm-tools/configure.ac index 1c5962f5c,6ba126eed..3531a8c35 --- a/open-vm-tools/configure.ac +++ b/open-vm-tools/configure.ac @@@ -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. diff --cc open-vm-tools/lib/asyncsocket/asyncsocket.c index 7806e62f2,13908679b..44b5e8390 --- a/open-vm-tools/lib/asyncsocket/asyncsocket.c +++ b/open-vm-tools/lib/asyncsocket/asyncsocket.c @@@ -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 diff --cc open-vm-tools/lib/include/asyncsocket.h index 63a145313,524147ea9..7982a52c0 --- a/open-vm-tools/lib/include/asyncsocket.h +++ b/open-vm-tools/lib/include/asyncsocket.h @@@ -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. */ diff --cc open-vm-tools/lib/include/productState.h index dbb241ae9,327a33f05..e4ed2f1d8 --- a/open-vm-tools/lib/include/productState.h +++ b/open-vm-tools/lib/include/productState.h @@@ -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); diff --cc open-vm-tools/lib/include/x86cpuid.h index a0b839d90,596664ffd..7731ba9af --- a/open-vm-tools/lib/include/x86cpuid.h +++ b/open-vm-tools/lib/include/x86cpuid.h @@@ -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) { diff --cc open-vm-tools/lib/misc/strutil.c index 18684b086,27f230bd1..6b5dabfe6 --- a/open-vm-tools/lib/misc/strutil.c +++ b/open-vm-tools/lib/misc/strutil.c @@@ -36,7 -37,11 +37,36 @@@ #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 + /* *----------------------------------------------------------------------------- * diff --cc open-vm-tools/lib/nicInfo/nicInfoPosix.c index c5f7917ac,818e61e72..e818e1c17 --- a/open-vm-tools/lib/nicInfo/nicInfoPosix.c +++ b/open-vm-tools/lib/nicInfo/nicInfoPosix.c @@@ -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 /* diff --cc open-vm-tools/lib/syncDriver/syncDriverLinux.c index da0a8cb6e,db042da4f..3671c9aaa --- a/open-vm-tools/lib/syncDriver/syncDriverLinux.c +++ b/open-vm-tools/lib/syncDriver/syncDriverLinux.c @@@ -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 diff --cc open-vm-tools/libDeployPkg/linuxDeployment.c index 8e536a972,023d41f11..9a86d92f5 --- a/open-vm-tools/libDeployPkg/linuxDeployment.c +++ b/open-vm-tools/libDeployPkg/linuxDeployment.c @@@ -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