GuestSessionImpl.cpp revision 3641904508e6a0671c21a083a2ed03ebad8d976c
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync/* $Id$ */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync/** @file
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * VirtualBox Main - XXX.
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync/*
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * Copyright (C) 2012 Oracle Corporation
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync *
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * available from http://www.virtualbox.org. This file is free software;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * you can redistribute it and/or modify it under the terms of the GNU
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * General Public License (GPL) as published by the Free Software
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync/*******************************************************************************
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync* Header Files *
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync*******************************************************************************/
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync#include "GuestImpl.h"
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#include "GuestSessionImpl.h"
7b9f0c34e9ea328981c99e97054bdf8684d9d620vboxsync#include "GuestCtrlImplPrivate.h"
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#include "Global.h"
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#include "AutoCaller.h"
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync#include "ProgressImpl.h"
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
b1cc3e87518139898395f96974ecff9e6bf228fbvboxsync#include <memory> /* For auto_ptr. */
b1cc3e87518139898395f96974ecff9e6bf228fbvboxsync
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync#include <iprt/env.h>
388b6b190a5407548753b7fde12fa58134ec3563vboxsync#include <iprt/file.h> /* For CopyTo/From. */
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#include <VBox/com/array.h>
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync#include <VBox/version.h>
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync#define VBOX_SERVICE_ENVARG_BUG
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync// constructor / destructor
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync/////////////////////////////////////////////////////////////////////////////
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncDEFINE_EMPTY_CTOR_DTOR(GuestSession)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncHRESULT GuestSession::FinalConstruct(void)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync LogFlowThisFunc(("\n"));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync return BaseFinalConstruct();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncvoid GuestSession::FinalRelease(void)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync LogFlowThisFuncEnter();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync uninit();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync BaseFinalRelease();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync LogFlowThisFuncLeave();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync// session task classes
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync/////////////////////////////////////////////////////////////////////////////
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsyncGuestSessionTask::GuestSessionTask(GuestSession *pSession)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync mSession = pSession;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsyncGuestSessionTask::~GuestSessionTask(void)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsyncint GuestSessionTask::setProgress(ULONG uPercent)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync if (mProgress.isNull()) /* Progress is optional. */
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync return VINF_SUCCESS;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync BOOL fCanceled;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync if ( SUCCEEDED(mProgress->COMGETTER(Canceled(&fCanceled)))
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync && fCanceled)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return VERR_CANCELLED;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync BOOL fCompleted;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync if ( SUCCEEDED(mProgress->COMGETTER(Completed(&fCompleted)))
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync && !fCompleted)
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync return VINF_SUCCESS;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync HRESULT hr = mProgress->SetCurrentOperationProgress(uPercent);
386a7cc6c736c97bb8839df94eef779de7fbfdc1vboxsync if (FAILED(hr))
386a7cc6c736c97bb8839df94eef779de7fbfdc1vboxsync return VERR_COM_UNEXPECTED;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return VINF_SUCCESS;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsyncint GuestSessionTask::setProgressSuccess(void)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync if (mProgress.isNull()) /* Progress is optional. */
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync return VINF_SUCCESS;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync BOOL fCanceled;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync BOOL fCompleted;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync if ( SUCCEEDED(mProgress->COMGETTER(Canceled(&fCanceled)))
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync && !fCanceled
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync && SUCCEEDED(mProgress->COMGETTER(Completed(&fCompleted)))
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync && !fCompleted)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync {
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync HRESULT hr = mProgress->notifyComplete(S_OK);
b1cc3e87518139898395f96974ecff9e6bf228fbvboxsync if (FAILED(hr))
b1cc3e87518139898395f96974ecff9e6bf228fbvboxsync return VERR_COM_UNEXPECTED; /** @todo Find a better rc. */
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync }
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return VINF_SUCCESS;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsyncHRESULT GuestSessionTask::setProgressErrorMsg(HRESULT hr, const Utf8Str &strMsg)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync if (mProgress.isNull()) /* Progress is optional. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync return hr; /* Return original rc. */
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync BOOL fCanceled;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync BOOL fCompleted;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync if ( SUCCEEDED(mProgress->COMGETTER(Canceled(&fCanceled)))
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync && !fCanceled
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync && SUCCEEDED(mProgress->COMGETTER(Completed(&fCompleted)))
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync && !fCompleted)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync {
b1cc3e87518139898395f96974ecff9e6bf228fbvboxsync HRESULT hr2 = mProgress->notifyComplete(hr,
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync COM_IIDOF(IGuestSession),
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync GuestSession::getStaticComponentName(),
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync strMsg.c_str());
b1cc3e87518139898395f96974ecff9e6bf228fbvboxsync if (FAILED(hr2))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync return hr2;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync return hr; /* Return original rc. */
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsyncSessionTaskCopyTo::SessionTaskCopyTo(GuestSession *pSession,
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync const Utf8Str &strSource, const Utf8Str &strDest, uint32_t uFlags)
c740281e4f5e61397e892447aeef2a7bdbbaaf8dvboxsync : mSource(strSource),
c740281e4f5e61397e892447aeef2a7bdbbaaf8dvboxsync mDest(strDest),
c740281e4f5e61397e892447aeef2a7bdbbaaf8dvboxsync mSourceFile(NULL),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mSourceOffset(0),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mSourceSize(0),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync GuestSessionTask(pSession)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync mCopyFileFlags = uFlags;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
ce46b563e3317d0c792fbe141e2978bfa0e91aaevboxsync/** @todo Merge this and the above call and let the above call do the open/close file handling so that the
ce46b563e3317d0c792fbe141e2978bfa0e91aaevboxsync * inner code only has to deal with file handles. No time now ... */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsyncSessionTaskCopyTo::SessionTaskCopyTo(GuestSession *pSession,
3d33b6a3faf40871bae75119c2569cdc4acb2d46vboxsync PRTFILE pSourceFile, size_t cbSourceOffset, uint64_t cbSourceSize,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync const Utf8Str &strDest, uint32_t uFlags)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync : GuestSessionTask(pSession)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync{
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mSourceFile = pSourceFile;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mSourceOffset = cbSourceOffset;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mSourceSize = cbSourceSize;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mDest = strDest;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mCopyFileFlags = uFlags;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync}
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsyncSessionTaskCopyTo::~SessionTaskCopyTo(void)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsyncint SessionTaskCopyTo::Run(void)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
388b6b190a5407548753b7fde12fa58134ec3563vboxsync LogFlowThisFuncEnter();
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
388b6b190a5407548753b7fde12fa58134ec3563vboxsync ComObjPtr<GuestSession> pSession = mSession;
388b6b190a5407548753b7fde12fa58134ec3563vboxsync Assert(!pSession.isNull());
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
388b6b190a5407548753b7fde12fa58134ec3563vboxsync AutoCaller autoCaller(pSession);
388b6b190a5407548753b7fde12fa58134ec3563vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync if (mCopyFileFlags)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync setProgressErrorMsg(VBOX_E_IPRT_ERROR,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Copy flags (%#x) not implemented yet"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mCopyFileFlags));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync return VERR_INVALID_PARAMETER;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
388b6b190a5407548753b7fde12fa58134ec3563vboxsync int rc;
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync RTFILE fileLocal;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync PRTFILE pFile = &fileLocal;
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (!mSourceFile)
388b6b190a5407548753b7fde12fa58134ec3563vboxsync {
388b6b190a5407548753b7fde12fa58134ec3563vboxsync /* Does our source file exist? */
388b6b190a5407548753b7fde12fa58134ec3563vboxsync if (!RTFileExists(mSource.c_str()))
388b6b190a5407548753b7fde12fa58134ec3563vboxsync {
388b6b190a5407548753b7fde12fa58134ec3563vboxsync rc = setProgressErrorMsg(VBOX_E_IPRT_ERROR,
388b6b190a5407548753b7fde12fa58134ec3563vboxsync Utf8StrFmt(GuestSession::tr("Source file \"%s\" does not exist or is not a file"),
5366e994777f9d9391cf809dc77610f57270d75dvboxsync mSource.c_str()));
388b6b190a5407548753b7fde12fa58134ec3563vboxsync }
388b6b190a5407548753b7fde12fa58134ec3563vboxsync else
388b6b190a5407548753b7fde12fa58134ec3563vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = RTFileOpen(pFile, mSource.c_str(),
388b6b190a5407548753b7fde12fa58134ec3563vboxsync RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE);
388b6b190a5407548753b7fde12fa58134ec3563vboxsync if (RT_FAILURE(rc))
388b6b190a5407548753b7fde12fa58134ec3563vboxsync {
388b6b190a5407548753b7fde12fa58134ec3563vboxsync rc = setProgressErrorMsg(VBOX_E_IPRT_ERROR,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Could not open source file \"%s\" for reading: %Rrc"),
5366e994777f9d9391cf809dc77610f57270d75dvboxsync mSource.c_str(), rc));
388b6b190a5407548753b7fde12fa58134ec3563vboxsync }
388b6b190a5407548753b7fde12fa58134ec3563vboxsync else
388b6b190a5407548753b7fde12fa58134ec3563vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = RTFileGetSize(*pFile, &mSourceSize);
388b6b190a5407548753b7fde12fa58134ec3563vboxsync if (RT_FAILURE(rc))
388b6b190a5407548753b7fde12fa58134ec3563vboxsync {
388b6b190a5407548753b7fde12fa58134ec3563vboxsync setProgressErrorMsg(VBOX_E_IPRT_ERROR,
5366e994777f9d9391cf809dc77610f57270d75dvboxsync Utf8StrFmt(GuestSession::tr("Could not query file size of \"%s\": %Rrc"),
5366e994777f9d9391cf809dc77610f57270d75dvboxsync mSource.c_str(), rc));
388b6b190a5407548753b7fde12fa58134ec3563vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync else
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync pFile = mSourceFile;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Size + offset are optional. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync GuestProcessStartupInfo procInfo;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync procInfo.mName = Utf8StrFmt(GuestSession::tr("Copying file \"%s\" to the guest to \"%s\" (%RU64 bytes)"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mSource.c_str(), mDest.c_str(), mSourceSize);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync procInfo.mCommand = Utf8Str(VBOXSERVICE_TOOL_CAT);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync procInfo.mFlags = ProcessCreateFlag_Hidden;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Set arguments.*/
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync procInfo.mArguments.push_back(Utf8StrFmt("--output=%s", mDest.c_str())); /** @todo Do we need path conversion? */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Startup process. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync ComObjPtr<GuestProcess> pProcess;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = pSession->processCreateExInteral(procInfo, pProcess);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (RT_SUCCESS(rc))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = pProcess->startProcess();
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (RT_FAILURE(rc))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync setProgressErrorMsg(VBOX_E_IPRT_ERROR,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Unable to start guest process: %Rrc"), rc));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync else
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync GuestProcessWaitResult waitRes;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync BYTE byBuf[_64K];
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync BOOL fCanceled = FALSE;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync uint64_t cbWrittenTotal = 0;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync uint64_t cbToRead = mSourceSize;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync for (;;)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = pProcess->waitFor(ProcessWaitForFlag_StdIn,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync 30 * 1000 /* Timeout */, waitRes);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if ( RT_FAILURE(rc)
25771ba4fe7e9fb9be963cf8289df6a0e8f93e56vboxsync || waitRes.mResult != ProcessWaitForFlag_StdIn)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync break;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync size_t cbRead = 0;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (mSourceSize) /* If we have nothing to write, take a shortcut. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /** @todo Not very efficient, but works for now. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = RTFileSeek(*pFile, mSourceOffset + cbWrittenTotal,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync RTFILE_SEEK_BEGIN, NULL /* poffActual */);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (RT_SUCCESS(rc))
388b6b190a5407548753b7fde12fa58134ec3563vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = RTFileRead(*pFile, (uint8_t*)byBuf,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync RT_MIN(cbToRead, sizeof(byBuf)), &cbRead);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /*
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * Some other error occured? There might be a chance that RTFileRead
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * could not resolve/map the native error code to an IPRT code, so just
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * print a generic error.
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (RT_FAILURE(rc))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync setProgressErrorMsg(VBOX_E_IPRT_ERROR,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Could not read from file \"%s\" (%Rrc)"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mSource.c_str(), rc));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync break;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync else
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync setProgressErrorMsg(VBOX_E_IPRT_ERROR,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Seeking file \"%s\" offset %RU64 failed: %Rrc"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mSource.c_str(), cbWrittenTotal, rc));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync break;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync uint32_t fFlags = ProcessInputFlag_None;
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Did we reach the end of the content we want to transfer (last chunk)? */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if ( (cbRead < sizeof(byBuf))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Did we reach the last block which is exactly _64K? */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync || (cbToRead - cbRead == 0)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* ... or does the user want to cancel? */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync || ( SUCCEEDED(mProgress->COMGETTER(Canceled(&fCanceled)))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync && fCanceled)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync )
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync fFlags |= ProcessInputFlag_EndOfFile;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync uint32_t cbWritten;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Assert(sizeof(byBuf) >= cbRead);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = pProcess->writeData(0 /* StdIn */, fFlags,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync byBuf, cbRead,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync 30 * 1000 /* Timeout */, &cbWritten);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (RT_FAILURE(rc))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync setProgressErrorMsg(VBOX_E_IPRT_ERROR,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Writing to file \"%s\" (offset %RU64) failed: %Rrc"),
25771ba4fe7e9fb9be963cf8289df6a0e8f93e56vboxsync mDest.c_str(), cbWrittenTotal, rc));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync break;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
25771ba4fe7e9fb9be963cf8289df6a0e8f93e56vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync LogFlowThisFunc(("cbWritten=%RU32, cbToRead=%RU64, cbWrittenTotal=%RU64, cbFileSize=%RU64\n",
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync cbWritten, cbToRead - cbWritten, cbWrittenTotal + cbWritten, mSourceSize));
25771ba4fe7e9fb9be963cf8289df6a0e8f93e56vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Only subtract bytes reported written by the guest. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Assert(cbToRead >= cbWritten);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync cbToRead -= cbWritten;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Update total bytes written to the guest. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync cbWrittenTotal += cbWritten;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Assert(cbWrittenTotal <= mSourceSize);
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Did the user cancel the operation above? */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (fCanceled)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync break;
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Update the progress.
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * Watch out for division by zero. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mSourceSize > 0
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync ? rc = setProgress((ULONG)(cbWrittenTotal * 100 / mSourceSize))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync : rc = setProgress(100);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (RT_FAILURE(rc))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync break;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* End of file reached? */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (!cbToRead)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync break;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync } /* for */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if ( !fCanceled
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync || RT_SUCCESS(rc))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /*
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * Even if we succeeded until here make sure to check whether we really transfered
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * everything.
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if ( mSourceSize > 0
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync && cbWrittenTotal == 0)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* If nothing was transfered but the file size was > 0 then "vbox_cat" wasn't able to write
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * to the destination -> access denied. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = setProgressErrorMsg(VBOX_E_IPRT_ERROR,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Access denied when copying file \"%s\" to \"%s\""),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mSource.c_str(), mDest.c_str()));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync else if (cbWrittenTotal < mSourceSize)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* If we did not copy all let the user know. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = setProgressErrorMsg(VBOX_E_IPRT_ERROR,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Copying file \"%s\" failed (%RU64/%RU64 bytes transfered)"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mSource.c_str(), cbWrittenTotal, mSourceSize));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync else
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = pProcess->waitFor(ProcessWaitForFlag_Terminate,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync 30 * 1000 /* Timeout */, waitRes);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if ( RT_FAILURE(rc)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync || waitRes.mResult != ProcessWaitResult_Terminate)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (RT_FAILURE(rc))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = setProgressErrorMsg(VBOX_E_IPRT_ERROR,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Waiting on termination for copying file \"%s\" failed: %Rrc"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mSource.c_str(), rc));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync else
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = setProgressErrorMsg(VBOX_E_IPRT_ERROR,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Waiting on termination for copying file \"%s\" failed with wait result %ld"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mSource.c_str(), waitRes.mResult));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (RT_SUCCESS(rc))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync ProcessStatus_T procStatus;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync LONG exitCode;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if ( ( SUCCEEDED(pProcess->COMGETTER(Status(&procStatus)))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync && procStatus != ProcessStatus_TerminatedNormally)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync || ( SUCCEEDED(pProcess->COMGETTER(ExitCode(&exitCode)))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync && exitCode != 0)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync )
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = setProgressErrorMsg(VBOX_E_IPRT_ERROR,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Copying file \"%s\" failed with status %ld, exit code %ld"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mSource.c_str(), procStatus, exitCode)); /**@todo Add stringify methods! */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (RT_SUCCESS(rc))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = setProgressSuccess();
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync pProcess->close();
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync } /* processCreateExInteral */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (!mSourceFile) /* Only close locally opened files. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync RTFileClose(*pFile);
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
388b6b190a5407548753b7fde12fa58134ec3563vboxsync LogFlowFuncLeaveRC(rc);
388b6b190a5407548753b7fde12fa58134ec3563vboxsync return rc;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsyncint SessionTaskCopyTo::RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync LogFlowThisFunc(("strDesc=%s, strSource=%s, strDest=%s, mCopyFileFlags=%x\n",
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync strDesc.c_str(), mSource.c_str(), mDest.c_str(), mCopyFileFlags));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync mDesc = strDesc;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync mProgress = pProgress;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync int rc = RTThreadCreate(NULL, SessionTaskCopyTo::taskThread, this,
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync 0, RTTHREADTYPE_MAIN_HEAVY_WORKER, 0,
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync "gctlCpyTo");
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync LogFlowFuncLeaveRC(rc);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return rc;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync/* static */
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsyncint SessionTaskCopyTo::taskThread(RTTHREAD Thread, void *pvUser)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync std::auto_ptr<SessionTaskCopyTo> task(static_cast<SessionTaskCopyTo*>(pvUser));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync AssertReturn(task.get(), VERR_GENERAL_FAILURE);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync LogFlowFunc(("pTask=%p\n", task.get()));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return task->Run();
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsyncSessionTaskCopyFrom::SessionTaskCopyFrom(GuestSession *pSession,
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync const Utf8Str &strSource, const Utf8Str &strDest, uint32_t uFlags)
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync : GuestSessionTask(pSession)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync mSource = strSource;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync mDest = strDest;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync mFlags = uFlags;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsyncSessionTaskCopyFrom::~SessionTaskCopyFrom(void)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsyncint SessionTaskCopyFrom::Run(void)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
5366e994777f9d9391cf809dc77610f57270d75dvboxsync LogFlowThisFuncEnter();
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync ComObjPtr<GuestSession> pSession = mSession;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync Assert(!pSession.isNull());
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync AutoCaller autoCaller(pSession);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /*
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * Note: There will be races between querying file size + reading the guest file's
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * content because we currently *do not* lock down the guest file when doing the
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * actual operations.
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync ** @todo Implement guest file locking!
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync GuestFsObjData objData;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync int rc = pSession->fileQueryInfoInternal(Utf8Str(mSource), objData);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (RT_FAILURE(rc))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync setProgressErrorMsg(VBOX_E_IPRT_ERROR,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Querying guest file information for \"%s\" failed: %Rrc"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mSource.c_str(), rc));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync else if (objData.mType != FsObjType_File) /* Only single files are supported at the moment. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = setProgressErrorMsg(VBOX_E_IPRT_ERROR,
25771ba4fe7e9fb9be963cf8289df6a0e8f93e56vboxsync Utf8StrFmt(GuestSession::tr("Object \"%s\" on the guest is not a file"), mSource.c_str()));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (RT_SUCCESS(rc))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync RTFILE fileDest;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = RTFileOpen(&fileDest, mDest.c_str(),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync RTFILE_O_WRITE | RTFILE_O_OPEN_CREATE | RTFILE_O_DENY_WRITE); /** @todo Use the correct open modes! */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (RT_FAILURE(rc))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync setProgressErrorMsg(VBOX_E_IPRT_ERROR,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Error opening destination file \"%s\": %Rrc"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mDest.c_str(), rc));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync else
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync GuestProcessStartupInfo procInfo;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync procInfo.mName = Utf8StrFmt(GuestSession::tr("Copying file \"%s\" from guest to the host to \"%s\" (%RI64 bytes)"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mSource.c_str(), mDest.c_str(), objData.mObjectSize);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync procInfo.mCommand = Utf8Str(VBOXSERVICE_TOOL_CAT);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync procInfo.mFlags = ProcessCreateFlag_Hidden | ProcessCreateFlag_WaitForStdOut;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Set arguments.*/
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync procInfo.mArguments.push_back(mSource); /* Which file to output? */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Startup process. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync ComObjPtr<GuestProcess> pProcess;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = pSession->processCreateExInteral(procInfo, pProcess);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (RT_SUCCESS(rc))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = pProcess->startProcess();
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (RT_FAILURE(rc))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync setProgressErrorMsg(VBOX_E_IPRT_ERROR,
25771ba4fe7e9fb9be963cf8289df6a0e8f93e56vboxsync Utf8StrFmt(GuestSession::tr("Unable to start guest process for copying data from guest to host: %Rrc"), rc));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync else
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync GuestProcessWaitResult waitRes;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync BYTE byBuf[_64K];
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync BOOL fCanceled = FALSE;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync uint64_t cbWrittenTotal = 0;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync uint64_t cbToRead = objData.mObjectSize;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync for (;;)
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = pProcess->waitFor(ProcessWaitForFlag_StdOut,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync 30 * 1000 /* Timeout */, waitRes);
fd195826ea128c13e468ada8761c83d50c71c498vboxsync if ( waitRes.mResult == ProcessWaitResult_StdOut
fd195826ea128c13e468ada8761c83d50c71c498vboxsync || waitRes.mResult == ProcessWaitResult_Any)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
fd195826ea128c13e468ada8761c83d50c71c498vboxsync size_t cbRead;
fd195826ea128c13e468ada8761c83d50c71c498vboxsync rc = pProcess->readData(OUTPUT_HANDLE_ID_STDOUT, sizeof(byBuf),
fd195826ea128c13e468ada8761c83d50c71c498vboxsync 30 * 1000 /* Timeout */, byBuf, sizeof(byBuf),
fd195826ea128c13e468ada8761c83d50c71c498vboxsync &cbRead);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (RT_FAILURE(rc))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync setProgressErrorMsg(VBOX_E_IPRT_ERROR,
fd195826ea128c13e468ada8761c83d50c71c498vboxsync Utf8StrFmt(GuestSession::tr("Reading from file \"%s\" (offset %RU64) failed: %Rrc"),
fd195826ea128c13e468ada8761c83d50c71c498vboxsync mSource.c_str(), cbWrittenTotal, rc));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync break;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
fd195826ea128c13e468ada8761c83d50c71c498vboxsync if (cbRead)
fd195826ea128c13e468ada8761c83d50c71c498vboxsync {
fd195826ea128c13e468ada8761c83d50c71c498vboxsync rc = RTFileWrite(fileDest, byBuf, cbRead, NULL /* No partial writes */);
fd195826ea128c13e468ada8761c83d50c71c498vboxsync if (RT_FAILURE(rc))
fd195826ea128c13e468ada8761c83d50c71c498vboxsync {
fd195826ea128c13e468ada8761c83d50c71c498vboxsync setProgressErrorMsg(VBOX_E_IPRT_ERROR,
fd195826ea128c13e468ada8761c83d50c71c498vboxsync Utf8StrFmt(GuestSession::tr("Error writing to file \"%s\" (%RU64 bytes left): %Rrc"),
fd195826ea128c13e468ada8761c83d50c71c498vboxsync mDest.c_str(), cbToRead, rc));
fd195826ea128c13e468ada8761c83d50c71c498vboxsync break;
fd195826ea128c13e468ada8761c83d50c71c498vboxsync }
fd195826ea128c13e468ada8761c83d50c71c498vboxsync
fd195826ea128c13e468ada8761c83d50c71c498vboxsync /* Only subtract bytes reported written by the guest. */
fd195826ea128c13e468ada8761c83d50c71c498vboxsync Assert(cbToRead >= cbRead);
fd195826ea128c13e468ada8761c83d50c71c498vboxsync cbToRead -= cbRead;
fd195826ea128c13e468ada8761c83d50c71c498vboxsync
fd195826ea128c13e468ada8761c83d50c71c498vboxsync /* Update total bytes written to the guest. */
fd195826ea128c13e468ada8761c83d50c71c498vboxsync cbWrittenTotal += cbRead;
fd195826ea128c13e468ada8761c83d50c71c498vboxsync Assert(cbWrittenTotal <= (uint64_t)objData.mObjectSize);
fd195826ea128c13e468ada8761c83d50c71c498vboxsync
fd195826ea128c13e468ada8761c83d50c71c498vboxsync /* Did the user cancel the operation above? */
fd195826ea128c13e468ada8761c83d50c71c498vboxsync if ( SUCCEEDED(mProgress->COMGETTER(Canceled(&fCanceled)))
fd195826ea128c13e468ada8761c83d50c71c498vboxsync && fCanceled)
fd195826ea128c13e468ada8761c83d50c71c498vboxsync break;
fd195826ea128c13e468ada8761c83d50c71c498vboxsync
fd195826ea128c13e468ada8761c83d50c71c498vboxsync rc = setProgress((ULONG)(cbWrittenTotal / ((uint64_t)objData.mObjectSize / 100.0)));
fd195826ea128c13e468ada8761c83d50c71c498vboxsync if (RT_FAILURE(rc))
fd195826ea128c13e468ada8761c83d50c71c498vboxsync break;
fd195826ea128c13e468ada8761c83d50c71c498vboxsync }
fd195826ea128c13e468ada8761c83d50c71c498vboxsync }
fd195826ea128c13e468ada8761c83d50c71c498vboxsync else if ( RT_FAILURE(rc)
fd195826ea128c13e468ada8761c83d50c71c498vboxsync || waitRes.mResult == ProcessWaitResult_Terminate
fd195826ea128c13e468ada8761c83d50c71c498vboxsync || waitRes.mResult == ProcessWaitResult_Error
fd195826ea128c13e468ada8761c83d50c71c498vboxsync || waitRes.mResult == ProcessWaitResult_Timeout)
fd195826ea128c13e468ada8761c83d50c71c498vboxsync {
fd195826ea128c13e468ada8761c83d50c71c498vboxsync if (RT_FAILURE(waitRes.mRC))
fd195826ea128c13e468ada8761c83d50c71c498vboxsync rc = waitRes.mRC;
fd195826ea128c13e468ada8761c83d50c71c498vboxsync break;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync } /* for */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
fd195826ea128c13e468ada8761c83d50c71c498vboxsync LogFlowThisFunc(("rc=%Rrc, cbWrittenTotal=%RU64, cbSize=%RI64, cbToRead=%RU64\n",
fd195826ea128c13e468ada8761c83d50c71c498vboxsync rc, cbWrittenTotal, objData.mObjectSize, cbToRead));
fd195826ea128c13e468ada8761c83d50c71c498vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if ( !fCanceled
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync || RT_SUCCESS(rc))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /*
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * Even if we succeeded until here make sure to check whether we really transfered
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * everything.
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if ( objData.mObjectSize > 0
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync && cbWrittenTotal == 0)
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* If nothing was transfered but the file size was > 0 then "vbox_cat" wasn't able to write
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * to the destination -> access denied. */
fd195826ea128c13e468ada8761c83d50c71c498vboxsync setProgressErrorMsg(VBOX_E_IPRT_ERROR,
fd195826ea128c13e468ada8761c83d50c71c498vboxsync Utf8StrFmt(GuestSession::tr("Access denied when copying file \"%s\" to \"%s\""),
fd195826ea128c13e468ada8761c83d50c71c498vboxsync mSource.c_str(), mDest.c_str()));
fd195826ea128c13e468ada8761c83d50c71c498vboxsync rc = VERR_GENERAL_FAILURE; /* Fudge. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync else if (cbWrittenTotal < (uint64_t)objData.mObjectSize)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* If we did not copy all let the user know. */
fd195826ea128c13e468ada8761c83d50c71c498vboxsync setProgressErrorMsg(VBOX_E_IPRT_ERROR,
fd195826ea128c13e468ada8761c83d50c71c498vboxsync Utf8StrFmt(GuestSession::tr("Copying file \"%s\" failed (%RU64/%RI64 bytes transfered)"),
fd195826ea128c13e468ada8761c83d50c71c498vboxsync mSource.c_str(), cbWrittenTotal, objData.mObjectSize));
fd195826ea128c13e468ada8761c83d50c71c498vboxsync rc = VERR_GENERAL_FAILURE; /* Fudge. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync else
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync ProcessStatus_T procStatus;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync LONG exitCode;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if ( ( SUCCEEDED(pProcess->COMGETTER(Status(&procStatus)))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync && procStatus != ProcessStatus_TerminatedNormally)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync || ( SUCCEEDED(pProcess->COMGETTER(ExitCode(&exitCode)))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync && exitCode != 0)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync )
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
fd195826ea128c13e468ada8761c83d50c71c498vboxsync setProgressErrorMsg(VBOX_E_IPRT_ERROR,
fd195826ea128c13e468ada8761c83d50c71c498vboxsync Utf8StrFmt(GuestSession::tr("Copying file \"%s\" failed with status %ld, exit code %d"),
fd195826ea128c13e468ada8761c83d50c71c498vboxsync mSource.c_str(), procStatus, exitCode)); /**@todo Add stringify methods! */
fd195826ea128c13e468ada8761c83d50c71c498vboxsync rc = VERR_GENERAL_FAILURE; /* Fudge. */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync else /* Yay, success! */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = setProgressSuccess();
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync pProcess->close();
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync RTFileClose(fileDest);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync LogFlowFuncLeaveRC(rc);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync return rc;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsyncint SessionTaskCopyFrom::RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync LogFlowThisFunc(("strDesc=%s, strSource=%s, strDest=%s, uFlags=%x\n",
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync strDesc.c_str(), mSource.c_str(), mDest.c_str(), mFlags));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync mDesc = strDesc;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync mProgress = pProgress;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync int rc = RTThreadCreate(NULL, SessionTaskCopyFrom::taskThread, this,
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync 0, RTTHREADTYPE_MAIN_HEAVY_WORKER, 0,
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync "gctlCpyFrom");
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync LogFlowFuncLeaveRC(rc);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return rc;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync/* static */
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsyncint SessionTaskCopyFrom::taskThread(RTTHREAD Thread, void *pvUser)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync std::auto_ptr<SessionTaskCopyFrom> task(static_cast<SessionTaskCopyFrom*>(pvUser));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync AssertReturn(task.get(), VERR_GENERAL_FAILURE);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync LogFlowFunc(("pTask=%p\n", task.get()));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return task->Run();
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsyncSessionTaskUpdateAdditions::SessionTaskUpdateAdditions(GuestSession *pSession,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync const Utf8Str &strSource, uint32_t uFlags)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync : GuestSessionTask(pSession)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync{
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mSource = strSource;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mFlags = uFlags;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync}
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsyncSessionTaskUpdateAdditions::~SessionTaskUpdateAdditions(void)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync{
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync}
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsyncint SessionTaskUpdateAdditions::copyFileToGuest(GuestSession *pSession, PRTISOFSFILE pISO,
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync Utf8Str const &strFileSource, const Utf8Str &strFileDest,
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync bool fOptional, uint32_t *pcbSize)
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync{
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync AssertPtrReturn(pSession, VERR_INVALID_POINTER);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync AssertPtrReturn(pISO, VERR_INVALID_POINTER);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync /* pcbSize is optional. */
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync uint32_t cbOffset;
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync size_t cbSize;
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync int rc = RTIsoFsGetFileInfo(pISO, strFileSource.c_str(), &cbOffset, &cbSize);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if (RT_FAILURE(rc))
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync {
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if (fOptional)
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync return VINF_SUCCESS;
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync return rc;
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync }
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync Assert(cbOffset);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync Assert(cbSize);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = RTFileSeek(pISO->file, cbOffset, RTFILE_SEEK_BEGIN, NULL);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync /* Copy over the Guest Additions file to the guest. */
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if (RT_SUCCESS(rc))
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync {
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync LogRel(("Copying Guest Additions installer file \"%s\" to \"%s\" on guest ...\n",
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync strFileSource.c_str(), strFileDest.c_str()));
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if (RT_SUCCESS(rc))
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync {
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync SessionTaskCopyTo *pTask = new SessionTaskCopyTo(pSession /* GuestSession */,
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync &pISO->file, cbOffset, cbSize,
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync strFileDest, CopyFileFlag_None);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync AssertPtrReturn(pTask, VERR_NO_MEMORY);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync ComObjPtr<Progress> pProgressCopyTo;
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = pSession->startTaskAsync(Utf8StrFmt(GuestSession::tr("Copying Guest Additions installer file \"%s\" to \"%s\" on guest"),
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync mSource.c_str(), strFileDest.c_str()),
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync pTask, pProgressCopyTo);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if (RT_SUCCESS(rc))
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync {
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync BOOL fCanceled = FALSE;
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync HRESULT hr = pProgressCopyTo->WaitForCompletion(-1);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if ( SUCCEEDED(pProgressCopyTo->COMGETTER(Canceled)(&fCanceled))
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync && fCanceled)
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync {
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = VERR_GENERAL_FAILURE; /* Fudge. */
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync }
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync else if (FAILED(hr))
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync {
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync Assert(FAILED(hr));
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = VERR_GENERAL_FAILURE; /* Fudge. */
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync }
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync }
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync }
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync }
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync /** @todo Note: Since there is no file locking involved at the moment, there can be modifications
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync * between finished copying, the verification and the actual execution. */
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync /* Determine where the installer image ended up and if it has the correct size. */
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if (RT_SUCCESS(rc))
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync {
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync LogRel(("Verifying Guest Additions installer file \"%s\" ...\n", strFileDest.c_str()));
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync GuestFsObjData objData;
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync int64_t cbSizeOnGuest;
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = pSession->fileQuerySizeInternal(strFileDest, &cbSizeOnGuest);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync#ifdef VBOX_SERVICE_ENVARG_BUG
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if (RT_FAILURE(rc))
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync {
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync /* Ugly hack: Because older Guest Additions have problems with environment variable
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync expansion in parameters we have to check an alternative location on Windows.
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync So check for "%TEMP%\" being "C:\\Windows\\system32\\EMP" actually. */
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if (strFileDest.startsWith("%TEMP%\\", RTCString::CaseSensitive))
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync {
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync Utf8Str strFileDestBug = "C:\\Windows\\system32\\EMP" + strFileDest.substr(sizeof("%TEMP%\\") - sizeof(char));
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = pSession->fileQuerySizeInternal(strFileDestBug, &cbSizeOnGuest);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync }
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync }
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync#endif
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if ( RT_SUCCESS(rc)
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync && cbSize == (uint64_t)cbSizeOnGuest)
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync {
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync LogRel(("Guest Additions installer file \"%s\" successfully verified\n",
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync strFileDest.c_str()));
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync }
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync else
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync {
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if (RT_SUCCESS(rc)) /* Size does not match. */
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = VERR_BROKEN_PIPE; /** @todo FInd a better error. */
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync }
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if (RT_SUCCESS(rc))
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync {
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if (pcbSize)
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync *pcbSize = cbSizeOnGuest;
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync }
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync }
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync return rc;
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync}
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsyncint SessionTaskUpdateAdditions::runFile(GuestSession *pSession, GuestProcessStartupInfo &procInfo)
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync{
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync AssertPtrReturn(pSession, VERR_INVALID_POINTER);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync#ifdef VBOX_SERVICE_ENVARG_BUG
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync GuestFsObjData objData;
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync int rc = pSession->fileQueryInfoInternal(procInfo.mCommand, objData);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if (RT_FAILURE(rc))
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync procInfo.mCommand = "C:\\Windows\\system32\\EMP" + procInfo.mCommand.substr(sizeof("%TEMP%\\") - sizeof(char));
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync#endif
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync ComObjPtr<GuestProcess> pProcess;
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = pSession->processCreateExInteral(procInfo, pProcess);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if (RT_SUCCESS(rc))
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = pProcess->startProcess();
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if (RT_SUCCESS(rc))
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync {
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync LogRel(("Running %s ...\n", procInfo.mName.c_str()));
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync GuestProcessWaitResult waitRes;
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = pProcess->waitFor(ProcessWaitForFlag_Terminate,
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync 10 * 60 * 1000 /* 10 mins Timeout */, waitRes);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if (waitRes.mResult == ProcessWaitResult_Terminate)
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync {
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync ProcessStatus_T procStatus;
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync LONG exitCode;
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if ( ( SUCCEEDED(pProcess->COMGETTER(Status(&procStatus)))
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync && procStatus != ProcessStatus_TerminatedNormally)
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync || ( SUCCEEDED(pProcess->COMGETTER(ExitCode(&exitCode)))
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync && exitCode != 0)
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync )
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync {
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync setProgressErrorMsg(VBOX_E_IPRT_ERROR,
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync Utf8StrFmt(GuestSession::tr("Running %s failed with status %ld, exit code %ld"),
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync procInfo.mName.c_str(), procStatus, exitCode));
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = VERR_GENERAL_FAILURE; /* Fudge. */
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync }
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync else /* Yay, success! */
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync {
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync LogRel(("%s successfully completed\n", procInfo.mName.c_str()));
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync }
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync }
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync else
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync {
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if (RT_FAILURE(rc))
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync setProgressErrorMsg(VBOX_E_IPRT_ERROR,
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync Utf8StrFmt(GuestSession::tr("Error while waiting running %s: %Rrc"),
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync procInfo.mName.c_str(), rc));
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync else
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync {
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync setProgressErrorMsg(VBOX_E_IPRT_ERROR, pProcess->errorMsg());
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = VERR_GENERAL_FAILURE; /* Fudge. */
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync }
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync }
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync }
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if (!pProcess.isNull())
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync pProcess->close();
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync return rc;
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync}
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsyncint SessionTaskUpdateAdditions::Run(void)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync{
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync LogFlowThisFuncEnter();
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync ComObjPtr<GuestSession> pSession = mSession;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Assert(!pSession.isNull());
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync AutoCaller autoCaller(pSession);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync int rc = setProgress(10);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (RT_FAILURE(rc))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync return rc;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync HRESULT hr = S_OK;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync LogRel(("Automatic update of Guest Additions started, using \"%s\"\n", mSource.c_str()));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /*
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * Determine guest OS type and the required installer image.
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * At the moment only Windows guests are supported.
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8Str strInstallerImage;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync ComObjPtr<Guest> pGuest(mSession->getParent());
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Bstr osTypeId;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if ( SUCCEEDED(pGuest->COMGETTER(OSTypeId(osTypeId.asOutParam())))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync && !osTypeId.isEmpty())
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8Str osTypeIdUtf8(osTypeId); /* Needed for .contains(). */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if ( osTypeIdUtf8.contains("Microsoft", Utf8Str::CaseInsensitive)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync || osTypeIdUtf8.contains("Windows", Utf8Str::CaseInsensitive))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (osTypeIdUtf8.contains("64", Utf8Str::CaseInsensitive))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync strInstallerImage = "VBOXWINDOWSADDITIONS_AMD64.EXE";
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync else
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync strInstallerImage = "VBOXWINDOWSADDITIONS_X86.EXE";
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Since the installers are located in the root directory,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * no further path processing needs to be done (yet). */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync else /* Everything else is not supported (yet). */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync hr = setProgressErrorMsg(VBOX_E_IPRT_ERROR,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Detected guest OS (%s) does not support automatic Guest Additions updating, please update manually"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync osTypeIdUtf8.c_str()));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = VERR_GENERAL_FAILURE; /* Fudge. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync else
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync hr = setProgressErrorMsg(VBOX_E_IPRT_ERROR,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Could not detected guest OS type/version, please update manually")));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = VERR_GENERAL_FAILURE; /* Fudge. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync RTISOFSFILE iso;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (RT_SUCCESS(rc))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Assert(!strInstallerImage.isEmpty());
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /*
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * Try to open the .ISO file and locate the specified installer.
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = RTIsoFsOpen(&iso, mSource.c_str());
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (RT_FAILURE(rc))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync hr = setProgressErrorMsg(VBOX_E_IPRT_ERROR,
ce46b563e3317d0c792fbe141e2978bfa0e91aaevboxsync Utf8StrFmt(GuestSession::tr("Unable to open Guest Additions .ISO file \"%s\": %Rrc"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mSource.c_str(), rc));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync else
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = setProgress(5);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /** @todo Add support for non-Windows as well! */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8Str strInstallerDest = "%TEMP%\\VBoxWindowsAdditions.exe";
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync bool fInstallCertificates = false;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (RT_SUCCESS(rc))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync /*
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync * Copy over main installer to the guest.
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync */
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = copyFileToGuest(pSession, &iso, strInstallerImage, strInstallerDest,
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync false /* File is not optional */, NULL /* cbSize */);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if (RT_SUCCESS(rc))
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = setProgress(20);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync /*
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync * Install needed certificates for the WHQL crap.
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync ** @todo Only for Windows!
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (RT_SUCCESS(rc))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = copyFileToGuest(pSession, &iso, "CERT/ORACLE_VBOX.CER", "%TEMP%\\oracle-vbox.cer",
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync true /* File is optional */, NULL /* cbSize */);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if (RT_SUCCESS(rc))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = setProgress(30);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if (RT_SUCCESS(rc))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = copyFileToGuest(pSession, &iso, "CERT/VBOXCERTUTIL.EXE", "%TEMP%\\VBoxCertUtil.exe",
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync true /* File is optional */, NULL /* cbSize */);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if (RT_SUCCESS(rc))
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync {
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync fInstallCertificates = true;
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = setProgress(40);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync }
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync else
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync hr = setProgressErrorMsg(VBOX_E_IPRT_ERROR,
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync Utf8StrFmt(GuestSession::tr("Error while copying certificate installation tool to the guest: %Rrc"), rc));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync else
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync hr = setProgressErrorMsg(VBOX_E_IPRT_ERROR,
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync Utf8StrFmt(GuestSession::tr("Error while copying certificate to the guest: %Rrc"), rc));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync /*
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync * Run VBoxCertUtil.exe to install the Oracle certificate.
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync */
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if ( RT_SUCCESS(rc)
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync && fInstallCertificates)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync LogRel(("Installing certificates on the guest ...\n"));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync GuestProcessStartupInfo procInfo;
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync procInfo.mName = Utf8StrFmt(GuestSession::tr("VirtualBox Guest Additions Certificate Utility"));
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync procInfo.mCommand = Utf8Str("%TEMP%\\VBoxCertUtil.exe");
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync procInfo.mFlags = ProcessCreateFlag_Hidden;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync /* Construct arguments. */
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync /** @todo Remove hardcoded paths. */
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync procInfo.mArguments.push_back(Utf8Str("add-trusted-publisher"));
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync /* Ugly hack: Because older Guest Additions have problems with environment variable
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync expansion in parameters we have to check an alternative location on Windows.
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync So check for "%TEMP%\VBoxWindowsAdditions.exe" in a screwed up way. */
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync#ifdef VBOX_SERVICE_ENVARG_BUG
ce46b563e3317d0c792fbe141e2978bfa0e91aaevboxsync GuestFsObjData objData;
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = pSession->fileQueryInfoInternal("%TEMP%\\oracle-vbox.cer", objData);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if (RT_SUCCESS(rc))
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync#endif
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync procInfo.mArguments.push_back(Utf8Str("%TEMP%\\oracle-vbox.cer"));
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync#ifdef VBOX_SERVICE_ENVARG_BUG
ce46b563e3317d0c792fbe141e2978bfa0e91aaevboxsync else
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync procInfo.mArguments.push_back(Utf8Str("C:\\Windows\\system32\\EMPoracle-vbox.cer"));
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync#endif
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync /* Overwrite rc in any case. */
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = runFile(pSession, procInfo);
ce46b563e3317d0c792fbe141e2978bfa0e91aaevboxsync }
ce46b563e3317d0c792fbe141e2978bfa0e91aaevboxsync
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if (RT_SUCCESS(rc))
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = setProgress(60);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (RT_SUCCESS(rc))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync {
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync LogRel(("Updating Guest Additions ...\n"));
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync GuestProcessStartupInfo procInfo;
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync procInfo.mName = Utf8StrFmt(GuestSession::tr("VirtualBox Guest Additions Setup"));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync procInfo.mCommand = Utf8Str(strInstallerDest);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync procInfo.mFlags = ProcessCreateFlag_Hidden;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* If the caller does not want to wait for out guest update process to end,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * complete the progress object now so that the caller can do other work. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (mFlags & AdditionsUpdateFlag_WaitForUpdateStartOnly)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync procInfo.mFlags |= ProcessCreateFlag_WaitForProcessStartOnly;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Construct arguments. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync procInfo.mArguments.push_back(Utf8Str("/S")); /* We want to install in silent mode. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync procInfo.mArguments.push_back(Utf8Str("/l")); /* ... and logging enabled. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Don't quit VBoxService during upgrade because it still is used for this
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * piece of code we're in right now (that is, here!) ... */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync procInfo.mArguments.push_back(Utf8Str("/no_vboxservice_exit"));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Tell the installer to report its current installation status
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * using a running VBoxTray instance via balloon messages in the
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * Windows taskbar. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync procInfo.mArguments.push_back(Utf8Str("/post_installstatus"));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = runFile(pSession, procInfo);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (RT_SUCCESS(rc))
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync hr = setProgressSuccess();
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync RTIsoFsClose(&iso);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync }
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync LogFlowFuncLeaveRC(rc);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync return rc;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync}
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsyncint SessionTaskUpdateAdditions::RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync{
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync LogFlowThisFunc(("strDesc=%s, strSource=%s, uFlags=%x\n",
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync strDesc.c_str(), mSource.c_str(), mFlags));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mDesc = strDesc;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mProgress = pProgress;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync int rc = RTThreadCreate(NULL, SessionTaskUpdateAdditions::taskThread, this,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync 0, RTTHREADTYPE_MAIN_HEAVY_WORKER, 0,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync "gctlUpGA");
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync LogFlowFuncLeaveRC(rc);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync return rc;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync}
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync/* static */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsyncint SessionTaskUpdateAdditions::taskThread(RTTHREAD Thread, void *pvUser)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync{
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync std::auto_ptr<SessionTaskUpdateAdditions> task(static_cast<SessionTaskUpdateAdditions*>(pvUser));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync AssertReturn(task.get(), VERR_GENERAL_FAILURE);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync LogFlowFunc(("pTask=%p\n", task.get()));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync return task->Run();
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync}
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync// public initializer/uninitializer for internal purposes only
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync/////////////////////////////////////////////////////////////////////////////
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
687794577e2e35c3cae67e692a7f2130d1262a82vboxsyncint GuestSession::init(Guest *aGuest, ULONG aSessionID,
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync Utf8Str aUser, Utf8Str aPassword, Utf8Str aDomain, Utf8Str aName)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
c142e0f462e6c921a73d84ee50f41396b3a99db5vboxsync AssertPtrReturn(aGuest, VERR_INVALID_POINTER);
c142e0f462e6c921a73d84ee50f41396b3a99db5vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync /* Enclose the state transition NotReady->InInit->Ready. */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoInitSpan autoInitSpan(this);
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync AssertReturn(autoInitSpan.isOk(), VERR_OBJECT_DESTROYED);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync mData.mTimeout = 30 * 60 * 1000; /* Session timeout is 30 mins by default. */
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync mData.mParent = aGuest;
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync mData.mId = aSessionID;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync mData.mCredentials.mUser = aUser;
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync mData.mCredentials.mPassword = aPassword;
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync mData.mCredentials.mDomain = aDomain;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync mData.mName = aName;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync /* Confirm a successful initialization when it's the case. */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync autoInitSpan.setSucceeded();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowFuncLeaveRC(VINF_SUCCESS);
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync return VINF_SUCCESS;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync/**
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * Uninitializes the instance.
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * Called from FinalRelease().
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncvoid GuestSession::uninit(void)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync /* Enclose the state transition Ready->InUninit->NotReady. */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoUninitSpan autoUninitSpan(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (autoUninitSpan.uninitDone())
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync return;
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync#ifdef VBOX_WITH_GUEST_CONTROL
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync for (SessionDirectories::iterator itDirs = mData.mDirectories.begin();
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync itDirs != mData.mDirectories.end(); ++itDirs)
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync {
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync (*itDirs)->uninit();
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync (*itDirs).setNull();
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync mData.mDirectories.clear();
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync for (SessionFiles::iterator itFiles = mData.mFiles.begin();
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync itFiles != mData.mFiles.end(); ++itFiles)
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync {
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync (*itFiles)->uninit();
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync (*itFiles).setNull();
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync mData.mFiles.clear();
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync for (SessionProcesses::iterator itProcs = mData.mProcesses.begin();
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync itProcs != mData.mProcesses.end(); ++itProcs)
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync {
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync itProcs->second->close();
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync }
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync for (SessionProcesses::iterator itProcs = mData.mProcesses.begin();
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync itProcs != mData.mProcesses.end(); ++itProcs)
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync {
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync itProcs->second->uninit();
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync itProcs->second.setNull();
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync mData.mProcesses.clear();
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync mData.mParent->sessionClose(this);
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncLeave();
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync#endif
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync// implementation of public getters/setters for attributes
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync/////////////////////////////////////////////////////////////////////////////
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::COMGETTER(User)(BSTR *aUser)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync CheckComArgOutPointerValid(aUser);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync mData.mCredentials.mUser.cloneTo(aUser);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowFuncLeaveRC(S_OK);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync return S_OK;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::COMGETTER(Domain)(BSTR *aDomain)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync CheckComArgOutPointerValid(aDomain);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync mData.mCredentials.mDomain.cloneTo(aDomain);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowFuncLeaveRC(S_OK);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync return S_OK;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::COMGETTER(Name)(BSTR *aName)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync CheckComArgOutPointerValid(aName);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync mData.mName.cloneTo(aName);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowFuncLeaveRC(S_OK);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync return S_OK;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncSTDMETHODIMP GuestSession::COMGETTER(Id)(ULONG *aId)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync CheckComArgOutPointerValid(aId);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync *aId = mData.mId;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowFuncLeaveRC(S_OK);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync return S_OK;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncSTDMETHODIMP GuestSession::COMGETTER(Timeout)(ULONG *aTimeout)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync CheckComArgOutPointerValid(aTimeout);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync *aTimeout = mData.mTimeout;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowFuncLeaveRC(S_OK);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync return S_OK;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
7e8ef90d3160234df0f254131b87af4243d79476vboxsyncSTDMETHODIMP GuestSession::COMSETTER(Timeout)(ULONG aTimeout)
7e8ef90d3160234df0f254131b87af4243d79476vboxsync{
7e8ef90d3160234df0f254131b87af4243d79476vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
7e8ef90d3160234df0f254131b87af4243d79476vboxsync ReturnComNotImplemented();
7e8ef90d3160234df0f254131b87af4243d79476vboxsync#else
7e8ef90d3160234df0f254131b87af4243d79476vboxsync LogFlowThisFuncEnter();
7e8ef90d3160234df0f254131b87af4243d79476vboxsync
7e8ef90d3160234df0f254131b87af4243d79476vboxsync AutoCaller autoCaller(this);
7e8ef90d3160234df0f254131b87af4243d79476vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
7e8ef90d3160234df0f254131b87af4243d79476vboxsync
7e8ef90d3160234df0f254131b87af4243d79476vboxsync AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
7e8ef90d3160234df0f254131b87af4243d79476vboxsync
7e8ef90d3160234df0f254131b87af4243d79476vboxsync mData.mTimeout = aTimeout;
7e8ef90d3160234df0f254131b87af4243d79476vboxsync
7e8ef90d3160234df0f254131b87af4243d79476vboxsync LogFlowFuncLeaveRC(S_OK);
7e8ef90d3160234df0f254131b87af4243d79476vboxsync return S_OK;
7e8ef90d3160234df0f254131b87af4243d79476vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
7e8ef90d3160234df0f254131b87af4243d79476vboxsync}
7e8ef90d3160234df0f254131b87af4243d79476vboxsync
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::COMGETTER(Environment)(ComSafeArrayOut(BSTR, aEnvironment))
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync CheckComArgOutSafeArrayPointerValid(aEnvironment);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync size_t cEnvVars = mData.mEnvironment.Size();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFunc(("%s cEnvVars=%RU32\n", mData.mName.c_str(), cEnvVars));
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync com::SafeArray<BSTR> environment(cEnvVars);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync for (size_t i = 0; i < cEnvVars; i++)
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync {
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync Bstr strEnv(mData.mEnvironment.Get(i));
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync strEnv.cloneTo(&environment[i]);
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync }
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync environment.detachTo(ComSafeArrayOutArg(aEnvironment));
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowFuncLeaveRC(S_OK);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync return S_OK;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsyncSTDMETHODIMP GuestSession::COMSETTER(Environment)(ComSafeArrayIn(IN_BSTR, aValues))
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync{
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync ReturnComNotImplemented();
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync#else
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync LogFlowThisFuncEnter();
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync AutoCaller autoCaller(this);
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync com::SafeArray<IN_BSTR> environment(ComSafeArrayInArg(aValues));
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync int rc = VINF_SUCCESS;
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync for (size_t i = 0; i < environment.size() && RT_SUCCESS(rc); i++)
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync {
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync Utf8Str strEnv(environment[i]);
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync if (!strEnv.isEmpty()) /* Silently skip empty entries. */
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync rc = mData.mEnvironment.Set(strEnv);
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync }
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync HRESULT hr = RT_SUCCESS(rc) ? S_OK : VBOX_E_IPRT_ERROR;
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync LogFlowFuncLeaveRC(hr);
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync return hr;
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync}
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncSTDMETHODIMP GuestSession::COMGETTER(Processes)(ComSafeArrayOut(IGuestProcess *, aProcesses))
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync CheckComArgOutSafeArrayPointerValid(aProcesses);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync SafeIfaceArray<IGuestProcess> collection(mData.mProcesses);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync collection.detachTo(ComSafeArrayOutArg(aProcesses));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowFuncLeaveRC(S_OK);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync return S_OK;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncSTDMETHODIMP GuestSession::COMGETTER(Directories)(ComSafeArrayOut(IGuestDirectory *, aDirectories))
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync CheckComArgOutSafeArrayPointerValid(aDirectories);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync SafeIfaceArray<IGuestDirectory> collection(mData.mDirectories);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync collection.detachTo(ComSafeArrayOutArg(aDirectories));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowFuncLeaveRC(S_OK);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync return S_OK;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncSTDMETHODIMP GuestSession::COMGETTER(Files)(ComSafeArrayOut(IGuestFile *, aFiles))
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync CheckComArgOutSafeArrayPointerValid(aFiles);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync SafeIfaceArray<IGuestFile> collection(mData.mFiles);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync collection.detachTo(ComSafeArrayOutArg(aFiles));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowFuncLeaveRC(S_OK);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync return S_OK;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync// private methods
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync/////////////////////////////////////////////////////////////////////////////
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsyncint GuestSession::directoryClose(ComObjPtr<GuestDirectory> pDirectory)
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync{
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync for (SessionDirectories::iterator itDirs = mData.mDirectories.begin();
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync itDirs != mData.mDirectories.end(); ++itDirs)
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync {
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync if (pDirectory == (*itDirs))
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync {
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync mData.mDirectories.erase(itDirs);
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync return VINF_SUCCESS;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync return VERR_NOT_FOUND;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync}
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsyncint GuestSession::directoryCreateInternal(const Utf8Str &strPath, uint32_t uMode, uint32_t uFlags, ComObjPtr<GuestDirectory> &pDirectory)
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync{
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync LogFlowThisFunc(("strPath=%s, uMode=%x, uFlags=%x\n",
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync strPath.c_str(), uMode, uFlags));
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync GuestProcessStartupInfo procInfo;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync procInfo.mName = Utf8StrFmt(tr("Creating directory \"%s\"", strPath.c_str()));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync procInfo.mCommand = Utf8Str(VBOXSERVICE_TOOL_MKDIR);
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync procInfo.mFlags = ProcessCreateFlag_Hidden;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync int rc = VINF_SUCCESS;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync /* Construct arguments. */
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (uFlags & DirectoryCreateFlag_Parents)
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync procInfo.mArguments.push_back(Utf8Str("--parents")); /* We also want to create the parent directories. */
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (uMode)
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync {
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync procInfo.mArguments.push_back(Utf8Str("--mode")); /* Set the creation mode. */
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync char szMode[16];
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (RTStrPrintf(szMode, sizeof(szMode), "%o", uMode))
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync {
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync procInfo.mArguments.push_back(Utf8Str(szMode));
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync }
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync else
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync rc = VERR_INVALID_PARAMETER;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync }
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync procInfo.mArguments.push_back(strPath); /* The directory we want to create. */
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync ComObjPtr<GuestProcess> pProcess;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync rc = processCreateExInteral(procInfo, pProcess);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (RT_SUCCESS(rc))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync rc = pProcess->startProcess();
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (RT_SUCCESS(rc))
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync {
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync GuestProcessWaitResult waitRes;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync rc = pProcess->waitFor(ProcessWaitForFlag_Terminate, 30 * 1000 /* Timeout */, waitRes);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (RT_SUCCESS(rc))
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync {
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync ProcessStatus_T procStatus;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync HRESULT hr = pProcess->COMGETTER(Status)(&procStatus);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync ComAssertComRC(hr);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (procStatus == ProcessStatus_TerminatedNormally)
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync {
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync LONG lExitCode;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync pProcess->COMGETTER(ExitCode)(&lExitCode);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (lExitCode != 0)
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync return VERR_CANT_CREATE;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync }
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync else
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync rc = VERR_BROKEN_PIPE; /** @todo Find a better rc. */
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync }
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync }
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (RT_FAILURE(rc))
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync return rc;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Create the directory object. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync HRESULT hr = pDirectory.createObject();
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (FAILED(hr))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync return VERR_COM_UNEXPECTED;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Note: There will be a race between creating and getting/initing the directory
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync object here. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = pDirectory->init(this /* Parent */, strPath);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (RT_FAILURE(rc))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync return rc;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Add the created directory to our vector. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mData.mDirectories.push_back(pDirectory);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync LogFlowFunc(("Added new directory \"%s\" (Session: %RU32)\n",
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync strPath.c_str(), mData.mId));
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync LogFlowFuncLeaveRC(rc);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync return rc;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync}
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsyncint GuestSession::directoryOpenInternal(const Utf8Str &strPath, const Utf8Str &strFilter,
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync uint32_t uFlags, ComObjPtr<GuestDirectory> &pDirectory)
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync{
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync LogFlowThisFunc(("strPath=%s, strPath=%s, uFlags=%x\n",
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync strPath.c_str(), strFilter.c_str(), uFlags));
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Create the directory object. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync HRESULT hr = pDirectory.createObject();
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (FAILED(hr))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync return VERR_COM_UNEXPECTED;
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync int rc = pDirectory->init(this /* Parent */,
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync strPath, strFilter, uFlags);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (RT_FAILURE(rc))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync return rc;
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Add the created directory to our vector. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mData.mDirectories.push_back(pDirectory);
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync LogFlowFunc(("Added new directory \"%s\" (Session: %RU32)\n",
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync strPath.c_str(), mData.mId));
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync LogFlowFuncLeaveRC(rc);
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync return rc;
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync}
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
687794577e2e35c3cae67e692a7f2130d1262a82vboxsyncint GuestSession::dispatchToProcess(uint32_t uContextID, uint32_t uFunction, void *pvData, size_t cbData)
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync{
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync LogFlowFuncEnter();
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync uint32_t uProcessID = VBOX_GUESTCTRL_CONTEXTID_GET_PROCESS(uContextID);
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync#ifdef DEBUG
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync LogFlowFunc(("uProcessID=%RU32 (%RU32 total)\n",
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync uProcessID, mData.mProcesses.size()));
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync#endif
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync int rc;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync SessionProcesses::const_iterator itProc
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync = mData.mProcesses.find(uProcessID);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync if (itProc != mData.mProcesses.end())
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync {
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync ComObjPtr<GuestProcess> pProcess(itProc->second);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync Assert(!pProcess.isNull());
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync alock.release();
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync rc = pProcess->callbackDispatcher(uContextID, uFunction, pvData, cbData);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync }
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync else
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync rc = VERR_NOT_FOUND;
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync LogFlowFuncLeaveRC(rc);
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync return rc;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync}
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsyncint GuestSession::fileClose(ComObjPtr<GuestFile> pFile)
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync{
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync for (SessionFiles::iterator itFiles = mData.mFiles.begin();
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync itFiles != mData.mFiles.end(); ++itFiles)
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync {
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync if (pFile == (*itFiles))
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync {
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync mData.mFiles.erase(itFiles);
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync return VINF_SUCCESS;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync return VERR_NOT_FOUND;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync}
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
004d74842597dacc4009803171296dfcf9398c69vboxsync/**
004d74842597dacc4009803171296dfcf9398c69vboxsync * Implementation of FileRemove(). Can throw an exception due to the use of
004d74842597dacc4009803171296dfcf9398c69vboxsync * Utf8Str, Utf8StrFmt and std::vector near the beginning (and others?). The
004d74842597dacc4009803171296dfcf9398c69vboxsync * caller should catch this. On success, *prc will be set to the return code
004d74842597dacc4009803171296dfcf9398c69vboxsync * of the delete operation to distinguish between API and command failure.
004d74842597dacc4009803171296dfcf9398c69vboxsync */
004d74842597dacc4009803171296dfcf9398c69vboxsyncint GuestSession::fileRemoveInternal(Utf8Str strPath, int *prc)
004d74842597dacc4009803171296dfcf9398c69vboxsync{
004d74842597dacc4009803171296dfcf9398c69vboxsync GuestProcessStartupInfo procInfo;
004d74842597dacc4009803171296dfcf9398c69vboxsync GuestProcessStream streamOut;
004d74842597dacc4009803171296dfcf9398c69vboxsync int rc = VINF_SUCCESS;
004d74842597dacc4009803171296dfcf9398c69vboxsync
004d74842597dacc4009803171296dfcf9398c69vboxsync AssertPtrReturn(prc, VERR_INVALID_POINTER);
004d74842597dacc4009803171296dfcf9398c69vboxsync procInfo.mName = Utf8StrFmt(tr("Removing file \"%s\"",
004d74842597dacc4009803171296dfcf9398c69vboxsync strPath.c_str()));
004d74842597dacc4009803171296dfcf9398c69vboxsync procInfo.mCommand = Utf8Str(VBOXSERVICE_TOOL_RM);
004d74842597dacc4009803171296dfcf9398c69vboxsync procInfo.mFlags = ProcessCreateFlag_Hidden
004d74842597dacc4009803171296dfcf9398c69vboxsync | ProcessCreateFlag_WaitForStdOut;
004d74842597dacc4009803171296dfcf9398c69vboxsync /* Construct arguments. */
004d74842597dacc4009803171296dfcf9398c69vboxsync procInfo.mArguments.push_back(Utf8Str("--machinereadable"));
004d74842597dacc4009803171296dfcf9398c69vboxsync procInfo.mArguments.push_back(strPath); /* The directory we want to create. */
004d74842597dacc4009803171296dfcf9398c69vboxsync
004d74842597dacc4009803171296dfcf9398c69vboxsync ComObjPtr<GuestProcess> pProcess;
004d74842597dacc4009803171296dfcf9398c69vboxsync rc = processCreateExInteral(procInfo, pProcess);
004d74842597dacc4009803171296dfcf9398c69vboxsync if (RT_SUCCESS(rc))
004d74842597dacc4009803171296dfcf9398c69vboxsync rc = pProcess->startProcess();
004d74842597dacc4009803171296dfcf9398c69vboxsync if (RT_SUCCESS(rc))
004d74842597dacc4009803171296dfcf9398c69vboxsync {
004d74842597dacc4009803171296dfcf9398c69vboxsync GuestProcessWaitResult waitRes;
004d74842597dacc4009803171296dfcf9398c69vboxsync BYTE byBuf[_64K];
004d74842597dacc4009803171296dfcf9398c69vboxsync size_t cbRead;
004d74842597dacc4009803171296dfcf9398c69vboxsync
004d74842597dacc4009803171296dfcf9398c69vboxsync for (;;)
004d74842597dacc4009803171296dfcf9398c69vboxsync {
004d74842597dacc4009803171296dfcf9398c69vboxsync rc = pProcess->waitFor(ProcessWaitForFlag_StdOut,
004d74842597dacc4009803171296dfcf9398c69vboxsync 30 * 1000 /* Timeout */, waitRes);
004d74842597dacc4009803171296dfcf9398c69vboxsync if ( RT_FAILURE(rc)
004d74842597dacc4009803171296dfcf9398c69vboxsync || waitRes.mResult == ProcessWaitResult_Terminate
004d74842597dacc4009803171296dfcf9398c69vboxsync || waitRes.mResult == ProcessWaitResult_Error
004d74842597dacc4009803171296dfcf9398c69vboxsync || waitRes.mResult == ProcessWaitResult_Timeout)
004d74842597dacc4009803171296dfcf9398c69vboxsync {
004d74842597dacc4009803171296dfcf9398c69vboxsync break;
004d74842597dacc4009803171296dfcf9398c69vboxsync }
004d74842597dacc4009803171296dfcf9398c69vboxsync
004d74842597dacc4009803171296dfcf9398c69vboxsync rc = pProcess->readData(OUTPUT_HANDLE_ID_STDOUT, sizeof(byBuf),
004d74842597dacc4009803171296dfcf9398c69vboxsync 30 * 1000 /* Timeout */, byBuf, sizeof(byBuf),
004d74842597dacc4009803171296dfcf9398c69vboxsync &cbRead);
004d74842597dacc4009803171296dfcf9398c69vboxsync if (RT_FAILURE(rc))
004d74842597dacc4009803171296dfcf9398c69vboxsync break;
004d74842597dacc4009803171296dfcf9398c69vboxsync
004d74842597dacc4009803171296dfcf9398c69vboxsync if (cbRead)
004d74842597dacc4009803171296dfcf9398c69vboxsync {
004d74842597dacc4009803171296dfcf9398c69vboxsync rc = streamOut.AddData(byBuf, cbRead);
004d74842597dacc4009803171296dfcf9398c69vboxsync if (RT_FAILURE(rc))
004d74842597dacc4009803171296dfcf9398c69vboxsync break;
004d74842597dacc4009803171296dfcf9398c69vboxsync }
004d74842597dacc4009803171296dfcf9398c69vboxsync }
004d74842597dacc4009803171296dfcf9398c69vboxsync
004d74842597dacc4009803171296dfcf9398c69vboxsync LogFlowThisFunc(("rc=%Rrc, cbRead=%RU32, cbStreamOut=%RU32\n",
004d74842597dacc4009803171296dfcf9398c69vboxsync rc, cbRead, streamOut.GetSize()));
004d74842597dacc4009803171296dfcf9398c69vboxsync }
004d74842597dacc4009803171296dfcf9398c69vboxsync else
004d74842597dacc4009803171296dfcf9398c69vboxsync LogThisFunc(("Error starting delete tool on guest: %Rrc\n", rc));
004d74842597dacc4009803171296dfcf9398c69vboxsync if (RT_FAILURE(rc))
004d74842597dacc4009803171296dfcf9398c69vboxsync LogThisFunc(("Error running delete tool on guest: %Rrc\n", rc));
004d74842597dacc4009803171296dfcf9398c69vboxsync else if (!streamOut.GetSize())
004d74842597dacc4009803171296dfcf9398c69vboxsync {
004d74842597dacc4009803171296dfcf9398c69vboxsync LogThisFunc(("No return code after deleting file"));
004d74842597dacc4009803171296dfcf9398c69vboxsync rc = VERR_NO_DATA;
004d74842597dacc4009803171296dfcf9398c69vboxsync }
004d74842597dacc4009803171296dfcf9398c69vboxsync if (RT_SUCCESS(rc))
004d74842597dacc4009803171296dfcf9398c69vboxsync {
004d74842597dacc4009803171296dfcf9398c69vboxsync GuestProcessStreamBlock streamBlock;
004d74842597dacc4009803171296dfcf9398c69vboxsync int64_t i64rc;
004d74842597dacc4009803171296dfcf9398c69vboxsync rc = streamOut.ParseBlock(streamBlock);
004d74842597dacc4009803171296dfcf9398c69vboxsync streamBlock.GetString("fname");
004d74842597dacc4009803171296dfcf9398c69vboxsync rc = streamBlock.GetInt64Ex("rc", &i64rc);
004d74842597dacc4009803171296dfcf9398c69vboxsync if (RT_SUCCESS(rc))
004d74842597dacc4009803171296dfcf9398c69vboxsync *prc = (int)i64rc;
004d74842597dacc4009803171296dfcf9398c69vboxsync }
004d74842597dacc4009803171296dfcf9398c69vboxsync else
004d74842597dacc4009803171296dfcf9398c69vboxsync Log(("Error getting return code from deleting file: %Rrc\n", rc));
004d74842597dacc4009803171296dfcf9398c69vboxsync return rc;
004d74842597dacc4009803171296dfcf9398c69vboxsync}
004d74842597dacc4009803171296dfcf9398c69vboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsyncint GuestSession::fileOpenInternal(const Utf8Str &strPath, const Utf8Str &strOpenMode, const Utf8Str &strDisposition,
5366e994777f9d9391cf809dc77610f57270d75dvboxsync uint32_t uCreationMode, int64_t iOffset, ComObjPtr<GuestFile> &pFile)
5366e994777f9d9391cf809dc77610f57270d75dvboxsync{
5366e994777f9d9391cf809dc77610f57270d75dvboxsync LogFlowThisFunc(("strPath=%s, strOpenMode=%s, strDisposition=%s, uCreationMode=%x, iOffset=%RI64\n",
5366e994777f9d9391cf809dc77610f57270d75dvboxsync strPath.c_str(), strOpenMode.c_str(), strDisposition.c_str(), uCreationMode, iOffset));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Create the directory object. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync HRESULT hr = pFile.createObject();
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (FAILED(hr))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync return VERR_COM_UNEXPECTED;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Note: There will be a race between creating and getting/initing the directory
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync object here. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync int rc = pFile->init(this /* Parent */,
5366e994777f9d9391cf809dc77610f57270d75dvboxsync strPath, strOpenMode, strDisposition, uCreationMode, iOffset);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (RT_FAILURE(rc))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync return rc;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Add the created directory to our vector. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mData.mFiles.push_back(pFile);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync LogFlowFunc(("Added new file \"%s\" (Session: %RU32\n",
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync strPath.c_str(), mData.mId));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync LogFlowFuncLeaveRC(rc);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync return rc;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync}
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync/* Note: Will work on directories and others, too. */
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsyncint GuestSession::fileQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData)
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync{
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync LogFlowThisFunc(("strPath=%s\n", strPath.c_str()));
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync GuestProcessStartupInfo procInfo;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync procInfo.mName = Utf8StrFmt(tr("Querying info for \"%s\""), strPath.c_str());
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync procInfo.mCommand = Utf8Str(VBOXSERVICE_TOOL_STAT);
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync procInfo.mFlags = ProcessCreateFlag_Hidden | ProcessCreateFlag_WaitForStdOut;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync /* Construct arguments. */
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync procInfo.mArguments.push_back(Utf8Str("--machinereadable"));
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync procInfo.mArguments.push_back(strPath);
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync GuestProcessStream streamOut;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync ComObjPtr<GuestProcess> pProcess;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync int rc = processCreateExInteral(procInfo, pProcess);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (RT_SUCCESS(rc))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync rc = pProcess->startProcess();
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync if (RT_SUCCESS(rc))
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync {
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync GuestProcessWaitResult waitRes;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync BYTE byBuf[_64K];
5366e994777f9d9391cf809dc77610f57270d75dvboxsync size_t cbRead = 0;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync /** @todo Merge with GuestDirectory::read. */
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync for (;;)
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync {
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync rc = pProcess->waitFor(ProcessWaitForFlag_StdOut,
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync 30 * 1000 /* Timeout */, waitRes);
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync if ( RT_FAILURE(rc)
5366e994777f9d9391cf809dc77610f57270d75dvboxsync || waitRes.mResult == ProcessWaitResult_Terminate
5366e994777f9d9391cf809dc77610f57270d75dvboxsync || waitRes.mResult == ProcessWaitResult_Error
5366e994777f9d9391cf809dc77610f57270d75dvboxsync || waitRes.mResult == ProcessWaitResult_Timeout)
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync {
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync break;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync }
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync rc = pProcess->readData(OUTPUT_HANDLE_ID_STDOUT, sizeof(byBuf),
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync 30 * 1000 /* Timeout */, byBuf, sizeof(byBuf),
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync &cbRead);
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync if (RT_FAILURE(rc))
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync break;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (cbRead)
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync rc = streamOut.AddData(byBuf, cbRead);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (RT_FAILURE(rc))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync break;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync }
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync LogFlowThisFunc(("rc=%Rrc, cbRead=%RU64, cbStreamOut=%RU32\n",
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync rc, cbRead, streamOut.GetSize()));
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync }
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync if (RT_SUCCESS(rc))
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync {
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync GuestProcessStreamBlock streamBlock;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync rc = streamOut.ParseBlock(streamBlock);
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync if (RT_SUCCESS(rc))
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync {
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync rc = objData.FromStat(streamBlock);
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync }
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync else
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync AssertMsgFailed(("Parsing stream block failed: %Rrc\n", rc));
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync }
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync LogFlowFuncLeaveRC(rc);
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync return rc;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync}
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsyncint GuestSession::fileQuerySizeInternal(const Utf8Str &strPath, int64_t *pllSize)
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync{
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync AssertPtrReturn(pllSize, VERR_INVALID_POINTER);
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync GuestFsObjData objData;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync int rc = fileQueryInfoInternal(strPath, objData);
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync if (RT_SUCCESS(rc))
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync {
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync if (objData.mType == FsObjType_File)
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync *pllSize = objData.mObjectSize;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync else
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync rc = VERR_NOT_A_FILE;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync }
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync return rc;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync}
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsyncconst GuestCredentials& GuestSession::getCredentials(void)
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync{
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync return mData.mCredentials;
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync}
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsyncconst GuestEnvironment& GuestSession::getEnvironment(void)
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync{
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync return mData.mEnvironment;
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync}
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync
40c1a23e86c79b24a917a43c186b2e54504d12c1vboxsyncUtf8Str GuestSession::getName(void)
40c1a23e86c79b24a917a43c186b2e54504d12c1vboxsync{
40c1a23e86c79b24a917a43c186b2e54504d12c1vboxsync return mData.mName;
40c1a23e86c79b24a917a43c186b2e54504d12c1vboxsync}
40c1a23e86c79b24a917a43c186b2e54504d12c1vboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsyncint GuestSession::processClose(ComObjPtr<GuestProcess> pProcess)
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync{
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync for (SessionProcesses::iterator itProcs = mData.mProcesses.begin();
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync itProcs != mData.mProcesses.end(); ++itProcs)
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync {
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync if (pProcess == itProcs->second)
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync {
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync LogFlowFunc(("Removing process (Session: %RU32) with process ID=%RU32, guest PID=%RU32 (now total %ld processes)\n",
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync mData.mId, itProcs->second->getProcessID(), itProcs->second->getPID(), mData.mProcesses.size() - 1));
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync mData.mProcesses.erase(itProcs);
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync return VINF_SUCCESS;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync return VERR_NOT_FOUND;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync}
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync/**
5366e994777f9d9391cf809dc77610f57270d75dvboxsync * Creates but does *not* start the process yet. See GuestProcess::startProcess() or
5366e994777f9d9391cf809dc77610f57270d75dvboxsync * GuestProcess::startProcessAsync() for that.
5366e994777f9d9391cf809dc77610f57270d75dvboxsync *
5366e994777f9d9391cf809dc77610f57270d75dvboxsync * @return IPRT status code.
5366e994777f9d9391cf809dc77610f57270d75dvboxsync * @param procInfo
5366e994777f9d9391cf809dc77610f57270d75dvboxsync * @param pProcess
5366e994777f9d9391cf809dc77610f57270d75dvboxsync */
5366e994777f9d9391cf809dc77610f57270d75dvboxsyncint GuestSession::processCreateExInteral(GuestProcessStartupInfo &procInfo, ComObjPtr<GuestProcess> &pProcess)
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync{
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync LogFlowFunc(("mCmd=%s, mFlags=%x, mTimeoutMS=%RU32\n",
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync procInfo.mCommand.c_str(), procInfo.mFlags, procInfo.mTimeoutMS));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync#ifdef DEBUG
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (procInfo.mArguments.size())
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync LogFlowFunc(("Arguments:"));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync ProcessArguments::const_iterator it = procInfo.mArguments.begin();
5366e994777f9d9391cf809dc77610f57270d75dvboxsync while (it != procInfo.mArguments.end())
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync LogFlow((" %s", (*it).c_str()));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync it++;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync LogFlow(("\n"));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync#endif
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync /* Validate flags. */
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync if (procInfo.mFlags)
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync {
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync if ( !(procInfo.mFlags & ProcessCreateFlag_IgnoreOrphanedProcesses)
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync && !(procInfo.mFlags & ProcessCreateFlag_WaitForProcessStartOnly)
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync && !(procInfo.mFlags & ProcessCreateFlag_Hidden)
7e8ef90d3160234df0f254131b87af4243d79476vboxsync && !(procInfo.mFlags & ProcessCreateFlag_NoProfile)
7e8ef90d3160234df0f254131b87af4243d79476vboxsync && !(procInfo.mFlags & ProcessCreateFlag_WaitForStdOut)
7e8ef90d3160234df0f254131b87af4243d79476vboxsync && !(procInfo.mFlags & ProcessCreateFlag_WaitForStdErr))
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync {
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync return VERR_INVALID_PARAMETER;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync /* Adjust timeout. If set to 0, we define
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync * an infinite timeout. */
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync if (procInfo.mTimeoutMS == 0)
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync procInfo.mTimeoutMS = UINT32_MAX;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync /** @tood Implement process priority + affinity. */
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync int rc = VERR_MAX_PROCS_REACHED;
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync if (mData.mProcesses.size() >= VBOX_GUESTCTRL_MAX_PROCESSES)
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync return rc;
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync /* Create a new (host-based) process ID and assign it. */
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync uint32_t uNewProcessID = 0;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync ULONG uTries = 0;
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync for (;;)
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync {
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync /* Is the context ID already used? */
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync if (!processExists(uNewProcessID, NULL /* pProgress */))
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync {
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync /* Callback with context ID was not found. This means
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync * we can use this context ID for our new callback we want
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync * to add below. */
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync rc = VINF_SUCCESS;
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync break;
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync }
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync uNewProcessID++;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync if (uNewProcessID == VBOX_GUESTCTRL_MAX_PROCESSES)
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync uNewProcessID = 0;
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync if (++uTries == UINT32_MAX)
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync break; /* Don't try too hard. */
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync }
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (RT_FAILURE(rc))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync return rc;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Create the process object. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync HRESULT hr = pProcess.createObject();
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (FAILED(hr))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync return VERR_COM_UNEXPECTED;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = pProcess->init(mData.mParent->getConsole() /* Console */, this /* Session */,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync uNewProcessID, procInfo);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (RT_FAILURE(rc))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync return rc;
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Add the created process to our map. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mData.mProcesses[uNewProcessID] = pProcess;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync LogFlowFunc(("Added new process (Session: %RU32) with process ID=%RU32 (now total %ld processes)\n",
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mData.mId, uNewProcessID, mData.mProcesses.size()));
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync return rc;
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync}
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
ccbdc11833996cb9f3be7868f1ebaefcacafb94dvboxsyncinline bool GuestSession::processExists(uint32_t uProcessID, ComObjPtr<GuestProcess> *pProcess)
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync{
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync SessionProcesses::const_iterator it = mData.mProcesses.find(uProcessID);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync if (it != mData.mProcesses.end())
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync {
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync if (pProcess)
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync *pProcess = it->second;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync return true;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync }
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync return false;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync}
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync
687794577e2e35c3cae67e692a7f2130d1262a82vboxsyncinline int GuestSession::processGetByPID(ULONG uPID, ComObjPtr<GuestProcess> *pProcess)
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync{
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync AssertReturn(uPID, false);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync /* pProcess is optional. */
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync SessionProcesses::iterator it = mData.mProcesses.begin();
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync for (; it != mData.mProcesses.end(); it++)
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync {
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync ComObjPtr<GuestProcess> pCurProc = it->second;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync AutoCaller procCaller(pCurProc);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync if (procCaller.rc())
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync return VERR_COM_INVALID_OBJECT_STATE;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync if (it->second->getPID() == uPID)
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync {
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync if (pProcess)
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync *pProcess = pCurProc;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync return VINF_SUCCESS;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync }
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync }
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync return VERR_NOT_FOUND;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync}
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsyncint GuestSession::startTaskAsync(const Utf8Str &strTaskDesc,
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync GuestSessionTask *pTask, ComObjPtr<Progress> &pProgress)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync LogFlowThisFunc(("strTaskDesc=%s, pTask=%p\n", strTaskDesc.c_str(), pTask));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync AssertPtrReturn(pTask, VERR_INVALID_POINTER);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Create the progress object. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync HRESULT hr = pProgress.createObject();
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (FAILED(hr))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync return VERR_COM_UNEXPECTED;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync hr = pProgress->init(static_cast<IGuestSession*>(this),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Bstr(strTaskDesc).raw(),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync TRUE /* aCancelable */);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (FAILED(hr))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync return VERR_COM_UNEXPECTED;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Initialize our worker task. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync std::auto_ptr<GuestSessionTask> task(pTask);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync int rc = task->RunAsync(strTaskDesc, pProgress);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (RT_FAILURE(rc))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync return rc;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Don't destruct on success. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync task.release();
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync LogFlowFuncLeaveRC(rc);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return rc;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync/**
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync * Queries/collects information prior to establishing a guest session.
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync * This is necessary to know which guest control protocol version to use,
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync * among other things (later).
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync *
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync * @return IPRT status code.
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync */
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsyncint GuestSession::queryInfo(void)
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync{
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync#if 1
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync /* Since the new functions were not implemented yet, force Main to use protocol ver 1. */
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync mData.mProtocolVersion = 1;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync#else
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync /*
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync * Try querying the guest control protocol version running on the guest.
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync * This is done using the Guest Additions version
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync */
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync ComObjPtr<Guest> pGuest = mData.mParent;
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync Assert(!pGuest.isNull());
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync uint32_t uVerAdditions = pGuest->getAdditionsVersion();
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync mData.mProtocolVersion = ( VBOX_FULL_VERSION_GET_MAJOR(uVerAdditions) >= 4
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync && VBOX_FULL_VERSION_GET_MINOR(uVerAdditions) >= 2) /** @todo What's about v5.0 ? */
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync ? 2 /* Guest control 2.0. */
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync : 1; /* Legacy guest control (VBox < 4.2). */
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync /* Build revision is ignored. */
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync /* Tell the user but don't bitch too often. */
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync static short s_gctrlLegacyWarning = 0;
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync if (s_gctrlLegacyWarning++ < 3) /** @todo Find a bit nicer text. */
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync LogRel((tr("Warning: Guest Additions are older (%ld.%ld) than host capabilities for guest control, please upgrade them. Using protocol version %ld now\n"),
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync VBOX_FULL_VERSION_GET_MAJOR(uVerAdditions), VBOX_FULL_VERSION_GET_MINOR(uVerAdditions), mData.mProtocolVersion));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync#endif
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync return VINF_SUCCESS;
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync}
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync// implementation of public methods
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync/////////////////////////////////////////////////////////////////////////////
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncSTDMETHODIMP GuestSession::Close(void)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync uninit();
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowFuncLeaveRC(S_OK);
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync return S_OK;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsyncSTDMETHODIMP GuestSession::CopyFrom(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(CopyFileFlag_T, aFlags), IProgress **aProgress)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync CheckComArgStrNotEmptyOrNull(aSource);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync CheckComArgStrNotEmptyOrNull(aDest);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync CheckComArgOutPointerValid(aProgress);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync if (RT_UNLIKELY((aSource) == NULL || *(aSource) == '\0'))
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return setError(E_INVALIDARG, tr("No source specified"));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync if (RT_UNLIKELY((aDest) == NULL || *(aDest) == '\0'))
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return setError(E_INVALIDARG, tr("No destination specified"));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync uint32_t fFlags = CopyFileFlag_None;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync if (aFlags)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync {
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync com::SafeArray<CopyFileFlag_T> flags(ComSafeArrayInArg(aFlags));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync for (size_t i = 0; i < flags.size(); i++)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync fFlags |= flags[i];
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync }
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync HRESULT hr = S_OK;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync ComObjPtr<Progress> pProgress;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync SessionTaskCopyFrom *pTask = new SessionTaskCopyFrom(this /* GuestSession */,
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync Utf8Str(aSource), Utf8Str(aDest), fFlags);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync AssertPtrReturn(pTask, VERR_NO_MEMORY);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync int rc = startTaskAsync(Utf8StrFmt(tr("Copying \"%ls\" from guest to \"%ls\" on the host"), aSource, aDest),
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync pTask, pProgress);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync if (RT_SUCCESS(rc))
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync {
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync /* Return progress to the caller. */
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync hr = pProgress.queryInterfaceTo(aProgress);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync }
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync else
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync hr = setError(VBOX_E_IPRT_ERROR,
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync tr("Starting task for copying file \"%ls\" from guest to \"%ls\" on the host failed: %Rrc"), rc);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return hr;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsyncSTDMETHODIMP GuestSession::CopyTo(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(CopyFileFlag_T, aFlags), IProgress **aProgress)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync CheckComArgStrNotEmptyOrNull(aSource);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync CheckComArgStrNotEmptyOrNull(aDest);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync CheckComArgOutPointerValid(aProgress);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync if (RT_UNLIKELY((aSource) == NULL || *(aSource) == '\0'))
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return setError(E_INVALIDARG, tr("No source specified"));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync if (RT_UNLIKELY((aDest) == NULL || *(aDest) == '\0'))
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return setError(E_INVALIDARG, tr("No destination specified"));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync uint32_t fFlags = CopyFileFlag_None;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync if (aFlags)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync {
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync com::SafeArray<CopyFileFlag_T> flags(ComSafeArrayInArg(aFlags));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync for (size_t i = 0; i < flags.size(); i++)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync fFlags |= flags[i];
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync }
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync HRESULT hr = S_OK;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync ComObjPtr<Progress> pProgress;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync SessionTaskCopyTo *pTask = new SessionTaskCopyTo(this /* GuestSession */,
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync Utf8Str(aSource), Utf8Str(aDest), fFlags);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync AssertPtrReturn(pTask, VERR_NO_MEMORY);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync int rc = startTaskAsync(Utf8StrFmt(tr("Copying \"%ls\" from host to \"%ls\" on the guest"), aSource, aDest),
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync pTask, pProgress);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync if (RT_SUCCESS(rc))
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync {
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync /* Return progress to the caller. */
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync hr = pProgress.queryInterfaceTo(aProgress);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync }
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync else
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync hr = setError(VBOX_E_IPRT_ERROR,
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync tr("Starting task for copying file \"%ls\" from host to \"%ls\" on the guest failed: %Rrc"), rc);
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync return hr;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsyncSTDMETHODIMP GuestSession::DirectoryCreate(IN_BSTR aPath, ULONG aMode,
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync ComSafeArrayIn(DirectoryCreateFlag_T, aFlags), IGuestDirectory **aDirectory)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync return setError(E_INVALIDARG, tr("No directory to create specified"));
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync /* aDirectory is optional. */
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync uint32_t fFlags = DirectoryCreateFlag_None;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (aFlags)
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync {
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync com::SafeArray<DirectoryCreateFlag_T> flags(ComSafeArrayInArg(aFlags));
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync for (size_t i = 0; i < flags.size(); i++)
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync fFlags |= flags[i];
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (fFlags)
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (!(fFlags & DirectoryCreateFlag_Parents))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync return setError(E_INVALIDARG, tr("Unknown flags (%#x)"), fFlags);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync }
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync HRESULT hr = S_OK;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync ComObjPtr <GuestDirectory> pDirectory;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync int rc = directoryCreateInternal(Utf8Str(aPath), (uint32_t)aMode, fFlags, pDirectory);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (RT_SUCCESS(rc))
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync {
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (aDirectory)
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync {
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync /* Return directory object to the caller. */
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync hr = pDirectory.queryInterfaceTo(aDirectory);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync }
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync else
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync {
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync rc = directoryClose(pDirectory);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (RT_FAILURE(rc))
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Unable to close directory object, rc=%Rrc"), rc);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync }
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync }
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync else
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync {
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync switch (rc)
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync {
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync case VERR_INVALID_PARAMETER:
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Directory creation failed: Invalid parameters given"));
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync break;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync case VERR_BROKEN_PIPE:
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Directory creation failed: Unexpectedly aborted"));
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync break;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync case VERR_CANT_CREATE:
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Directory creation failed: Could not create directory"));
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync break;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync default:
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Directory creation failed: %Rrc"), rc);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync break;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync }
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync }
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync return hr;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
3641904508e6a0671c21a083a2ed03ebad8d976cvboxsyncSTDMETHODIMP GuestSession::DirectoryCreateTemp(IN_BSTR aTemplate, ULONG aMode, IN_BSTR aPath, BOOL aSecure, BSTR *aDirectory)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync if (RT_UNLIKELY((aTemplate) == NULL || *(aTemplate) == '\0'))
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync return setError(E_INVALIDARG, tr("No file to remove specified"));
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync GuestProcessStartupInfo procInfo;
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync GuestProcessStream streamOut;
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync int rc = VINF_SUCCESS;
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync try /* Can this be done without exceptions? */
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync {
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync Utf8Str strTemplate(aTemplate);
3641904508e6a0671c21a083a2ed03ebad8d976cvboxsync Utf8Str strPath(aPath);
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync procInfo.mName = Utf8StrFmt(tr("Creating temporary directory from template \"%s\"",
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync strTemplate.c_str()));
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync procInfo.mCommand = Utf8Str(VBOXSERVICE_TOOL_MKTEMP);
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync procInfo.mFlags = ProcessCreateFlag_Hidden
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync | ProcessCreateFlag_WaitForStdOut;
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync /* Construct arguments. */
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync procInfo.mArguments.push_back(Utf8Str("--machinereadable"));
3641904508e6a0671c21a083a2ed03ebad8d976cvboxsync if (strPath.length()) /* Otherwise use /tmp or equivalent. */
3641904508e6a0671c21a083a2ed03ebad8d976cvboxsync {
3641904508e6a0671c21a083a2ed03ebad8d976cvboxsync procInfo.mArguments.push_back(Utf8Str("-d"));
3641904508e6a0671c21a083a2ed03ebad8d976cvboxsync procInfo.mArguments.push_back(strPath);
3641904508e6a0671c21a083a2ed03ebad8d976cvboxsync }
3641904508e6a0671c21a083a2ed03ebad8d976cvboxsync procInfo.mArguments.push_back(strTemplate);
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync }
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync catch (...)
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync {
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync return E_OUTOFMEMORY;
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync }
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync ComObjPtr<GuestProcess> pProcess;
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync rc = processCreateExInteral(procInfo, pProcess);
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync if (RT_SUCCESS(rc))
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync {
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync GuestProcessWaitResult waitRes;
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync BYTE byBuf[_64K];
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync size_t cbRead;
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync for (;;)
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync {
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync rc = pProcess->waitFor(ProcessWaitForFlag_StdOut,
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync 30 * 1000 /* Timeout */, waitRes);
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync if ( RT_FAILURE(rc)
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync || waitRes.mResult == ProcessWaitResult_Terminate
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync || waitRes.mResult == ProcessWaitResult_Error
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync || waitRes.mResult == ProcessWaitResult_Timeout)
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync {
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync break;
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync }
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync rc = pProcess->readData(OUTPUT_HANDLE_ID_STDOUT, sizeof(byBuf),
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync 30 * 1000 /* Timeout */, byBuf, sizeof(byBuf),
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync &cbRead);
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync if (RT_FAILURE(rc))
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync break;
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync if (cbRead)
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync {
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync rc = streamOut.AddData(byBuf, cbRead);
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync if (RT_FAILURE(rc))
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync break;
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync }
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync }
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync LogFlowThisFunc(("rc=%Rrc, cbRead=%RU32, cbStreamOut=%RU32\n",
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync rc, cbRead, streamOut.GetSize()));
a160e6af8f766b85db20b6caecb65284c9a385f9vboxsync }
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync else
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync return setError(E_FAIL, tr("Error while starting temporary directory creation tool on guest: %Rrc"), rc);
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync if (RT_FAILURE(rc))
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync return setError(E_FAIL, tr("Error while running temporary directory creation tool: %Rrc"), rc);
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync if (!streamOut.GetSize())
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync return setError(E_FAIL, tr("No return code after creating temporary directory"));
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync GuestProcessStreamBlock streamBlock;
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync rc = streamOut.ParseBlock(streamBlock);
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync if (RT_SUCCESS(rc))
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync {
3641904508e6a0671c21a083a2ed03ebad8d976cvboxsync const char *pcszName = streamBlock.GetString("name");
3641904508e6a0671c21a083a2ed03ebad8d976cvboxsync if (!pcszName)
3641904508e6a0671c21a083a2ed03ebad8d976cvboxsync return setError(E_FAIL, tr("No name returned after creating temporary directory"));
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync int64_t i64rc;
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync if (RT_FAILURE(streamBlock.GetInt64Ex("rc", &i64rc)))
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync return setError(E_FAIL, tr("No return code after creating temporary directory"));
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync if (RT_FAILURE((int)i64rc))
3641904508e6a0671c21a083a2ed03ebad8d976cvboxsync {
3641904508e6a0671c21a083a2ed03ebad8d976cvboxsync HRESULT hrc = i64rc == VERR_INVALID_PARAMETER ? E_INVALIDARG
3641904508e6a0671c21a083a2ed03ebad8d976cvboxsync : i64rc == VERR_NOT_SUPPORTED ? VBOX_E_NOT_SUPPORTED
3641904508e6a0671c21a083a2ed03ebad8d976cvboxsync : VBOX_E_IPRT_ERROR;
3641904508e6a0671c21a083a2ed03ebad8d976cvboxsync return setError(hrc, tr("Temporary directory creation failed: %Rrc"),
3641904508e6a0671c21a083a2ed03ebad8d976cvboxsync (int)i64rc);
3641904508e6a0671c21a083a2ed03ebad8d976cvboxsync }
3641904508e6a0671c21a083a2ed03ebad8d976cvboxsync try
3641904508e6a0671c21a083a2ed03ebad8d976cvboxsync {
3641904508e6a0671c21a083a2ed03ebad8d976cvboxsync Bstr(pcszName).cloneTo(aDirectory);
3641904508e6a0671c21a083a2ed03ebad8d976cvboxsync }
3641904508e6a0671c21a083a2ed03ebad8d976cvboxsync catch (...)
3641904508e6a0671c21a083a2ed03ebad8d976cvboxsync {
3641904508e6a0671c21a083a2ed03ebad8d976cvboxsync return E_OUTOFMEMORY;
3641904508e6a0671c21a083a2ed03ebad8d976cvboxsync }
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync }
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync else
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync return setError(E_FAIL, tr("Error while getting return code from creating temporary directory: %Rrc"), rc);
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync return S_OK;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::DirectoryExists(IN_BSTR aPath, BOOL *aExists)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync return setError(E_INVALIDARG, tr("No directory to check existence for specified"));
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync CheckComArgOutPointerValid(aExists);
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync HRESULT hr = S_OK;
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync GuestFsObjData objData;
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync int rc = fileQueryInfoInternal(Utf8Str(aPath), objData);
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync if (RT_SUCCESS(rc))
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync {
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync *aExists = objData.mType == FsObjType_Directory;
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync }
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync else
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync {
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync switch (rc)
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync {
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync /** @todo Add more errors here! */
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync default:
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Querying directory existence failed: %Rrc"), rc);
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync break;
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync }
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync }
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync return hr;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsyncSTDMETHODIMP GuestSession::DirectoryOpen(IN_BSTR aPath, IN_BSTR aFilter, ComSafeArrayIn(DirectoryOpenFlag_T, aFlags), IGuestDirectory **aDirectory)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync return setError(E_INVALIDARG, tr("No directory to open specified"));
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync if (RT_UNLIKELY((aFilter) != NULL && *(aFilter) != '\0'))
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync return setError(E_INVALIDARG, tr("Directory filters not implemented yet"));
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync CheckComArgOutPointerValid(aDirectory);
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync uint32_t fFlags = DirectoryOpenFlag_None;
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync if (aFlags)
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync {
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync com::SafeArray<DirectoryOpenFlag_T> flags(ComSafeArrayInArg(aFlags));
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync for (size_t i = 0; i < flags.size(); i++)
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync fFlags |= flags[i];
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync if (fFlags)
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync return setError(E_INVALIDARG, tr("Open flags (%#x) not implemented yet"), fFlags);
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync }
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync HRESULT hr = S_OK;
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync ComObjPtr <GuestDirectory> pDirectory;
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync int rc = directoryOpenInternal(Utf8Str(aPath), Utf8Str(aFilter), fFlags, pDirectory);
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync if (RT_SUCCESS(rc))
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync {
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync if (aDirectory)
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync {
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync /* Return directory object to the caller. */
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync hr = pDirectory.queryInterfaceTo(aDirectory);
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync }
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync else
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync {
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync rc = directoryClose(pDirectory);
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync if (RT_FAILURE(rc))
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Unable to close directory object, rc=%Rrc"), rc);
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync }
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync }
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync else
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync {
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync switch (rc)
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync {
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync case VERR_INVALID_PARAMETER:
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Opening directory failed: Invalid parameters given"));
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync break;
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync case VERR_BROKEN_PIPE:
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Opening directory failed: Unexpectedly aborted"));
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync break;
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync default:
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Opening directory failed: %Rrc"), rc);
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync break;
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync }
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync }
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync return hr;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::DirectoryQueryInfo(IN_BSTR aPath, IGuestFsObjInfo **aInfo)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::DirectoryRemove(IN_BSTR aPath)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::DirectoryRemoveRecursive(IN_BSTR aPath, ComSafeArrayIn(DirectoryRemoveRecFlag_T, aFlags), IProgress **aProgress)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::DirectoryRename(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(PathRenameFlag_T, aFlags))
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::DirectorySetACL(IN_BSTR aPath, IN_BSTR aACL)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncSTDMETHODIMP GuestSession::EnvironmentClear(void)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync mData.mEnvironment.Clear();
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowFuncLeaveRC(S_OK);
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync return S_OK;
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync}
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsyncSTDMETHODIMP GuestSession::EnvironmentGet(IN_BSTR aName, BSTR *aValue)
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync{
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync#ifndef VBOX_WITH_GUEST_CONTROL
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync ReturnComNotImplemented();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync if (RT_UNLIKELY((aName) == NULL || *(aName) == '\0'))
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync return setError(E_INVALIDARG, tr("No value name specified"));
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync CheckComArgOutPointerValid(aValue);
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync AutoCaller autoCaller(this);
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync Bstr strValue(mData.mEnvironment.Get(Utf8Str(aName)));
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync strValue.cloneTo(aValue);
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowFuncLeaveRC(S_OK);
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync return S_OK;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::EnvironmentSet(IN_BSTR aName, IN_BSTR aValue)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync if (RT_UNLIKELY((aName) == NULL || *(aName) == '\0'))
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync return setError(E_INVALIDARG, tr("No value name specified"));
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync int rc = mData.mEnvironment.Set(Utf8Str(aName), Utf8Str(aValue));
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync HRESULT hr = RT_SUCCESS(rc) ? S_OK : VBOX_E_IPRT_ERROR;
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowFuncLeaveRC(hr);
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync return hr;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::EnvironmentUnset(IN_BSTR aName)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync mData.mEnvironment.Unset(Utf8Str(aName));
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowFuncLeaveRC(S_OK);
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync return S_OK;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
92e624e40b06b4dc6d0a8222e1de33bd3e879a63vboxsyncSTDMETHODIMP GuestSession::FileCreateTemp(IN_BSTR aTemplate, ULONG aMode, IN_BSTR aPath, BOOL aSecure, IGuestFile **aFile)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::FileExists(IN_BSTR aPath, BOOL *aExists)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync return setError(E_INVALIDARG, tr("No file to check existence for specified"));
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync CheckComArgOutPointerValid(aExists);
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync HRESULT hr = S_OK;
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync GuestFsObjData objData;
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync int rc = fileQueryInfoInternal(Utf8Str(aPath), objData);
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync if (RT_SUCCESS(rc))
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync {
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync *aExists = objData.mType == FsObjType_File;
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync }
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync else
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync {
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync switch (rc)
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync {
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync /** @todo Add more errors here! */
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync default:
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Querying file existence failed: %Rrc"), rc);
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync break;
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync }
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync }
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync return hr;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsyncSTDMETHODIMP GuestSession::FileRemove(IN_BSTR aPath)
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync{
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync ReturnComNotImplemented();
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync#else
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync LogFlowThisFuncEnter();
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync return setError(E_INVALIDARG, tr("No file to remove specified"));
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync AutoCaller autoCaller(this);
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync try /* Can this be done without exceptions? */
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync {
004d74842597dacc4009803171296dfcf9398c69vboxsync int rc2;
004d74842597dacc4009803171296dfcf9398c69vboxsync int rc = fileRemoveInternal(Utf8Str(aPath), &rc2);
004d74842597dacc4009803171296dfcf9398c69vboxsync if (RT_FAILURE((rc)))
004d74842597dacc4009803171296dfcf9398c69vboxsync return setError(E_FAIL,
004d74842597dacc4009803171296dfcf9398c69vboxsync tr("Internal error deleting file: %Rrc"), rc);
004d74842597dacc4009803171296dfcf9398c69vboxsync else if (RT_FAILURE((rc2)))
004d74842597dacc4009803171296dfcf9398c69vboxsync return setError(VBOX_E_IPRT_ERROR,
004d74842597dacc4009803171296dfcf9398c69vboxsync tr("File deletion on guest returned: %Rrc"), rc2);
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync }
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync catch (...)
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync {
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync return E_OUTOFMEMORY;
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync }
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync return S_OK;
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync}
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::FileOpen(IN_BSTR aPath, IN_BSTR aOpenMode, IN_BSTR aDisposition, ULONG aCreationMode, LONG64 aOffset, IGuestFile **aFile)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync return setError(E_INVALIDARG, tr("No file to open specified"));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (RT_UNLIKELY((aOpenMode) == NULL || *(aOpenMode) == '\0'))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync return setError(E_INVALIDARG, tr("No open mode specified"));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (RT_UNLIKELY((aDisposition) == NULL || *(aDisposition) == '\0'))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync return setError(E_INVALIDARG, tr("No disposition mode specified"));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync CheckComArgOutPointerValid(aFile);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /** @todo Validate open mode. */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /** @todo Validate disposition mode. */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /** @todo Validate creation mode. */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync uint32_t uCreationMode = 0;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync HRESULT hr = S_OK;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync ComObjPtr <GuestFile> pFile;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync int rc = fileOpenInternal(Utf8Str(aPath), Utf8Str(aOpenMode), Utf8Str(aDisposition),
5366e994777f9d9391cf809dc77610f57270d75dvboxsync aCreationMode, aOffset, pFile);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (RT_SUCCESS(rc))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /* Return directory object to the caller. */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync hr = pFile.queryInterfaceTo(aFile);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync else
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync switch (rc)
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /** @todo Add more error info! */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync default:
5366e994777f9d9391cf809dc77610f57270d75dvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Directory creation failed: %Rrc"), rc);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync break;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync return hr;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::FileQueryInfo(IN_BSTR aPath, IGuestFsObjInfo **aInfo)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::FileQuerySize(IN_BSTR aPath, LONG64 *aSize)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync return setError(E_INVALIDARG, tr("No file to query size for specified"));
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync CheckComArgOutPointerValid(aSize);
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync HRESULT hr = S_OK;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync int64_t llSize;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync int rc = fileQuerySizeInternal(Utf8Str(aPath), &llSize);
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync if (RT_SUCCESS(rc))
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync {
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync *aSize = llSize;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync }
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync else
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync {
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync switch (rc)
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync {
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync /** @todo Add more errors here! */
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync default:
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Querying file size failed: %Rrc"), rc);
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync break;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync }
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync }
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync return hr;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::FileRename(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(PathRenameFlag_T, aFlags))
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::FileSetACL(IN_BSTR aPath, IN_BSTR aACL)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::ProcessCreate(IN_BSTR aCommand, ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync ComSafeArrayIn(ProcessCreateFlag_T, aFlags), ULONG aTimeoutMS, IGuestProcess **aProcess)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync com::SafeArray<LONG> affinity;
45655563f818c5d5bbf4b3d14aa48cbd92a871f1vboxsync
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync HRESULT hr = ProcessCreateEx(aCommand, ComSafeArrayInArg(aArguments), ComSafeArrayInArg(aEnvironment),
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync ComSafeArrayInArg(aFlags), aTimeoutMS, ProcessPriority_Default, ComSafeArrayAsInParam(affinity), aProcess);
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync return hr;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::ProcessCreateEx(IN_BSTR aCommand, ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsync ComSafeArrayIn(ProcessCreateFlag_T, aFlags), ULONG aTimeoutMS,
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsync ProcessPriority_T aPriority, ComSafeArrayIn(LONG, aAffinity),
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync IGuestProcess **aProcess)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync if (RT_UNLIKELY((aCommand) == NULL || *(aCommand) == '\0'))
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync return setError(E_INVALIDARG, tr("No command to execute specified"));
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync CheckComArgOutPointerValid(aProcess);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync GuestProcessStartupInfo procInfo;
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync procInfo.mCommand = Utf8Str(aCommand);
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync if (aArguments)
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync {
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync com::SafeArray<IN_BSTR> arguments(ComSafeArrayInArg(aArguments));
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync for (size_t i = 0; i < arguments.size(); i++)
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync procInfo.mArguments.push_back(Utf8Str(arguments[i]));
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync }
45655563f818c5d5bbf4b3d14aa48cbd92a871f1vboxsync
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync int rc = VINF_SUCCESS;
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync /*
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync * Create the process environment:
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync * - Apply the session environment in a first step, and
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync * - Apply environment variables specified by this call to
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync * have the chance of overwriting/deleting session entries.
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync */
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync procInfo.mEnvironment = mData.mEnvironment; /* Apply original session environment. */
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync if (aEnvironment)
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync {
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync com::SafeArray<IN_BSTR> environment(ComSafeArrayInArg(aEnvironment));
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync for (size_t i = 0; i < environment.size() && RT_SUCCESS(rc); i++)
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync rc = procInfo.mEnvironment.Set(Utf8Str(environment[i]));
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync }
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync HRESULT hr = S_OK;
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync if (RT_SUCCESS(rc))
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync {
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync if (aFlags)
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync {
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync com::SafeArray<ProcessCreateFlag_T> flags(ComSafeArrayInArg(aFlags));
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync for (size_t i = 0; i < flags.size(); i++)
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync procInfo.mFlags |= flags[i];
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync }
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync procInfo.mTimeoutMS = aTimeoutMS;
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync if (aAffinity)
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync {
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync com::SafeArray<LONG> affinity(ComSafeArrayInArg(aAffinity));
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync for (size_t i = 0; i < affinity.size(); i++)
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync procInfo.mAffinity[i] = affinity[i]; /** @todo Really necessary? Later. */
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync }
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync procInfo.mPriority = aPriority;
45655563f818c5d5bbf4b3d14aa48cbd92a871f1vboxsync
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync ComObjPtr<GuestProcess> pProcess;
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync rc = processCreateExInteral(procInfo, pProcess);
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync if (RT_SUCCESS(rc))
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync {
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync /* Return guest session to the caller. */
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync HRESULT hr2 = pProcess.queryInterfaceTo(aProcess);
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync if (FAILED(hr2))
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync rc = VERR_COM_OBJECT_NOT_FOUND;
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync if (RT_SUCCESS(rc))
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync rc = pProcess->startProcessAsync();
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync }
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync }
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync if (RT_FAILURE(rc))
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync {
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync switch (rc)
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync {
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync case VERR_MAX_PROCS_REACHED:
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Maximum number of guest processes per session (%ld) reached"),
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync VBOX_GUESTCTRL_MAX_PROCESSES);
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync break;
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync /** @todo Add more errors here. */
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync default:
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Could not create guest process, rc=%Rrc"), rc);
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync break;
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync }
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync }
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync LogFlowFuncLeaveRC(rc);
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync return hr;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsyncSTDMETHODIMP GuestSession::ProcessGet(ULONG aPID, IGuestProcess **aProcess)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync LogFlowThisFunc(("aPID=%RU32\n", aPID));
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync CheckComArgOutPointerValid(aProcess);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync if (aPID == 0)
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync return setError(E_INVALIDARG, tr("No valid process ID (PID) specified"));
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync HRESULT hr = S_OK;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync ComObjPtr<GuestProcess> pProcess;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync int rc = processGetByPID(aPID, &pProcess);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync if (RT_FAILURE(rc))
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync hr = setError(E_INVALIDARG, tr("No process with PID %RU32 found"), aPID);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync /* This will set (*aProcess) to NULL if pProgress is NULL. */
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync HRESULT hr2 = pProcess.queryInterfaceTo(aProcess);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync if (SUCCEEDED(hr))
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync hr = hr2;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync LogFlowThisFunc(("aProcess=%p, hr=%Rhrc\n", *aProcess, hr));
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync return hr;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::SymlinkCreate(IN_BSTR aSource, IN_BSTR aTarget, SymlinkType_T aType)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::SymlinkExists(IN_BSTR aSymlink, BOOL *aExists)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::SymlinkRead(IN_BSTR aSymlink, ComSafeArrayIn(SymlinkReadFlag_T, aFlags), BSTR *aTarget)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::SymlinkRemoveDirectory(IN_BSTR aPath)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::SymlinkRemoveFile(IN_BSTR aFile)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync