#else
/** The FD to access the VMware blocking fs. -1 if no FD available. */
int blockFD;
+ /** The native environment (without any VMware modifications). */
+ const char **envp;
#endif
/**
* A GObject instance shared among all plugins. The object itself doesn't
#include "conf.h"
#include "guestApp.h"
#include "serviceObj.h"
+#include "system.h"
#include "util.h"
#include "vm_app.h"
#include "vmcheck.h"
state->debugLib = NULL;
}
+#if !defined(_WIN32)
+ if (state->ctx.envp) {
+ System_FreeNativeEnviron(state->ctx.envp);
+ state->ctx.envp = NULL;
+ }
+#endif
+
g_object_unref(state->ctx.serviceObj);
state->ctx.serviceObj = NULL;
state->ctx.config = NULL;
#include <unistd.h>
#include <glib/gstdio.h>
#include "file.h"
+#include "guestApp.h"
#include "hostinfo.h"
+#include "system.h"
#include "unicode.h"
#include "util.h"
#include "vmtools.h"
*
* @param[in] argc Argument count.
* @param[in] argv Argument array.
+ * @param[in] envp User environment.
*
* @return 0 on successful execution, error code otherwise.
*/
int
main(int argc,
- char *argv[])
+ char *argv[],
+ const char *envp[])
{
int i;
int ret = EXIT_FAILURE;
VMTOOLSAPP_ATTACH_SOURCE(&gState.ctx, src, ToolsCoreSigUsrHandler, NULL, NULL);
g_source_unref(src);
+ /*
+ * Save the original environment so that we can safely spawn other
+ * applications (since we may have to modify the original environment
+ * to launch vmtoolsd successfully).
+ */
+ gState.ctx.envp = System_GetNativeEnviron(envp);
+
ret = ToolsCore_Run(&gState);
ToolsCore_Cleanup(&gState);