From: John Wolfe Date: Fri, 11 Sep 2020 19:11:05 +0000 (-0700) Subject: Ensuring vmtools utilities are only used in a VMware virtual environment. X-Git-Tag: stable-11.2.0~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1f66f283c20f7f5cd154ca34c33e3e145659916a;p=thirdparty%2Fopen-vm-tools.git Ensuring vmtools utilities are only used in a VMware virtual environment. Several utilities do not check that their running environment is in a VMware hypervisor. Add checks and generate error messages if the running environment is a physical machine. Some makefiles were altered o resolve dependency issues. --- diff --git a/open-vm-tools/namespacetool/namespacetool.c b/open-vm-tools/namespacetool/namespacetool.c index 25317ea76..482f02ab3 100644 --- a/open-vm-tools/namespacetool/namespacetool.c +++ b/open-vm-tools/namespacetool/namespacetool.c @@ -25,6 +25,7 @@ #include #include #include "vmware.h" +#include "vmcheck.h" #include "str.h" #include "util.h" #include "dynbuf.h" @@ -639,6 +640,16 @@ main(int argc, char *argv[]) gAppName = g_path_get_basename(argv[0]); g_set_prgname(gAppName); + /* + * Checking if environment is VM + */ + if (!VmCheck_IsVirtualWorld()) { + g_printerr("Error: %s must be run inside a virtual machine" + " on a VMware hypervisor product.\n", gAppName); + g_free(gAppName); + return success; + } + optCtx = g_option_context_new("[get-value | set-key | delete-key] " "[]"); diff --git a/open-vm-tools/rpctool/Makefile.am b/open-vm-tools/rpctool/Makefile.am index cb05cf8ae..90b567fc8 100644 --- a/open-vm-tools/rpctool/Makefile.am +++ b/open-vm-tools/rpctool/Makefile.am @@ -1,5 +1,5 @@ ################################################################################ -### Copyright (C) 2009-2016 VMware, Inc. All rights reserved. +### Copyright (C) 2009-2016,2020 VMware, Inc. All rights reserved. ### ### This program is free software; you can redistribute it and/or modify ### it under the terms of version 2 of the GNU General Public License as @@ -25,4 +25,8 @@ vmware_rpctool_LDADD += ../lib/rpcOut/libRpcOut.la vmware_rpctool_LDADD += ../lib/message/libMessage.la vmware_rpctool_LDADD += ../lib/backdoor/libBackdoor.la vmware_rpctool_LDADD += ../lib/string/libString.la +vmware_rpctool_LDADD += ../lib/vmCheck/libVmCheck.la +vmware_rpctool_LDADD += ../lib/vmSignal/libVmSignal.la +vmware_rpctool_LDADD += ../lib/misc/libMisc.la +vmware_rpctool_LDADD += ../lib/stubs/libStubs.la diff --git a/open-vm-tools/rpctool/rpctool.c b/open-vm-tools/rpctool/rpctool.c index f189c4434..6220a0a83 100644 --- a/open-vm-tools/rpctool/rpctool.c +++ b/open-vm-tools/rpctool/rpctool.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2002-2019 VMware, Inc. All rights reserved. + * Copyright (C) 2002-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 @@ -33,6 +33,7 @@ #include "vmware.h" #include "rpcout.h" +#include "vmcheck.h" #include "str.h" #include "backdoor_def.h" #ifdef _WIN32 @@ -147,6 +148,15 @@ main(int argc, char *argv[]) WinUtil_EnableSafePathSearching(TRUE); #endif + /* + * Check if environment is VM + */ + if (!VmCheck_IsVirtualWorld()) { + fprintf(stderr, "Error: %s must be run inside a virtual machine" + " on a VMware hypervisor product.\n", argv[0]); + return -1; + } + if (argc <= 1) { PrintUsage(); return 1; diff --git a/open-vm-tools/services/vmtoolsd/mainPosix.c b/open-vm-tools/services/vmtoolsd/mainPosix.c index f46e9e77e..cd8f2dbee 100644 --- a/open-vm-tools/services/vmtoolsd/mainPosix.c +++ b/open-vm-tools/services/vmtoolsd/mainPosix.c @@ -35,6 +35,7 @@ #include "system.h" #include "unicode.h" #include "util.h" +#include "vmcheck.h" #include "vmware/tools/log.h" #include "vmware/tools/i18n.h" #include "vmware/tools/utils.h" @@ -173,6 +174,15 @@ main(int argc, char **argvCopy; GSource *src; + /* + * Check that environment is a VM + */ + if (!VmCheck_IsVirtualWorld()) { + g_printerr("Error: %s must be run inside a virtual machine" + " on a VMware hypervisor product.\n", argv[0]); + goto exit; + } + Unicode_Init(argc, &argv, NULL); /* diff --git a/open-vm-tools/xferlogs/xferlogs.c b/open-vm-tools/xferlogs/xferlogs.c index 603c6782f..d3c6712c2 100644 --- a/open-vm-tools/xferlogs/xferlogs.c +++ b/open-vm-tools/xferlogs/xferlogs.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2006-2019 VMware, Inc. All rights reserved. + * Copyright (C) 2006-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 @@ -46,6 +46,7 @@ #include "vmware.h" #include "vmsupport.h" +#include "vmcheck.h" #include "debug.h" #include "rpcvmx.h" #include "rpcout.h" @@ -323,6 +324,15 @@ main(int argc, WinUtil_EnableSafePathSearching(TRUE); #endif + /* + * Check if environment is a VM + */ + if (!VmCheck_IsVirtualWorld()) { + fprintf(stderr, "Error: %s must be run inside a virtual machine" + " on a VMware hypervisor product.\n", argv[0]); + return -1; + } + if (argc == 2 && (!strncmp(argv[1], "-h", 2) || !strncmp(argv[1], "--help", 6))) {