]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
AppInfo updates.
authorOliver Kurth <okurth@vmware.com>
Tue, 21 Apr 2020 21:43:45 +0000 (14:43 -0700)
committerOliver Kurth <okurth@vmware.com>
Tue, 21 Apr 2020 21:43:45 +0000 (14:43 -0700)
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.

open-vm-tools/lib/include/conf.h
open-vm-tools/services/plugins/appInfo/appInfo.c
open-vm-tools/services/plugins/appInfo/appInfoInt.h

index 7632a4e2ecc10a8253b2ff174e023057acbabf0d..7bbc837d3c2cf657636429c0dd8b2527215a3788 100644 (file)
  */
 #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.
  ******************************************************************************
index af6e7c3d99ecdf65dd1149378e07a776cf2a296f..22f3425f9d525128c9dbc875a952d5dc91482987 100644 (file)
@@ -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
index b550fc35df56a28e262a853af1831abcfd706ade..e66d5313a98001ad17683a4d0aaef3221f33bf41 100644 (file)
@@ -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_ */