]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Remove logic for unsupported versions of macOS.
authorOliver Kurth <okurth@vmware.com>
Fri, 15 Sep 2017 18:23:45 +0000 (11:23 -0700)
committerOliver Kurth <okurth@vmware.com>
Fri, 15 Sep 2017 18:23:45 +0000 (11:23 -0700)
We no longer support macOS 10.4-10.7.  Remove the old logic that supported
these versions.

open-vm-tools/lib/auth/authPosix.c
open-vm-tools/lib/file/fileIOPosix.c
open-vm-tools/lib/include/vm_basic_defs.h
open-vm-tools/lib/misc/hostinfoPosix.c

index 399f78a002b6a39f777f3ffaf16aad93669ea546..f47bca24ee962654525ad484aab02e6b62a65f77 100644 (file)
 #   include "file.h"
 #   include "config.h"
 #   include "localconfig.h"
-#   if defined __APPLE__
-#      include <AvailabilityMacros.h>
-#      if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5
-#         include <pam/pam_appl.h>
-#      else
-#         include <security/pam_appl.h>
-#      endif
-#   else
-#      include <security/pam_appl.h>
-#   endif
+#   include <security/pam_appl.h>
 #   include <dlfcn.h>
 #endif
 
index 282cdd6b13988aa3222ecb1ecc1493611167044d..47e11381e60d846082c0316701facade8a791546 100644 (file)
@@ -53,7 +53,7 @@
 #include "su.h"
 
 #if defined(__APPLE__)
-#include "sysSocket.h" // Don't move this: it fixes a system header.
+#include <sys/socket.h>
 #include <sys/un.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 
 #if defined(__APPLE__)
 #include <sys/sysctl.h>
-
-/*
- * F_NODIRECT was added in Mac OS 10.7.0 "Lion".  We test at runtime for the
- * right version before using it, but we also need to get the definition.
- */
-
 #include <sys/fcntl.h>
-
-#ifndef F_NODIRECT
-#define F_NODIRECT 62
-#endif
-
 #endif
 
 /*
@@ -969,19 +958,14 @@ FileIOCreateRetry(FileIODescriptor *file,   // OUT:
       }
 
       if (!(access & FILEIO_OPEN_SYNC)) {
-         /*
-          * F_NODIRECT was added in Mac OS 10.7.0 "Lion".
-          */
-         if (Hostinfo_OSVersion(0) >= HOSTINFO_OS_VERSION_MACOS_10_7) {
-            error = fcntl(fd, F_NODIRECT, 1);
-            if (error == -1) {
-               ret = FileIOErrno2Result(errno);
-               if (ret == FILEIO_ERROR) {
-                  Log(LGPFX "fcntl error on %s: %s\n", pathName,
-                      Err_Errno2String(errno));
-               }
-               goto error;
+         error = fcntl(fd, F_NODIRECT, 1);
+         if (error == -1) {
+            ret = FileIOErrno2Result(errno);
+            if (ret == FILEIO_ERROR) {
+               Log(LGPFX "fcntl error on %s: %s\n", pathName,
+                   Err_Errno2String(errno));
             }
+            goto error;
          }
       }
    }
index 4e5aabc79014e0f85bfc30e8147ab699d40bd011..faca55747ce7f1ee9fe2a27c9501461523ceda0e 100644 (file)
@@ -536,19 +536,8 @@ typedef int pid_t;
 
 #elif defined(__APPLE__) && defined(KERNEL)
 
-#include "availabilityMacOS.h"
-
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
-// The Mac OS 10.5 kernel SDK defines va_copy in stdarg.h.
+// The macOS kernel SDK defines va_copy in stdarg.h.
 #include <stdarg.h>
-#else
-/*
- * The Mac OS 10.4 kernel SDK needs va_copy. Based on inspection of
- * stdarg.h from the MacOSX10.4u.sdk kernel framework, this should
- * work.
- */
-#define va_copy(dest, src) ((dest) = (src))
-#endif // MAC_OS_X_VERSION_MIN_REQUIRED
 
 #elif defined(__GNUC__) && (__GNUC__ < 3)
 
index ca161e23edf0c71ea308c89b69e0e19708ae6873..d1c36d613534e8699a4b274cb9447475bdedca60 100644 (file)
@@ -59,9 +59,6 @@
 #include <mach/vm_map.h>
 #include <sys/mman.h>
 #include <AvailabilityMacros.h>
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 // Must run on Mac OS versions < 10.7
-#   include <dlfcn.h>
-#endif
 #elif defined(__FreeBSD__)
 #if !defined(RLIMIT_AS)
 #  if defined(RLIMIT_VMEM)
@@ -2554,7 +2551,7 @@ Hostinfo_Execute(const char *path,   // IN:
  *
  * 3) In Mac OS 10.7, Apple cleaned their mess and solved all the above
  *    problems by introducing a new mach_zone_info() Mach call. So this is what
