[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#612498: open-vm-tools: Preliminary support for kfreebsd



Source: open-vm-tools
Version: 2:8.8.0+2011.10.26-514583-1
Followup-For: Bug #612498

Hello,


I managed to add preliminary support for kfreebsd to open-vm-tools.

Placing attached patch '02-kfreebsd.patch' in debian/patches, adding the filename to
debian/patches/series and adding 'libkvm-dev' to Build-Depends makes open-vm-tools build .deb files.

What works:
- vmtoolsd runs
- virtual center recognizes the vm's hostname

What does not work:
- virtual center does not recognize the vm's ip address
  ('Failed to get nic info.' in /var/log/messages)
- probably everything else



Hopefully this patch can be used as a starter for full open-vm-tools support on kfreebsd.



Robin


-- System Information:
Debian Release: wheezy/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: kfreebsd-amd64 (x86_64)

Kernel: kFreeBSD 8.2-1-amd64
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/configure.ac open-vm-tools-8.8.0+2011.10.26-514583/configure.ac
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/configure.ac	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/configure.ac	2011-11-18 08:38:14.000000000 +0000
@@ -130,6 +130,9 @@
    [freebsd*])
       os="freebsd"
       ;;
+   [kfreebsd*-gnu])
+      os="kfreebsd-gnu"
+      ;;
    [solaris*])
       os="solaris"
       ;;
@@ -970,6 +973,23 @@
    fi
 fi
 
+if test "$os" = "kfreebsd-gnu"; then
+   LIBVMTOOLS_LIBADD="$LIBVMTOOLS_LIBADD -lkvm"
+   MODULES_DIR="$LINUXDIR/"
+
+   MODULES="$MODULES vmmemctl"
+   MODULES="$MODULES vmxnet"
+   MODULES="$MODULES vmblock vmhgfs"
+   buildHgfsmounter=yes
+
+   if test "$with_kernel_modules" = "yes"; then
+      echo "****************************************************************"
+      echo "   You are building FreeBSD kernel modules. Make sure you use   "
+      echo "   'make' to build open-vm-tools, and not GNU make ('gmake').   "
+      echo "****************************************************************"
+   fi
+fi
+
 if test "$os" = "solaris"; then
    LIB_IMPERSONATE_CPPFLAGS="$LIB_IMPERSONATE_CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
    LIB_USER_CPPFLAGS="$LIB_USER_CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
@@ -1018,6 +1038,7 @@
 AM_CONDITIONAL(SOLARIS, test "$os" = "solaris")
 AM_CONDITIONAL(FREEBSD, test "$os" = "freebsd")
 AM_CONDITIONAL(FREEBSD_CUSTOM_SYSDIR, test "$os" = "freebsd" -a -n "$SYSDIR")
+AM_CONDITIONAL(KFREEBSD, test "$os" = "kfreebsd-gnu")
 AM_CONDITIONAL(THIRTY_TWO_BIT_USERSPACE, test "$userSpaceBitness" = "32")
 AM_CONDITIONAL(HAVE_X11, test "$have_x" = "yes")
 AM_CONDITIONAL(HAVE_ICU, test "$with_icu" = "yes")
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/hgfsmounter/hgfsmounter.c open-vm-tools-8.8.0+2011.10.26-514583/hgfsmounter/hgfsmounter.c
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/hgfsmounter/hgfsmounter.c	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/hgfsmounter/hgfsmounter.c	2011-11-18 08:38:10.000000000 +0000
@@ -36,7 +36,7 @@
 #   include <mntent.h>
 #endif
 
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__)
 #   include <sys/uio.h>
 #   include <sys/param.h>
 
@@ -64,7 +64,7 @@
 #   define MS_NOCLUSTERW MNT_NOCLUSTERW
 #   define MS_REMOUNT MNT_RELOAD
 
-#  if defined(__FreeBSD__)
+#  if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #     define MS_NOATIME MNT_NOATIME
 #  elif defined(__APPLE__)
 /*
@@ -101,7 +101,7 @@
 #include "hgfsmounter_version.h"
 
 /* XXX embed_version.h does not currently support Mach-O binaries (OS X). */
-#if defined(linux) || defined(__FreeBSD__)
+#if defined(linux) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #  include "embed_version.h"
    VM_EMBED_VERSION(HGFSMOUNTER_VERSION_STRING);
 #endif
@@ -1114,7 +1114,7 @@
    /* Go! */
 #if defined(linux)
    mntRes = mount(shareName, mountPoint, HGFS_NAME, flags, &mountInfo);
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
    {
       struct iovec iov[] = {{"fstype", sizeof("fstype")},
                             {HGFS_NAME, sizeof(HGFS_NAME)},
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/file/fileIO.c open-vm-tools-8.8.0+2011.10.26-514583/lib/file/fileIO.c
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/file/fileIO.c	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/lib/file/fileIO.c	2011-11-18 08:38:03.000000000 +0000
@@ -270,7 +270,7 @@
 
    ASSERT(file);
 
-#if !defined(__FreeBSD__) && !defined(sun)
+#if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && !defined(sun)
    if (access & FILEIO_OPEN_LOCKED) {
       int err = 0;
 
@@ -340,7 +340,7 @@
 
    ASSERT(file);
 
-#if !defined(__FreeBSD__) && !defined(sun)
+#if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && !defined(sun)
    if (file->lockToken != NULL) {
       int err = 0;
 
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/file/fileLockPosix.c open-vm-tools-8.8.0+2011.10.26-514583/lib/file/fileLockPosix.c
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/file/fileLockPosix.c	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/lib/file/fileLockPosix.c	2011-11-18 08:38:03.000000000 +0000
@@ -77,7 +77,7 @@
  * into the log file.
  */
 
-#if !defined(__FreeBSD__) && !defined(sun)
+#if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && !defined(sun)
 /*
  *----------------------------------------------------------------------
  *
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/file/filePosix.c open-vm-tools-8.8.0+2011.10.26-514583/lib/file/filePosix.c
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/file/filePosix.c	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/lib/file/filePosix.c	2011-11-18 08:38:03.000000000 +0000
@@ -24,7 +24,7 @@
 
 #include <sys/types.h> /* Needed before sys/vfs.h with glibc 2.0 --hpreg */
 
-#if defined(__FreeBSD__)
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 # include <sys/param.h>
 # include <sys/mount.h>
 #else
@@ -72,7 +72,7 @@
 
 #include "unicodeOperations.h"
 
-#if !defined(__FreeBSD__) && !defined(sun)
+#if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && !defined(sun)
 #if !defined(__APPLE__)
 static char *FilePosixLookupMountPoint(char const *canPath, Bool *bind);
 #endif
@@ -381,7 +381,7 @@
  *----------------------------------------------------------------------
  */
 
-#if !defined(__FreeBSD__) && !defined(sun)
+#if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && !defined(sun)
 Bool
 File_IsRemote(ConstUnicode pathName)  // IN: Path name
 {
@@ -889,7 +889,7 @@
 }
 
 
-#if !defined(__FreeBSD__) && !defined(sun)
+#if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && !defined(sun)
 /*
  *-----------------------------------------------------------------------------
  *
@@ -1889,7 +1889,7 @@
       return FALSE;
    }
 
-#if defined(__APPLE__) || defined(__FreeBSD__) 
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
    if ((stfs1.f_flags & MNT_LOCAL) && (stfs2.f_flags & MNT_LOCAL)) {
       return TRUE;
    }
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/hgfsHelper/hgfsHelperPosix.c open-vm-tools-8.8.0+2011.10.26-514583/lib/hgfsHelper/hgfsHelperPosix.c
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/hgfsHelper/hgfsHelperPosix.c	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/lib/hgfsHelper/hgfsHelperPosix.c	2011-11-18 08:38:03.000000000 +0000
@@ -24,7 +24,7 @@
  *
  */
 
-#if !defined __linux__ && !defined __FreeBSD__ && !defined sun && !defined __APPLE__
+#if !defined __linux__ && !defined __FreeBSD__ && !defined __FreeBSD_kernel__ && !defined sun && !defined __APPLE__
 #   error This file should not be compiled
 #endif
 
@@ -65,7 +65,7 @@
 Bool
 HgfsHlpr_QuerySharesDefaultRootPath(Unicode *hgfsRootPath)
 {
-#if defined __FreeBSD__
+#if defined __FreeBSD__ || defined __FreeBSD_kernel__
    return FALSE;
 #else
    ASSERT(hgfsRootPath != NULL);
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/hgfsServer/hgfsServerLinux.c open-vm-tools-8.8.0+2011.10.26-514583/lib/hgfsServer/hgfsServerLinux.c
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/hgfsServer/hgfsServerLinux.c	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/lib/hgfsServer/hgfsServerLinux.c	2011-11-18 08:38:03.000000000 +0000
@@ -44,7 +44,7 @@
 #include <sys/types.h>
 #include <dirent.h>
 
-#if defined(__FreeBSD__)
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #   include <sys/param.h>
 #else
 #   include <wchar.h>
@@ -161,7 +161,7 @@
 #   endif
 }
 #      define getdents getdents_linux
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #define getdents(fd, dirp, count)                                             \
 ({                                                                            \
    long basep;                                                                \
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/include/iovector.h open-vm-tools-8.8.0+2011.10.26-514583/lib/include/iovector.h
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/include/iovector.h	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/lib/include/iovector.h	2011-11-18 08:38:03.000000000 +0000
@@ -32,7 +32,7 @@
 /*
  * Ugly definition of struct iovec.
  */
-#if defined(__linux__) || defined(sun) || defined(__APPLE__) || defined(__FreeBSD__)
+#if defined(__linux__) || defined(sun) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #include <sys/uio.h>    // for struct iovec
 #else
 
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/include/mntinfo.h open-vm-tools-8.8.0+2011.10.26-514583/lib/include/mntinfo.h
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/include/mntinfo.h	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/lib/include/mntinfo.h	2011-11-18 08:38:03.000000000 +0000
@@ -34,7 +34,7 @@
 # include <limits.h>
 #elif defined(__linux__)
 # include <mntent.h>
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 # include <sys/mount.h>
 #endif
 #include "posix.h"
@@ -106,7 +106,7 @@
 # define MNTINFO_FSTYPE(mnt)            mnt->mnt_type
 # define MNTINFO_MNTPT(mnt)             mnt->mnt_dir
 # define MNTINFO_MNT_IS_RO(mnt)         (hasmntopt((mnt), "rw") == NULL)
-#elif defined(__FreeBSD__) || defined(__APPLE__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__)
 struct mntHandle {
    struct statfs *mountPoints;  // array of mountpoints per getmntinfo(3)
    int numMountPoints;          // number of elements in mntArray
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/include/sigPosixRegs.h open-vm-tools-8.8.0+2011.10.26-514583/lib/include/sigPosixRegs.h
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/include/sigPosixRegs.h	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/lib/include/sigPosixRegs.h	2011-11-18 08:38:03.000000000 +0000
@@ -145,7 +145,7 @@
 #define SC_ESP(uc) ((unsigned long) (uc)->uc_mcontext->ss.esp)
 #define SC_EIP(uc) ((unsigned long) (uc)->uc_mcontext->ss.eip)
 #endif
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #ifdef __x86_64__
 #define SC_EAX(uc) ((unsigned long) (uc)->uc_mcontext.mc_rax)
 #define SC_EBX(uc) ((unsigned long) (uc)->uc_mcontext.mc_rbx)
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/include/su.h open-vm-tools-8.8.0+2011.10.26-514583/lib/include/su.h
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/include/su.h	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/lib/include/su.h	2011-11-18 08:38:03.000000000 +0000
@@ -50,7 +50,7 @@
                   char const *localizedDescription,
                   Bool showDialogIfNeeded);
 
-#elif (defined(__linux__) || defined(sun) || defined(__FreeBSD__))
+#elif (defined(__linux__) || defined(sun) || defined(__FreeBSD__)|| defined(__FreeBSD_kernel__))
 
 #include <sys/types.h>
 #include <unistd.h>
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/include/util.h open-vm-tools-8.8.0+2011.10.26-514583/lib/include/util.h
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/include/util.h	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/lib/include/util.h	2011-11-18 08:38:03.000000000 +0000
@@ -50,7 +50,7 @@
 /*
  * Define the Util_ThreadID type.
  */
-#if defined(__APPLE__) || defined(__FreeBSD__)
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #include <pthread.h>
 typedef pthread_t Util_ThreadID;
 #elif defined(_WIN32)
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/include/vmblock.h open-vm-tools-8.8.0+2011.10.26-514583/lib/include/vmblock.h
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/include/vmblock.h	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/lib/include/vmblock.h	2011-11-18 08:38:03.000000000 +0000
@@ -148,7 +148,7 @@
 # define VMBLOCK_DEVICE_MODE           VMBLOCK_FUSE_DEVICE_MODE
 # define VMBLOCK_MOUNT_POINT           VMBLOCK_FUSE_MOUNT_POINT
 
-#elif defined(linux)
+#elif defined(linux) || defined(__GLIBC__)
 # define VMBLOCK_ADD_FILEBLOCK         98
 # define VMBLOCK_DEL_FILEBLOCK         99
 # ifdef VMX86_DEVEL
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/include/vmblock_user.h open-vm-tools-8.8.0+2011.10.26-514583/lib/include/vmblock_user.h
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/include/vmblock_user.h	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/lib/include/vmblock_user.h	2011-11-18 08:38:03.000000000 +0000
@@ -120,7 +120,7 @@
 
 #define VMBLOCK_CONTROL(fd, op, path) VMBLOCK_CONTROL_FUSE(fd, op, path)
 
-#elif defined(linux)
+#elif defined(linux) || defined(__GLIBC__)
 
 static INLINE int
 VMBLOCK_CONTROL(int fd, int op, const char *path)
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/include/vm_product.h open-vm-tools-8.8.0+2011.10.26-514583/lib/include/vm_product.h
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/include/vm_product.h	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/lib/include/vm_product.h	2011-11-18 08:38:03.000000000 +0000
@@ -584,6 +584,8 @@
 #  define PRODUCT_NAME_PLATFORM         PRODUCT_NAME " for Windows"
 #elif defined(__FreeBSD__)
 #  define PRODUCT_NAME_PLATFORM         PRODUCT_NAME " for FreeBSD"
+#elif defined(__FreeBSD_kernel__)
+#  define PRODUCT_NAME_PLATFORM         PRODUCT_NAME " for kFreeBSD"
 #elif defined(sun)
 #  define PRODUCT_NAME_PLATFORM         PRODUCT_NAME " for Solaris"
 #elif defined(__APPLE__)
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/misc/codesetOld.c open-vm-tools-8.8.0+2011.10.26-514583/lib/misc/codesetOld.c
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/misc/codesetOld.c	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/lib/misc/codesetOld.c	2011-11-18 08:38:03.000000000 +0000
@@ -634,7 +634,7 @@
 {
    char *codeset;
 
-#if defined(__linux__)
+#if defined(__linux__) || defined (__GLIBC__)
 
    locale_t new = newlocale(LC_CTYPE_MASK, "", NULL);
    if (!new) {
@@ -907,7 +907,7 @@
        * change bufIn so a simple cast is safe. --plangdale
        */
 
-#ifdef __linux__
+#if defined __linux__ || defined __GLIBC__
       status = iconv(cd, (char **)&bufIn, &sizeIn, &out, &outLeft);
 #else
       status = iconv(cd, &bufIn, &sizeIn, &out, &outLeft);
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/misc/hostinfoPosix.c open-vm-tools-8.8.0+2011.10.26-514583/lib/misc/hostinfoPosix.c
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/misc/hostinfoPosix.c	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/lib/misc/hostinfoPosix.c	2011-11-18 08:38:03.000000000 +0000
@@ -41,7 +41,7 @@
 #include <sys/systeminfo.h>
 #endif
 #include <sys/socket.h>
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__)
 # include <sys/sysctl.h>
 #endif
 #if defined(__APPLE__)
@@ -54,7 +54,7 @@
 #include <mach/mach.h>
 #include <mach/mach_time.h>
 #include <sys/mman.h>
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #if !defined(RLIMIT_AS)
 #  if defined(RLIMIT_VMEM)
 #     define RLIMIT_AS RLIMIT_VMEM
@@ -77,7 +77,7 @@
 #endif
 #endif
 
-#if defined(__APPLE__) || defined(__FreeBSD__)
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #include <paths.h>
 #endif
 
@@ -3023,7 +3023,7 @@
 #endif // ifndef __APPLE__
 
 
-#if defined(__linux__) || defined(__FreeBSD__) || defined(sun)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(sun)
 /*
  *-----------------------------------------------------------------------------
  *
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/misc/idLinux.c open-vm-tools-8.8.0+2011.10.26-514583/lib/misc/idLinux.c
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/misc/idLinux.c	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/lib/misc/idLinux.c	2011-11-18 08:38:03.000000000 +0000
@@ -105,7 +105,7 @@
 int
 Id_SetUid(uid_t euid)		// IN: new euid
 {
-#if defined(__FreeBSD__) || defined(sun)
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(sun)
    return setuid(euid);
 #elif defined(linux) || defined __ANDROID__
    if (uid32) {
@@ -148,7 +148,7 @@
    Warning("XXXMACOS: implement %s\n", __func__);
 
    return -1;
-#elif defined(sun) || defined(__FreeBSD__)
+#elif defined(sun) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
    return setgid(egid);
 #else
    if (uid32) {
@@ -279,7 +279,7 @@
 #if defined(__APPLE__)
    Warning("XXXMACOS: implement %s\n", __func__);
    return -1;
-#elif defined(sun) || defined(__FreeBSD__)
+#elif defined(sun) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
    return setreuid(uid, euid);
 #else
    if (uid32) {
@@ -320,7 +320,7 @@
 Id_SetREGid(gid_t gid,		// IN: new gid
 	    gid_t egid)		// IN: new effective gid
 {
-#if defined(sun) || defined(__FreeBSD__)
+#if defined(sun) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
    return setregid(gid, egid);
 #else
    if (uid32) {
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/misc/posixPosix.c open-vm-tools-8.8.0+2011.10.26-514583/lib/misc/posixPosix.c
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/misc/posixPosix.c	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/lib/misc/posixPosix.c	2011-11-18 08:38:03.000000000 +0000
@@ -2791,7 +2791,7 @@
 
 #if !defined(sun) // {
 
-#if !defined(__APPLE__) && !defined(__FreeBSD__) // {
+#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) // {
 /*
  *----------------------------------------------------------------------
  *
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/misc/util_misc.c open-vm-tools-8.8.0+2011.10.26-514583/lib/misc/util_misc.c
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/misc/util_misc.c	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/lib/misc/util_misc.c	2011-11-18 08:38:03.000000000 +0000
@@ -47,7 +47,7 @@
 #  include <pwd.h>
 #endif
 
-#if defined(__APPLE__) || defined(__FreeBSD__)
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #include <pthread.h>
 #endif
 
@@ -493,7 +493,7 @@
    ASSERT(tid != (pid_t)-1);
 
    return tid;
-#elif defined(__APPLE__) || defined(__FreeBSD__)
+#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
    ASSERT_ON_COMPILE(sizeof(Util_ThreadID) == sizeof(pthread_t));
 
    return pthread_self();
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/netUtil/netUtilLinux.c open-vm-tools-8.8.0+2011.10.26-514583/lib/netUtil/netUtilLinux.c
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/netUtil/netUtilLinux.c	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/lib/netUtil/netUtilLinux.c	2011-11-18 08:38:03.000000000 +0000
@@ -31,7 +31,7 @@
 #endif
 
 
-#if !defined(__linux__) && !defined(__FreeBSD__) && !defined(sun) && !defined(__APPLE__)
+#if !defined(__linux__) && !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && !defined(sun) && !defined(__APPLE__)
 #   error This file should not be compiled
 #endif
 
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/procMgr/procMgrPosix.c open-vm-tools-8.8.0+2011.10.26-514583/lib/procMgr/procMgrPosix.c
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/procMgr/procMgrPosix.c	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/lib/procMgr/procMgrPosix.c	2011-11-18 08:38:03.000000000 +0000
@@ -31,7 +31,7 @@
 // pull in setresuid()/setresgid() if possible
 #define  _GNU_SOURCE
 #include <unistd.h>
-#if !defined(__FreeBSD__) && !defined(sun) && !defined(__APPLE__)
+#if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && !defined(sun) && !defined(__APPLE__)
 #include <asm/param.h>
 #endif
 #if !defined(sun) && !defined(__APPLE__)
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/system/systemLinux.c open-vm-tools-8.8.0+2011.10.26-514583/lib/system/systemLinux.c
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/system/systemLinux.c	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/lib/system/systemLinux.c	2011-11-18 08:38:03.000000000 +0000
@@ -26,7 +26,7 @@
  *
  */
 
-#if !defined(__linux__) && !defined(__FreeBSD__) && !defined(sun) && !defined(__APPLE__)
+#if !defined(__linux__) && !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && !defined(sun) && !defined(__APPLE__)
 #   error This file should not be compiled
 #endif
 
@@ -183,7 +183,7 @@
 {
    uint64 uptime = -1;
 
-#ifdef __linux__
+#if defined __linux__ || defined __GLIBC__
    {
       FILE *procStream;
       char *buf = NULL;
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/unicode/unicodeSimpleTypes.c open-vm-tools-8.8.0+2011.10.26-514583/lib/unicode/unicodeSimpleTypes.c
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/unicode/unicodeSimpleTypes.c	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/lib/unicode/unicodeSimpleTypes.c	2011-11-18 08:38:03.000000000 +0000
@@ -2806,7 +2806,7 @@
     * on lib/sync, so cheese it.
     */
    while (1 == Atomic_ReadIfEqualWrite(&locked, 0, 1)) {
-#if !defined(__FreeBSD__)
+#if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__)
       usleep(250 * 1000);
 #endif
    }
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/wiper/wiperPosix.c open-vm-tools-8.8.0+2011.10.26-514583/lib/wiper/wiperPosix.c
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/lib/wiper/wiperPosix.c	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/lib/wiper/wiperPosix.c	2011-11-18 08:38:03.000000000 +0000
@@ -23,7 +23,7 @@
  *
  */
 
-#if !defined(__linux__) && !defined(sun) && !defined(__FreeBSD__) && !defined(__APPLE__)
+#if !defined(__linux__) && !defined(sun) && !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && !defined(__APPLE__)
 #error This file should not be compiled on this platform.
 #endif
 
@@ -31,7 +31,7 @@
 #include <sys/stat.h>
 #if defined(__linux__) || defined(sun)
 # include <sys/vfs.h>
-#elif defined(__FreeBSD__) || defined(__APPLE__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__)
 # include <sys/param.h>
 # include <sys/ucred.h>
 # include <sys/mount.h>
@@ -72,7 +72,7 @@
 
 #if defined(sun) || defined(__linux__)
 # define PROCFS "proc"
-#elif defined(__FreeBSD__) || defined(__APPLE__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__)
 # define PROCFS "procfs"
 #endif
 
@@ -326,7 +326,7 @@
    return FALSE;
 }
 
-#elif defined(__FreeBSD__) /* } FreeBSD { */
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) /* } FreeBSD { */
 
 static Bool
 WiperIsDiskDevice(MNTINFO *mnt,         // IN: file system being considered
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/scripts/kfreebsd-gnu/network open-vm-tools-8.8.0+2011.10.26-514583/scripts/kfreebsd-gnu/network
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/scripts/kfreebsd-gnu/network	1970-01-01 00:00:00.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/scripts/kfreebsd-gnu/network	2011-11-18 08:38:03.000000000 +0000
@@ -0,0 +1,298 @@
+#!/bin/sh
+##########################################################
+# Copyright (C) 2001-2010 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
+# by the Free Software Foundation version 2.1 and no later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser GNU General Public
+# License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
+#
+##########################################################
+
+
+#
+# network (kFreeBSD-GNU)
+#
+# Using a combination of a system networking script, ifconfig, and ifup,
+# attempt to release and renew DHCP leases upon receipt of suspend and resume
+# events, respectively.
+#
+
+
+echo `date` ": Executing '$0'"
+echo
+
+. `dirname "$0"`/../../statechange.subr
+
+
+#
+# find_networking_script --
+#
+#    Searches common kFreeBSD-GNU distro init/rc paths to find a singular network
+#    services script.
+#
+# Result:
+#    Returns a valid networking script path on success or "error" on failure.
+#
+# Side effects:
+#    None.
+#
+
+find_networking_script() {
+    local script="error"
+    for dir in "/etc/init.d" "/sbin/init.d" "/etc" "/etc/rc.d" ; do
+        if [ -d "$dir/rc0.d" ] &&
+	    [ -d "$dir/rc1.d" ] &&
+	    [ -d "$dir/rc2.d" ] &&
+	    [ -d "$dir/rc3.d" ] &&
+	    [ -d "$dir/rc4.d" ] &&
+	    [ -d "$dir/rc5.d" ] &&
+	    [ -d "$dir/rc6.d" ]; then
+
+	    # Now find the appropriate networking script.
+	    if [ -d "$dir/init.d" ]; then
+		if [ -x "$dir/init.d/network" ]; then
+		    script="$dir/init.d/network"
+		elif [ -x "$dir/init.d/networking" ]; then
+		    script="$dir/init.d/networking"
+		fi
+	    else
+		if [ -x "$dir/network" ]; then
+		    script="$dir/network"
+		elif [ -x "$dir/networking" ]; then
+		    script="$dir/networking"
+		fi
+	    fi
+        fi
+    done
+
+    echo "$script"
+}
+
+
+#
+# save_active_NIC_list --
+#
+#    Records a list of every active NIC to /var/run/vmware-active-nics.
+#
+#    XXX What's the story on aliases?  Should they still be included, or will
+#    they be recreated automatically upon resume?
+#
+# Results:
+#    $activeList has, one per line, a list of all active NICs.
+#
+# Side effects:
+#    None.
+#
+
+save_active_NIC_list() {
+   >$activeList
+
+   for nic in `ifconfig | awk '/^eth/ { print $1 }'`; do
+      ifconfig $nic | egrep -q '\bUP\b' && echo $nic >> $activeList
+      exitCode=`expr $exitCode \| $?`
+   done
+}
+
+
+#
+# rescue_NIC --
+#
+#    For each NIC recorded in $activeList that is not currently "up", run
+#    "ifup $nic".
+#
+# Results:
+#    All downed NICs should be active.
+#
+
+rescue_NIC() {
+   if [ -f "$activeList" ]; then
+      while read nic; do
+         if ifconfig $nic | egrep -q '\bUP\b'; then
+            echo `date` "[rescue_nic] $nic is already active."
+         else
+            echo `date` "[rescue_nic] activating $nic ..."
+
+            ifup $nic
+            exitCode=`expr $exitCode \| $?`
+         fi
+      done < $activeList
+
+      rm -f $activeList
+   fi
+}
+
+
+#
+# TranquilizeNetworkManager --
+#
+#    Put the NetworkManager daemon to sleep (maybe).
+#
+#    See http://projects.gnome.org/NetworkManager/developers/spec.html .
+#
+# Results:
+#    Sleep(true) request is sent to the NetworkManager D-Bus interface.
+#
+# Side effects:
+#    None.
+#
+
+TranquilizeNetworkManager()
+{
+   # `which' may be a bit noisy, so we'll shush it.
+   dbusSend=`which dbus-send 2>/dev/null`
+   rc=$?
+   if [ $rc = 0 ]; then
+      # NetworkManager 0.8.0
+      $dbusSend --system --print-reply          \
+         --dest=org.freedesktop.NetworkManager  \
+         /org/freedesktop/NetworkManager        \
+         org.freedesktop.NetworkManager.Enable boolean:false
+      rc=$?
+      if [ $rc = 0 ]; then
+         return $rc
+      fi
+      # NetworkManager 0.7.0
+      $dbusSend --system --print-reply          \
+         --dest=org.freedesktop.NetworkManager  \
+         /org/freedesktop/NetworkManager        \
+         org.freedesktop.NetworkManager.Sleep boolean:true
+      rc=$?
+      if [ $rc = 0 ]; then
+         return $rc
+      fi
+      # NetworkManager 0.6
+      $dbusSend --system --print-reply          \
+         --dest=org.freedesktop.NetworkManager  \
+         /org/freedesktop/NetworkManager        \
+         org.freedesktop.NetworkManager.sleep
+      rc=$?
+   fi
+   return $rc
+}
+
+
+#
+# WakeNetworkManager --
+#
+#    Wake the NetworkManager daemon (maybe).
+#
+#    See http://projects.gnome.org/NetworkManager/developers/spec.html .
+#
+# Results:
+#    Sleep(false)request is sent to the NetworkManager D-Bus interface.
+#
+# Side effects:
+#    None.
+#
+
+WakeNetworkManager()
+{
+   # `which' may be a bit noisy, so we'll shush it.
+   dbusSend=`which dbus-send 2>/dev/null`
+   rc=$?
+   if [ $rc = 0 ]; then
+      # NetworkManager 0.8.0
+      $dbusSend --system --print-reply          \
+         --dest=org.freedesktop.NetworkManager  \
+         /org/freedesktop/NetworkManager        \
+         org.freedesktop.NetworkManager.Enable boolean:true
+      rc=$?
+      if [ $rc = 0 ]; then
+         return $rc
+      fi
+      # NetworkManager 0.7.0
+      $dbusSend --system --print-reply          \
+         --dest=org.freedesktop.NetworkManager  \
+         /org/freedesktop/NetworkManager        \
+         org.freedesktop.NetworkManager.Sleep boolean:false
+      rc=$?
+      if [ $rc = 0 ]; then
+         return $rc
+      fi
+      # NetworkManager 0.6
+      $dbusSend --system --print-reply          \
+         --dest=org.freedesktop.NetworkManager  \
+         /org/freedesktop/NetworkManager        \
+         org.freedesktop.NetworkManager.wake
+      rc=$?
+   fi
+   return $rc
+}
+
+
+#
+# main --
+#
+#    Main entry point.  Perform some sanity checking, then map state change
+#    events to relevant networking operations.
+#
+# Results:
+#    See comment at top of file.
+#
+
+main() {
+   exitCode=0
+   activeList=/var/run/vmware-active-nics
+
+   networkScript=`find_networking_script`
+   [ "$networkScript" != "error" ] || Panic "Cannot find system networking script."
+
+   # XXX Are these really necessary?  If so, we should have seen customer
+   # complaints by now.
+   which ifup >/dev/null 2>&1      || Panic "ifup not in search path."
+   which ifconfig >/dev/null 2>&1  || Panic "ifconfig not in search path."
+
+   case "$1" in
+      poweron-vm)
+         rm -f $activeList
+         ;;
+      suspend-vm)
+         TranquilizeNetworkManager
+         exitCode=$?
+         if [ $exitCode != 0 ]; then
+            save_active_NIC_list
+            "$networkScript" stop
+            exitCode=$?
+         fi
+         ;;
+      resume-vm)
+         WakeNetworkManager
+         exitCode=$?
+         if [ $exitCode != 0 ]; then
+            # According to hfu, "/etc/init.d/networking restart" on Debian 5.0
+            # may bring down ethernet interfaces tagged as "allow-hotplug" without
+            # bringing them back up.
+            #
+            # This is especially a problem when reverting to a live, running
+            # VM snapshot where an active NIC list hadn't yet been generated,
+            # resulting in sudden loss of an otherwise operational NIC.
+            #
+            # So, if the active list doesn't exist, assume we're coming back to
+            # a live snapshot and capture the current active list now for
+            # rescue later.
+            if [ ! -s $activeList ]; then
+               save_active_NIC_list
+            fi
+            # XXX Do we really want restart or is start sufficient?  Like, would
+            # using start avoid the problem mentioned above?
+            "$networkScript" restart
+            rescue_NIC
+            exitCode=$?
+         fi
+         ;;
+      *) ;;
+   esac
+
+   return $exitCode
+}
+
+main "$@"
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/scripts/kfreebsd-gnu/pam.d/vmtoolsd open-vm-tools-8.8.0+2011.10.26-514583/scripts/kfreebsd-gnu/pam.d/vmtoolsd
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/scripts/kfreebsd-gnu/pam.d/vmtoolsd	1970-01-01 00:00:00.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/scripts/kfreebsd-gnu/pam.d/vmtoolsd	2011-11-18 08:38:03.000000000 +0000
@@ -0,0 +1,7 @@
+#%PAM-1.0
+auth       sufficient       pam_unix2.so nullok
+auth       sufficient       pam_unix.so shadow nullok
+auth       required         pam_unix_auth.so shadow nullok
+account    sufficient       pam_unix2.so
+account    sufficient       pam_unix.so
+account    required         pam_unix_acct.so
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/services/plugins/dndcp/dnd/dndLinux.c open-vm-tools-8.8.0+2011.10.26-514583/services/plugins/dndcp/dnd/dndLinux.c
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/services/plugins/dndcp/dnd/dndLinux.c	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/services/plugins/dndcp/dnd/dndLinux.c	2011-11-18 08:38:03.000000000 +0000
@@ -39,7 +39,7 @@
 #include "util.h"
 #include "escape.h"
 #include "su.h"
-#if defined(linux) || defined(sun) || defined(__FreeBSD__)
+#if defined(linux) || defined(sun) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #include "vmblock_user.h"
 #include "mntinfo.h"
 #endif
@@ -303,7 +303,7 @@
 
 
 /* We need to make this suck less. */
-#if defined(linux) || defined(sun) || defined(__FreeBSD__)
+#if defined(linux) || defined(sun) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 
 /*
  *----------------------------------------------------------------------------
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/services/plugins/guestInfo/getlib/guestInfoPosix.c open-vm-tools-8.8.0+2011.10.26-514583/services/plugins/guestInfo/getlib/guestInfoPosix.c
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/services/plugins/guestInfo/getlib/guestInfoPosix.c	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/services/plugins/guestInfo/getlib/guestInfoPosix.c	2011-11-18 08:38:07.000000000 +0000
@@ -34,7 +34,7 @@
 #include <sys/socket.h>
 #include <sys/stat.h>
 #include <errno.h>
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__)
 # include <sys/sysctl.h>
 #endif
 #ifndef NO_DNET
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/services/plugins/Makefile.am open-vm-tools-8.8.0+2011.10.26-514583/services/plugins/Makefile.am
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/services/plugins/Makefile.am	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/services/plugins/Makefile.am	2011-11-18 08:38:03.000000000 +0000
@@ -28,8 +28,6 @@
 if HAVE_X11
    SUBDIRS += resolutionSet
 endif
-SUBDIRS += timeSync
-SUBDIRS += vix
 SUBDIRS += vmbackup
 
 #
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/services/plugins/Makefile.in open-vm-tools-8.8.0+2011.10.26-514583/services/plugins/Makefile.in
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/services/plugins/Makefile.in	2011-10-27 18:57:23.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/services/plugins/Makefile.in	2011-11-18 08:38:03.000000000 +0000
@@ -82,7 +82,7 @@
 ETAGS = etags
 CTAGS = ctags
 DIST_SUBDIRS = desktopEvents dndcp guestInfo hgfsServer powerOps \
-	resolutionSet timeSync vix vmbackup
+	resolutionSet vmbackup
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 am__relativize = \
   dir0=`pwd`; \
@@ -295,7 +295,7 @@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 SUBDIRS = $(am__append_1) $(am__append_2) guestInfo hgfsServer \
-	powerOps $(am__append_3) timeSync vix vmbackup
+	powerOps $(am__append_3) vmbackup
 all: all-recursive
 
 .SUFFIXES:
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/services/plugins/timeSync/Makefile.am open-vm-tools-8.8.0+2011.10.26-514583/services/plugins/timeSync/Makefile.am
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/services/plugins/timeSync/Makefile.am	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/services/plugins/timeSync/Makefile.am	2011-11-18 08:38:03.000000000 +0000
@@ -39,6 +39,10 @@
 libtimeSync_la_SOURCES += slewAdjtime.c
 libtimeSync_la_SOURCES += pllNone.c
 endif
+if KFREEBSD
+libtimeSync_la_SOURCES += slewAdjtime.c
+libtimeSync_la_SOURCES += pllNone.c
+endif
 if LINUX
 libtimeSync_la_SOURCES += slewLinux.c
 libtimeSync_la_SOURCES += pllLinux.c
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/services/plugins/timeSync/Makefile.in open-vm-tools-8.8.0+2011.10.26-514583/services/plugins/timeSync/Makefile.in
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/services/plugins/timeSync/Makefile.in	2011-10-27 18:57:24.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/services/plugins/timeSync/Makefile.in	2011-11-18 08:38:03.000000000 +0000
@@ -53,7 +53,8 @@
 host_triplet = @host@
 @SOLARIS_TRUE@am__append_1 = slewAdjtime.c pllNone.c
 @FREEBSD_TRUE@am__append_2 = slewAdjtime.c pllNone.c
-@LINUX_TRUE@am__append_3 = slewLinux.c pllLinux.c
+@KFREEBSD_TRUE@am__append_3 = slewAdjtime.c pllNone.c
+@LINUX_TRUE@am__append_4 = slewLinux.c pllLinux.c
 subdir = services/plugins/timeSync
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in COPYING
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -96,11 +97,13 @@
 @SOLARIS_TRUE@	libtimeSync_la-pllNone.lo
 @FREEBSD_TRUE@am__objects_2 = libtimeSync_la-slewAdjtime.lo \
 @FREEBSD_TRUE@	libtimeSync_la-pllNone.lo
-@LINUX_TRUE@am__objects_3 = libtimeSync_la-slewLinux.lo \
+@KFREEBSD_TRUE@am__objects_3 = libtimeSync_la-slewAdjtime.lo \
+@KFREEBSD_TRUE@	libtimeSync_la-pllNone.lo
+@LINUX_TRUE@am__objects_4 = libtimeSync_la-slewLinux.lo \
 @LINUX_TRUE@	libtimeSync_la-pllLinux.lo
 am_libtimeSync_la_OBJECTS = libtimeSync_la-timeSync.lo \
 	libtimeSync_la-timeSyncPosix.lo $(am__objects_1) \
-	$(am__objects_2) $(am__objects_3)
+	$(am__objects_2) $(am__objects_3) $(am__objects_4)
 libtimeSync_la_OBJECTS = $(am_libtimeSync_la_OBJECTS)
 libtimeSync_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
@@ -314,7 +317,7 @@
 libtimeSync_la_LDFLAGS = @PLUGIN_LDFLAGS@
 libtimeSync_la_LIBADD = @VMTOOLS_LIBS@
 libtimeSync_la_SOURCES = timeSync.c timeSyncPosix.c $(am__append_1) \
-	$(am__append_2) $(am__append_3)
+	$(am__append_2) $(am__append_3) $(am__append_4)
 all: all-am
 
 .SUFFIXES:
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/tests/testVmblock/vmblocktest.c open-vm-tools-8.8.0+2011.10.26-514583/tests/testVmblock/vmblocktest.c
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/tests/testVmblock/vmblocktest.c	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/tests/testVmblock/vmblocktest.c	2011-11-18 08:38:03.000000000 +0000
@@ -24,7 +24,7 @@
  *
  */
 
-#if !defined(linux) && !defined(sun) && !defined(__FreeBSD__) && !defined(vmblock_fuse)
+#if !defined(linux) && !defined(sun) && !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && !defined(vmblock_fuse)
 # error "vmblocktest.c needs to be ported to your OS."
 #endif
 
@@ -76,7 +76,7 @@
 #define THREAD_LOG(fmt, args...)   lprintf(" (%lx) " fmt, (unsigned long)pthread_self(), ## args)
 #define THREAD_ERROR(fmt, args...) lfprintf(stderr, " (%"FMTPID") " fmt, getpid(), ## args)
 
-#if defined (linux) || defined(__FreeBSD__)
+#if defined (linux) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 # define os_thread_yield()      sched_yield()
 #elif defined(sun)
 # define os_thread_yield()      yield()
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/vmblockmounter/vmblockmounter.c open-vm-tools-8.8.0+2011.10.26-514583/vmblockmounter/vmblockmounter.c
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/vmblockmounter/vmblockmounter.c	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/vmblockmounter/vmblockmounter.c	2011-11-18 08:38:03.000000000 +0000
@@ -29,7 +29,7 @@
 #include <ctype.h>
 #include <errno.h>
 #include <getopt.h>
-#if defined(__FreeBSD__)
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #   include <sys/uio.h>
 #   include <sys/param.h>
 #endif
@@ -221,7 +221,7 @@
    /* Go! */
 #if defined(sun)
    mntRes = mount(sourceDir, mountPoint, MS_DATA, VMBLOCK_FS_NAME);
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
    {
       struct iovec iov[] = {
          { .iov_base = "fstype", .iov_len = sizeof "fstype" },
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/vmware-user-suid-wrapper/main.c open-vm-tools-8.8.0+2011.10.26-514583/vmware-user-suid-wrapper/main.c
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/vmware-user-suid-wrapper/main.c	2011-10-27 18:57:11.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/vmware-user-suid-wrapper/main.c	2011-11-18 08:38:03.000000000 +0000
@@ -28,7 +28,7 @@
  *      remove blocks in the blocking file system.
  */
 
-#if !defined(sun) && !defined(__FreeBSD__) && !defined(linux)
+#if !defined(sun) && !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && !defined(linux)
 # error This program is not supported on your platform.
 #endif
 
diff -uNr open-vm-tools-8.8.0+2011.10.26-514583.orig/vmware-user-suid-wrapper/wrapper-kfreebsd-gnu.c open-vm-tools-8.8.0+2011.10.26-514583/vmware-user-suid-wrapper/wrapper-kfreebsd-gnu.c
--- open-vm-tools-8.8.0+2011.10.26-514583.orig/vmware-user-suid-wrapper/wrapper-kfreebsd-gnu.c	1970-01-01 00:00:00.000000000 +0000
+++ open-vm-tools-8.8.0+2011.10.26-514583/vmware-user-suid-wrapper/wrapper-kfreebsd-gnu.c	2011-11-18 08:38:03.000000000 +0000
@@ -0,0 +1,136 @@
+/*********************************************************
+ * Copyright (C) 2007 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
+ * by the Free Software Foundation version 2.1 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
+ *
+ *********************************************************/
+
+/*
+ * wrapper.c --
+ *
+ *      Platform specific code for the VMware User Agent setuid wrapper.
+ */
+
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "vmware.h"
+#include "wrapper.h"
+
+
+/*
+ * Global functions
+ */
+
+
+#ifdef USES_LOCATIONS_DB
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * BuildExecPath --
+ *
+ *      Determine & return path of vmware-user for use by execve(2).
+ *
+ * Results:
+ *      TRUE on success, FALSE otherwise
+ *
+ * Side effects:
+ *      None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+Bool
+BuildExecPath(char *execPath,           // OUT: Buffer to store executable's path
+              size_t execPathSize)      // IN : size of execPath buffer
+{
+   char tmpPath[MAXPATHLEN];
+   int execLen;
+
+   /*
+    * The locations database is the only path that's fixed, and it contains the
+    * paths to all the other paths selected during Tools configuration.  The
+    * locations database file is only writable by root, so we can trust it.
+    */
+   if (!QueryLocationsDB(LOCATIONS_PATH, QUERY_BINDIR, tmpPath, sizeof tmpPath)) {
+      Error("could not obtain BINDIR\n");
+      return FALSE;
+   }
+
+   if (strlcat(tmpPath,
+               "/vmware-user-wrapper", sizeof tmpPath) >= sizeof tmpPath) {
+      Error("could not construct program filename\n");
+      return FALSE;
+   }
+
+   /*
+    * From readlink(2), "The readlink() system call does not append a NUL
+    * character to buf."  (NB:  This breaks if user ever replaces the symlink
+    * with the target.)
+    */
+   if ((execLen = readlink(tmpPath, execPath, execPathSize - 1)) == -1) {
+      Error("could not resolve symlink: %s\n", strerror(errno));
+      return FALSE;
+   }
+
+   execPath[execLen] = '\0';
+
+   /*
+    * Now make sure that the target is actually part of our "trusted"
+    * directory.  (Check that execPath has LIBDIR as a prefix and does
+    * not contain "..".)
+    */
+   if (!QueryLocationsDB(LOCATIONS_PATH, QUERY_LIBDIR, tmpPath,
+                         sizeof tmpPath)) {
+      Error("could not obtain LIBDIR\n");
+      return FALSE;
+   }
+
+   if ((strncmp(execPath, tmpPath, strlen(tmpPath)) != 0) ||
+       (strstr(execPath, "..") != NULL)) {
+      Error("vmware-user path untrusted\n");
+      return FALSE;
+   }
+
+   return TRUE;
+}
+#endif // ifdef USES_LOCATIONS_DB
+
+
+/*
+ *----------------------------------------------------------------------------
+ *
+ * CompatExec --
+ *
+ *      Simple platform-dependent execve() wrapper.
+ *
+ * Results:
+ *      False.
+ *
+ * Side effects:
+ *      This function may not return.
+ *
+ *----------------------------------------------------------------------------
+ */
+
+Bool
+CompatExec(const char *path, char * const argv[], char * const envp[])
+{
+   execve(path, argv, envp);
+   return FALSE;
+}

Reply to: