VirtualBox

Changeset 44468 in vbox


Ignore:
Timestamp:
Jan 30, 2013 2:58:07 PM (12 years ago)
Author:
vboxsync
Message:

ConsoleVRDPServer: use a separate thread to call the external auth module (xTracket #6500)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/ConsoleVRDPServer.cpp

    r44191 r44468  
    29582958#endif /* VBOX_WITH_USB */
    29592959
     2960typedef struct AuthCtx
     2961{
     2962    AuthResult result;
     2963
     2964    PAUTHENTRY3 pfnAuthEntry3;
     2965    PAUTHENTRY2 pfnAuthEntry2;
     2966    PAUTHENTRY  pfnAuthEntry;
     2967
     2968    const char         *pszCaller;
     2969    PAUTHUUID          pUuid;
     2970    AuthGuestJudgement guestJudgement;
     2971    const char         *pszUser;
     2972    const char         *pszPassword;
     2973    const char         *pszDomain;
     2974    int                fLogon;
     2975    unsigned           clientId;
     2976} AuthCtx;
     2977
     2978static DECLCALLBACK(int) authThread(RTTHREAD self, void *pvUser)
     2979{
     2980    AuthCtx *pCtx = (AuthCtx *)pvUser;
     2981
     2982    if (pCtx->pfnAuthEntry3)
     2983    {
     2984        pCtx->result = pCtx->pfnAuthEntry3(pCtx->pszCaller, pCtx->pUuid, pCtx->guestJudgement,
     2985                                           pCtx->pszUser, pCtx->pszPassword, pCtx->pszDomain,
     2986                                           pCtx->fLogon, pCtx->clientId);
     2987    }
     2988    else if (pCtx->pfnAuthEntry2)
     2989    {
     2990        pCtx->result = pCtx->pfnAuthEntry2(pCtx->pUuid, pCtx->guestJudgement,
     2991                                           pCtx->pszUser, pCtx->pszPassword, pCtx->pszDomain,
     2992                                           pCtx->fLogon, pCtx->clientId);
     2993    }
     2994    else if (pCtx->pfnAuthEntry)
     2995    {
     2996        pCtx->result = pCtx->pfnAuthEntry(pCtx->pUuid, pCtx->guestJudgement,
     2997                                          pCtx->pszUser, pCtx->pszPassword, pCtx->pszDomain);
     2998    }
     2999    return VINF_SUCCESS;
     3000}
     3001
     3002static AuthResult authCall(AuthCtx *pCtx)
     3003{
     3004    AuthResult result = AuthResultAccessDenied;
     3005
     3006    /* Use a separate thread because external modules might need a lot of stack space. */
     3007    RTTHREAD thread = NIL_RTTHREAD;
     3008    int rc = RTThreadCreate(&thread, authThread, pCtx, 512*_1K,
     3009                            RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "VRDEAuth");
     3010    LogFlow(("authCall: RTThreadCreate %Rrc\n", rc));
     3011
     3012    if (RT_SUCCESS(rc))
     3013    {
     3014        rc = RTThreadWait(thread, RT_INDEFINITE_WAIT, NULL);
     3015        LogFlow(("authCall: RTThreadWait %Rrc\n", rc));
     3016    }
     3017
     3018    if (RT_SUCCESS(rc))
     3019    {
     3020        /* Only update the result if the thread finished without errors. */
     3021        result = pCtx->result;
     3022    }
     3023    else
     3024    {
     3025        LogRel(("AUTH: unable to execute the auth thread %Rrc\n", rc));
     3026    }
     3027
     3028    return result;
     3029}
     3030
    29603031AuthResult ConsoleVRDPServer::Authenticate(const Guid &uuid, AuthGuestJudgement guestJudgement,
    29613032                                                const char *pszUser, const char *pszPassword, const char *pszDomain,
     
    29813052        Utf8Str filename = authLibrary;
    29823053
    2983         LogRel(("AUTH: ConsoleVRDPServer::Authenticate: loading external authentication library '%ls'\n", authLibrary.raw()));
     3054        LogRel(("AUTH: loading external authentication library '%ls'\n", authLibrary.raw()));
    29843055
    29853056        int rc;
     
    30693140    Assert(mAuthLibrary && (mpfnAuthEntry || mpfnAuthEntry2 || mpfnAuthEntry3));
    30703141
    3071     AuthResult result = AuthResultAccessDenied;
    3072     if (mpfnAuthEntry3)
    3073     {
    3074         result = mpfnAuthEntry3("vrde", &rawuuid, guestJudgement, pszUser, pszPassword, pszDomain, true, u32ClientId);
    3075     }
    3076     else if (mpfnAuthEntry2)
    3077     {
    3078         result = mpfnAuthEntry2(&rawuuid, guestJudgement, pszUser, pszPassword, pszDomain, true, u32ClientId);
    3079     }
    3080     else if (mpfnAuthEntry)
    3081     {
    3082         result = mpfnAuthEntry(&rawuuid, guestJudgement, pszUser, pszPassword, pszDomain);
    3083     }
     3142    AuthCtx ctx;
     3143    ctx.result         = AuthResultAccessDenied; /* Denied by default. */
     3144    ctx.pfnAuthEntry3  = mpfnAuthEntry3;
     3145    ctx.pfnAuthEntry2  = mpfnAuthEntry2;
     3146    ctx.pfnAuthEntry   = mpfnAuthEntry;
     3147    ctx.pszCaller      = "vrde";
     3148    ctx.pUuid          = &rawuuid;
     3149    ctx.guestJudgement = guestJudgement;
     3150    ctx.pszUser        = pszUser;
     3151    ctx.pszPassword    = pszPassword;
     3152    ctx.pszDomain      = pszDomain;
     3153    ctx.fLogon         = true;
     3154    ctx.clientId       = u32ClientId;
     3155
     3156    AuthResult result = authCall(&ctx);
    30843157
    30853158    switch (result)
     
    31153188    Assert(mAuthLibrary && (mpfnAuthEntry || mpfnAuthEntry2 || mpfnAuthEntry3));
    31163189
    3117     if (mpfnAuthEntry3)
    3118         mpfnAuthEntry3("vrde", &rawuuid, AuthGuestNotAsked, NULL, NULL, NULL, false, u32ClientId);
    3119     else if (mpfnAuthEntry2)
    3120         mpfnAuthEntry2(&rawuuid, AuthGuestNotAsked, NULL, NULL, NULL, false, u32ClientId);
     3190    AuthCtx ctx;
     3191    ctx.result         = AuthResultAccessDenied; /* Not used. */
     3192    ctx.pfnAuthEntry3  = mpfnAuthEntry3;
     3193    ctx.pfnAuthEntry2  = mpfnAuthEntry2;
     3194    ctx.pfnAuthEntry   = NULL;                   /* Does not use disconnect notification. */
     3195    ctx.pszCaller      = "vrde";
     3196    ctx.pUuid          = &rawuuid;
     3197    ctx.guestJudgement = AuthGuestNotAsked;
     3198    ctx.pszUser        = NULL;
     3199    ctx.pszPassword    = NULL;
     3200    ctx.pszDomain      = NULL;
     3201    ctx.fLogon         = false;
     3202    ctx.clientId       = u32ClientId;
     3203
     3204    authCall(&ctx);
    31213205}
    31223206
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