VirtualBox

Changeset 40531 in vbox for trunk/src/VBox/Additions/common


Ignore:
Timestamp:
Mar 19, 2012 11:13:32 AM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
76918
Message:

VBoxService/GuestCtrl: Simplified resolving of executable names, logging adjustments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlThread.cpp

    r40529 r40531  
    11311131 *
    11321132 * @return  IPRT status code.
    1133  * @param   pszFileName                 File name to resovle.
     1133 * @param   pszFileName                 File name to resolve.
    11341134 * @param   pszResolved                 Pointer to a string where the resolved file name will be stored.
    11351135 * @param   cbResolved                  Size (in bytes) of resolved file name string.
     
    11381138                                                     char *pszResolved, size_t cbResolved)
    11391139{
     1140    AssertPtrReturn(pszFileName, VERR_INVALID_POINTER);
     1141    AssertPtrReturn(pszResolved, VERR_INVALID_POINTER);
     1142    AssertReturn(cbResolved, VERR_INVALID_PARAMETER);
     1143
    11401144    int rc = VINF_SUCCESS;
    11411145
    1142     /* Search the path of our executable. */
    1143     char szVBoxService[RTPATH_MAX];
    1144     if (RTProcGetExecutablePath(szVBoxService, sizeof(szVBoxService)))
    1145     {
    1146         char *pszExecResolved = NULL;
    1147         if (   (g_pszProgName && RTStrICmp(pszFileName, g_pszProgName) == 0)
    1148             || !RTStrICmp(pszFileName, VBOXSERVICE_NAME))
    1149         {
    1150             /* We just want to execute VBoxService (no toolbox). */
    1151             pszExecResolved = RTStrDup(szVBoxService);
    1152         }
    1153         else /* Nothing to resolve, copy original. */
    1154             pszExecResolved = RTStrDup(pszFileName);
    1155         AssertPtr(pszExecResolved);
    1156 
    1157         rc = VBoxServiceControlThreadMakeFullPath(pszExecResolved, pszResolved, cbResolved);
    1158 #ifdef DEBUG
    1159         VBoxServiceVerbose(3, "ControlThread: VBoxServiceControlExecResolveExecutable: %s -> %s\n",
    1160                            pszFileName, pszResolved);
    1161 #endif
    1162         RTStrFree(pszExecResolved);
    1163     }
     1146    char szPathToResolve[RTPATH_MAX];
     1147    if (    (g_pszProgName && (RTStrICmp(pszFileName, g_pszProgName) == 0))
     1148        || !RTStrICmp(pszFileName, VBOXSERVICE_NAME))
     1149    {
     1150        /* Resolve executable name of this process. */
     1151        if (!RTProcGetExecutablePath(szPathToResolve, sizeof(szPathToResolve)))
     1152            rc = VERR_FILE_NOT_FOUND;
     1153    }
     1154    else
     1155    {
     1156        /* Take the raw argument to resolve. */
     1157        rc = RTStrCopy(szPathToResolve, sizeof(szPathToResolve), pszFileName);
     1158    }
     1159
     1160    if (RT_SUCCESS(rc))
     1161    {
     1162        rc = VBoxServiceControlThreadMakeFullPath(szPathToResolve, pszResolved, cbResolved);
     1163        if (RT_SUCCESS(rc))
     1164            VBoxServiceVerbose(3, "Looked up executable: %s -> %s\n",
     1165                               pszFileName, pszResolved);
     1166    }
     1167
     1168    if (RT_FAILURE(rc))
     1169        VBoxServiceError("Failed to lookup executable \"%s\" with rc=%Rrc\n",
     1170                         pszFileName, rc);
    11641171    return rc;
    11651172}
     
    12531260     * won't be shown (doesn't have a desktop).
    12541261     */
    1255     if (RTStrICmp(pszExec, "sysprep") == 0)
     1262    if (!RTStrICmp(pszExec, "sysprep"))
    12561263    {
    12571264        /* Use a predefined sysprep path as default. */
     
    12861293            }
    12871294        }
     1295
     1296        if (RT_FAILURE(rc))
     1297            VBoxServiceVerbose(3, "Starting sysprep returned rc=%Rrc\n", rc);
     1298
    12881299        return rc;
    12891300    }
     
    13121323        rc = VBoxServiceControlThreadPrepareArgv(pszExec /* Always use the unmodified executable name as argv0. */,
    13131324                                                 papszArgs /* Append the rest of the argument vector (if any). */, &papszArgsExp);
    1314         if (RT_SUCCESS(rc))
     1325        if (RT_FAILURE(rc))
     1326        {
     1327            /* Don't print any arguments -- may contain passwords or other sensible data! */
     1328            VBoxServiceError("Could not prepare arguments, rc=%Rrc\n", rc);
     1329        }
     1330        else
    13151331        {
    13161332            uint32_t uProcFlags = 0;
     
    13361352                VBoxServiceVerbose(3, "\targv[%ld]: %s\n", i, papszArgsExp[i]);
    13371353#endif
     1354            VBoxServiceVerbose(3, "Starting process \"%s\" ...\n", szExecExp);
     1355
    13381356            /* Do normal execution. */
    13391357            rc = RTProcCreateEx(szExecExp, papszArgsExp, hEnv, uProcFlags,
     
    13421360                                *pszPassword ? pszPassword : NULL,
    13431361                                phProcess);
     1362
     1363            VBoxServiceVerbose(3, "Starting process \"%s\" returned rc=%Rrc\n",
     1364                               szExecExp, rc);
     1365
    13441366            RTGetOptArgvFree(papszArgsExp);
    13451367        }
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