VirtualBox

Changeset 38087 in vbox


Ignore:
Timestamp:
Jul 21, 2011 9:01:44 AM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
73034
Message:

VBoxService/VMInfo: Enhanced logging.

Location:
trunk/src/VBox/Additions/common/VBoxService
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo-win.cpp

    r33895 r38087  
    256256bool VBoxServiceVMInfoWinSessionHasProcesses(PLUID pSession, VBOXSERVICEVMINFOPROC const *paProcs, DWORD cProcs)
    257257{
    258     AssertPtr(pSession);
    259 
    260     if (!cProcs) /* To be on the safe side. */
     258    if (!pSession)
     259    {
     260        VBoxServiceVerbose(1, "VMInfo/Users: Session became invalid while enumerating!\n");
    261261        return false;
    262     AssertPtr(paProcs);
     262    }
    263263
    264264    PSECURITY_LOGON_SESSION_DATA pSessionData = NULL;
     
    266266    if (rcNt != STATUS_SUCCESS)
    267267    {
    268         VBoxServiceError("Could not get logon session data! rcNt=%#x", rcNt);
     268        VBoxServiceError("VMInfo/Users: Could not get logon session data! rcNt=%#x", rcNt);
    269269        return false;
    270270    }
    271     AssertPtrReturn(pSessionData, false);
    272271
    273272    /*
     
    276275     * session <-> process LUIDs.
    277276     */
     277    uint32_t cNumProcs = 0;
    278278    for (DWORD i = 0; i < cProcs; i++)
    279279    {
     
    284284            && paProcs[i].luid.LowPart  == pSessionData->LogonId.LowPart)
    285285        {
    286             VBoxServiceVerbose(3, "Users: Session %ld:%ld has active processes\n",
    287                                pSessionData->LogonId.HighPart, pSessionData->LogonId.LowPart);
    288             LsaFreeReturnBuffer(pSessionData);
    289             return true;
    290         }
    291     }
     286            cNumProcs++;
     287            if (g_cVerbosity < 4) /* We want a bit more info on high verbosity. */
     288                break;
     289        }
     290    }
     291
     292    VBoxServiceVerbose(3, "VMInfo/Users: Session %u has %u processes\n",
     293                       pSessionData->Session, cNumProcs);
     294
    292295    LsaFreeReturnBuffer(pSessionData);
    293     return false;
     296    return cNumProcs ? true : false;
    294297}
    295298
     
    324327 *
    325328 * @returns true if logged in, false if not (or error).
    326  * @param   a_pUserInfo     Where to return the user information.
    327  * @param   a_pSession      The session to check.
    328  */
    329 bool VBoxServiceVMInfoWinIsLoggedIn(PVBOXSERVICEVMINFOUSER a_pUserInfo, PLUID a_pSession)
    330 {
    331     AssertPtr(a_pUserInfo);
    332     if (!a_pSession)
     329 * @param   pUserInfo           Where to return the user information.
     330 * @param   pSession            The session to check.
     331 */
     332bool VBoxServiceVMInfoWinIsLoggedIn(PVBOXSERVICEVMINFOUSER pUserInfo, PLUID pSession)
     333{
     334    AssertPtr(pUserInfo);
     335    if (!pSession)
    333336        return false;
    334337
    335338    PSECURITY_LOGON_SESSION_DATA pSessionData = NULL;
    336     NTSTATUS rcNt = LsaGetLogonSessionData(a_pSession, &pSessionData);
     339    NTSTATUS rcNt = LsaGetLogonSessionData(pSession, &pSessionData);
    337340    if (rcNt != STATUS_SUCCESS)
    338341    {
     
    373376         * Copy out relevant data.
    374377         */
    375         VBoxServiceVMInfoWinSafeCopy(a_pUserInfo->wszUser, sizeof(a_pUserInfo->wszUser),
     378        VBoxServiceVMInfoWinSafeCopy(pUserInfo->wszUser, sizeof(pUserInfo->wszUser),
    376379                                     &pSessionData->UserName, "User name");
    377         VBoxServiceVMInfoWinSafeCopy(a_pUserInfo->wszAuthenticationPackage, sizeof(a_pUserInfo->wszAuthenticationPackage),
     380        VBoxServiceVMInfoWinSafeCopy(pUserInfo->wszAuthenticationPackage, sizeof(pUserInfo->wszAuthenticationPackage),
    378381                                     &pSessionData->AuthenticationPackage, "Authentication pkg name");
    379         VBoxServiceVMInfoWinSafeCopy(a_pUserInfo->wszLogonDomain, sizeof(a_pUserInfo->wszLogonDomain),
     382        VBoxServiceVMInfoWinSafeCopy(pUserInfo->wszLogonDomain, sizeof(pUserInfo->wszLogonDomain),
    380383                                     &pSessionData->LogonDomain, "Logon domain name");
    381384
     
    401404             */
    402405            if (dwErr != ERROR_NONE_MAPPED)
    403                 VBoxServiceError("VMInfo/Users: Failed looking up account info for user '%ls': %ld!\n",
    404                                  a_pUserInfo->wszUser, dwErr);
     406                VBoxServiceError("VMInfo/Users: Failed looking up account info for user=%ls, error=$ld!\n",
     407                                 pUserInfo->wszUser, dwErr);
    405408        }
    406409        else
     
    409412            {
    410413                VBoxServiceVerbose(3, "VMInfo/Users: Account User=%ls, Session=%ld, LUID=%ld,%ld, AuthPkg=%ls, Domain=%ls\n",
    411                                    a_pUserInfo->wszUser, pSessionData->Session, pSessionData->LogonId.HighPart,
    412                                    pSessionData->LogonId.LowPart, a_pUserInfo->wszAuthenticationPackage,
    413                                    a_pUserInfo->wszLogonDomain);
     414                                   pUserInfo->wszUser, pSessionData->Session, pSessionData->LogonId.HighPart,
     415                                   pSessionData->LogonId.LowPart, pUserInfo->wszAuthenticationPackage,
     416                                   pUserInfo->wszLogonDomain);
    414417
    415418                /* Detect RDP sessions as well. */
     
    425428                    if (cbRet)
    426429                        iState = *pBuffer;
    427                     VBoxServiceVerbose(3, "VMInfo/Users:  Account User=%ls, WTSConnectState=%d\n",
    428                                        a_pUserInfo->wszUser, iState);
     430                    VBoxServiceVerbose(3, "VMInfo/Users: Account User=%ls, WTSConnectState=%d\n",
     431                                       pUserInfo->wszUser, iState);
    429432                    if (    iState == WTSActive           /* User logged on to WinStation. */
    430433                         || iState == WTSShadow           /* Shadowing another WinStation. */
     
    433436                        /** @todo On Vista and W2K, always "old" user name are still
    434437                         *        there. Filter out the old one! */
    435                         VBoxServiceVerbose(3, "VMInfo/Users: Account User=%ls is logged in via TCS/RDP. State=%d\n",
    436                                            a_pUserInfo->wszUser, iState);
     438                        VBoxServiceVerbose(3, "VMInfo/Users: Account User=%ls using TCS/RDP, state=%d\n",
     439                                           pUserInfo->wszUser, iState);
    437440                        fFoundUser = true;
    438441                    }
     
    442445                else
    443446                {
    444                     VBoxServiceVerbose(3, "VMInfo/Users:  Account User=%ls, WTSConnectState returned %ld\n",
    445                                        a_pUserInfo->wszUser, GetLastError());
    446 
    447                     /*
    448                      * Terminal services don't run (for example in W2K,
    449                      * nothing to worry about ...).  ... or is on the Vista
    450                      * fast user switching page!
    451                      */
     447                    DWORD dwLastErr = GetLastError();
     448                    switch (dwLastErr)
     449                    {
     450                        /*
     451                         * Terminal services don't run (for example in W2K,
     452                         * nothing to worry about ...).  ... or is on the Vista
     453                         * fast user switching page!
     454                         */
     455                        case ERROR_CTX_WINSTATION_NOT_FOUND:
     456                            VBoxServiceVerbose(3, "VMInfo/Users: Account User=%ls, no WinSta found\n",
     457                                               pUserInfo->wszUser);
     458                            break;
     459
     460                        default:
     461                            VBoxServiceVerbose(3, "VMInfo/Users: Account User=%ls, error=%ld\n",
     462                                               pUserInfo->wszUser, dwLastErr);
     463                            break;
     464                    }
     465
    452466                    fFoundUser = true;
    453467                }
    454468            }
    455469        }
     470
     471        VBoxServiceVerbose(3, "VMInfo/Users: Account User=%ls %s logged in\n",
     472                           pUserInfo->wszUser, fFoundUser ? "is" : "is not");
    456473    }
    457474
     
    493510        return RTErrConvertFromWin32(rcWin);
    494511    }
    495     VBoxServiceVerbose(3, "VMInfo/Users: Found %ld users\n", cSession);
     512    VBoxServiceVerbose(3, "VMInfo/Users: Found %ld sessions\n", cSession);
    496513
    497514    PVBOXSERVICEVMINFOPROC  paProcs;
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo.cpp

    r37256 r38087  
    262262           && RT_SUCCESS(rc))
    263263    {
    264         VBoxServiceVerbose(4, "VMInfo: Found logged in user \"%s\"\n", ut_user->ut_user);
    265 
     264        VBoxServiceVerbose(4, "VMInfo/Users: Found logged in user \"%s\"\n",
     265                           ut_user->ut_user);
    266266        if (cUsersInList > cListSize)
    267267        {
     
    322322        cUsersInList = 0;
    323323
    324     VBoxServiceVerbose(4, "VMInfo: cUsersInList: %u, pszUserList: %s, rc=%Rrc\n",
     324    VBoxServiceVerbose(4, "VMInfo/Users: cUsersInList: %u, pszUserList: %s, rc=%Rrc\n",
    325325                       cUsersInList, pszUserList ? pszUserList : "<NULL>", rc);
    326326
     
    764764        if (idNewSession != g_idVMInfoSession)
    765765        {
    766             VBoxServiceVerbose(3, "VMInfo: The VM session ID changed, flushing all properties.\n");
     766            VBoxServiceVerbose(3, "VMInfo: The VM session ID changed, flushing all properties\n");
    767767            vboxserviceVMInfoWriteFixedProperties();
    768768            VBoxServicePropCacheFlush(&g_VMInfoPropCache);
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