VirtualBox

Ignore:
Timestamp:
Jun 16, 2010 1:48:29 PM (15 years ago)
Author:
vboxsync
Message:

Windows Guest Additions Credential Provider:

  • Added reverse lookup for using "display names" as the user account name ("John Doe" -> "jdoe").
  • Fixed showing empty user tile on invalid user/credentials.
  • Fixed domain name handling.
  • Fixed "dot" caption when no domain name is used.
  • Wipe credentials after passing over to Kerberos.
  • Beautified code a bit.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/VBoxCredProv/VBoxCredPoller.cpp

    r28800 r30252  
    55
    66/*
    7  * Copyright (C) 2009 Oracle Corporation
     7 * Copyright (C) 2010 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    5757    m_pProv->AddRef();
    5858
    59     /* don't create more than one of them */
     59    /* Don't create more than one of them. */
    6060    if (m_hThreadPoller != NIL_RTTHREAD)
    6161    {
     
    6868        Log(("VBoxCredPoller: Could not init critical section! rc = %Rrc\n", rc));
    6969
    70     /* create the poller thread */
     70    /* Create the poller thread. */
    7171    rc = RTThreadCreate(&m_hThreadPoller, VBoxCredPoller::threadPoller, this, 0, RTTHREADTYPE_INFREQUENT_POLLER,
    7272                        RTTHREADFLAGS_WAITABLE, "creds");
     
    9090    }
    9191
    92     /* Post termination event semaphore */
     92    /* Post termination event semaphore. */
    9393    int rc = RTThreadUserSignal(m_hThreadPoller);
    9494    if (RT_SUCCESS(rc))
    9595    {
    9696        Log(("VBoxCredPoller::Shutdown: Waiting for thread to terminate\n"));
    97         /* wait until the thread has terminated */
     97        /* Wait until the thread has terminated. */
    9898        rc = RTThreadWait(m_hThreadPoller, RT_INDEFINITE_WAIT, NULL);
    9999        Log(("VBoxCredPoller::Shutdown: Thread has (probably) terminated (rc = %Rrc)\n", rc));
     
    101101    else
    102102    {
    103         /* failed to signal the thread - very unlikely - so no point in waiting long. */
     103        /* Failed to signal the thread - very unlikely - so no point in waiting long. */
    104104        Log(("VBoxCredPoller::Shutdown: Failed to signal semaphore, rc = %Rrc\n", rc));
    105105        rc = RTThreadWait(m_hThreadPoller, 100, NULL);
     
    125125    credentialsReset();
    126126
    127     /* get credentials */
     127    /* Get credentials. */
    128128    RTCritSectEnter(&m_csCredUpate);
    129129    int rc = VbglR3CredentialsRetrieve(&m_pszUser, &m_pszPw, &m_pszDomain);
    130130    if (RT_SUCCESS(rc))
    131131    {
    132         Log(("VBoxCredPoller::credentialsRetrieve: Credentials retrieved (user=%s, pw=%s, domain=%s)\n",
     132        /* NULL/free domain if it's empty (""). */
     133        if (m_pszDomain && strlen(m_pszDomain) == 0)
     134        {
     135            RTStrFree(m_pszDomain);
     136            m_pszDomain = NULL;
     137        }
     138
     139        Log(("VBoxCredPoller::credentialsRetrieve: Credentials retrieved (User=%s, Password=%s, Domain=%s)\n",
    133140             m_pszUser ? m_pszUser : "<empty>",
    134141             m_pszPw ? m_pszPw : "<empty>",
    135              m_pszDomain ? m_pszDomain : "<empty>"));
    136 
    137         /* allocated but empty? delete and re-fill with default value in block below. */
    138         if (strlen(m_pszDomain) == 0)
    139         {
    140             RTStrFree(m_pszDomain);
    141             m_pszDomain = NULL;
    142         }
    143 
    144         /* if we don't have a domain specified, fill in a dot (".") specifying the
    145          * local computer. */
    146         if (m_pszDomain == NULL)
    147         {
    148             rc = RTStrAPrintf(&m_pszDomain, ".");
    149             if (RT_FAILURE(rc))
    150                 Log(("VBoxCredPoller::credentialsRetrieve: Could not set default domain name, rc = %Rrc", rc));
    151             else
    152                 Log(("VBoxCredPoller::credentialsRetrieve: No domain name given, set default value to: %s\n", m_pszDomain));
    153         }
    154     }
    155 
    156     /* if all went fine, notify parent */
    157     if (RT_SUCCESS(rc))
    158     {
     142             m_pszDomain ? m_pszDomain : "NULL"));
     143
    159144        AssertPtr(m_pProv);
    160         m_pProv->OnCredentialsProvided(m_pszUser,
    161                                        m_pszPw,
    162                                        m_pszDomain);
     145        m_pProv->OnCredentialsProvided();
    163146    }
    164147    RTCritSectLeave(&m_csCredUpate);
     
    216199        if (RT_FAILURE(rc))
    217200        {
    218             if (rc == VERR_NOT_FOUND)
    219                 Log(("VBoxCredPoller::threadPoller: No credentials availabe.\n"));
    220             else
     201            if (rc != VERR_NOT_FOUND)
    221202                Log(("VBoxCredPoller::threadPoller: Could not retrieve credentials! rc = %Rc\n", rc));
    222203        }
     
    228209        }
    229210
    230         /* wait a bit */
     211        /* Wait a bit. */
    231212        if (RTThreadUserWait(ThreadSelf, 500) == VINF_SUCCESS)
    232213        {
    233214            Log(("VBoxCredPoller::threadPoller: Terminating\n"));
    234             /* we were asked to terminate, do that instantly! */
     215            /* We were asked to terminate, do that instantly! */
    235216            return 0;
    236217        }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette