Changeset 39437 in vbox
- Timestamp:
- Nov 28, 2011 1:31:03 PM (13 years ago)
- Location:
- trunk/src/VBox/Additions/common/VBoxService
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.cpp
r39428 r39437 262 262 #endif 263 263 264 if (cParms != 11) 265 return VERR_INVALID_PARAMETER; 266 267 int rc = VbglR3GuestCtrlExecGetHostCmdExec(idClient, 264 int rc; 265 bool fStartAllowed = false; /* Flag indicating whether starting a process is allowed or not. */ 266 if (cParms == 11) 267 { 268 rc = VbglR3GuestCtrlExecGetHostCmdExec(idClient, 268 269 cParms, 269 270 &uContextID, … … 281 282 /* Timelimit */ 282 283 &uTimeLimitMS); 283 if (RT_SUCCESS(rc)) 284 { 285 #ifdef DEBUG 286 VBoxServiceVerbose(3, "Control: Start process szCmd=%s, uFlags=%u, szArgs=%s, szEnv=%s, szUser=%s, szPW=%s, uTimeout=%u\n", 287 szCmd, uFlags, cArgs ? szArgs : "<None>", cEnvVars ? szEnv : "<None>", szUser, szPassword, uTimeLimitMS); 288 #endif 289 bool fAllowed = false; 290 rc = VBoxServiceControlStartAllowed(&fAllowed); 291 if (RT_FAILURE(rc)) 292 VBoxServiceError("Control: Error determining whether process can be started or not, rc=%Rrc\n", rc); 293 294 if ( RT_SUCCESS(rc) 295 && fAllowed) 296 { 297 rc = RTCritSectEnter(&g_GuestControlThreadsCritSect); 284 285 if (RT_SUCCESS(rc)) 286 { 287 #ifdef DEBUG 288 VBoxServiceVerbose(3, "Control: Start process szCmd=%s, uFlags=%u, szArgs=%s, szEnv=%s, szUser=%s, szPW=%s, uTimeout=%u\n", 289 szCmd, uFlags, cArgs ? szArgs : "<None>", cEnvVars ? szEnv : "<None>", szUser, szPassword, uTimeLimitMS); 290 #endif 291 rc = VBoxServiceControlStartAllowed(&fStartAllowed); 292 if (RT_FAILURE(rc)) 293 VBoxServiceError("Control: Error determining whether process can be started or not, rc=%Rrc\n", rc); 294 298 295 if (RT_SUCCESS(rc)) 299 296 { 300 /** @todo Put the following params into a struct! */ 301 RTLISTNODE *pThreadNode; 302 rc = VBoxServiceControlThreadStart(idClient, uContextID, 303 szCmd, uFlags, szArgs, cArgs, 304 szEnv, cbEnv, cEnvVars, 305 szUser, szPassword, uTimeLimitMS, 306 &pThreadNode); 307 if (RT_SUCCESS(rc)) 297 if (fStartAllowed) 308 298 { 309 /* Insert thread node into thread list. */ 310 /*rc =*/ RTListAppend(&g_GuestControlThreads, pThreadNode); 299 rc = RTCritSectEnter(&g_GuestControlThreadsCritSect); 300 if (RT_SUCCESS(rc)) 301 { 302 /** @todo Put the following params into a struct! */ 303 RTLISTNODE *pThreadNode; 304 rc = VBoxServiceControlThreadStart(idClient, uContextID, 305 szCmd, uFlags, szArgs, cArgs, 306 szEnv, cbEnv, cEnvVars, 307 szUser, szPassword, uTimeLimitMS, 308 &pThreadNode); 309 if (RT_SUCCESS(rc)) 310 { 311 /* Insert thread node into thread list. */ 312 /*rc =*/ RTListAppend(&g_GuestControlThreads, pThreadNode); 313 } 314 315 int rc2 = RTCritSectLeave(&g_GuestControlThreadsCritSect); 316 if (RT_SUCCESS(rc)) 317 rc = rc2; 318 } 311 319 } 312 313 int rc2 = RTCritSectLeave(&g_GuestControlThreadsCritSect); 314 if (RT_SUCCESS(rc)) 315 rc = rc2; 320 else 321 rc = VERR_MAX_PROCS_REACHED; /* Maximum number of processes reached. */ 316 322 } 317 /** @todo r=bird: VbglR3GuestCtrlExecReportStatus isn't called for a number318 * of error paths. Both here and in the thread. I guess that will leave the319 * host waiting, possibly for ever, for a status report that never arrives.320 *321 * There are similar concerns with the termination status report in case the322 * loop exitted with an error status (VBoxServiceControlThreadProcLoop).323 */324 }325 else /* Process start is not allowed due to policy settings. */326 {327 /* Tell the host. */328 rc = VbglR3GuestCtrlExecReportStatus(idClient, uContextID, 0 /* PID, invalid. */,329 PROC_STS_ERROR,330 !fAllowed ? VERR_MAX_PROCS_REACHED : rc,331 NULL /* pvData */, 0 /* cbData */);332 323 } 333 324 } 334 325 else 335 VBoxServiceError("Control: Failed to retrieve exec start command! Error: %Rrc\n", rc); 326 rc = VERR_INVALID_PARAMETER; /* Incorrect number of parameters. */ 327 328 /* In case of an error we need to notify the host to not wait forever for our response. */ 329 if (RT_FAILURE(rc)) 330 { 331 VBoxServiceError("Control: Starting process failed with rc=%Rrc\n", rc); 332 333 int rc2 = VbglR3GuestCtrlExecReportStatus(idClient, uContextID, 0 /* PID, invalid. */, 334 PROC_STS_ERROR, rc, 335 NULL /* pvData */, 0 /* cbData */); 336 if (RT_FAILURE(rc2)) 337 { 338 VBoxServiceError("Control: Error sending start process status to host, rc=%Rrc\n", rc2); 339 if (RT_SUCCESS(rc)) 340 rc = rc2; 341 } 342 } 343 336 344 return rc; 337 345 } -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlThread.cpp
r39434 r39437 429 429 430 430 PVBOXSERVICECTRLREQUEST pRequest = pThread->pRequest; 431 AssertPtr(pRequest); /** @todo r=bird: Print error and return if invalid pointer! */ 431 if (!pRequest) 432 { 433 VBoxServiceError("ControlThread: IPC request is invalid\n"); 434 return VERR_INVALID_POINTER; 435 } 432 436 433 437 switch (pRequest->enmType) … … 1291 1295 pThread->pipeStdInW = NIL_RTPIPE; 1292 1296 } 1293 else /* Something went wrong; report error! */1294 {1295 VBoxServiceError("ControlThread: Could not start process '%s' (CID: %u)! Error: %Rrc\n",1296 pThread->pszCmd, pThread->uContextID, rc);1297 1298 rc2 = VbglR3GuestCtrlExecReportStatus(pThread->uClientID, pThread->uContextID, pThread->uPID,1299 PROC_STS_ERROR, rc,1300 NULL /* pvData */, 0 /* cbData */);1301 if (RT_FAILURE(rc2))1302 VBoxServiceError("ControlThread: Could not report process start error! Error: %Rrc (process error %Rrc)\n",1303 rc2, rc);1304 }1305 1297 } 1306 1298 RTPollSetDestroy(hPollSet); … … 1328 1320 if (pThread->uClientID) 1329 1321 { 1322 int rc2; 1323 if (RT_FAILURE(rc)) 1324 { 1325 rc2 = VbglR3GuestCtrlExecReportStatus(pThread->uClientID, pThread->uContextID, pThread->uPID, 1326 PROC_STS_ERROR, rc, 1327 NULL /* pvData */, 0 /* cbData */); 1328 if (RT_FAILURE(rc2)) 1329 VBoxServiceError("ControlThread: Could not report process failure error; rc=%Rrc (process error %Rrc)\n", 1330 rc2, rc); 1331 } 1332 1330 1333 VBoxServiceVerbose(3, "ControlThread: [PID %u]: Cancelling pending waits (client ID=%u)\n", 1331 1334 pThread->uPID, pThread->uClientID); 1332 intrc2 = VbglR3GuestCtrlCancelPendingWaits(pThread->uClientID);1335 rc2 = VbglR3GuestCtrlCancelPendingWaits(pThread->uClientID); 1333 1336 if (RT_FAILURE(rc2)) 1334 1337 {
Note:
See TracChangeset
for help on using the changeset viewer.