From: VMware, Inc <> Date: Thu, 24 Feb 2011 22:01:31 +0000 (-0800) Subject: Get mac version from system_profiler. X-Git-Tag: 2011.02.23-368700~37 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f7bd0935998908b427d4ab45f648d940e28274d2;p=thirdparty%2Fopen-vm-tools.git Get mac version from system_profiler. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/lib/misc/hostinfoPosix.c b/open-vm-tools/lib/misc/hostinfoPosix.c index b6336f13a..c9b1c1780 100644 --- a/open-vm-tools/lib/misc/hostinfoPosix.c +++ b/open-vm-tools/lib/misc/hostinfoPosix.c @@ -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) {