VirtualBox

Changeset 12126

Show
Ignore:
Timestamp:
09/05/08 14:28:36 (3 months ago)
Author:
vboxsync
Message:

Drop existing RDP connection and allow the new client to connect, configurable, default off.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp

    r12057 r12126  
    425425                     "                            [-vrdpaddress <host>]\n" 
    426426                     "                            [-vrdpauthtype null|external|guest]\n" 
    427                      "                            [-vrdpmulticon on|off]\n"); 
     427                     "                            [-vrdpmulticon on|off]\n" 
     428                     "                            [-vrdpreusecon on|off]\n"); 
    428429        } 
    429430        RTPrintf("                            [-usb on|off]\n" 
     
    16481649            BOOL fMultiCon; 
    16491650            vrdpServer->COMGETTER(AllowMultiConnection)(&fMultiCon); 
     1651            BOOL fReuseCon; 
     1652            vrdpServer->COMGETTER(ReuseSingleConnection)(&fReuseCon); 
    16501653            VRDPAuthType_T vrdpAuthType; 
    16511654            const char *strAuthType; 
     
    16731676                RTPrintf("vrdpauthtype=\"%s\"\n", strAuthType); 
    16741677                RTPrintf("vrdpmulticon=\"%s\"\n", fMultiCon ? "on" : "off"); 
     1678                RTPrintf("vrdpreusecon=\"%s\"\n", fReuseCon ? "on" : "off"); 
    16751679            } 
    16761680            else 
     
    16781682                if (address.isEmpty()) 
    16791683                    address = "0.0.0.0"; 
    1680                 RTPrintf("VRDP:            enabled (Address %lS, Port %d, MultiConn: %s, Authentication type: %s)\n", address.raw(), port, fMultiCon ? "on" : "off", strAuthType); 
     1684                RTPrintf("VRDP:            enabled (Address %lS, Port %d, MultiConn: %s, ReuseSingleConn: %s, Authentication type: %s)\n", address.raw(), port, fMultiCon ? "on" : "off", fReuseCon ? "on" : "off", strAuthType); 
    16811685            } 
    16821686        } 
     
    37943798    char *vrdpauthtype = NULL; 
    37953799    char *vrdpmulticon = NULL; 
     3800    char *vrdpreusecon = NULL; 
    37963801#endif 
    37973802    int   fUsbEnabled = -1; 
     
    42464251            i++; 
    42474252            vrdpmulticon = argv[i]; 
     4253        } 
     4254        else if (strcmp(argv[i], "-vrdpreusecon") == 0) 
     4255        { 
     4256            if (argc <= i + 1) 
     4257                return errorArgument("Missing argument to '%s'", argv[i]); 
     4258            i++; 
     4259            vrdpreusecon = argv[i]; 
    42484260        } 
    42494261#endif /* VBOX_WITH_VRDP */ 
     
    53345346 
    53355347#ifdef VBOX_WITH_VRDP 
    5336         if (vrdp || (vrdpport != UINT16_MAX) || vrdpaddress || vrdpauthtype || vrdpmulticon
     5348        if (vrdp || (vrdpport != UINT16_MAX) || vrdpaddress || vrdpauthtype || vrdpmulticon || vrdpreusecon
    53375349        { 
    53385350            ComPtr<IVRDPServer> vrdpServer; 
     
    54005412                    { 
    54015413                        errorArgument("Invalid -vrdpmulticon argument '%s'", vrdpmulticon); 
     5414                        rc = E_FAIL; 
     5415                        break; 
     5416                    } 
     5417                } 
     5418                if (vrdpreusecon) 
     5419                { 
     5420                    if (strcmp(vrdpreusecon, "on") == 0) 
     5421                    { 
     5422                        CHECK_ERROR(vrdpServer, COMSETTER(ReuseSingleConnection)(true)); 
     5423                    } 
     5424                    else if (strcmp(vrdpreusecon, "off") == 0) 
     5425                    { 
     5426                        CHECK_ERROR(vrdpServer, COMSETTER(ReuseSingleConnection)(false)); 
     5427                    } 
     5428                    else 
     5429                    { 
     5430                        errorArgument("Invalid -vrdpreusecon argument '%s'", vrdpreusecon); 
    54025431                        rc = E_FAIL; 
    54035432                        break; 
  • trunk/src/VBox/Main/ConsoleImpl.cpp

    r11832 r12126  
    332332    mcAudioRefs = 0; 
    333333    mcVRDPClients = 0; 
     334    mu32SingleRDPClientId = 0; 
    334335 
    335336    unconst (mVMMDev) = new VMMDev(this); 
     
    512513                    ) 
    513514            )); 
    514  
    515     /* Multiconnection check. */ 
    516     BOOL allowMultiConnection = FALSE; 
    517     hrc = mVRDPServer->COMGETTER(AllowMultiConnection) (&allowMultiConnection); 
    518     AssertComRCReturn (hrc, VERR_ACCESS_DENIED); 
    519  
    520     LogFlowFunc(("allowMultiConnection %d, mcVRDPClients = %d\n", allowMultiConnection, mcVRDPClients)); 
    521  
    522     if (allowMultiConnection == FALSE) 
    523     { 
    524         /* Note: the variable is incremented in ClientConnect callback, which is called when the client 
    525          * is successfully connected, that is after the ClientLogon callback. Therefore the mcVRDPClients 
    526          * value is 0 for first client. 
    527          */ 
    528         if (mcVRDPClients > 0) 
    529         { 
    530             /* Reject. */ 
    531             LogRel(("VRDPAUTH: Multiple connections are not enabled. Access denied.\n")); 
    532             return VERR_ACCESS_DENIED; 
    533         } 
    534     } 
    535515 
    536516    switch (authType) 
     
    627607    LogFlowFuncLeave(); 
    628608 
    629     if (result == VRDPAuthAccessGranted) 
    630     { 
    631         LogRel(("VRDPAUTH: Access granted.\n")); 
    632         return VINF_SUCCESS; 
    633     } 
    634  
    635     /* Reject. */ 
    636     LogRel(("VRDPAUTH: Access denied.\n")); 
    637     return VERR_ACCESS_DENIED; 
     609    if (result != VRDPAuthAccessGranted) 
     610    { 
     611        /* Reject. */ 
     612        LogRel(("VRDPAUTH: Access denied.\n")); 
     613        return VERR_ACCESS_DENIED; 
     614    } 
     615 
     616    LogRel(("VRDPAUTH: Access granted.\n")); 
     617 
     618    /* Multiconnection check must be made after authentication, so bad clients would not interfere with a good one. */ 
     619    BOOL allowMultiConnection = FALSE; 
     620    hrc = mVRDPServer->COMGETTER(AllowMultiConnection) (&allowMultiConnection); 
     621    AssertComRCReturn (hrc, VERR_ACCESS_DENIED); 
     622     
     623    BOOL reuseSingleConnection = FALSE; 
     624    hrc = mVRDPServer->COMGETTER(ReuseSingleConnection) (&reuseSingleConnection); 
     625    AssertComRCReturn (hrc, VERR_ACCESS_DENIED); 
     626 
     627    LogFlowFunc(("allowMultiConnection %d, reuseSingleConnection = %d, mcVRDPClients = %d, mu32SingleRDPClientId = %d\n", allowMultiConnection, reuseSingleConnection, mcVRDPClients, mu32SingleRDPClientId)); 
     628 
     629    if (allowMultiConnection == FALSE) 
     630    { 
     631        /* Note: the 'mcVRDPClients' variable is incremented in ClientConnect callback, which is called when the client 
     632         * is successfully connected, that is after the ClientLogon callback. Therefore the mcVRDPClients 
     633         * value is 0 for first client. 
     634         */ 
     635        if (mcVRDPClients != 0) 
     636        { 
     637            Assert(mcVRDPClients == 1); 
     638            /* There is a client already. 
     639             * If required drop the existing client connection and let the connecting one in. 
     640             */ 
     641            if (reuseSingleConnection) 
     642            { 
     643                LogRel(("VRDPAUTH: Multiple connections are not enabled. Disconnecting existing client.\n")); 
     644                mConsoleVRDPServer->DisconnectClient (mu32SingleRDPClientId, false); 
     645            } 
     646            else 
     647            { 
     648                /* Reject. */ 
     649                LogRel(("VRDPAUTH: Multiple connections are not enabled. Access denied.\n")); 
     650                return VERR_ACCESS_DENIED; 
     651            } 
     652        } 
     653 
     654        /* Save the connected client id. From now on it will be necessary to disconnect this one. */ 
     655        mu32SingleRDPClientId = u32ClientId; 
     656    } 
     657 
     658    return VINF_SUCCESS; 
    638659} 
    639660 
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r12020 r12126  
    96809680  <interface 
    96819681     name="IVRDPServer" extends="$unknown" 
    9682      uuid="ed9d31ae-867f-45fc-b727-6740084d1883
     9682     uuid="f4584ae7-6bce-474b-83d6-17d235e6aa89
    96839683     wsmap="managed" 
    96849684     > 
     
    97169716        Flag whether multiple simultaneous connections to the VM are permitted. 
    97179717        Note that this will be replaced by a more powerful mechanism in the future. 
     9718      </desc> 
     9719    </attribute> 
     9720 
     9721    <attribute name="reuseSingleConnection" type="boolean"> 
     9722      <desc> 
     9723        Flag whether the existing connection must be dropped and a new connection 
     9724        must be established by the VRDP server, when a new client connects in single 
     9725        connection mode. 
    97189726      </desc> 
    97199727    </attribute> 
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r11083 r12126  
    472472    int mcAudioRefs; 
    473473    volatile uint32_t mcVRDPClients; 
     474    uint32_t mu32SingleRDPClientId; /* The id of a connected client in the single connection mode. */ 
    474475 
    475476    static const char *sSSMConsoleUnit; 
  • trunk/src/VBox/Main/include/ConsoleVRDPServer.h

    r11820 r12126  
    9898 
    9999    void EnableConnections (void); 
     100    void DisconnectClient (uint32_t u32ClientId, bool fReconnect); 
    100101    void MousePointerUpdate (const VRDPCOLORPOINTER *pPointer); 
    101102    void MousePointerHide (void); 
  • trunk/src/VBox/Main/include/VRDPServerImpl.h

    r8155 r12126  
    4949                    mAuthType == that.mAuthType && 
    5050                    mAuthTimeout == that.mAuthTimeout && 
    51                     mAllowMultiConnection == that.mAllowMultiConnection); 
     51                    mAllowMultiConnection == that.mAllowMultiConnection && 
     52                    mReuseSingleConnection == that.mReuseSingleConnection); 
    5253        } 
    5354 
     
    5859        ULONG mAuthTimeout; 
    5960        BOOL mAllowMultiConnection; 
     61        BOOL mReuseSingleConnection; 
    6062    }; 
    6163 
     
    9799    STDMETHOD(COMGETTER(AllowMultiConnection)) (BOOL *aAllowMultiConnection); 
    98100    STDMETHOD(COMSETTER(AllowMultiConnection)) (BOOL aAllowMultiConnection); 
     101    STDMETHOD(COMGETTER(ReuseSingleConnection)) (BOOL *aReuseSingleConnection); 
     102    STDMETHOD(COMSETTER(ReuseSingleConnection)) (BOOL aReuseSingleConnection); 
    99103 
    100104    // IVRDPServer methods 
  • trunk/src/VBox/Main/xml/VirtualBox-settings-common.xsd

    r12020 r12126  
    472472  <xsd:attribute name="authTimeout" type="xsd:unsignedInt" default="5000"/> 
    473473  <xsd:attribute name="allowMultiConnection" type="xsd:boolean" default="false"/> 
     474  <xsd:attribute name="reuseSingleConnection" type="xsd:boolean" default="false"/> 
    474475</xsd:complexType> 
    475476 

© 2008 Sun Microsystems, Inc.
ContactPrivacy policy