]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Ensuring vmtools utilities are only used in a VMware virtual environment.
authorJohn Wolfe <jwolfe@vmware.com>
Fri, 11 Sep 2020 19:11:05 +0000 (12:11 -0700)
committerJohn Wolfe <jwolfe@vmware.com>
Fri, 11 Sep 2020 19:11:05 +0000 (12:11 -0700)
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.

open-vm-tools/namespacetool/namespacetool.c
open-vm-tools/rpctool/Makefile.am
open-vm-tools/rpctool/rpctool.c
open-vm-tools/services/vmtoolsd/mainPosix.c
open-vm-tools/xferlogs/xferlogs.c

index 25317ea76071811c373d1081e600a046ff3fbbf5..482f02ab35505b512beae5d8c36e90c0a3e7a6ee 100644 (file)
@@ -25,6 +25,7 @@
 #include <stdio.h>
 #include <glib.h>
 #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] "
                                   "[<namespace-name>]");
 
index cb05cf8ae4c6a71c47485517105201cb04f37684..90b567fc831f406ed7e06fcb325cd0aaf1212bf5 100644 (file)
@@ -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
 
index f189c4434aa49ecf5f3cf3524d85622d60a834af..6220a0a835330f96d3dcf094c29862e12c3722a5 100644 (file)
@@ -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;
index f46e9e77ed238a445441d1f0fef9720d33ce9cf7..cd8f2dbee465296f577f0d63ca099d61aa571a4a 100644 (file)
@@ -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);
 
    /*
index 603c6782f49980bf1aab5560dce8dddeddf0d52c..d3c6712c2f1ad1903a969e3b554299efa5490bd1 100644 (file)
@@ -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))) {