[],
[],
[],
- [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.
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
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
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;
*-----------------------------------------------------------------------------
*/
- 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
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.
*/
* 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);
}
+
+
+ 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)
{
#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
+
/*
*-----------------------------------------------------------------------------
*
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
/*
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
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.
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