- *    we use now, when available. Was bug 816610.
+ *    we use now. Was bug 816610.
  *
  * 4) In Mac OS 10.8, Apple appears to have modified mach_zone_info() to always
  *    return KERN_INVALID_HOST(!) when the calling process (not the calling
@@ -2562,135 +2559,6 @@ Hostinfo_Execute(const char *path,   // IN:
  */
 
 
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 // Must run on Mac OS versions < 10.7
-/*
- *-----------------------------------------------------------------------------
- *
- * HostinfoGetKernelZoneElemSizeZprint --
- *
- *      Retrieve the size of the elements in a named kernel zone, by invoking
- *      zprint.
- *
- * Results:
- *      On success: the size (in bytes) > 0.
- *      On failure: 0.
- *
- * Side effects:
- *      None
- *
- *-----------------------------------------------------------------------------
- */
-
-static size_t
-HostinfoGetKernelZoneElemSizeZprint(char const *name) // IN: Kernel zone name
-{
-   size_t retval = 0;
-   struct {
-      size_t retval;
-   } volatile *shared;
-   pid_t child;
-   pid_t pid;
-
-   /*
-    * popen(3) incorrectly executes the shell with the identity of the calling
-    * process, ignoring a potential per-thread identity. And starting with
-    * Mac OS 10.6 it is even worse: if there is a per-thread identity,
-    * popen(3) removes it!
-    *
-    * So we run this code in a separate process which runs with the same
-    * identity as the current thread.
-    */
-
-   shared = mmap(NULL, sizeof *shared, PROT_READ | PROT_WRITE,
-                 MAP_ANON | MAP_SHARED, -1, 0);
-
-   if (shared == (void *)-1) {
-      Warning("%s: mmap error %d.\n", __FUNCTION__, errno);
-
-      return retval;
-   }
-
-   // In case the child is terminated before it can set it.
-   shared->retval = retval;
-
-   child = fork();
-   if (child == (pid_t)-1) {
-      Warning("%s: fork error %d.\n", __FUNCTION__, errno);
-      munmap((void *)shared, sizeof *shared);
-
-      return retval;
-   }
-
-   // This executes only in the child process.
-   if (!child) {
-      size_t nameLen;
-      FILE *stream;
-      Bool parsingProperties = FALSE;
-
-      ASSERT(name);
-
-      nameLen = strlen(name);
-      ASSERT(nameLen && *name != '\t');
-
-      stream = popen("/usr/bin/zprint -C", "r");
-      if (!stream) {
-         Warning("%s: popen error %d.\n", __FUNCTION__, errno);
-         exit(EXIT_SUCCESS);
-      }
-
-      for (;;) {
-         char *line;
-         size_t lineLen;
-
-         if (StdIO_ReadNextLine(stream, &line, 0,
-                                &lineLen) != StdIO_Success) {
-            break;
-         }
-
-         if (parsingProperties) {
-            if (   // Not a property line anymore. Property not found.
-                   lineLen < 1 || memcmp(line, "\t", 1)
-                   // Property found.
-                || sscanf(line, " elem_size: %"FMTSZ"u bytes",
-                          &shared->retval) == 1) {
-               free(line);
-               break;
-            }
-         } else if (!(lineLen < nameLen + 6 ||
-                    memcmp(line, name, nameLen) ||
-                    memcmp(line + nameLen, " zone:", 6))) {
-            // Zone found.
-            parsingProperties = TRUE;
-         }
-
-         free(line);
-      }
-
-      pclose(stream);
-      exit(EXIT_SUCCESS);
-   }
-
-   /*
-    * This executes only in the parent process.
-    * Wait for the child to terminate, and return its retval.
-    */
-
-   do {
-      int status;
-
-      pid = waitpid(child, &status, 0);
-   } while ((pid == -1) && (errno == EINTR));
-
-   VERIFY(pid == child);
-
-   retval = shared->retval;
-   munmap((void *)shared, sizeof *shared);
-
-   return retval;
-}
-#endif
-
-
 /*
  *-----------------------------------------------------------------------------
  *
@@ -2711,21 +2579,6 @@ HostinfoGetKernelZoneElemSizeZprint(char const *name) // IN: Kernel zone name
 size_t
 Hostinfo_GetKernelZoneElemSize(char const *name) // IN: Kernel zone name
 {
-#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070 // Compiles against SDK version < 10.7
-   typedef struct {
-      char mzn_name[80];
-   } mach_zone_name_t;
-   typedef struct {
-      uint64_t mzi_count;
-      uint64_t mzi_cur_size;
-      uint64_t mzi_max_size;
-      uint64_t mzi_elem_size;
-      uint64_t mzi_alloc_size;
-      uint64_t mzi_sum_size;
-      uint64_t mzi_exhaustible;
-      uint64_t mzi_collectable;
-   } mach_zone_info_t;
-#endif
    size_t result = 0;
    mach_zone_name_t *namesPtr;
    mach_msg_type_number_t namesSize;
@@ -2734,16 +2587,6 @@ Hostinfo_GetKernelZoneElemSize(char const *name) // IN: Kernel zone name
    kern_return_t kr;
    mach_msg_type_number_t i;
 
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 // Must run on Mac OS versions < 10.7
-   kern_return_t (*mach_zone_info)(host_t host,
-      mach_zone_name_t **names, mach_msg_type_number_t *namesCnt,
-      mach_zone_info_t **info, mach_msg_type_number_t *infoCnt) =
-         dlsym(RTLD_DEFAULT, "mach_zone_info");
-   if (!mach_zone_info) {
-      return HostinfoGetKernelZoneElemSizeZprint(name);
-   }
-#endif
-
    ASSERT(name);
 
    kr = mach_zone_info(mach_host_self(), &namesPtr, &namesSize, &infosPtr,