]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Changes to common source files not directly applicable to open-vm-tools.
authorJohn Wolfe <jwolfe@vmware.com>
Mon, 19 Apr 2021 18:08:11 +0000 (11:08 -0700)
committerJohn Wolfe <jwolfe@vmware.com>
Mon, 19 Apr 2021 18:08:11 +0000 (11:08 -0700)
open-vm-tools/services/vmtoolsd/mainLoop.c
open-vm-tools/services/vmtoolsd/toolsCoreInt.h
open-vm-tools/toolbox/toolbox-cmd.c
open-vm-tools/toolbox/toolboxCmdInt.h
open-vm-tools/toolbox/toolboxcmd-config.c
open-vm-tools/toolbox/toolboxcmd-logging.c
open-vm-tools/toolbox/toolboxcmd-scripts.c

index 3a3cf0cdc10ac1ca20d1e1b7cab5e2645b664b24..23c9afd5e5f57eeaa4f298723e3e1fadbd51548b 100644 (file)
@@ -87,7 +87,7 @@
 
 #define CONFNAME_MAX_CHANNEL_ATTEMPTS "maxChannelAttempts"
 
-#if defined(_WIN32)
+#if defined(GLOBALCONFIG_SUPPORTED)
 /*
  * The state of the global conf module.
  */
@@ -523,7 +523,7 @@ ToolsCoreRunLoop(ToolsServiceState *state)
 #endif
       }
 
-#if defined(_WIN32)
+#if defined(GLOBALCONFIG_SUPPORTED)
       if (GlobalConfig_Start(&state->ctx)) {
          g_info("%s: Successfully started global config module.",
                   __FUNCTION__);
@@ -672,7 +672,7 @@ ToolsCore_ReloadConfig(ToolsServiceState *state,
    gboolean first = state->ctx.config == NULL;
    gboolean loaded;
 
-#if defined(_WIN32)
+#if defined(GLOBALCONFIG_SUPPORTED)
    gboolean globalConfLoaded = FALSE;
 
    if (gGlobalConfStarted) {
@@ -695,7 +695,7 @@ ToolsCore_ReloadConfig(ToolsServiceState *state,
                                &state->ctx.config,
                                &state->configMtime);
 
-#if defined(_WIN32)
+#if defined(GLOBALCONFIG_SUPPORTED)
    if (loaded || globalConfLoaded) {
       gboolean configUpdated = VMTools_AddConfig(state->globalConfig,
                                                  state->ctx.config);
index fe5125a976417b6df00137a31761bd1b250cd724..d79bad8485cc5d8397cf2287a668f004b40b9307 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2008-2020 VMware, Inc. All rights reserved.
+ * Copyright (C) 2008-2021 VMware, Inc. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published
 #include <glib-object.h>
 #include <gmodule.h>
 #include <time.h>
+#if defined(_WIN32)
+/* Need this header for GLOBALCONFIG_SUPPORTED definition.*/
+#include "globalConfig.h"
+#endif
 #include "vmware/tools/plugin.h"
 #include "vmware/tools/rpcdebug.h"
 
@@ -72,7 +76,7 @@ typedef struct ToolsServiceState {
    gchar         *name;
    gchar         *configFile;
    time_t         configMtime;
-#if defined(_WIN32)
+#if defined(GLOBALCONFIG_SUPPORTED)
    GKeyFile      *globalConfig;
    time_t         globalConfigMtime;
 #endif
index f50d013ef73fcf7fde5d1ef52229b1aa8f3a9e96..6bde3747df16d116ec3090b408e14808ee4324b0 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2008-2020 VMware, Inc. All rights reserved.
+ * Copyright (C) 2008-2021 VMware, Inc. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published
@@ -117,7 +117,7 @@ static CmdTable commands[] = {
    (defined(__linux__) && !defined(USERWORLD))
    { "gueststore", GuestStore_Command, TRUE,  FALSE, GuestStore_Help},
 #endif
-#if defined(_WIN32)
+#if defined(GLOBALCONFIG_SUPPORTED)
    { "globalconf", GlobalConf_Command, TRUE,  TRUE,  GlobalConf_Help},
 #endif
    { "logging",    Logging_Command,    TRUE,  TRUE,  Logging_Help},
@@ -471,15 +471,7 @@ main(int argc,    // IN: length of command line arguments
    setlocale(LC_ALL, "");
    VMTools_LoadConfig(NULL, G_KEY_FILE_NONE, &conf, NULL);
 
-#if defined(_WIN32)
-   if (GlobalConfig_GetEnabled(conf)) {
-      GKeyFile *globalConf = NULL;
-      if (GlobalConfig_LoadConfig(&globalConf, NULL)) {
-         VMTools_AddConfig(globalConf, conf);
-         g_key_file_free(globalConf);
-      }
-   }
-#endif
+   TOOLBOXCMD_LOAD_GLOBALCONFIG(conf)
 
    VMTools_ConfigLogging("toolboxcmd", conf, FALSE, FALSE);
    VMTools_BindTextDomain(VMW_TEXT_DOMAIN, NULL, NULL);
index 005eb0ae5c6c1d596fcad2f8043a7ab8adb52bda..d8f6f6be1fcc2bcb62e8cbfa0577792a6c1e0c02 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2008-2020 VMware, Inc. All rights reserved.
+ * Copyright (C) 2008-2021 VMware, Inc. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published
@@ -33,6 +33,7 @@
 #include <string.h>
 #ifdef _WIN32
 #   include "getoptwin32.h"
+#   include "globalConfig.h"
 #else
 #   include <getopt.h>
 #   include <sysexits.h>
@@ -160,4 +161,22 @@ DECLARE_COMMAND(GuestStore);
 DECLARE_COMMAND(GlobalConf)
 #endif
 
+#if defined(GLOBALCONFIG_SUPPORTED)
+
+#define TOOLBOXCMD_LOAD_GLOBALCONFIG(conf)                        \
+   {                                                              \
+      if (GlobalConfig_GetEnabled(conf)) {                        \
+         GKeyFile *__globalConf = NULL;                           \
+         if (GlobalConfig_LoadConfig(&__globalConf, NULL)) {      \
+            VMTools_AddConfig(__globalConf, conf);                \
+            g_key_file_free(__globalConf);                        \
+         }                                                        \
+      }                                                           \
+   }
+#else
+
+#define TOOLBOXCMD_LOAD_GLOBALCONFIG(conf)
+
+#endif
+
 #endif /*_TOOLBOX_CMD_H_*/
index 31715a04c7cb5cccc3dcabe39557e989b7208a03..a5c040adb85ad91efa6eef41a1c8b97e8b37dd49 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2016,2020 VMware, Inc. All rights reserved.
+ * Copyright (C) 2016,2020-2021 VMware, Inc. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published
@@ -29,9 +29,6 @@
 
 #include "conf.h"
 #include "toolboxCmdInt.h"
-#if defined(_WIN32)
-#include "globalConfig.h"
-#endif
 #include "vmware/tools/i18n.h"
 #include "vmware/tools/utils.h"
 #include "vmware/tools/log.h"
@@ -119,15 +116,7 @@ ConfigGet(const char *section,      // section
                       NULL);
 
    if (confDict) {
-#if defined(_WIN32)
-      if (GlobalConfig_GetEnabled(confDict)) {
-         GKeyFile *globalConf = NULL;
-         if (GlobalConfig_LoadConfig(&globalConf, NULL)) {
-            VMTools_AddConfig(globalConf, confDict);
-            g_key_file_free(globalConf);
-         }
-      }
-#endif
+      TOOLBOXCMD_LOAD_GLOBALCONFIG(confDict)
       value = g_key_file_get_string(confDict, section,
                                     key, NULL);
    } else {
index 4dce693198ec4267cdcfd993f75d8c5b58b3835e..1c23bb7b0377461e10f1e21823ab7c033ab97cd7 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2015-2016,2020 VMware, Inc. All rights reserved.
+ * Copyright (C) 2015-2016,2020-2021 VMware, Inc. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published
@@ -38,9 +38,6 @@
 
 #include "conf.h"
 #include "toolboxCmdInt.h"
-#if defined(_WIN32)
-#include "globalConfig.h"
-#endif
 #include "vmware/tools/i18n.h"
 #include "vmware/tools/utils.h"
 #include "vmware/tools/log.h"
@@ -167,15 +164,7 @@ LoggingGetLevel(char *service)         // service
       confDict = g_key_file_new();
    }
 
-#if defined(_WIN32)
-   if (GlobalConfig_GetEnabled(confDict)) {
-      GKeyFile *globalConf = NULL;
-      if (GlobalConfig_LoadConfig(&globalConf, NULL)) {
-         VMTools_AddConfig(globalConf, confDict);
-         g_key_file_free(globalConf);
-      }
-   }
-#endif
+   TOOLBOXCMD_LOAD_GLOBALCONFIG(confDict)
 
    confName = g_strdup_printf("%s.level", service);
 
index 98755d977ed230179c8015ec0fe3ef08ee779fc3..cc6b8c83b5e5bcd19961f1442d3fbf21c9d5a671 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2008-2016,2020 VMware, Inc. All rights reserved.
+ * Copyright (C) 2008-2016,2020-2021 VMware, Inc. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published
@@ -33,9 +33,6 @@
 #include "guestApp.h"
 #include "system.h"
 #include "toolboxCmdInt.h"
-#if defined(_WIN32)
-#include "globalConfig.h"
-#endif
 #include "vmware/tools/i18n.h"
 #include "vmware/tools/utils.h"
 
@@ -155,15 +152,7 @@ GetConfEntry(const char *progName,  // IN: program name (argv[0])
    }
 
    confDict = LoadConfFile();
-#if defined(_WIN32)
-   if (GlobalConfig_GetEnabled(confDict)) {
-      GKeyFile *globalConf = NULL;
-      if (GlobalConfig_LoadConfig(&globalConf, NULL)) {
-         VMTools_AddConfig(globalConf, confDict);
-         g_key_file_free(globalConf);
-      }
-   }
-#endif
+   TOOLBOXCMD_LOAD_GLOBALCONFIG(confDict)
 
    switch (type) {
    case Current: