Changeset 33558 in vbox
- Timestamp:
- Oct 28, 2010 1:37:37 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/HostServices/GuestControlSvc.h
r33492 r33558 76 76 #define INPUT_FLAG_EOF RT_BIT(0) 77 77 78 /* 79 * Internal tools built into VBoxService which are 80 * used in order to accomplish tasks host<->guest. 81 */ 82 #define VBOXSERVICE_TOOL_CAT "vbox_cat" 83 78 84 /** 79 85 * Input status, reported by the client. -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlExec.cpp
r33492 r33558 1133 1133 else if (RTStrStr(pszExec, "vbox_") == pszExec) 1134 1134 { 1135 /* We want to use the internal toolbox. */ 1135 /* We want to use the internal toolbox (all internal 1136 * tools are starting with "vbox_" (e.g. "vbox_cat"). */ 1136 1137 pszCmdTool = RTStrDup(szVBoxService); 1137 1138 rc = VBoxServiceControlExecPrepareToolboxArgv(pszCmdTool, papszArgs, &papszArgsTool); … … 1158 1159 #endif 1159 1160 1161 /* If no user name specified run with current credentials. 1162 * This is prohibited via official Main API! */ 1163 if (!strlen(pszAsUser)) 1164 fFlags &= ~RTPROC_FLAGS_SERVICE; 1165 1160 1166 /* Do normal execution. */ 1161 1167 rc = RTProcCreateEx(pszExec, papszArgs, hEnv, fFlags, 1162 phStdIn, phStdOut, phStdErr, pszAsUser, 1163 pszPassword, phProcess); 1168 phStdIn, phStdOut, phStdErr, 1169 strlen(pszAsUser) ? pszAsUser : NULL, 1170 strlen(pszPassword) ? pszPassword : NULL, 1171 phProcess); 1164 1172 return rc; 1165 1173 } -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp
r33464 r33558 453 453 } 454 454 } 455 456 #if 0457 static int sent = 0;458 if (sent < 1)459 {460 RTISOFSFILE file;461 int vrc = RTIsoFsOpen(&file, "c:\\Downloads\\VBoxGuestAdditions_3.2.8.iso");462 if (RT_SUCCESS(vrc))463 {464 uint32_t cbOffset;465 size_t cbLength;466 vrc = RTIsoFsGetFileInfo(&file, "VBOXWINDOWSADDITIONS_X86.EXE", &cbOffset, &cbLength);467 //vrc = RTIsoFsGetFileInfo(&file, "32BIT/README.TXT", &cbOffset, &cbLength);468 if ( RT_SUCCESS(vrc)469 && cbOffset470 && cbLength)471 {472 vrc = RTFileSeek(file.file, cbOffset, RTFILE_SEEK_BEGIN, NULL);473 474 size_t cbRead;475 size_t cbToRead;476 SafeArray<BYTE> aInputData(_64K);477 while ( cbLength478 && RT_SUCCESS(vrc))479 {480 cbToRead = RT_MIN(cbLength, _64K);481 vrc = RTFileRead(file.file, (uint8_t*)aInputData.raw(), cbToRead, &cbRead);482 if ( cbRead483 && RT_SUCCESS(vrc))484 {485 aInputData.resize(cbRead);486 487 /* Did we reach the end of the content488 * we want to transfer (last chunk)? */489 ULONG uFlags = ProcessInputFlag_None;490 if (cbLength < _64K)491 {492 RTPrintf("Last!\n");493 uFlags |= ProcessInputFlag_EndOfFile;494 }495 496 ULONG uBytesWritten;497 rc = guest->SetProcessInput(uPID, uFlags,498 ComSafeArrayAsInParam(aInputData), &uBytesWritten);499 if (FAILED(rc))500 {501 /* If we got a VBOX_E_IPRT error we handle the error in a more gentle way502 * because it contains more accurate info about what went wrong. */503 ErrorInfo info(guest, COM_IIDOF(IGuest));504 if (info.isFullAvailable())505 {506 if (rc == VBOX_E_IPRT_ERROR)507 RTMsgError("%ls.", info.getText().raw());508 else509 RTMsgError("%ls (%Rhrc).", info.getText().raw(), info.getResultCode());510 }511 break;512 }513 else514 {515 //Assert(uTransfered == cbRead);516 cbLength -= uBytesWritten;517 RTPrintf("Left: %u\n", cbLength);518 }519 }520 }521 RTPrintf("Finished\n");522 }523 RTIsoFsClose(&file);524 }525 }526 sent++;527 #endif528 455 if (cbOutputData <= 0) /* No more output data left? */ 529 456 { -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.cpp
r33540 r33558 292 292 VBoxProgressDialog progressDlg (aProgress, aTitle, aMinDuration, aParent ? aParent : mainWindowShown()); 293 293 294 /* run the dialog with the 100 ms refresh interval*/294 /* Run the dialog with the 350 ms refresh interval. */ 295 295 progressDlg.run (350); 296 296 … … 2387 2387 message (aParent ? aParent : mainWindowShown(), 2388 2388 Error, 2389 tr ("Failed to update Guest Additions. "),2389 tr ("Failed to update Guest Additions. The Guest Additions installation image will be mounted to provide a manual installation."), 2390 2390 formatErrorInfo (aProgress.GetErrorInfo())); 2391 2391 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r33540 r33558 356 356 CVirtualBox vbox = vboxGlobal().virtualBox(); 357 357 358 #ifdef DEBUG_andy 358 /* 359 * Flag indicating whether we want to do the usual .ISO mounting or not. 360 * First try updating the Guest Additions directly without mounting the .ISO. 361 */ 362 bool fDoMount = false; 359 363 /* 360 364 * If the already installed Guest Additions indicate a … … 375 379 { 376 380 #ifdef DEBUG_andy 377 CProgress progressInstall = guest.UpdateGuestAdditions("c:\\Downloads\\VBoxGuestAdditions _3.2.8.iso");381 CProgress progressInstall = guest.UpdateGuestAdditions("c:\\Downloads\\VBoxGuestAdditions-r67158.iso"); 378 382 #else 379 383 CProgress progressInstall = guest.UpdateGuestAdditions(strSource); 380 384 #endif 381 #if 0382 385 bool fResult = guest.isOk(); 383 386 if (fResult) 384 387 { 385 vboxProblem().showModalProgressDialog(progressInstall, tr("Updating Guest Additions ..."), mainMachineWindow()); 388 vboxProblem().showModalProgressDialog(progressInstall, tr("Install"), 389 mainMachineWindow(), 0 /* No delay */); 386 390 if (progressInstall.GetCanceled()) 387 391 return; … … 389 393 { 390 394 vboxProblem().cannotUpdateGuestAdditions(progressInstall, mainMachineWindow()); 391 return;395 fDoMount = true; /* Since automatic updating failed, fall back to .ISO mounting. */ 392 396 } 393 397 } 394 #endif 395 } 396 else /* Fallback to only mounting the .ISO file. */ 397 { 398 #endif /* DEBUG_andy */ 398 } 399 else 400 { 401 /* Running guest OS not suitable (yet) for automatic updating, 402 * fall back to .ISO mounting. */ 403 fDoMount = true; 404 } 405 406 if (fDoMount) /* Fallback to only mounting the .ISO file. */ 407 { 399 408 QString strUuid; 400 409 CMedium image = vbox.FindMedium(strSource, KDeviceType_DVD); … … 471 480 else 472 481 vboxProblem().cannotMountGuestAdditions(machine.GetName()); 473 #ifdef DEBUG_andy 474 } 475 #endif /* DEBUG_andy */ 482 } 476 483 } 477 484 -
trunk/src/VBox/Main/GuestImpl.cpp
r33540 r33558 54 54 enum TaskType 55 55 { 56 /** Update Guest Additions by directly copying the required installer 57 * off the .ISO file, transfer it to the guest and execute the installer 58 * with system priviledges. */ 56 59 UpdateGuestAdditions = 100 57 60 }; … … 148 151 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 149 152 150 AutoWriteLock appLock(this COMMA_LOCKVAL_SRC_POS); 153 /* 154 * Do *not* take a write lock here since we don't (and won't) 155 * touch any class-specific data (of IGuest) here - only the member functions 156 * which get called here can do that. 157 */ 151 158 152 159 HRESULT rc = S_OK; … … 202 209 } 203 210 204 /** @todo Only Windows! */ 211 /** @todo Only Windows! Don't use percent (like %TEMP%) env vars -- Windows 212 * will quote it like "%TEMP%" which results in a *not* working command 213 * line! */ 205 214 Utf8Str strInstallerPath = "C:\\Windows\\VBoxWindowsAdditions.exe"; 206 215 … … 214 223 215 224 default: 216 rc = setError(VBOX_E_IPRT_ERROR, tr("An unknown error occured , rc=%Rrc"), vrc);225 rc = setError(VBOX_E_IPRT_ERROR, tr("An unknown error occured (%Rrc)"), vrc); 217 226 break; 218 227 } … … 220 229 else 221 230 { 222 /* Okay, we're ready to transfer the bits! */231 /* Okay, we're ready to start our copy routine on the guest! */ 223 232 if (aTask->progress) 224 233 aTask->progress->SetCurrentOperationProgress(15); … … 231 240 if (RTStrPrintf(szOutput, sizeof(szOutput), "--output=%s", strInstallerPath.c_str())) 232 241 { 233 args.push_back(Bstr( "vbox_cat").raw()); /* The actual (internal) tool to use (as argv[0]). */234 args.push_back(Bstr(szOutput).raw()); /* We want to write a file ... */242 args.push_back(Bstr(VBOXSERVICE_TOOL_CAT).raw()); /* The actual (internal) tool to use (as argv[0]). */ 243 args.push_back(Bstr(szOutput).raw()); /* We want to write a file ... */ 235 244 } 236 245 else … … 247 256 * system rights, no username/password specified). 248 257 */ 249 rc = pGuest->executeProcessInternal(Bstr( "vbox_cat").raw(),258 rc = pGuest->executeProcessInternal(Bstr(VBOXSERVICE_TOOL_CAT).raw(), 250 259 ExecuteProcessFlag_WaitForProcessStartOnly, 251 260 ComSafeArrayAsInParam(args), … … 270 279 && !fCompleted) 271 280 { 281 /* cbLength contains remaining bytes of our installer file 282 * opened above to read. */ 272 283 cbToRead = RT_MIN(cbLength, _64K); 273 vrc = RTFileRead(iso.file, (uint8_t*)aInputData.raw(), cbToRead, &cbRead); 274 if ( cbRead 275 && RT_SUCCESS(vrc)) 284 if (cbToRead) 276 285 { 277 aInputData.resize(cbRead); 278 279 /* Did we reach the end of the content 280 * we want to transfer (last chunk)? */ 281 ULONG uFlags = ProcessInputFlag_None; 282 if (cbRead < _64K) 283 uFlags |= ProcessInputFlag_EndOfFile; 284 285 /* Transfer the current chunk ... */ 286 ULONG uBytesWritten; 287 rc = SetProcessInput(uPID, uFlags, 288 ComSafeArrayAsInParam(aInputData), &uBytesWritten); 289 if (FAILED(rc)) 286 vrc = RTFileRead(iso.file, (uint8_t*)aInputData.raw(), cbToRead, &cbRead); 287 if ( cbRead 288 && RT_SUCCESS(vrc)) 290 289 { 291 break; 292 } 293 else 294 { 290 /* Did we reach the end of the content 291 * we want to transfer (last chunk)? */ 292 ULONG uFlags = ProcessInputFlag_None; 293 if (cbRead < _64K) 294 { 295 uFlags |= ProcessInputFlag_EndOfFile; 296 if (cbRead > 0) /* Don't allow an empty array! */ 297 aInputData.resize(cbRead); /* Adjust array size (less than 64K read). */ 298 } 299 300 /* Transfer the current chunk ... */ 301 ULONG uBytesWritten; 302 rc = SetProcessInput(uPID, uFlags, 303 ComSafeArrayAsInParam(aInputData), &uBytesWritten); 304 if (FAILED(rc)) 305 break; 306 307 Assert(cbLength >= uBytesWritten); 295 308 cbLength -= uBytesWritten; 296 } 297 298 /* Progress canceled by Main API? */299 if ( SUCCEEDED(progressCopy->COMGETTER(Canceled(&fCanceled)))300 && fCanceled)301 {302 break;309 310 /* Progress canceled by Main API? */ 311 if ( SUCCEEDED(progressCopy->COMGETTER(Canceled(&fCanceled))) 312 && fCanceled) 313 { 314 break; 315 } 303 316 } 304 317 } … … 324 337 /** @todo Only Windows! */ 325 338 installerArgs.push_back(Bstr(strInstallerPath).raw()); /* The actual (internal) installer image (as argv[0]). */ 326 installerArgs.push_back(Bstr("/S").raw()); /* We want to install in silent mode. */ 327 installerArgs.push_back(Bstr("/l").raw()); /* ... and logging enabled. */ 339 /* Note that starting at Windows Vista the lovely session 0 separation applies: 340 * This means that if we run an application with the profile/security context 341 * of VBoxService (system rights!) we're not able to show any UI. */ 342 installerArgs.push_back(Bstr("/S").raw()); /* We want to install in silent mode. */ 343 installerArgs.push_back(Bstr("/l").raw()); /* ... and logging enabled. */ 344 /* Don't quit VBoxService during upgrade because it still is used for this 345 * piece of code we're in right now (that is, here!) ... */ 346 installerArgs.push_back(Bstr("/no_vboxservice_exit").raw()); 328 347 329 348 /* 330 * Start built-in "vbox_cat" tool (inside VBoxService) to 331 * copy over/pipe the data into a file on the guest (with 332 * system rights, no username/password specified). 349 * Start the just copied over installer with system rights 350 * in silent mode on the guest. 333 351 */ 334 352 ComPtr<IProgress> progressInstaller; … … 2264 2282 if (RTStrPrintf(szOutput, sizeof(szOutput), "--output=%s", Utf8Dest.c_str())) 2265 2283 { 2266 args.push_back(Bstr( "vbox_cat").raw()); /* The actual (internal) tool to use (as argv[0]). */2267 args.push_back(Bstr(szOutput).raw()); /* We want to write a file ... */2284 args.push_back(Bstr(VBOXSERVICE_TOOL_CAT).raw()); /* The actual (internal) tool to use (as argv[0]). */ 2285 args.push_back(Bstr(szOutput).raw()); /* We want to write a file ... */ 2268 2286 } 2269 2287 else … … 2280 2298 * actual copying, start the guest part now. 2281 2299 */ 2282 rc = ExecuteProcess(Bstr( "vbox_cat").raw(),2300 rc = ExecuteProcess(Bstr(VBOXSERVICE_TOOL_CAT).raw(), 2283 2301 ExecuteProcessFlag_WaitForProcessStartOnly, 2284 2302 ComSafeArrayAsInParam(args), … … 2377 2395 std::auto_ptr<TaskGuest> task(new TaskGuest(TaskGuest::UpdateGuestAdditions, this, progress)); 2378 2396 2379 /* Assign data. */ 2397 /* Assign data - in that case aSource is the full path 2398 * to the Guest Additions .ISO we want to mount. */ 2380 2399 task->strSource = (Utf8Str(aSource)); 2381 2400
Note:
See TracChangeset
for help on using the changeset viewer.