- Timestamp:
- Sep 16, 2019 1:18:44 PM (5 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxAutostart/VBoxAutostartStart.cpp
r76553 r80824 139 139 140 140 CHECK_ERROR_BREAK(machine, LaunchVMProcess(g_pSession, Bstr("headless").raw(), 141 Bstr("").raw(), progress.asOutParam()));141 ComSafeArrayNullInParam(), progress.asOutParam())); 142 142 if (SUCCEEDED(rc) && !progress.isNull()) 143 143 { -
trunk/src/VBox/Frontends/VBoxHeadless/testcase/tstHeadless.cpp
r76553 r80824 17 17 */ 18 18 19 #include <VBox/com/array.h> 19 20 #include <VBox/com/com.h> 20 21 #include <VBox/com/string.h> … … 121 122 CHECK_ERROR_BREAK(m, 122 123 LaunchVMProcess(session, Bstr("vrdp").raw(), 123 NULL, progress.asOutParam()));124 ComSafeArrayNullInParam(), progress.asOutParam())); 124 125 125 126 RTPrintf("Waiting for the remote session to open...\n"); -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp
r78296 r80824 625 625 std::list<const char *> VMs; 626 626 Bstr sessionType; 627 Utf8StrstrEnv;627 com::SafeArray<IN_BSTR> aBstrEnv; 628 628 629 629 #if defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) … … 632 632 const char *pszDisplay = RTEnvGet("DISPLAY"); 633 633 if (pszDisplay) 634 strEnv = Utf8StrFmt("DISPLAY=%s\n", pszDisplay);634 aBstrEnv.push_back(BstrFmt("DISPLAY=%s", pszDisplay).raw()); 635 635 const char *pszXAuth = RTEnvGet("XAUTHORITY"); 636 636 if (pszXAuth) 637 strEnv.append(Utf8StrFmt("XAUTHORITY=%s\n", pszXAuth));637 aBstrEnv.push_back(BstrFmt("XAUTHORITY=%s", pszXAuth).raw()); 638 638 } 639 639 #endif … … 682 682 case 'E': // --putenv 683 683 if (!RTStrStr(ValueUnion.psz, "\n")) 684 strEnv.append(Utf8StrFmt("%s\n", ValueUnion.psz));684 aBstrEnv.push_back(Bstr(ValueUnion.psz).raw()); 685 685 else 686 686 return errorSyntax(USAGE_STARTVM, "Parameter to option --putenv must not contain any newline character"); … … 725 725 ComPtr<IProgress> progress; 726 726 CHECK_ERROR(machine, LaunchVMProcess(a->session, sessionType.raw(), 727 Bstr(strEnv).raw(), progress.asOutParam()));727 ComSafeArrayAsInParam(aBstrEnv), progress.asOutParam())); 728 728 if (SUCCEEDED(rc) && !progress.isNull()) 729 729 { … … 1866 1866 else 1867 1867 { 1868 Bstr env;1868 com::SafeArray<IN_BSTR> aBstrEnv; 1869 1869 #if defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) 1870 1870 /* make sure the VM process will start on the same display as VBoxManage */ 1871 Utf8Str str;1872 1871 const char *pszDisplay = RTEnvGet("DISPLAY"); 1873 1872 if (pszDisplay) 1874 str = Utf8StrFmt("DISPLAY=%s\n", pszDisplay);1873 aBstrEnv.push_back(BstrFmt("DISPLAY=%s", pszDisplay).raw()); 1875 1874 const char *pszXAuth = RTEnvGet("XAUTHORITY"); 1876 1875 if (pszXAuth) 1877 str.append(Utf8StrFmt("XAUTHORITY=%s\n", pszXAuth)); 1878 env = str; 1876 aBstrEnv.push_back(BstrrFmt("XAUTHORITY=%s", pszXAuth).raw()); 1879 1877 #endif 1880 1878 ComPtr<IProgress> ptrProgress; 1881 CHECK_ERROR2(hrc, ptrMachine, LaunchVMProcess(a->session, Bstr(pszSessionType).raw(), env.raw(), ptrProgress.asOutParam()));1879 CHECK_ERROR2(hrc, ptrMachine, LaunchVMProcess(a->session, Bstr(pszSessionType).raw(), ComSafeArrayAsInParam(aBstrEnv), ptrProgress.asOutParam())); 1882 1880 if (SUCCEEDED(hrc) && !ptrProgress.isNull()) 1883 1881 { -
trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp
r80569 r80824 1527 1527 { 1528 1528 ComPtr<IProgress> progress; 1529 rc = pMachine->LaunchVMProcess(pSession, Bstr("headless").raw(), NULL, progress.asOutParam());1529 rc = pMachine->LaunchVMProcess(pSession, Bstr("headless").raw(), ComSafeArrayNullInParam(), progress.asOutParam()); 1530 1530 if (SUCCEEDED(rc) && !progress.isNull()) 1531 1531 { -
trunk/src/VBox/Frontends/VBoxShell/vboxshell.py
r77978 r80824 268 268 perf = ctx['perf'] 269 269 session = ctx['global'].getSessionObject() 270 progress = mach.launchVMProcess(session, vmtype, "") 270 asEnv = [] 271 progress = mach.launchVMProcess(session, vmtype, asEnv) 271 272 if progressBar(ctx, progress, 100) and int(progress.resultCode) == 0: 272 273 # we ignore exceptions to allow starting VM even if -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp
r80498 r80824 2390 2390 2391 2391 /* Configure environment: */ 2392 Q StringstrEnv;2392 QVector<QString> astrEnv; 2393 2393 #ifdef Q_OS_WIN 2394 2394 /* Allow started VM process to be foreground window: */ … … 2399 2399 const char *pDisplay = RTEnvGet("DISPLAY"); 2400 2400 if (pDisplay) 2401 strEnv.append(QString("DISPLAY=%1\n").arg(pDisplay));2401 astrEnv.append(QString("DISPLAY=%1").arg(pDisplay)); 2402 2402 const char *pXauth = RTEnvGet("XAUTHORITY"); 2403 2403 if (pXauth) 2404 strEnv.append(QString("XAUTHORITY=%1\n").arg(pXauth));2404 astrEnv.append(QString("XAUTHORITY=%1").arg(pXauth)); 2405 2405 #endif 2406 2406 QString strType; … … 2414 2414 2415 2415 /* Prepare "VM spawning" progress: */ 2416 CProgress comProgress = comMachine.LaunchVMProcess(comSession, strType, strEnv);2416 CProgress comProgress = comMachine.LaunchVMProcess(comSession, strType, astrEnv); 2417 2417 if (!comMachine.isOk()) 2418 2418 { -
trunk/src/VBox/Main/cbinding/tstCAPIGlue.c
r80074 r80824 743 743 IMachine *machine = NULL; 744 744 IProgress *progress = NULL; 745 BSTR env= NULL;745 SAFEARRAY *env = NULL; 746 746 BSTR sessionType; 747 747 SAFEARRAY *groupsSA = g_pVBoxFuncs->pfnSafeArrayOutParamAlloc(); … … 780 780 781 781 g_pVBoxFuncs->pfnUtf8ToUtf16("gui", &sessionType); 782 rc = IMachine_LaunchVMProcess(machine, session, sessionType, env, &progress);782 rc = IMachine_LaunchVMProcess(machine, session, sessionType, ComSafeArrayAsInParam(env), &progress); 783 783 g_pVBoxFuncs->pfnUtf16Free(sessionType); 784 784 if (SUCCEEDED(rc)) -
trunk/src/VBox/Main/glue/tests/TestVBox.java
r76553 r80824 20 20 import java.util.List; 21 21 import java.util.Arrays; 22 import java.util.ArrayList; 22 23 import java.math.BigInteger; 23 24 … … 145 146 146 147 ISession session = mgr.getSessionObject(); 147 IProgress p = m.launchVMProcess(session, "gui", ""); 148 ArrayList<String> env = new ArrayList<String>(); 149 IProgress p = m.launchVMProcess(session, "gui", env); 148 150 progressBar(mgr, p, 10000); 149 151 session.unlockMachine(); … … 167 169 ISession session1 = mgr1.getSessionObject(); 168 170 ISession session2 = mgr2.getSessionObject(); 169 IProgress p1 = m1.launchVMProcess(session1, "gui", ""); 170 IProgress p2 = m2.launchVMProcess(session2, "gui", ""); 171 ArrayList<String> env = new ArrayList<String>(); 172 IProgress p1 = m1.launchVMProcess(session1, "gui", env); 173 IProgress p2 = m2.launchVMProcess(session2, "gui", env); 171 174 progressBar(mgr1, p1, 10000); 172 175 progressBar(mgr2, p2, 10000); -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r80781 r80824 5839 5839 <interface 5840 5840 name="IMachine" extends="$unknown" 5841 uuid=" 008d62ad-00dc-4685-00f4-60bf00fc0dbd"5841 uuid="13a7c7cb-02fd-4962-a578-5660a5035776" 5842 5842 wsmap="managed" 5843 5843 wrap-hint-server-addinterfaces="IInternalMachineControl" … … 6732 6732 <link to="IConsole::powerUp"/>. 6733 6733 6734 <!-- TODO/r=bird: What about making @a environment into a smart array? Guess 6735 this predates our safe array support by a year or so... Dmitry wrote the text here, right? 6736 Just rename it to @a environmentChanges and shorten the documentation to say the string 6737 are applied onto the server environment putenv style, i.e. "VAR=VALUE" for setting/replacing 6738 and "VAR" for unsetting. --> 6739 The @a environment argument is a string containing definitions of 6740 environment variables in the following format: 6741 <pre> 6742 NAME[=VALUE]\n 6743 NAME[=VALUE]\n 6744 ... 6745 </pre> 6746 where <tt>\\n</tt> is the new line character. These environment 6747 variables will be appended to the environment of the VirtualBox server 6748 process. If an environment variable exists both in the server process 6749 and in this list, the value from this list takes precedence over the 6750 server's variable. If the value of the environment variable is 6751 omitted, this variable will be removed from the resulting environment. 6752 If the environment string is @c null or empty, the server environment 6753 is inherited by the started process as is. 6734 The @a environmentChanges argument is a list of strings where every string contains 6735 environment variable in the putenv style, i.e. "VAR=VALUE" for setting/replacing 6736 and "VAR" for unsetting. These environment variables will be applied to the environment 6737 of the VirtualBox server process. If an environment variable exists both in the server 6738 process and in this list, the value from this list takes precedence over the 6739 server's variable. If the value of the environment variable is omitted, this variable 6740 will be removed from the resulting environment. If the list is empty, the server 6741 environment is inherited by the started process as is. 6754 6742 6755 6743 <result name="E_UNEXPECTED"> … … 6799 6787 </desc> 6800 6788 </param> 6801 <param name="environment " type="wstring" dir="in">6802 <desc> 6803 Environment to pass to the VM process.6789 <param name="environmentChanges" type="wstring" safearray="yes" dir="in"> 6790 <desc> 6791 The list of putenv-style changes to the VM process environment. 6804 6792 </desc> 6805 6793 </param> … … 27042 27030 <interface 27043 27031 name="IVirtualBoxSDS" extends="$unknown" notdual="yes" 27044 uuid=" bc1a2773-18f2-4066-08ce-1e44d59d84af"27032 uuid="890ed3dc-cc19-43fa-8ebf-baecb6b9ec87" 27045 27033 wsmap="suppress" internal="yes" 27046 27034 reservedMethods="0" reservedAttributes="0" … … 27130 27118 </desc> 27131 27119 </param> 27132 <param name="environmentChanges" type="wstring" dir="in">27120 <param name="environmentChanges" type="wstring" safearray="yes" dir="in"> 27133 27121 <desc> 27134 Environment changes to pass to the VM process, putenv style using newline as separator.27135 <!-- TODO: make this a safearray so values can safely contain newlines and '\'. -->27122 The list of putenv-style changes to the VM process environment. 27123 See <link to="IMachine::launchVMProcess" /> for details. 27136 27124 </desc> 27137 27125 </param> -
trunk/src/VBox/Main/include/MachineImpl.h
r80074 r80824 549 549 HRESULT i_launchVMProcess(IInternalSessionControl *aControl, 550 550 const Utf8Str &strType, 551 const Utf8Str &strEnvironment,551 const std::vector<com::Utf8Str> &aEnvironmentChanges, 552 552 ProgressProxy *aProgress); 553 553 … … 973 973 HRESULT launchVMProcess(const ComPtr<ISession> &aSession, 974 974 const com::Utf8Str &aType, 975 const com::Utf8Str &aEnvironment,975 const std::vector<com::Utf8Str> &aEnvironmentChanges, 976 976 ComPtr<IProgress> &aProgress); 977 977 HRESULT setBootOrder(ULONG aPosition, -
trunk/src/VBox/Main/include/MachineLaunchVMCommonWorker.h
r80569 r80824 22 22 #endif 23 23 24 #include <vector> 24 25 #include "VirtualBoxBase.h" 25 26 … … 27 28 const Utf8Str &aComment, 28 29 const Utf8Str &aFrontend, 29 const Utf8Str &aEnvironment,30 const std::vector<com::Utf8Str> &aEnvironmentChanges, 30 31 const Utf8Str &aExtraArg, 31 32 const Utf8Str &aFilename, -
trunk/src/VBox/Main/include/VirtualBoxSDSImpl.h
r80569 r80824 94 94 STDMETHOD(RegisterVBoxSVC)(IVBoxSVCRegistration *aVBoxSVC, LONG aPid, IUnknown **aExistingVirtualBox); 95 95 STDMETHOD(DeregisterVBoxSVC)(IVBoxSVCRegistration *aVBoxSVC, LONG aPid); 96 STDMETHOD(LaunchVMProcess)(IN_BSTR aMachine, IN_BSTR aComment, IN_BSTR aFrontend, IN_BSTR aEnvironmentChanges, 97 IN_BSTR aCmdOptions, ULONG aSessionId, ULONG *aPid); 96 STDMETHOD(LaunchVMProcess)(IN_BSTR aMachine, IN_BSTR aComment, IN_BSTR aFrontend, 97 ComSafeArrayIn(IN_BSTR, aEnvironmentChanges), IN_BSTR aCmdOptions, 98 ULONG aSessionId, ULONG *aPid); 98 99 /** @} */ 99 100 -
trunk/src/VBox/Main/src-all/MachineLaunchVMCommonWorker.cpp
r80614 r80824 75 75 const Utf8Str &aComment, 76 76 const Utf8Str &aFrontend, 77 const Utf8Str &aEnvironment,77 const std::vector<com::Utf8Str> &aEnvironmentChanges, 78 78 const Utf8Str &aExtraArg, 79 79 const Utf8Str &aFilename, … … 105 105 106 106 RTENV hEnv = RTENV_DEFAULT; 107 if (!aEnvironment.isEmpty()) 108 { 109 Utf8Str strEnvCopy(aEnvironment); /* auto release trick */ 110 107 if (!aEnvironmentChanges.empty()) 108 { 111 109 #ifdef IN_VBOXSVC 112 110 /* VBoxSVC: clone the current environment */ … … 120 118 AssertRCReturn(vrc, vrc); 121 119 122 /* Apply the specified environment changes (ignoring empty variable names 123 as RTEnv intentionally does not support that). */ 124 char *pszEnvMutable = strEnvCopy.mutableRaw(); 125 char *pszVar = pszEnvMutable; 126 for (char *psz = pszEnvMutable; ; ++psz) 127 { 128 /** @todo r=bird: Broken escaping rule, how to end a variable with '\\'? 129 * E.g. TMP=C:\\TEMP\\ */ 130 char const ch = *psz; 131 if ( (ch == '\n' && (psz == pszEnvMutable || psz[-1] != '\\')) 132 || ch == '\0') 133 { 134 *psz = '\0'; 135 if (*pszVar) 136 { 137 char *val = strchr(pszVar, '='); 138 if (val) 139 { 140 *val++ = '\0'; 141 vrc = RTEnvSetEx(hEnv, pszVar, val); 142 } 143 else 144 vrc = RTEnvUnsetEx(hEnv, pszVar); 145 if (RT_FAILURE(vrc)) 146 { 147 RTEnvDestroy(hEnv); 148 return vrc; 149 } 150 } 151 if (!ch) 152 break; 153 pszVar = psz + 1; 154 } 120 /* Apply the specified environment changes. */ 121 for (std::vector<com::Utf8Str>::const_iterator itEnv = aEnvironmentChanges.begin(); 122 itEnv != aEnvironmentChanges.end(); 123 ++itEnv) 124 { 125 vrc = RTEnvPutEx(hEnv, itEnv->c_str()); 126 AssertRCReturnStmt(vrc, RTEnvDestroy(hEnv), vrc); 155 127 } 156 128 } -
trunk/src/VBox/Main/src-global/win/VirtualBoxSDSImpl.cpp
r80569 r80824 26 26 #include "AutoCaller.h" 27 27 #include "LoggingNew.h" 28 #include "Wrapper.h" /* for ArrayBSTRInConverter */ 28 29 29 30 #include <iprt/errcore.h> … … 404 405 405 406 406 STDMETHODIMP VirtualBoxSDS::LaunchVMProcess(IN_BSTR aMachine, IN_BSTR aComment, IN_BSTR aFrontend, IN_BSTR aEnvironmentChanges, 407 STDMETHODIMP VirtualBoxSDS::LaunchVMProcess(IN_BSTR aMachine, IN_BSTR aComment, IN_BSTR aFrontend, 408 ComSafeArrayIn(IN_BSTR, aEnvironmentChanges), 407 409 IN_BSTR aCmdOptions, ULONG aSessionId, ULONG *aPid) 408 410 { … … 413 415 Utf8Str strComment(aComment); 414 416 Utf8Str strFrontend(aFrontend); 415 Utf8Str strEnvironmentChanges(aEnvironmentChanges);417 ArrayBSTRInConverter aStrEnvironmentChanges(ComSafeArrayInArg(aEnvironmentChanges)); 416 418 Utf8Str strCmdOptions(aCmdOptions); 417 419 … … 429 431 RTPROCESS pid; 430 432 AssertCompile(sizeof(aSessionId) == sizeof(uint32_t)); 431 int vrc = ::MachineLaunchVMCommonWorker(strMachine, strComment, strFrontend, strEnvironmentChanges,433 int vrc = ::MachineLaunchVMCommonWorker(strMachine, strComment, strFrontend, aStrEnvironmentChanges.array(), 432 434 strCmdOptions, Utf8Str(), 433 435 RTPROC_FLAGS_AS_IMPERSONATED_TOKEN | RTPROC_FLAGS_SERVICE -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r80787 r80824 3358 3358 HRESULT Machine::launchVMProcess(const ComPtr<ISession> &aSession, 3359 3359 const com::Utf8Str &aName, 3360 const com::Utf8Str &aEnvironment,3360 const std::vector<com::Utf8Str> &aEnvironmentChanges, 3361 3361 ComPtr<IProgress> &aProgress) 3362 3362 { … … 3435 3435 if (SUCCEEDED(rc)) 3436 3436 { 3437 rc = i_launchVMProcess(control, strFrontend, aEnvironment , progress);3437 rc = i_launchVMProcess(control, strFrontend, aEnvironmentChanges, progress); 3438 3438 if (SUCCEEDED(rc)) 3439 3439 { … … 7370 7370 HRESULT Machine::i_launchVMProcess(IInternalSessionControl *aControl, 7371 7371 const Utf8Str &strFrontend, 7372 const Utf8Str &strEnvironment,7372 const std::vector<com::Utf8Str> &aEnvironmentChanges, 7373 7373 ProgressProxy *aProgress) 7374 7374 { … … 7606 7606 if (FAILED(rc)) 7607 7607 return setError(rc, tr("Failed to start the machine '%s'. CoSetProxyBlanket failed"), strMachineName.c_str()); 7608 7609 size_t const cEnvVars = aEnvironmentChanges.size(); 7610 com::SafeArray<IN_BSTR> aBstrEnvironmentChanges(cEnvVars); 7611 for (size_t i = 0; i < cEnvVars; i++) 7612 aBstrEnvironmentChanges[i] = Bstr(aEnvironmentChanges[i]).raw(); 7613 7608 7614 ULONG uPid = 0; 7609 7615 rc = pVBoxSDS->LaunchVMProcess(Bstr(idStr).raw(), Bstr(strMachineName).raw(), Bstr(strFrontend).raw(), 7610 Bstr(strEnvironment).raw(), Bstr(strSupHardeningLogArg).raw(),7616 ComSafeArrayAsInParam(aBstrEnvironmentChanges), Bstr(strSupHardeningLogArg).raw(), 7611 7617 idCallerSession, &uPid); 7612 7618 if (FAILED(rc)) … … 7617 7623 #endif /* VBOX_WITH_VBOXSDS && RT_OS_WINDOWS */ 7618 7624 { 7619 int vrc = MachineLaunchVMCommonWorker(idStr, strMachineName, strFrontend, strEnvironment, strSupHardeningLogArg,7625 int vrc = MachineLaunchVMCommonWorker(idStr, strMachineName, strFrontend, aEnvironmentChanges, strSupHardeningLogArg, 7620 7626 strAppOverride, 0 /*fFlags*/, NULL /*pvExtraData*/, pid); 7621 7627 if (RT_FAILURE(vrc)) -
trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp
r80754 r80824 1157 1157 /** @todo This needs to be the same in OSE and non-OSE, preferrably 1158 1158 * only changing when actual API changes happens. */ 1159 uRevision |= 0;1159 uRevision |= 1; 1160 1160 1161 1161 *aAPIRevision = uRevision; -
trunk/src/VBox/Main/testcase/tstAPI.cpp
r76553 r80824 21 21 #include <VBox/com/com.h> 22 22 #include <VBox/com/string.h> 23 #include <VBox/com/array.h>24 23 #include <VBox/com/Guid.h> 25 24 #include <VBox/com/ErrorInfo.h> … … 1309 1308 RTPrintf("Launching VM process...\n"); 1310 1309 CHECK_ERROR_BREAK(machine, LaunchVMProcess(session, sessionType.raw(), 1311 NULL, progress.asOutParam()));1310 ComSafeArrayNullInParam(), progress.asOutParam())); 1312 1311 RTPrintf("Waiting for the VM to power on...\n"); 1313 1312 CHECK_ERROR_BREAK(progress, WaitForCompletion(-1)); -
trunk/src/VBox/Main/testcase/tstVBoxMultipleVM.cpp
r76553 r80824 109 109 rc = TST_COM_EXPR(machine->COMGETTER(Name)(machineName.asOutParam())); 110 110 if(SUCCEEDED(rc)) 111 { 111 112 rc = machine->LaunchVMProcess(pSession, Bstr("headless").raw(), 112 Bstr("").raw(), progress.asOutParam()); 113 ComSafeArrayNullInParam(), progress.asOutParam()); 114 } 113 115 if (SUCCEEDED(rc) && !progress.isNull()) 114 116 { -
trunk/src/VBox/Main/webservice/samples/java/jax-ws/clienttest.java
r76553 r80824 229 229 String uuid = oMachine.getId(); 230 230 String sessionType = "gui"; 231 String env = "DISPLAY=:0.0"; 231 ArrayList<String> env = new ArrayList<String>(); 232 env.add("DISPLAY=:0.0"); 232 233 IProgress oProgress = 233 234 oMachine.launchVMProcess(oSession, -
trunk/src/VBox/Main/webservice/samples/perl/clienttest.pl
r76553 r80824 179 179 print "[$cmd] UUID: $uuid\n"; 180 180 181 my @env = (); 181 182 my $progress = vboxService->IMachine_launchVMProcess($machine, 182 183 $session, 183 184 "headless", 184 "");185 @env); 185 186 die "[$cmd] Cannot launch VM; stopped" 186 187 if (!$progress);
Note:
See TracChangeset
for help on using the changeset viewer.