javalinuxunixvmware-toolsvix

VMWare guest tools (vixtools) API is not finding the system /tmp directory


I am working on a Java class that accesses VMWare VMs on a VCenter using the Java API.

The Java API allows us to connect to the VCenter, access the guest VM (CentOS7) and list files in directories with no problems except for the /tmp directory.

for usage reference: Doc : GuestFileManager

// filePathToCheck = "/tmp/some-file-to-find.txt
ManagedObjectReference fileManager = ...; // GuestFileManager
ManagedObjectReference vmGuest = ...;  // VirtualMachine
String fileToCheckName = FilenameUtils.getName(filePathToCheck); // -> some-file-to-find.txt
String guestDirectory = filePathToCheck.replace(fileToCheckName,""); // -> /tmp/
guestFiles = vimPort.listFilesInGuest(fileManager, vmGuest, auth, guestDirectory, null, null, null);

I am using GuestFileManager.listFilesInGuest() and find that with any directory other than /tmp I can list the files in the directory exactly as they appear in an ssh session.

With a listFilesInGuest() looking at the path "/tmp" directory I get a listing of:

.
..
vmware-root (directory)

even though my ssh session shows:

.
..
finishedinstall
.font-unix
.ICE-unix
systemd-private-f2b5415058d14dbfa4306235d53fed88-vmtoolsd.service-QN0Muw
.Test-unix
.X11-unix
.XIM-unix

I did a find on vmware-root and it showed up at

/tmp/systemd-private-f2b5415058d14dbfa4306235d53fed88-vmtoolsd.service-QN0Muw/tmp/vmware-root

navigation into that folder revealed the files found in listFilesInGuest():

.
..
vmware-root

This would be fine we operated in a vacuum, but the program will need to read, modify or execute files in the temp directory from other program installers and interfaces which use "the" /tmp directory and not VMWare's buried location.

I have not been able to find any documentation on some way to re-configure VMWare Tools nor a way to get to the /tmp directory using the API and I am hoping someone in SO will encountered and found a victorious path for this VMWare feature.

EDIT : With further testing I have found that this "special" tmp directory only happens in posix, the VMWareTools API on Windows navigates as I would expect in all OS.


Solution

  • Try disabling the private tmp directory. There should be some setting file for vmtoolsd service. For example: apache

    As it turned out ( see the comments ), such setting can be found in: /usr/lib/systemd/system/vmtoolsd.service