VBoxCredPoller.cpp revision dee9dd86962066a952b5343dc01f59328f532138
/* $Id$ */
/** @file
* VBoxCredPoller - Thread for retrieving user credentials.
*/
/*
* Copyright (C) 2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#include <windows.h>
#include <VBox/VBoxGuest.h>
#include <VBox/VBoxGuestLib.h>
#include "dll.h"
#include "VBoxCredProv.h"
#include "VBoxCredential.h"
#include "VBoxCredPoller.h"
{
m_pszDomain = NULL;
}
{
Shutdown();
}
{
Log(("VBoxCredPoller::Initialize\n"));
/* Don't create more than one of them. */
if (m_hThreadPoller != NIL_RTTHREAD)
{
Log(("VBoxCredPoller::Initialize: Thread already running, returning!\n"));
return false;
}
if (RT_FAILURE(rc))
/* Create the poller thread. */
rc = RTThreadCreate(&m_hThreadPoller, VBoxCredPoller::threadPoller, this, 0, RTTHREADTYPE_INFREQUENT_POLLER,
RTTHREADFLAGS_WAITABLE, "creds");
if (RT_FAILURE(rc))
{
return false;
}
return true;
}
bool VBoxCredPoller::Shutdown(void)
{
Log(("VBoxCredPoller::Shutdown\n"));
if (m_hThreadPoller == NIL_RTTHREAD)
{
Log(("VBoxCredPoller::Shutdown: Either thread or exit sem is NULL!\n"));
return false;
}
/* Post termination event semaphore. */
if (RT_SUCCESS(rc))
{
Log(("VBoxCredPoller::Shutdown: Waiting for thread to terminate\n"));
/* Wait until the thread has terminated. */
}
else
{
/* Failed to signal the thread - very unlikely - so no point in waiting long. */
}
{
}
return true;
}
int VBoxCredPoller::credentialsRetrieve(void)
{
/* Get credentials. */
if (RT_SUCCESS(rc))
{
{
m_pszDomain = NULL;
}
Log(("VBoxCredPoller::credentialsRetrieve: Credentials retrieved (User=%s, Password=%s, Domain=%s)\n",
}
return rc;
}
{
return bRet;
}
void VBoxCredPoller::credentialsReset(void)
{
if (m_pszUser)
if (m_pszPw)
if (m_pszDomain)
m_pszDomain = NULL;
}
{
Log(("VBoxCredPoller::threadPoller\n"));
do
{
int rc;
if (RT_FAILURE(rc))
{
if (rc != VERR_NOT_FOUND)
}
else
{
Log(("VBoxCredPoller::threadPoller: Credentials available.\n"));
}
/* Wait a bit. */
{
Log(("VBoxCredPoller::threadPoller: Terminating\n"));
/* We were asked to terminate, do that instantly! */
return 0;
}
}
while (1);
return 0;
}