From: John Wolfe Date: Mon, 19 Apr 2021 18:08:11 +0000 (-0700) Subject: Changes to common source files not directly applicable to open-vm-tools. X-Git-Tag: stable-11.3.0~47 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=52523347adccc1ec3670488c6c61ed4c998372f3;p=thirdparty%2Fopen-vm-tools.git Changes to common source files not directly applicable to open-vm-tools. --- diff --git a/open-vm-tools/services/vmtoolsd/mainLoop.c b/open-vm-tools/services/vmtoolsd/mainLoop.c index 3a3cf0cdc..23c9afd5e 100644 --- a/open-vm-tools/services/vmtoolsd/mainLoop.c +++ b/open-vm-tools/services/vmtoolsd/mainLoop.c @@ -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); diff --git a/open-vm-tools/services/vmtoolsd/toolsCoreInt.h b/open-vm-tools/services/vmtoolsd/toolsCoreInt.h index fe5125a97..d79bad848 100644 --- a/open-vm-tools/services/vmtoolsd/toolsCoreInt.h +++ b/open-vm-tools/services/vmtoolsd/toolsCoreInt.h @@ -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 @@ -32,6 +32,10 @@ #include #include #include +#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 diff --git a/open-vm-tools/toolbox/toolbox-cmd.c b/open-vm-tools/toolbox/toolbox-cmd.c index f50d013ef..6bde3747d 100644 --- a/open-vm-tools/toolbox/toolbox-cmd.c +++ b/open-vm-tools/toolbox/toolbox-cmd.c @@ -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); diff --git a/open-vm-tools/toolbox/toolboxCmdInt.h b/open-vm-tools/toolbox/toolboxCmdInt.h index 005eb0ae5..d8f6f6be1 100644 --- a/open-vm-tools/toolbox/toolboxCmdInt.h +++ b/open-vm-tools/toolbox/toolboxCmdInt.h @@ -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 #ifdef _WIN32 # include "getoptwin32.h" +# include "globalConfig.h" #else # include # include @@ -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_*/ diff --git a/open-vm-tools/toolbox/toolboxcmd-config.c b/open-vm-tools/toolbox/toolboxcmd-config.c index 31715a04c..a5c040adb 100644 --- a/open-vm-tools/toolbox/toolboxcmd-config.c +++ b/open-vm-tools/toolbox/toolboxcmd-config.c @@ -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 { diff --git a/open-vm-tools/toolbox/toolboxcmd-logging.c b/open-vm-tools/toolbox/toolboxcmd-logging.c index 4dce69319..1c23bb7b0 100644 --- a/open-vm-tools/toolbox/toolboxcmd-logging.c +++ b/open-vm-tools/toolbox/toolboxcmd-logging.c @@ -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); diff --git a/open-vm-tools/toolbox/toolboxcmd-scripts.c b/open-vm-tools/toolbox/toolboxcmd-scripts.c index 98755d977..cc6b8c83b 100644 --- a/open-vm-tools/toolbox/toolboxcmd-scripts.c +++ b/open-vm-tools/toolbox/toolboxcmd-scripts.c @@ -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: