Changeset 49349 in vbox for trunk/src/VBox/Additions/common/VBoxService
- Timestamp:
- Oct 31, 2013 4:40:46 PM (11 years ago)
- Location:
- trunk/src/VBox/Additions/common/VBoxService
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxService.cpp
r46506 r49349 216 216 /** 217 217 * Creates the default release logger outputting to the specified file. 218 * Pass NULL for disabled logging. 218 219 * 219 220 * @return IPRT status code. … … 222 223 int VBoxServiceLogCreate(const char *pszLogFile) 223 224 { 225 if (!pszLogFile) /* No logging wanted? Take a shortcut. */ 226 return VINF_SUCCESS; 227 224 228 /* Create release logger (stdout + file). */ 225 229 static const char * const s_apszGroups[] = VBOX_LOGGROUP_NAMES; -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.cpp
r47817 r49349 268 268 * The global session object then acts as a host for all 269 269 * started guest processes which bring all their 270 * credentials with them with the actual execution call. 270 * credentials with them with the actual guest process 271 * execution call. 271 272 */ 272 273 if (ctxHost.uProtocol == 1) … … 407 408 408 409 /* 409 * Ask the host service to cancel all pending requests so that we can410 * shutdown properly here.410 * Ask the host service to cancel all pending requests for the main 411 * control thread so that we can shutdown properly here. 411 412 */ 412 413 if (g_uControlSvcClientID) -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlProcess.cpp
r47695 r49349 525 525 pProcess->uPID, PROC_STS_STARTED, 0 /* u32Flags */, 526 526 NULL /* pvData */, 0 /* cbData */); 527 if (RT_FAILURE(rc)) 528 VBoxServiceError("[PID %RU32]: Error reporting starting status to host, rc=%Rrc\n", 529 pProcess->uPID, rc); 527 530 528 531 /* … … 576 579 if (RT_FAILURE(rc2)) 577 580 VBoxServiceError("Draining IPC notification pipe failed with rc=%Rrc\n", rc2); 578 #ifdef DEBUG 581 582 /* Process all pending requests. */ 579 583 VBoxServiceVerbose(4, "[PID %RU32]: Processing pending requests ...\n", 580 584 pProcess->uPID); 581 #endif582 /* Process all pending requests. */583 585 Assert(pProcess->hReqQueue != NIL_RTREQQUEUE); 584 586 rc2 = RTReqQueueProcess(pProcess->hReqQueue, -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp
r49039 r49349 23 23 #include <iprt/asm.h> 24 24 #include <iprt/assert.h> 25 #include <iprt/dir.h> 25 26 #include <iprt/env.h> 26 27 #include <iprt/file.h> … … 57 58 static DECLCALLBACK(int) gstcntlSessionThread(RTTHREAD ThreadSelf, void *pvUser); 58 59 /* Host -> Guest handlers. */ 60 static int gstcntlSessionHandleDirRemove(PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx); 59 61 static int gstcntlSessionHandleFileOpen(PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx); 60 62 static int gstcntlSessionHandleFileClose(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx); … … 63 65 static int gstcntlSessionHandleFileSeek(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx); 64 66 static int gstcntlSessionHandleFileTell(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx); 67 static int gstcntlSessionHandlePathRename(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx); 65 68 static int gstcntlSessionHandleProcExec(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx); 66 69 static int gstcntlSessionHandleProcInput(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx, void *pvScratchBuf, size_t cbScratchBuf); … … 118 121 119 122 return NULL; 123 } 124 125 126 static int gstcntlSessionHandleDirRemove(PVBOXSERVICECTRLSESSION pSession, 127 PVBGLR3GUESTCTRLCMDCTX pHostCtx) 128 { 129 AssertPtrReturn(pSession, VERR_INVALID_POINTER); 130 AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER); 131 132 char szDir[RTPATH_MAX]; 133 uint32_t uFlags = 0; 134 135 int rc = VbglR3GuestCtrlDirGetRemove(pHostCtx, 136 /* Directory to remove. */ 137 szDir, sizeof(szDir), 138 /* Flags of type DIRREMOVE_FLAG_. */ 139 &uFlags); 140 if (RT_SUCCESS(rc)) 141 { 142 uint32_t uFlagsRemRec = 0; 143 bool fRecursive = false; 144 145 if (!(uFlags & ~DIRREMOVE_FLAG_VALID_MASK)) 146 { 147 if (uFlags & DIRREMOVE_FLAG_RECURSIVE) 148 { 149 /* Note: DIRREMOVE_FLAG_RECURSIVE must be set explicitly. 150 * Play safe here. */ 151 fRecursive = true; 152 } 153 154 if (uFlags & DIRREMOVE_FLAG_CONTENT_AND_DIR) 155 { 156 /* Setting direct value is intentional. */ 157 uFlagsRemRec = RTDIRRMREC_F_CONTENT_AND_DIR; 158 } 159 160 if (uFlags & DIRREMOVE_FLAG_CONTENT_ONLY) 161 { 162 /* Setting direct value is intentional. */ 163 uFlagsRemRec |= RTDIRRMREC_F_CONTENT_ONLY; 164 } 165 } 166 else 167 rc = VERR_NOT_SUPPORTED; 168 169 VBoxServiceVerbose(4, "[Dir %s]: Removing with uFlags=0x%x, fRecursive=%RTbool\n", 170 szDir, uFlags, fRecursive); 171 172 if (RT_SUCCESS(rc)) 173 { 174 /** @todo Add own recursive function (or a new IPRT function w/ callback?) to 175 * provide guest-to-host progress reporting. */ 176 if (fRecursive) 177 rc = RTDirRemoveRecursive(szDir, uFlagsRemRec); 178 else 179 rc = RTDirRemove(szDir); 180 } 181 182 /* Report back in any case. */ 183 int rc2 = VbglR3GuestCtrlMsgReply(pHostCtx, rc); 184 if (RT_FAILURE(rc2)) 185 VBoxServiceError("[Dir %s]: Failed to report removing status, rc=%Rrc\n", 186 szDir, rc2); 187 if (RT_SUCCESS(rc)) 188 rc = rc2; 189 } 190 191 #ifdef DEBUG 192 VBoxServiceVerbose(4, "Removing directory \"%s\" returned rc=%Rrc\n", 193 szDir, rc); 194 #endif 195 return rc; 120 196 } 121 197 … … 583 659 VBoxServiceVerbose(4, "Telling file \"%s\" (handle=%RU32) returned rc=%Rrc\n", 584 660 pFile ? pFile->szName : "<Not found>", uHandle, rc); 661 #endif 662 return rc; 663 } 664 665 666 static int gstcntlSessionHandlePathRename(PVBOXSERVICECTRLSESSION pSession, 667 PVBGLR3GUESTCTRLCMDCTX pHostCtx) 668 { 669 AssertPtrReturn(pSession, VERR_INVALID_POINTER); 670 AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER); 671 672 char szSource[RTPATH_MAX]; 673 char szDest[RTPATH_MAX]; 674 uint32_t uFlags = 0; 675 676 int rc = VbglR3GuestCtrlPathGetRename(pHostCtx, 677 szSource, sizeof(szSource), 678 szDest, sizeof(szDest), 679 /* Flags of type PATHRENAME_FLAG_. */ 680 &uFlags); 681 if (RT_SUCCESS(rc)) 682 { 683 if (uFlags & ~PATHRENAME_FLAG_VALID_MASK) 684 rc = VERR_NOT_SUPPORTED; 685 686 VBoxServiceVerbose(4, "Renaming \"%s\" to \"%s\", uFlags=0x%x, rc=%Rrc\n", 687 szSource, szDest, uFlags, rc); 688 689 if (RT_SUCCESS(rc)) 690 { 691 if (uFlags & PATHRENAME_FLAG_NO_REPLACE) 692 uFlags |= RTPATHRENAME_FLAGS_NO_REPLACE; 693 694 if (uFlags & PATHRENAME_FLAG_REPLACE) 695 uFlags |= RTPATHRENAME_FLAGS_REPLACE; 696 697 if (uFlags & PATHRENAME_FLAG_NO_SYMLINKS) 698 uFlags |= RTPATHRENAME_FLAGS_NO_SYMLINKS; 699 700 rc = RTPathRename(szSource, szDest, uFlags); 701 } 702 703 /* Report back in any case. */ 704 int rc2 = VbglR3GuestCtrlMsgReply(pHostCtx, rc); 705 if (RT_FAILURE(rc2)) 706 VBoxServiceError("Failed to report renaming status, rc=%Rrc\n", rc2); 707 if (RT_SUCCESS(rc)) 708 rc = rc2; 709 } 710 711 #ifdef DEBUG 712 VBoxServiceVerbose(4, "Renaming \"%s\" to \"%s\" returned rc=%Rrc\n", 713 szSource, szDest, rc); 585 714 #endif 586 715 return rc; … … 905 1034 switch (uMsg) 906 1035 { 907 case HOST_CANCEL_PENDING_WAITS:908 VBoxServiceVerbose(1, "We were asked to quit ...\n");909 /* Fall thru is intentional. */910 1036 case HOST_SESSION_CLOSE: 911 /* Shutdown this fork. */1037 /* Shutdown (this fork). */ 912 1038 rc = GstCntlSessionClose(pSession); 913 1039 *pfShutdown = true; /* Shutdown in any case. */ 1040 break; 1041 1042 case HOST_DIR_REMOVE: 1043 rc = fImpersonated 1044 ? gstcntlSessionHandleDirRemove(pSession, pHostCtx) 1045 : VERR_NOT_SUPPORTED; 914 1046 break; 915 1047 … … 984 1116 rc = fImpersonated 985 1117 ? gstcntlSessionHandleFileTell(pSession, pHostCtx) 1118 : VERR_NOT_SUPPORTED; 1119 break; 1120 1121 case HOST_PATH_RENAME: 1122 rc = fImpersonated 1123 ? gstcntlSessionHandlePathRename(pSession, pHostCtx) 986 1124 : VERR_NOT_SUPPORTED; 987 1125 break; … … 1057 1195 if (RT_SUCCESS(rc)) 1058 1196 { 1059 uint32_t uTimeoutsMS = 5 * 60 * 1000; /** @todo Make this configurable. Later. */1197 uint32_t uTimeoutsMS = 30 * 1000; /** @todo Make this configurable. Later. */ 1060 1198 uint64_t u64TimeoutStart = 0; 1061 1199 … … 1080 1218 if (!u64TimeoutStart) 1081 1219 { 1082 VBoxServiceVerbose(3, "Guest session ID=%RU32 thread was asked to terminate, waiting for session process to exit ...\n", 1083 uSessionID); 1220 VBoxServiceVerbose(3, "Notifying guest session process (PID=%RU32, session ID=%RU32) ...\n", 1221 pThread->hProcess, uSessionID); 1222 1223 VBGLR3GUESTCTRLCMDCTX hostCtx = { uClientID, 1224 VBOX_GUESTCTRL_CONTEXTID_MAKE_SESSION(uSessionID), 1225 pThread->StartupInfo.uProtocol, 2 /* uNumParms */ }; 1226 rc = VbglR3GuestCtrlSessionClose(&hostCtx, 0 /* uFlags */); 1227 if (RT_FAILURE(rc)) 1228 { 1229 VBoxServiceError("Unable to notify guest session process (PID=%RU32, session ID=%RU32), rc=%Rrc\n", 1230 pThread->hProcess, uSessionID, rc); 1231 1232 if (rc == VERR_NOT_SUPPORTED) 1233 { 1234 /* Terminate guest session process in case it's not supported by a too old host. */ 1235 rc = RTProcTerminate(pThread->hProcess); 1236 VBoxServiceVerbose(3, "Terminating guest session process (PID=%RU32) ended with rc=%Rrc\n", 1237 pThread->hProcess, rc); 1238 } 1239 break; 1240 } 1241 1242 VBoxServiceVerbose(3, "Guest session ID=%RU32 thread was asked to terminate, waiting for session process to exit (%RU32ms timeout) ...\n", 1243 uSessionID, uTimeoutsMS); 1084 1244 u64TimeoutStart = RTTimeMilliTS(); 1245 1085 1246 continue; /* Don't waste time on waiting. */ 1086 1247 } … … 1222 1383 GUEST_SESSION_NOTIFYTYPE_STARTED, VINF_SUCCESS); 1223 1384 if (RT_FAILURE(rc2)) 1385 { 1224 1386 VBoxServiceError("Reporting session ID=%RU32 started status failed with rc=%Rrc\n", 1225 1387 pSession->StartupInfo.uSessionID, rc2); 1388 1389 /* 1390 * If session status cannot be posted to the host for 1391 * some reason, bail out. 1392 */ 1393 if (RT_SUCCESS(rc)) 1394 rc = rc2; 1395 } 1226 1396 1227 1397 /* Allocate a scratch buffer for commands which also send … … 1284 1454 RTMemFree(pvScratchBuf); 1285 1455 1286 VBoxServiceVerbose(3, "Disconnecting client ID=%RU32 ...\n", uClientID); 1287 VbglR3GuestCtrlDisconnect(uClientID); 1456 if (uClientID) 1457 { 1458 VBoxServiceVerbose(3, "Disconnecting client ID=%RU32 ...\n", uClientID); 1459 VbglR3GuestCtrlDisconnect(uClientID); 1460 } 1288 1461 1289 1462 VBoxServiceVerbose(3, "Session worker returned with rc=%Rrc\n", rc); … … 1755 1928 } 1756 1929 #else 1930 /* Include the session thread ID in the log file name. */ 1757 1931 if (RTStrAPrintf(&pszLogNewSuffix, "-%RU32-%RU32-%s", 1758 1932 pSessionStartupInfo->uSessionID, … … 1793 1967 rc = rc2; 1794 1968 #ifdef DEBUG 1795 VBoxServiceVerbose(4, " rc=%Rrc, session flags=%x\n",1969 VBoxServiceVerbose(4, "Argv building rc=%Rrc, session flags=%x\n", 1796 1970 rc, g_Session.uFlags); 1797 1971 char szParmDumpStdOut[32]; … … 2049 2223 int rc = VINF_SUCCESS; 2050 2224 2225 /*int rc = VbglR3GuestCtrlClose 2226 if (RT_FAILURE(rc)) 2227 VBoxServiceError("Cancelling pending waits failed; rc=%Rrc\n", rc);*/ 2228 2051 2229 PVBOXSERVICECTRLSESSIONTHREAD pSessionThread 2052 2230 = RTListGetFirst(pList, VBOXSERVICECTRLSESSIONTHREAD, Node); … … 2140 2318 break; 2141 2319 2320 #ifdef DEBUG 2142 2321 case VBOXSERVICESESSIONOPT_THREAD_ID: 2143 2322 /* Not handled. */ 2144 2323 break; 2145 2324 #endif 2146 2325 /** @todo Implement help? */ 2147 2326
Note:
See TracChangeset
for help on using the changeset viewer.