Changeset 27926 in vbox
- Timestamp:
- Apr 1, 2010 8:58:39 AM (15 years ago)
- Location:
- trunk/src/VBox/Additions/common/VBoxService
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/Makefile.kmk
r27852 r27926 57 57 ifdef VBOX_WITH_GUEST_CONTROL 58 58 VBoxService_SOURCES += \ 59 VBoxServiceControl.cpp 59 VBoxServiceControl.cpp \ 60 VBoxServiceControlExec.cpp 60 61 endif 61 62 ifdef VBOX_WITH_GUEST_PROPS -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.cpp
r27865 r27926 26 26 *******************************************************************************/ 27 27 #include <iprt/assert.h> 28 #include <iprt/ctype.h> 29 #include <iprt/env.h> 30 #include <iprt/file.h> 28 #include <iprt/getopt.h> 31 29 #include <iprt/mem.h> 32 #include <iprt/path.h>33 #include <iprt/param.h>34 #include <iprt/process.h>35 #include <iprt/string.h>36 30 #include <iprt/semaphore.h> 37 31 #include <iprt/thread.h> 38 #include <VBox/version.h>39 32 #include <VBox/VBoxGuestLib.h> 40 33 #include <VBox/HostServices/GuestControlSvc.h> … … 100 93 } 101 94 102 int VBoxServiceControlHandleCmdExec(uint32_t u32ClientId, uint32_t uNumParms) 95 96 static int VBoxServiceControlHandleCmdExec(uint32_t u32ClientId, uint32_t uNumParms) 103 97 { 104 98 VBoxServiceVerbose(3, "VBoxServiceControlHandleCmdExec: Called uNumParms=%ld\n", uNumParms); 105 99 106 char szCmd[_1K]; 107 uint32_t uFlags; 108 char szArgs[_1K]; 109 uint32_t uNumArgs; 110 char szEnv[_64K]; 111 uint32_t cbEnv = sizeof(szEnv); 112 uint32_t uNumEnvVars; 113 char szStdIn[_1K]; 114 char szStdOut[_1K]; 115 char szStdErr[_1K]; 116 char szUser[128]; 117 char szPassword[128]; 118 uint32_t uTimeLimitMS; 100 VBOXSERVICECTRLPROCDATA execData; 101 execData.cbEnv = sizeof(execData.szEnv); 119 102 120 103 int rc = VbglR3GuestCtrlGetHostCmdExec(u32ClientId, uNumParms, 121 szCmd, sizeof(szCmd), 122 &uFlags, 123 szArgs, sizeof(szArgs), &uNumArgs, 124 szEnv, &cbEnv, &uNumEnvVars, 125 szStdIn, sizeof(szStdIn), 126 szStdOut, sizeof(szStdOut), 127 szStdErr, sizeof(szStdErr), 128 szUser, sizeof(szUser), 129 szPassword, sizeof(szPassword), 130 &uTimeLimitMS); 131 return 0; 104 execData.szCmd, sizeof(execData.szCmd), 105 &execData.uFlags, 106 execData.szArgs, sizeof(execData.szArgs), &execData.uNumArgs, 107 execData.szEnv, &execData.cbEnv, &execData.uNumEnvVars, 108 execData.szStdIn, sizeof(execData.szStdIn), 109 execData.szStdOut, sizeof(execData.szStdOut), 110 execData.szStdErr, sizeof(execData.szStdErr), 111 execData.szUser, sizeof(execData.szUser), 112 execData.szPassword, sizeof(execData.szPassword), 113 &execData.uTimeLimitMS); 114 if (RT_SUCCESS(rc)) 115 { 116 /* Adjust time limit value. */ 117 execData.uTimeLimitMS = UINT32_MAX ? 118 RT_INDEFINITE_WAIT : execData.uTimeLimitMS; 119 120 /* Prepare argument list. */ 121 char **ppaArg; 122 int iArgs; 123 rc = RTGetOptArgvFromString(&ppaArg, &iArgs, execData.szArgs, NULL); 124 Assert(execData.uNumArgs == iArgs); 125 if (RT_SUCCESS(rc)) 126 { 127 /* Prepare environment list. */ 128 char **ppaEnv; 129 if (execData.uNumEnvVars) 130 { 131 ppaEnv = (char**)RTMemAlloc(execData.uNumEnvVars * sizeof(char*)); 132 AssertPtr(ppaEnv); 133 134 char *pcCur = execData.szEnv; 135 uint32_t i = 0; 136 while (pcCur < execData.szEnv + execData.cbEnv) 137 { 138 if (RTStrAPrintf(&ppaEnv[i++], "%s", pcCur) < 0) 139 { 140 rc = VERR_NO_MEMORY; 141 break; 142 } 143 pcCur += strlen(pcCur) + 1; /* Skip terminating zero. */ 144 } 145 } 146 147 if (RT_SUCCESS(rc)) 148 { 149 /* Do the actual execution. */ 150 rc = VBoxServiceControlExecProcess(&execData, ppaArg, ppaEnv); 151 for (uint32_t i = 0; i < execData.uNumEnvVars; i++) 152 RTStrFree(ppaEnv[i]); 153 RTMemFree(ppaEnv); 154 } 155 RTGetOptArgvFree(ppaArg); 156 } 157 } 158 return rc; 132 159 } 133 160 … … 168 195 break; 169 196 } 197 break; /* DEBUG BREAK */ 170 198 } 171 199 -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceInternal.h
r27114 r27926 125 125 #endif /* RT_OS_WINDOWS */ 126 126 127 #ifdef VBOX_WITH_GUEST_CONTROL 128 /* Structure for holding process execution data. */ 129 typedef struct _VBoxServiceControlProcessData 130 { 131 char szCmd[_1K]; 132 uint32_t uFlags; 133 char szArgs[_1K]; 134 uint32_t uNumArgs; 135 char szEnv[_64K]; 136 uint32_t cbEnv; 137 uint32_t uNumEnvVars; 138 char szStdIn[_1K]; 139 char szStdOut[_1K]; 140 char szStdErr[_1K]; 141 char szUser[128]; 142 char szPassword[128]; 143 uint32_t uTimeLimitMS; 144 } VBOXSERVICECTRLPROCDATA; 145 /** Pointer to execution data. */ 146 typedef VBOXSERVICECTRLPROCDATA *PVBOXSERVICECTRLPROCDATA; 147 /** 148 * For buffering process input supplied by the client. 149 */ 150 typedef struct _VBoxServiceControlStdInBuf 151 { 152 /** The mount of buffered data. */ 153 size_t cb; 154 /** The current data offset. */ 155 size_t off; 156 /** The data buffer. */ 157 char *pch; 158 /** The amount of allocated buffer space. */ 159 size_t cbAllocated; 160 /** Send further input into the bit bucket (stdin is dead). */ 161 bool fBitBucket; 162 /** The CRC-32 for standard input (received part). */ 163 uint32_t uCrc32; 164 } VBOXSERVICECTRLSTDINBUF; 165 /** Pointer to a standard input buffer. */ 166 typedef VBOXSERVICECTRLSTDINBUF *PVBOXSERVICECTRLSTDINBUF; 167 #endif 168 127 169 RT_C_DECLS_BEGIN 128 170 … … 167 209 #endif /* RT_OS_WINDOWS */ 168 210 211 #ifdef VBOX_WITH_GUEST_CONTROL 212 extern int VBoxServiceControlExecProcess(PVBOXSERVICECTRLPROCDATA pExecData, 213 const char * const *papszArgs, 214 const char * const *papszEnv); 215 #endif 216 169 217 #ifdef VBOXSERVICE_MANAGEMENT 170 218 extern uint32_t VBoxServiceBalloonQueryChunks(void);
Note:
See TracChangeset
for help on using the changeset viewer.