VirtualBox

Changeset 58383 in vbox


Ignore:
Timestamp:
Oct 23, 2015 9:24:16 AM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
103617
Message:

Main: an option to use VRDE auth library from VBoxSVC (not enabled)

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/Makefile.kmk

    r58368 r58383  
    346346VBoxSVC_SOURCES = \
    347347        $(VBoxAPIWrap_0_OUTDIR)/VBoxAPI.d \
     348        src-all/AuthLibrary.cpp \
    348349        src-all/DisplayPNGUtil.cpp \
    349350        src-all/DisplayResampleImage.cpp \
     
    652653        $(if $(VBOX_WITH_EXTPACK),VBOX_WITH_EXTPACK,) \
    653654        $(if $(VBOX_WITH_PCI_PASSTHROUGH),VBOX_WITH_PCI_PASSTHROUGH,) \
     655        $(if $(VBOX_WITH_VRDEAUTH_IN_VBOXSVC),VBOX_WITH_VRDEAUTH_IN_VBOXSVC,) \
    654656        $(if $(VBOX_WITH_VPX),VBOX_WITH_VPX,)
    655657ifdef VBOX_WITH_CRHGSMI
     
    726728VBoxC_SOURCES = \
    727729        $(VBoxAPIWrap_0_OUTDIR)/VBoxAPI.d \
    728         src-all/AuthLibrary.cpp \
    729730        src-all/DisplayPNGUtil.cpp \
    730731        src-all/DisplayResampleImage.cpp \
     
    813814        src-client/EbmlWriter.cpp \
    814815        src-client/VideoRec.cpp
     816endif
     817ifndef VBOX_WITH_VRDEAUTH_IN_VBOXSVC
     818 VBoxC_SOURCES += \
     819        src-all/AuthLibrary.cpp
    815820endif
    816821
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r58134 r58383  
    36013601  <interface
    36023602    name="IInternalMachineControl" extends="$unknown"
    3603     uuid="ec36f437-ad4d-4512-94dd-f4c568143aa7"
     3603    uuid="cdbc59df-4f4d-4cf2-809c-917601355afc"
    36043604    internal="yes"
    36053605    wsmap="suppress"
     
    39233923      <param name="vmNetTx" type="unsigned long" dir="in">
    39243924        <desc>Network transmit rate for VM.</desc>
     3925      </param>
     3926    </method>
     3927
     3928    <method name="authenticateExternal">
     3929      <desc>
     3930        Verify credentials using the external auth library.
     3931      </desc>
     3932      <param name="authParams" type="wstring" dir="in" safearray="yes">
     3933        <desc>
     3934          The auth parameters, credentials, etc.
     3935        </desc>
     3936      </param>
     3937      <param name="result" type="wstring" dir="out">
     3938        <desc>
     3939          The authentification result.
     3940        </desc>
    39253941      </param>
    39263942    </method>
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r58004 r58383  
    979979
    980980    friend struct VMTask;
     981    friend class ConsoleVRDPServer;
    981982};
    982983
  • trunk/src/VBox/Main/include/ConsoleVRDPServer.h

    r58368 r58383  
    245245#endif /* VBOX_WITH_USB */
    246246
     247#ifndef VBOX_WITH_VRDEAUTH_IN_VBOXSVC
    247248    /* External authentication library context. The library is loaded in the
    248249     * Authenticate method and unloaded at the object destructor.
    249250     */
    250251    AUTHLIBRARYCONTEXT mAuthLibCtx;
     252#endif
    251253
    252254    uint32_t volatile mu32AudioInputClientId;
  • trunk/src/VBox/Main/include/MachineImpl.h

    r57832 r58383  
    1919#define ____H_MACHINEIMPL
    2020
     21#include "AuthLibrary.h"
    2122#include "VirtualBoxBase.h"
    2223#include "SnapshotImpl.h"
     
    12601261                               ULONG aVmNetRx,
    12611262                               ULONG aVmNetTx);
     1263    HRESULT authenticateExternal(const std::vector<com::Utf8Str> &aAuthParams,
     1264                                 com::Utf8Str &aResult);
    12621265};
    12631266
     
    14081411                               ULONG aVmNetRx,
    14091412                               ULONG aVmNetTx);
     1413    HRESULT authenticateExternal(const std::vector<com::Utf8Str> &aAuthParams,
     1414                                 com::Utf8Str &aResult);
    14101415
    14111416
     
    15101515
    15111516    int miNATNetworksStarted;
     1517
     1518    AUTHLIBRARYCONTEXT mAuthLibCtx;
    15121519};
    15131520
  • trunk/src/VBox/Main/src-client/ConsoleVRDPServer.cpp

    r58368 r58383  
    13621362    mVRDPBindPort = -1;
    13631363
     1364#ifndef VBOX_WITH_VRDEAUTH_IN_VBOXSVC
    13641365    RT_ZERO(mAuthLibCtx);
     1366#endif
    13651367
    13661368    mu32AudioInputClientId = 0;
     
    30043006    }
    30053007
     3008#ifndef VBOX_WITH_VRDEAUTH_IN_VBOXSVC
    30063009    AuthLibUnload(&mAuthLibCtx);
     3010#endif
    30073011}
    30083012
     
    31243128
    31253129AuthResult ConsoleVRDPServer::Authenticate(const Guid &uuid, AuthGuestJudgement guestJudgement,
    3126                                                 const char *pszUser, const char *pszPassword, const char *pszDomain,
    3127                                                 uint32_t u32ClientId)
     3130                                           const char *pszUser, const char *pszPassword, const char *pszDomain,
     3131                                           uint32_t u32ClientId)
    31283132{
    31293133    LogFlowFunc(("uuid = %RTuuid, guestJudgement = %d, pszUser = %s, pszPassword = %s, pszDomain = %s, u32ClientId = %d\n",
    31303134                 uuid.raw(), guestJudgement, pszUser, pszPassword, pszDomain, u32ClientId));
    31313135
     3136    AuthResult result = AuthResultAccessDenied;
     3137
     3138#ifdef VBOX_WITH_VRDEAUTH_IN_VBOXSVC
     3139    try
     3140    {
     3141        /* Init auth parameters. Order is important. */
     3142        SafeArray<BSTR> authParams;
     3143        Bstr("VRDEAUTH"          ).detachTo(authParams.appendedRaw());
     3144        Bstr(uuid.toUtf16()      ).detachTo(authParams.appendedRaw());
     3145        BstrFmt("%u", guestJudgement).detachTo(authParams.appendedRaw());
     3146        Bstr(pszUser             ).detachTo(authParams.appendedRaw());
     3147        Bstr(pszPassword         ).detachTo(authParams.appendedRaw());
     3148        Bstr(pszDomain           ).detachTo(authParams.appendedRaw());
     3149        BstrFmt("%u", u32ClientId).detachTo(authParams.appendedRaw());
     3150
     3151        Bstr authResult;
     3152        HRESULT hr = mConsole->mControl->AuthenticateExternal(ComSafeArrayAsInParam(authParams),
     3153                                                              authResult.asOutParam());
     3154        LogFlowFunc(("%Rhrc [%ls]\n", hr, authResult.raw()));
     3155
     3156        size_t cbPassword = RTUtf16Len((PRTUTF16)authParams[4]) * sizeof(RTUTF16);
     3157        if (cbPassword)
     3158            RTMemWipeThoroughly(authParams[4], cbPassword, 10 /* cPasses */);
     3159
     3160        if (SUCCEEDED(hr) && authResult == "granted")
     3161            result = AuthResultAccessGranted;
     3162    }
     3163    catch (std::bad_alloc)
     3164    {
     3165    }
     3166#else
    31323167    /*
    31333168     * Called only from VRDP input thread. So thread safety is not required.
     
    31553190    }
    31563191
    3157     AuthResult result = AuthLibAuthenticate(&mAuthLibCtx,
    3158                                             uuid.raw(), guestJudgement,
    3159                                             pszUser, pszPassword, pszDomain,
    3160                                             u32ClientId);
     3192    result = AuthLibAuthenticate(&mAuthLibCtx,
     3193                                 uuid.raw(), guestJudgement,
     3194                                 pszUser, pszPassword, pszDomain,
     3195                                 u32ClientId);
     3196#endif /* !VBOX_WITH_VRDEAUTH_IN_VBOXSVC */
    31613197
    31623198    switch (result)
     
    31863222             uuid.raw(), u32ClientId));
    31873223
     3224#ifdef VBOX_WITH_VRDEAUTH_IN_VBOXSVC
     3225    try
     3226    {
     3227        /* Init auth parameters. Order is important. */
     3228        SafeArray<BSTR> authParams;
     3229        Bstr("VRDEAUTHDISCONNECT").detachTo(authParams.appendedRaw());
     3230        Bstr(uuid.toUtf16()      ).detachTo(authParams.appendedRaw());
     3231        BstrFmt("%u", u32ClientId).detachTo(authParams.appendedRaw());
     3232
     3233        Bstr authResult;
     3234        HRESULT hr = mConsole->mControl->AuthenticateExternal(ComSafeArrayAsInParam(authParams),
     3235                                                              authResult.asOutParam());
     3236        LogFlowFunc(("%Rhrc [%ls]\n", hr, authResult.raw())); NOREF(hr);
     3237    }
     3238    catch (std::bad_alloc)
     3239    {
     3240    }
     3241#else
    31883242    AuthLibDisconnect(&mAuthLibCtx, uuid.raw(), u32ClientId);
     3243#endif /* !VBOX_WITH_VRDEAUTH_IN_VBOXSVC */
    31893244}
    31903245
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r58132 r58383  
    1233212332    HRESULT rc = S_OK;
    1233312333
     12334    RT_ZERO(mAuthLibCtx);
     12335
    1233412336    /* create the machine client token */
    1233512337    try
     
    1267912681    unconst(mParent) = NULL;
    1268012682    unconst(mPeer) = NULL;
     12683
     12684    AuthLibUnload(&mAuthLibCtx);
    1268112685
    1268212686    LogFlowThisFuncLeave();
     
    1354913553}
    1355013554
     13555HRESULT SessionMachine::authenticateExternal(const std::vector<com::Utf8Str> &aAuthParams,
     13556                                             com::Utf8Str &aResult)
     13557{
     13558    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     13559
     13560    HRESULT hr = S_OK;
     13561
     13562    if (aAuthParams[0] == "VRDEAUTH" && aAuthParams.size() == 7)
     13563    {
     13564        enum VRDEAuthParams
     13565        {
     13566           parmUuid = 1,
     13567           parmGuestJudgement,
     13568           parmUser,
     13569           parmPassword,
     13570           parmDomain,
     13571           parmClientId
     13572        };
     13573
     13574        AuthResult result = AuthResultAccessDenied;
     13575
     13576        if (!mAuthLibCtx.hAuthLibrary)
     13577        {
     13578            /* Load the external authentication library. */
     13579            Bstr authLibrary;
     13580            mVRDEServer->COMGETTER(AuthLibrary)(authLibrary.asOutParam());
     13581
     13582            Utf8Str filename = authLibrary;
     13583
     13584            int rc = AuthLibLoad(&mAuthLibCtx, filename.c_str());
     13585            if (RT_FAILURE(rc))
     13586            {
     13587                hr = setError(E_FAIL,
     13588                              tr("Could not load the external authentication library '%s' (%Rrc)"),
     13589                              filename.c_str(), rc);
     13590            }
     13591        }
     13592
     13593        if (SUCCEEDED(hr))
     13594        {
     13595            Guid uuid(aAuthParams[parmUuid]);
     13596            AuthGuestJudgement guestJudgement = (AuthGuestJudgement)aAuthParams[parmGuestJudgement].toUInt32();
     13597            uint32_t u32ClientId = aAuthParams[parmClientId].toUInt32();
     13598
     13599            result = AuthLibAuthenticate(&mAuthLibCtx,
     13600                                         uuid.raw(), guestJudgement,
     13601                                         aAuthParams[parmUser].c_str(),
     13602                                         aAuthParams[parmPassword].c_str(),
     13603                                         aAuthParams[parmDomain].c_str(),
     13604                                         u32ClientId);
     13605        }
     13606
     13607        /* Hack: aAuthParams[parmPassword] is const but the code believes in writable memory. */
     13608        size_t cbPassword = aAuthParams[parmPassword].length();
     13609        if (cbPassword)
     13610        {
     13611            RTMemWipeThoroughly((void *)aAuthParams[parmPassword].c_str(), cbPassword, 10 /* cPasses */);
     13612            memset((void *)aAuthParams[parmPassword].c_str(), 'x', cbPassword);
     13613        }
     13614
     13615        if (result == AuthResultAccessGranted)
     13616            aResult = "granted";
     13617        else
     13618            aResult = "denied";
     13619
     13620        LogRel(("AUTH: VRDE authentification for user '%s' result '%s'\n",
     13621                aAuthParams[parmUser].c_str(), aResult.c_str()));
     13622    }
     13623    else if (aAuthParams[0] == "VRDEAUTHDISCONNECT" && aAuthParams.size() == 3)
     13624    {
     13625        enum VRDEAuthDisconnectParams
     13626        {
     13627           parmUuid = 1,
     13628           parmClientId
     13629        };
     13630
     13631        Guid uuid(aAuthParams[parmUuid]);
     13632        uint32_t u32ClientId = 0;
     13633        AuthLibDisconnect(&mAuthLibCtx, uuid.raw(), u32ClientId);
     13634    }
     13635    else
     13636    {
     13637        hr = E_INVALIDARG;
     13638    }
     13639
     13640    return hr;
     13641}
     13642
    1355113643// public methods only for internal purposes
    1355213644/////////////////////////////////////////////////////////////////////////////
     
    1477914871}
    1478014872
     14873HRESULT Machine::authenticateExternal(const std::vector<com::Utf8Str> &aAuthParams,
     14874                                             com::Utf8Str &aResult)
     14875{
     14876    NOREF(aAuthParams);
     14877    NOREF(aResult);
     14878    ReturnComNotImplemented();
     14879}
     14880
    1478114881HRESULT Machine::applyDefaults(const com::Utf8Str &aFlags)
    1478214882{
Note: See TracChangeset for help on using the changeset viewer.

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