]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Get mac version from system_profiler.
authorVMware, Inc <>
Thu, 24 Feb 2011 22:01:31 +0000 (14:01 -0800)
committerMarcelo Vanzin <mvanzin@vmware.com>
Thu, 24 Feb 2011 22:01:31 +0000 (14:01 -0800)
Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/lib/misc/hostinfoPosix.c

index b6336f13a082c1ddc4b6120f74b69791e6482aa0..c9b1c17801cec25c6236f58280a2f2c84659b9f4 100644 (file)
@@ -984,6 +984,28 @@ HostinfoOSData(void)
 
       Str_Snprintf(osName, sizeof osName, "%s%s", STR_OS_SOLARIS,
                    solarisRelease);
+#if defined(__APPLE__)
+   } else {
+      /*
+       * XXX: using the CF API to read the server / system plist is kind of a
+       * PITA. Get the output of system_profiler instead; downside is that any
+       * changes to the format of the output of system_profiler may break this.
+       */
+      const char *cmd = "/usr/sbin/system_profiler | "
+                        "/usr/bin/grep 'System Version:' | "
+                        "/usr/bin/cut -d : -f 2";
+      char *sysname = HostinfoGetCmdOutput(cmd);
+
+      if (sysname != NULL) {
+         char *trimmed = Unicode_Trim(sysname);
+         ASSERT_MEM_ALLOC(trimmed);
+         Str_Snprintf(osNameFull, sizeof osNameFull, "%s", trimmed);
+         free(trimmed);
+         free(sysname);
+      } else {
+         Log("%s: Failed to get output of system_profiler.\n", __FUNCTION__);
+      }
+#endif
    }
 
    if (Hostinfo_GetSystemBitness() == 64) {