Changeset 57960 in vbox for trunk/src/VBox/Additions/common
- Timestamp:
- Sep 30, 2015 9:49:32 AM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 102948
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp
r57834 r57960 1845 1845 RTStrPrintf(szParmThreadId, sizeof(szParmThreadId), "--thread-id=%RU32", s_uCtrlSessionThread); 1846 1846 #endif 1847 char szParmUserName[GUESTPROCESS_MAX_USER_LEN + 32]; 1848 1849 int iArgIdx = 0; /* Current index in argument vector. */ 1850 char const *papszArgs[16]; 1851 1852 papszArgs[iArgIdx++] = pszExeName; 1853 papszArgs[iArgIdx++] = "guestsession"; 1854 papszArgs[iArgIdx++] = szParmSessionID; 1855 papszArgs[iArgIdx++] = szParmSessionProto; 1856 #ifdef DEBUG 1857 papszArgs[iArgIdx++] = szParmThreadId; 1847 int idxArg = 0; /* Next index in argument vector. */ 1848 char const *apszArgs[24]; 1849 1850 apszArgs[idxArg++] = pszExeName; 1851 apszArgs[idxArg++] = "guestsession"; 1852 apszArgs[idxArg++] = szParmSessionID; 1853 apszArgs[idxArg++] = szParmSessionProto; 1854 #ifdef DEBUG 1855 apszArgs[idxArg++] = szParmThreadId; 1858 1856 #endif 1859 1857 if (!fAnonymous) /* Do we need to pass a user name? */ 1860 1858 { 1861 RTStrPrintf(szParmUserName, sizeof(szParmUserName), "--user=%s", pSessionThread->StartupInfo.szUser);1862 papszArgs[iArgIdx++] = szParmUserName;1859 apszArgs[idxArg++] = "--user"; 1860 apszArgs[idxArg++] = pSessionThread->StartupInfo.szUser; 1863 1861 } 1864 1862 1865 1863 /* Add same verbose flags as parent process. */ 1864 /** @todo r=bird: how does this stuff work when g_cVerbosity = 0? Also, why do you need rc2 here? Do we actually care about the RC anyway? */ 1866 1865 int rc2 = VINF_SUCCESS; 1867 1866 char szParmVerbose[32] = { 0 }; … … 1875 1874 } 1876 1875 if (RT_SUCCESS(rc2)) 1877 papszArgs[iArgIdx++] = szParmVerbose; 1876 apszArgs[idxArg++] = szParmVerbose; 1877 1878 /** @todo r=bird: As I already mentioned in the review comment you removed in 1879 * r102561, the log file name handling is rather mangled. You have a 4K stack 1880 * buffer, but you insist on doing 2-5 heap allocations when constructing the 1881 * name. Either you do it in the stack buffer or you do it on the heap. 1882 * 1883 * Now, if you make sure szParmLogFile is, say, 128 byte larger than 1884 * g_szLogFile, you won't need to consider overflows any more. You can easily 1885 * construct the whole thing with a strcpy, RTPathStripSuffix and a sprintf. 1886 */ 1878 1887 1879 1888 /* Add log file handling. Each session will have an own 1880 1889 * log file, naming based on the parent log file. */ 1890 #if 1 1881 1891 char szParmLogFile[RTPATH_MAX]; 1882 1892 if ( RT_SUCCESS(rc2) … … 1926 1936 } 1927 1937 if (RT_SUCCESS(rc2)) 1928 papszArgs[iArgIdx++] = szParmLogFile;1938 apszArgs[idxArg++] = szParmLogFile; 1929 1939 1930 1940 rc = rc2; … … 1932 1942 else if (RT_FAILURE(rc2)) 1933 1943 rc = rc2; 1944 #else 1945 char szParmLogFile[sizeof(g_szLogFile) + 128]; 1946 if (g_szLogFile) 1947 { 1948 const char *pszSuffix = RTPathSuffix(g_szLogFile); 1949 if (!pszSuffix) 1950 pszSuffix = strchr(g_szLogFile, '\0'); 1951 size_t cchBase = pszSuffix - g_szLogFile; 1952 #ifndef DEBUG 1953 RTStrPrintf(szParmLogFile, sizeof(szParmLogFile), "%.*s-%RU32-%s%s", 1954 cchBase, g_szLogFile, pSessionStartupInfo->uSessionID, pSessionStartupInfo->szUser, pszSuffix); 1955 #else 1956 RTStrPrintf(szParmLogFile, sizeof(szParmLogFile), "%.*s-%RU32-%RU32-%s%s", 1957 cchBase, g_szLogFile, pSessionStartupInfo->uSessionID, s_uCtrlSessionThread, 1958 pSessionStartupInfo->szUser, pszSuffix); 1959 #endif 1960 apszArgs[idxArg++] = "--logfile"; 1961 apszArgs[idxArg++] = szParmLogFile; 1962 } 1963 #endif /* alternative version */ 1934 1964 #ifdef DEBUG 1935 1965 VBoxServiceVerbose(4, "Argv building rc=%Rrc, session flags=%x\n", rc, g_Session.fFlags); … … 1937 1967 { 1938 1968 if (g_Session.fFlags & VBOXSERVICECTRLSESSION_FLAG_DUMPSTDOUT) 1939 papszArgs[iArgIdx++] = "--dump-stdout";1969 apszArgs[idxArg++] = "--dump-stdout"; 1940 1970 if (g_Session.fFlags & VBOXSERVICECTRLSESSION_FLAG_DUMPSTDERR) 1941 papszArgs[iArgIdx++] = "--dump-stderr"; 1942 } 1943 #endif 1944 papszArgs[iArgIdx++] = NULL; 1971 apszArgs[idxArg++] = "--dump-stderr"; 1972 } 1973 #endif 1974 apszArgs[idxArg] = NULL; 1975 Assert(idxArg < RT_ELEMENTS(apszArgs)); 1945 1976 1946 1977 if (g_cVerbosity > 3) … … 1948 1979 VBoxServiceVerbose(4, "Spawning parameters:\n"); 1949 1980 1950 i ArgIdx= 0;1951 while ( papszArgs[iArgIdx])1952 VBoxServiceVerbose(4, "\t%s\n", papszArgs[iArgIdx++]);1981 idxArg = 0; 1982 while (apszArgs[idxArg]) 1983 VBoxServiceVerbose(4, "\t%s\n", apszArgs[idxArg++]); 1953 1984 } 1954 1985 … … 2025 2056 2026 2057 if (RT_SUCCESS(rc)) 2027 rc = RTProcCreateEx(pszExeName, papszArgs, hEnv, uProcFlags,2058 rc = RTProcCreateEx(pszExeName, apszArgs, hEnv, uProcFlags, 2028 2059 pSession->StdIn.phChild, pSession->StdOut.phChild, pSession->StdErr.phChild, 2029 2060 !fAnonymous ? pSession->StartupInfo.szUser : NULL, … … 2059 2090 hStdOutAndErr.enmType = RTHANDLETYPE_FILE; 2060 2091 2061 rc = RTProcCreateEx(pszExeName, papszArgs, RTENV_DEFAULT, uProcFlags,2092 rc = RTProcCreateEx(pszExeName, apszArgs, RTENV_DEFAULT, uProcFlags, 2062 2093 &hStdIn, &hStdOutAndErr, &hStdOutAndErr, 2063 2094 !fAnonymous ? pSessionThread->StartupInfo.szUser : NULL,
Note:
See TracChangeset
for help on using the changeset viewer.