VirtualBox

Changeset 2527 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 7, 2007 4:19:14 PM (18 years ago)
Author:
vboxsync
Message:

Check VRDP multiconnection property. A new external authentication prototype for multiconnection.

Location:
trunk/src/VBox/Main
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/ConsoleImpl.cpp

    r2463 r2527  
    302302
    303303#ifdef VRDP_MC
    304     m_cAudioRefs = 0;
     304    mcAudioRefs = 0;
     305    mcVRDPClients = 0;
    305306#endif /* VRDP_MC */
    306307
     
    457458    LogFlowFunc (("%d, %s, %s, %s\n", u32ClientId, pszUser, pszPassword, pszDomain));
    458459#else
     460    uint32_t u32ClientId = 0;
    459461    LogFlowFunc (("%s, %s, %s\n", pszUser, pszPassword, pszDomain));
    460462#endif /* VRDP_MC */
     
    502504            ));
    503505
     506    /* Multiconnection check. */
     507    BOOL allowMultiConnection = FALSE;
     508    hrc = console->mVRDPServer->COMGETTER(AllowMultiConnection) (&allowMultiConnection);
     509    AssertComRCReturn (hrc, VERR_ACCESS_DENIED);
     510
     511    LogFlowFunc(("allowMultiConnection %d, console->mcVRDPClients = %d\n", allowMultiConnection, console->mcVRDPClients));
     512
     513    if (allowMultiConnection == FALSE)
     514    {
     515        /* Note: the variable is incremented in ClientConnect callback, which is called when the client
     516         * is successfully connected, that is after the ClientLogon callback. Therefore the mcVRDPClients
     517         * value is 0 for first client.
     518         */
     519        if (console->mcVRDPClients > 0)
     520        {
     521            /* Reject. */
     522            LogRel(("VRDPAUTH: Multiple connections are not enabled. Access denied.\n"));
     523            return VERR_ACCESS_DENIED;
     524        }
     525    }
     526
    504527    switch (authType)
    505528    {
     
    513536        {
    514537            /* Call the external library. */
    515             result = console->mConsoleVRDPServer->Authenticate (uuid, guestJudgement, pszUser, pszPassword, pszDomain);
     538            result = console->mConsoleVRDPServer->Authenticate (uuid, guestJudgement, pszUser, pszPassword, pszDomain, u32ClientId);
    516539
    517540            if (result != VRDPAuthDelegateToGuest)
     
    572595                LogRel(("VRDPAUTH: Guest judgement %d.\n", guestJudgement));
    573596                LogFlowFunc (("External auth called again with guest judgement = %d\n", guestJudgement));
    574                 result = console->mConsoleVRDPServer->Authenticate (uuid, guestJudgement, pszUser, pszPassword, pszDomain);
     597                result = console->mConsoleVRDPServer->Authenticate (uuid, guestJudgement, pszUser, pszPassword, pszDomain, u32ClientId);
    575598            }
    576599            else
     
    624647#ifdef VBOX_VRDP
    625648#ifdef VRDP_MC
     649    ASMAtomicIncU32(&console->mcVRDPClients);
     650
    626651    NOREF(u32ClientId);
    627652    console->mDisplay->VideoAccelVRDP (true);
     
    655680#ifdef VBOX_VRDP
    656681#ifdef VRDP_MC
     682    ASMAtomicDecU32(&console->mcVRDPClients);
     683
    657684    console->mDisplay->VideoAccelVRDP (false);
    658685#else
     686    u32ClientId = 0;
    659687    console->mDisplay->VideoAccelVRDP (false, 0);
    660688#endif /* VRDP_MC */
     
    679707    if (fu32Intercepted & VRDP_CLIENT_INTERCEPT_AUDIO)
    680708    {
    681         console->m_cAudioRefs--;
    682 
    683         if (console->m_cAudioRefs <= 0)
     709        console->mcAudioRefs--;
     710
     711        if (console->mcAudioRefs <= 0)
    684712        {
    685713            if (console->mAudioSniffer)
     
    705733#endif /* VBOX_VRDP */
    706734
     735    Guid uuid;
     736    HRESULT hrc = console->mMachine->COMGETTER (Id) (uuid.asOutParam());
     737    AssertComRC (hrc);
     738
     739    VRDPAuthType_T authType = VRDPAuthType_VRDPAuthNull;
     740    hrc = console->mVRDPServer->COMGETTER(AuthType) (&authType);
     741    AssertComRC (hrc);
     742
     743    if (authType == VRDPAuthType_VRDPAuthExternal)
     744        console->mConsoleVRDPServer->AuthDisconnect (uuid, u32ClientId);
     745
    707746    LogFlowFuncLeave();
    708747    return;
     
    735774#ifdef VBOX_VRDP
    736775#ifdef VRDP_MC
    737     console->m_cAudioRefs++;
    738 
    739     if (console->m_cAudioRefs == 1)
     776    console->mcAudioRefs++;
     777
     778    if (console->mcAudioRefs == 1)
    740779    {
    741780        if (console->mAudioSniffer)
  • trunk/src/VBox/Main/ConsoleVRDPServer.cpp

    r2522 r2527  
    193193
    194194    mpfnAuthEntry = NULL;
     195    mpfnAuthEntry2 = NULL;
    195196
    196197    if (mAuthLibrary)
     
    322323
    323324VRDPAuthResult ConsoleVRDPServer::Authenticate (const Guid &uuid, VRDPAuthGuestJudgement guestJudgement,
    324                                                 const char *pszUser, const char *pszPassword, const char *pszDomain)
     325                                                const char *pszUser, const char *pszPassword, const char *pszDomain,
     326                                                uint32_t u32ClientId)
    325327{
    326328    VRDPAUTHUUID rawuuid;
     
    328330    memcpy (rawuuid, ((Guid &)uuid).ptr (), sizeof (rawuuid));
    329331
    330     LogFlow(("ConsoleVRDPServer::Authenticate: uuid = %Vuuid, guestJudgement = %d, pszUser = %s, pszPassword = %s, pszDomain = %s\n",
    331              rawuuid, guestJudgement, pszUser, pszPassword, pszDomain));
     332    LogFlow(("ConsoleVRDPServer::Authenticate: uuid = %Vuuid, guestJudgement = %d, pszUser = %s, pszPassword = %s, pszDomain = %s, u32ClientId = %d\n",
     333             rawuuid, guestJudgement, pszUser, pszPassword, pszDomain, u32ClientId));
    332334
    333335    /*
     
    362364        {
    363365            /* Get the entry point. */
    364             rc = RTLdrGetSymbol(mAuthLibrary, "VRDPAuth", (void**)&mpfnAuthEntry);
    365             if (VBOX_FAILURE (rc))
    366                 LogRel(("VRDPAUTH: Failed to resolve import 'VRDPAuth'. Error code: %Vrc\n", rc));
     366            mpfnAuthEntry2 = NULL;
     367            int rc2 = RTLdrGetSymbol(mAuthLibrary, "VRDPAuth2", (void**)&mpfnAuthEntry2);
     368            if (VBOX_FAILURE (rc2))
     369            {
     370                LogRel(("VRDPAUTH: Could not resolve import '%s'. Error code: %Vrc\n", "VRDPAuth2", rc2));
     371                rc = rc2;
     372            }
     373
     374            /* Get the entry point. */
     375            mpfnAuthEntry = NULL;
     376            rc2 = RTLdrGetSymbol(mAuthLibrary, "VRDPAuth", (void**)&mpfnAuthEntry);
     377            if (VBOX_FAILURE (rc2))
     378            {
     379                LogRel(("VRDPAUTH: Could not resolve import '%s'. Error code: %Vrc\n", "VRDPAuth", rc2));
     380                rc = rc2;
     381            }
     382
     383            if (mpfnAuthEntry2 || mpfnAuthEntry)
     384            {
     385                LogRel(("VRDPAUTH: Using entry point '%s'.\n", mpfnAuthEntry2? "VRDPAuth2": "VRDPAuth"));
     386                rc = VINF_SUCCESS;
     387            }
    367388        }
    368389
     
    372393
    373394            mpfnAuthEntry = NULL;
     395            mpfnAuthEntry2 = NULL;
    374396
    375397            if (mAuthLibrary)
     
    383405    }
    384406
    385     Assert (mAuthLibrary && mpfnAuthEntry);
    386 
    387     VRDPAuthResult result = mpfnAuthEntry (&rawuuid, guestJudgement, pszUser, pszPassword, pszDomain);
     407    Assert (mAuthLibrary && (mpfnAuthEntry || mpfnAuthEntry2));
     408
     409    VRDPAuthResult result = mpfnAuthEntry?
     410                                mpfnAuthEntry (&rawuuid, guestJudgement, pszUser, pszPassword, pszDomain):
     411                                mpfnAuthEntry2 (&rawuuid, guestJudgement, pszUser, pszPassword, pszDomain, true, u32ClientId);
    388412
    389413    switch (result)
     
    408432}
    409433
     434void ConsoleVRDPServer::AuthDisconnect (const Guid &uuid, uint32_t u32ClientId)
     435{
     436    VRDPAUTHUUID rawuuid;
     437
     438    memcpy (rawuuid, ((Guid &)uuid).ptr (), sizeof (rawuuid));
     439
     440    LogFlow(("ConsoleVRDPServer::AuthDisconnect: uuid = %Vuuid, u32ClientId = %d\n",
     441             rawuuid, u32ClientId));
     442
     443    Assert (mAuthLibrary && (mpfnAuthEntry || mpfnAuthEntry2));
     444
     445    if (mpfnAuthEntry2)
     446        mpfnAuthEntry2 (&rawuuid, VRDPAuthGuestNotAsked, NULL, NULL, NULL, false, u32ClientId);
     447}
    410448
    411449#ifdef VRDP_MC
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r2463 r2527  
    405405
    406406#ifdef VRDP_MC
    407     int m_cAudioRefs;
     407    int mcAudioRefs;
     408    volatile uint32_t mcVRDPClients;
    408409
    409410    static DECLCALLBACK(int)    vrdp_ClientLogon (void *pvUser, uint32_t u32ClientId, const char *pszUser, const char *pszPassword, const char *pszDomain);
  • trunk/src/VBox/Main/include/ConsoleVRDPServer.h

    r2522 r2527  
    4545
    4646    VRDPAuthResult Authenticate (const Guid &uuid, VRDPAuthGuestJudgement guestJudgement,
    47                                  const char *pszUser, const char *pszPassword, const char *pszDomain);
     47                                 const char *pszUser, const char *pszPassword, const char *pszDomain,
     48                                 uint32_t u32ClientId);
     49
     50    void AuthDisconnect (const Guid &uuid, uint32_t u32ClientId);
    4851
    4952#ifdef VRDP_MC
     
    169172
    170173    /* External authentication library handle. The library is loaded in the
    171      * Authenticate  method and unloaded at the object destructor.
     174     * Authenticate method and unloaded at the object destructor.
    172175     */
    173176    RTLDRMOD mAuthLibrary;
    174177    PVRDPAUTHENTRY mpfnAuthEntry;
     178    PVRDPAUTHENTRY2 mpfnAuthEntry2;
    175179};
    176180
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