From: Oliver Kurth Date: Tue, 21 Apr 2020 21:43:45 +0000 (-0700) Subject: AppInfo updates. X-Git-Tag: stable-11.2.0~246 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4a049ceec7e2e1fafbfece34e29c4f7b14962e7c;p=thirdparty%2Fopen-vm-tools.git AppInfo updates. While most of the changes are only applicable to VMware Tools for Windows and are not applicable to open-vm-tools, the following changes do apply. - Modified few log messages from g_debug from g_warning. - Modified the default poll interval to 360 minutes (Once in six hours). - Modified log messages to log the filepath whose version is being retrieved. --- diff --git a/open-vm-tools/lib/include/conf.h b/open-vm-tools/lib/include/conf.h index 7632a4e2e..7bbc837d3 100644 --- a/open-vm-tools/lib/include/conf.h +++ b/open-vm-tools/lib/include/conf.h @@ -85,6 +85,18 @@ */ #define CONFNAME_APPINFO_DISABLED "disabled" +/** + * Defines the configuration to use the WMI for getting the application + * version information. + * + * @note Illegal values result in a @c g_warning and fallback to the default + * value. + * + * @param boolean Set to TRUE to use WMI. + * Set to FALSE to use native Win32 APIs. + */ +#define CONFNAME_APPINFO_USE_WMI "useWMI" + /* * END AppInfo goodies. ****************************************************************************** diff --git a/open-vm-tools/services/plugins/appInfo/appInfo.c b/open-vm-tools/services/plugins/appInfo/appInfo.c index af6e7c3d9..22f3425f9 100644 --- a/open-vm-tools/services/plugins/appInfo/appInfo.c +++ b/open-vm-tools/services/plugins/appInfo/appInfo.c @@ -60,9 +60,9 @@ VM_EMBED_VERSION(VMTOOLSD_VERSION_STRING); #define MAX_APP_INFO_SIZE (62 * 1024) /** - * Default poll interval for appInfo is 30m + * Default poll interval for appInfo is 6 hours */ -#define APP_INFO_POLL_INTERVAL (30 * 60) +#define APP_INFO_POLL_INTERVAL (360 * 60) /** * Default value for CONFNAME_APPINFO_DISABLED setting in @@ -72,6 +72,15 @@ VM_EMBED_VERSION(VMTOOLSD_VERSION_STRING); */ #define APP_INFO_CONF_DEFAULT_DISABLED_VALUE FALSE +/** + * Default value for CONFNAME_APPINFO_USE_WMI setting in + * tools configuration file. + * + * TRUE will force the plugin to use WMI for getting + * the application version information. + */ +#define APP_INFO_CONF_USE_WMI_DEFAULT_VALUE FALSE + /** * Defines the current poll interval (in seconds). * @@ -191,6 +200,8 @@ SetGuestInfo(ToolsAppCtx *ctx, // IN: * * Generates the application information list. * + * @param[in] config Tools configuration dictionary. + * * @retval Pointer to the newly allocated application list. The caller must * free the memory using AppInfoDestroyAppList function. * NULL if any error occurs. @@ -199,13 +210,17 @@ SetGuestInfo(ToolsAppCtx *ctx, // IN: */ GSList * -AppInfo_GetAppList(void) +AppInfo_GetAppList(GKeyFile *config) // IN { GSList *appList = NULL; int i; ProcMgrProcInfoArray *procList = NULL; size_t procCount; +#ifdef _WIN32 + Bool useWMI; +#endif + procList = ProcMgr_ListProcesses(); if (procList == NULL) { @@ -213,11 +228,24 @@ AppInfo_GetAppList(void) return appList; } +#ifdef _WIN32 + useWMI = VMTools_ConfigGetBoolean(config, + CONFGROUPNAME_APPINFO, + CONFNAME_APPINFO_USE_WMI, + APP_INFO_CONF_USE_WMI_DEFAULT_VALUE); + + g_debug("%s: useWMI: %d", __FUNCTION__, useWMI); +#endif + procCount = ProcMgrProcInfoArray_Count(procList); for (i = 0; i < procCount; i++) { AppInfo *appInfo; ProcMgrProcInfo *procInfo = ProcMgrProcInfoArray_AddressOf(procList, i); +#ifdef _WIN32 + appInfo = AppInfo_GetAppInfo(procInfo, useWMI); +#else appInfo = AppInfo_GetAppInfo(procInfo); +#endif if (NULL != appInfo) { appList = g_slist_prepend(appList, appInfo); } @@ -286,7 +314,7 @@ AppInfoGatherTask(ToolsAppCtx *ctx, // IN DynBuf_Append(&dynBuffer, tmpBuf, len); - appList = AppInfo_SortAppList(AppInfo_GetAppList()); + appList = AppInfo_SortAppList(AppInfo_GetAppList(ctx->config)); for (appNode = appList; appNode != NULL; appNode = appNode->next) { size_t currentBufferSize = DynBuf_GetSize(&dynBuffer); @@ -604,4 +632,4 @@ ToolsOnLoad(ToolsAppCtx *ctx) // IN } return NULL; -} +} \ No newline at end of file diff --git a/open-vm-tools/services/plugins/appInfo/appInfoInt.h b/open-vm-tools/services/plugins/appInfo/appInfoInt.h index b550fc35d..e66d5313a 100644 --- a/open-vm-tools/services/plugins/appInfo/appInfoInt.h +++ b/open-vm-tools/services/plugins/appInfo/appInfoInt.h @@ -58,11 +58,15 @@ typedef struct AppInfo { #endif } AppInfo; -GSList *AppInfo_GetAppList(void); +GSList *AppInfo_GetAppList(GKeyFile *config); GSList *AppInfo_SortAppList(GSList *appList); void AppInfo_DestroyAppList(GSList *appList); +#if defined(WIN32) +AppInfo *AppInfo_GetAppInfo(ProcMgrProcInfo *procInfo, Bool useWMI); +#else AppInfo *AppInfo_GetAppInfo(ProcMgrProcInfo *procInfo); +#endif #endif /* _APPINFOINT_H_ */