From: Oliver Kurth Date: Wed, 10 Jun 2020 19:05:44 +0000 (-0700) Subject: Move appInfo and serviceDiscovery plugin related header files. X-Git-Tag: stable-11.2.0~174 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0c7eb59720429fb8fa5872e432104731520e8799;p=thirdparty%2Fopen-vm-tools.git Move appInfo and serviceDiscovery plugin related header files. As part of an upcoming project, some appinfo and serviceDiscovery header files are needed at a different location in the common source tree. * Moved the appInfo.h and serviceDiscovery.h to a different location. * Made necessary code and OVT changes to refer to new file paths. * Did some cleanup related to the MACRO names for the keys and scripts. --- diff --git a/open-vm-tools/lib/include/appInfo.h b/open-vm-tools/lib/include/vmware/guestrpc/appInfo.h similarity index 88% rename from open-vm-tools/lib/include/appInfo.h rename to open-vm-tools/lib/include/vmware/guestrpc/appInfo.h index f6a27ed6f..bef7fc685 100644 --- a/open-vm-tools/lib/include/appInfo.h +++ b/open-vm-tools/lib/include/vmware/guestrpc/appInfo.h @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2019 VMware, Inc. All rights reserved. + * Copyright (C) 2020 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 @@ -22,7 +22,8 @@ /** * @file appInfo.h * - * Declares few constants for the appInfo plugin. + * Common declarations that aid in sending application information + * from 'appInfo' plugin in 'VMware Tools' to the host. */ /** diff --git a/open-vm-tools/lib/include/vmware/guestrpc/serviceDiscovery.h b/open-vm-tools/lib/include/vmware/guestrpc/serviceDiscovery.h new file mode 100644 index 000000000..8a6d869af --- /dev/null +++ b/open-vm-tools/lib/include/vmware/guestrpc/serviceDiscovery.h @@ -0,0 +1,58 @@ +/********************************************************* + * Copyright (C) 2020 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 + * by the Free Software Foundation version 2.1 and no later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + *********************************************************/ + +#ifndef _SERVICEDISCOVERY_H_ +#define _SERVICEDISCOVERY_H_ + +/** + * @file serviceDiscovery.h + * + * Common declarations that aid in sending services information + * from 'serviceDiscovery' plugin in 'VMware Tools' to the host. + */ + + +/* + * Namespace DB used for service discovery + */ +#define SERVICE_DISCOVERY_NAMESPACE_DB_NAME "com.vmware.vrops.sdmp" + +/* + * ready - used to identify if data is succesfully written to Namespace DB + * signal - signal send by sdmp client for plugin to start data collection + */ +#define SERVICE_DISCOVERY_KEY_READY "ready" +#define SERVICE_DISCOVERY_KEY_SIGNAL "signal" + +/* + * keys for types of service data collected by plugin. + */ +#define SERVICE_DISCOVERY_KEY_PROCESSES "listening-process-info" +#define SERVICE_DISCOVERY_KEY_CONNECTIONS "connection-info" +#define SERVICE_DISCOVERY_KEY_PERFORMANCE_METRICS \ + "listening-process-perf-metrics" +#define SERVICE_DISCOVERY_KEY_VERSIONS "versions" + +/* + * keys for types of service data collected by plugin from Windows guest + */ +#define SERVICE_DISCOVERY_WIN_KEY_RELATIONSHIP "pid-to-ppid" +#define SERVICE_DISCOVERY_WIN_KEY_NET "net" +#define SERVICE_DISCOVERY_WIN_KEY_IIS_PORTS "iis-ports-info" + +#endif /* _SERVICEDISCOVERY_H_ */ diff --git a/open-vm-tools/services/plugins/appInfo/appInfo.c b/open-vm-tools/services/plugins/appInfo/appInfo.c index 4e64799b6..3e4a259b9 100644 --- a/open-vm-tools/services/plugins/appInfo/appInfo.c +++ b/open-vm-tools/services/plugins/appInfo/appInfo.c @@ -28,7 +28,6 @@ #include #include -#include "appInfo.h" #include "appInfoInt.h" #include "vmware.h" #include "conf.h" @@ -38,6 +37,7 @@ #include "util.h" #include "vm_atomic.h" #include "vmcheck.h" +#include "vmware/guestrpc/appInfo.h" #include "vmware/tools/log.h" #include "vmware/tools/threadPool.h" #include "vmware/tools/utils.h" diff --git a/open-vm-tools/services/plugins/serviceDiscovery/Makefile.am b/open-vm-tools/services/plugins/serviceDiscovery/Makefile.am index f341f9b54..f16964c24 100644 --- a/open-vm-tools/services/plugins/serviceDiscovery/Makefile.am +++ b/open-vm-tools/services/plugins/serviceDiscovery/Makefile.am @@ -34,7 +34,7 @@ libserviceDiscovery_la_LIBADD += @GOBJECT_LIBS@ libserviceDiscovery_la_SOURCES = libserviceDiscovery_la_SOURCES += serviceDiscovery.c libserviceDiscovery_la_SOURCES += serviceDiscoveryPosix.c -libserviceDiscovery_la_SOURCES += serviceDiscovery.h +libserviceDiscovery_la_SOURCES += serviceDiscoveryInt.h install-data-local: $(INSTALL) -d $(DESTDIR)/$(libdir)/open-vm-tools/serviceDiscovery/scripts/ diff --git a/open-vm-tools/services/plugins/serviceDiscovery/serviceDiscovery.c b/open-vm-tools/services/plugins/serviceDiscovery/serviceDiscovery.c index f57f02446..622f5c3f8 100644 --- a/open-vm-tools/services/plugins/serviceDiscovery/serviceDiscovery.c +++ b/open-vm-tools/services/plugins/serviceDiscovery/serviceDiscovery.c @@ -25,7 +25,7 @@ #include -#include "serviceDiscovery.h" +#include "serviceDiscoveryInt.h" #include "vmware.h" #include "conf.h" #include "dynbuf.h" @@ -34,6 +34,7 @@ #include "util.h" #include "vm_atomic.h" #include "vmcheck.h" +#include "vmware/guestrpc/serviceDiscovery.h" #include "vmware/tools/log.h" #include "vmware/tools/threadPool.h" #include "vmware/tools/utils.h" @@ -50,61 +51,42 @@ VM_EMBED_VERSION(VMTOOLSD_VERSION_STRING); #define NSDB_PRIV_GET_VALUES_CMD "namespace-priv-get-values" #define NSDB_PRIV_SET_KEYS_CMD "namespace-priv-set-keys" -/* - * Namespace DB used for service discovery - */ -#define SERVICE_DISCOVERY_NAMESPACE_DB_NAME "com.vmware.vrops.sdmp" - -/* - * ready - used to identify if data is succesfully written to Namespace DB - * signal - signal send by sdmp client for plugin to start data collection - */ -#define SERVICE_DISCOVERY_KEY_NAME_READY "ready" -#define SERVICE_DISCOVERY_KEY_NAME_SIGNAL "signal" #if defined (_WIN32) -/* - * keys for types of service data collected by plugin from Windows guest - */ -#define WIN_KEY_NAME_PROCESSES "listening-process-info" -#define WIN_KEY_NAME_CONNECTIONS "connection-info" -#define WIN_KEY_NAME_PERFORMANCE_METRICS "listening-process-perf-metrics" -#define WIN_KEY_NAME_VERSIONS "versions" -#define WIN_KEY_NAME_RELATIONSHIP "pid-to-ppid" -#define WIN_KEY_NAME_NET "net" -#define WIN_KEY_NAME_IIS_PORTS "iis-ports-info" +#define SCRIPT_EXTN ".bat" /* - * scripts used by plugin to collect from Windows guest + * Scripts used by plugin in Windows guests to capture information about + * running services. */ -#define WIN_SCRIPT_NAME_PROCESSES "get-listening-process-info.bat" -#define WIN_SCRIPT_NAME_CONNECTIONS "get-connection-info.bat" -#define WIN_SCRIPT_NAME_PERFORMANCE_METRICS "get-performance-metrics.bat" -#define WIN_SCRIPT_NAME_VERSIONS "get-versions.bat" -#define WIN_SCRIPT_NAME_RELATIONSHIP "get-parent-child-rels.bat" -#define WIN_SCRIPT_NAME_NET "net-share.bat" -#define WIN_SCRIPT_NAME_IIS_PORTS "get-iis-ports-info.bat" +#define SERVICE_DISCOVERY_SCRIPT_PERFORMANCE_METRICS \ + "get-performance-metrics" SCRIPT_EXTN +#define SERVICE_DISCOVERY_WIN_SCRIPT_RELATIONSHIP "get-parent-child-rels" \ + SCRIPT_EXTN +#define SERVICE_DISCOVERY_WIN_SCRIPT_NET "net-share" SCRIPT_EXTN +#define SERVICE_DISCOVERY_WIN_SCRIPT_IIS_PORTS "get-iis-ports-info" SCRIPT_EXTN #else +#define SCRIPT_EXTN ".sh" + /* - * keys for types of service data collected by plugin from Linux guest + * Scripts used by plugin in Linux guests to capture information about + * running services. */ -#define LIN_KEY_NAME_PROCESSES "listening-process-info" -#define LIN_KEY_NAME_CONNECTIONS "connection-info" -#define LIN_KEY_NAME_PERFORMANCE_METRICS "listening-process-perf-metrics" -#define LIN_KEY_NAME_VERSIONS "versions" +#define SERVICE_DISCOVERY_SCRIPT_PERFORMANCE_METRICS \ + "get-listening-process-perf-metrics" SCRIPT_EXTN +#endif /* - * scripts used by plugin to collect from Linux guest + * Scripts used by plugin in both Windows and Linux guests to capture + * information about running services. */ -#define LIN_SCRIPT_NAME_PROCESSES "get-listening-process-info.sh" -#define LIN_SCRIPT_NAME_CONNECTIONS "get-connection-info.sh" -#define LIN_SCRIPT_NAME_PERFORMANCE_METRICS "get-listening-process-perf-metrics.sh" -#define LIN_SCRIPT_NAME_VERSIONS "get-versions.sh" - -#endif +#define SERVICE_DISCOVERY_SCRIPT_PROCESSES "get-listening-process-info" \ + SCRIPT_EXTN +#define SERVICE_DISCOVERY_SCRIPT_CONNECTIONS "get-connection-info" SCRIPT_EXTN +#define SERVICE_DISCOVERY_SCRIPT_VERSIONS "get-versions" SCRIPT_EXTN /* * Default value for CONFNAME_SERVICE_DISCOVERY_DISABLED setting in @@ -139,24 +121,21 @@ typedef struct { gchar *val; } KeyNameValue; -#if defined(_WIN32) static KeyNameValue gKeyScripts[] = { - { WIN_KEY_NAME_PROCESSES, WIN_SCRIPT_NAME_PROCESSES }, - { WIN_KEY_NAME_CONNECTIONS, WIN_SCRIPT_NAME_CONNECTIONS }, - { WIN_KEY_NAME_PERFORMANCE_METRICS, WIN_SCRIPT_NAME_PERFORMANCE_METRICS }, - { WIN_KEY_NAME_VERSIONS, WIN_SCRIPT_NAME_VERSIONS }, - { WIN_KEY_NAME_RELATIONSHIP, WIN_SCRIPT_NAME_RELATIONSHIP }, - { WIN_KEY_NAME_IIS_PORTS, WIN_SCRIPT_NAME_IIS_PORTS }, - { WIN_KEY_NAME_NET, WIN_SCRIPT_NAME_NET }, -}; -#else -static KeyNameValue gKeyScripts[] = { - { LIN_KEY_NAME_PROCESSES, LIN_SCRIPT_NAME_PROCESSES }, - { LIN_KEY_NAME_CONNECTIONS, LIN_SCRIPT_NAME_CONNECTIONS }, - { LIN_KEY_NAME_PERFORMANCE_METRICS, LIN_SCRIPT_NAME_PERFORMANCE_METRICS }, - { LIN_KEY_NAME_VERSIONS, LIN_SCRIPT_NAME_VERSIONS }, -}; + { SERVICE_DISCOVERY_KEY_PROCESSES, SERVICE_DISCOVERY_SCRIPT_PROCESSES }, + { SERVICE_DISCOVERY_KEY_CONNECTIONS, + SERVICE_DISCOVERY_SCRIPT_CONNECTIONS }, + { SERVICE_DISCOVERY_KEY_PERFORMANCE_METRICS, + SERVICE_DISCOVERY_SCRIPT_PERFORMANCE_METRICS }, + { SERVICE_DISCOVERY_KEY_VERSIONS, SERVICE_DISCOVERY_SCRIPT_VERSIONS }, +#if defined(_WIN32) + { SERVICE_DISCOVERY_WIN_KEY_RELATIONSHIP, + SERVICE_DISCOVERY_WIN_SCRIPT_RELATIONSHIP }, + { SERVICE_DISCOVERY_WIN_KEY_IIS_PORTS, + SERVICE_DISCOVERY_WIN_SCRIPT_IIS_PORTS }, + { SERVICE_DISCOVERY_WIN_KEY_NET, SERVICE_DISCOVERY_WIN_SCRIPT_NET }, #endif +}; static GSource *gServiceDiscoveryTimeoutSource = NULL; static gint64 gLastWriteTime = 0; @@ -609,11 +588,11 @@ ServiceDiscoveryTask(ToolsAppCtx *ctx, /* * Reset "ready" flag to stop readers until all data is written */ - status = WriteData(ctx, SERVICE_DISCOVERY_KEY_NAME_READY, "FALSE", 5); + status = WriteData(ctx, SERVICE_DISCOVERY_KEY_READY, "FALSE", 5); if (!status) { gLastWriteTime = previousWriteTime; g_warning("%s: Failed to reset %s flag", __FUNCTION__, - SERVICE_DISCOVERY_KEY_NAME_READY); + SERVICE_DISCOVERY_KEY_READY); goto out; } @@ -633,7 +612,7 @@ ServiceDiscoveryTask(ToolsAppCtx *ctx, /* * Update ready flag */ - status = WriteData(ctx, SERVICE_DISCOVERY_KEY_NAME_READY, "TRUE", 4); + status = WriteData(ctx, SERVICE_DISCOVERY_KEY_READY, "TRUE", 4); if (!status) { g_warning("%s: Failed to update ready flag", __FUNCTION__); } @@ -674,7 +653,7 @@ checkForWrite(ToolsAppCtx *ctx) /* * Read signal from Namespace DB */ - if (!ReadData(ctx, SERVICE_DISCOVERY_KEY_NAME_SIGNAL, &signal, &signalLen)) { + if (!ReadData(ctx, SERVICE_DISCOVERY_KEY_SIGNAL, &signal, &signalLen)) { g_debug("%s: Failed to read necessary information from Namespace DB\n", __FUNCTION__); } else { diff --git a/open-vm-tools/services/plugins/serviceDiscovery/serviceDiscovery.h b/open-vm-tools/services/plugins/serviceDiscovery/serviceDiscoveryInt.h similarity index 91% rename from open-vm-tools/services/plugins/serviceDiscovery/serviceDiscovery.h rename to open-vm-tools/services/plugins/serviceDiscovery/serviceDiscoveryInt.h index 445c20a74..71267cd56 100644 --- a/open-vm-tools/services/plugins/serviceDiscovery/serviceDiscovery.h +++ b/open-vm-tools/services/plugins/serviceDiscovery/serviceDiscoveryInt.h @@ -16,11 +16,11 @@ * *********************************************************/ -#ifndef _SERVICEDISCOVERY_H_ -#define _SERVICEDISCOVERY_H_ +#ifndef _SERVICEDISCOVERYINT_H_ +#define _SERVICEDISCOVERYINT_H_ /** - * @file serviceDiscovery.h + * @file serviceDiscoveryInt.h * * Declares few constants for the serviceDiscovery plugin. */ @@ -45,4 +45,4 @@ Bool WriteData(ToolsAppCtx *ctx, const char *data, const size_t len); -#endif /* _SERVICEDISCOVERY_H_ */ \ No newline at end of file +#endif /* _SERVICEDISCOVERYINT_H_ */ diff --git a/open-vm-tools/services/plugins/serviceDiscovery/serviceDiscoveryPosix.c b/open-vm-tools/services/plugins/serviceDiscovery/serviceDiscoveryPosix.c index 2b1b9d371..c3c2b83bd 100644 --- a/open-vm-tools/services/plugins/serviceDiscovery/serviceDiscoveryPosix.c +++ b/open-vm-tools/services/plugins/serviceDiscovery/serviceDiscoveryPosix.c @@ -27,7 +27,7 @@ # error This file should not be compiled. #endif -#include "serviceDiscovery.h" +#include "serviceDiscoveryInt.h" #include "dynbuf.h" #include