- Timestamp:
- Oct 16, 2008 10:16:40 AM (16 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/GuestProperties/service.cpp
r13293 r13328 148 148 rc = RTThreadCreate(&mReqThread, reqThreadFn, this, 0, RTTHREADTYPE_MSG_PUMP, 149 149 RTTHREADFLAGS_WAITABLE, "GuestPropReq"); 150 if ( !RT_SUCCESS(rc))150 if (RT_FAILURE(rc)) 151 151 throw rc; 152 152 } … … 214 214 int getPropValue(uint32_t cParms, VBOXHGCMSVCPARM paParms[]); 215 215 int getProperty(uint32_t cParms, VBOXHGCMSVCPARM paParms[]); 216 int setProperty(uint32_t cParms, VBOXHGCMSVCPARM paParms[], bool notify);217 int delProperty(uint32_t cParms, VBOXHGCMSVCPARM paParms[], bool notify);216 int setProperty(uint32_t cParms, VBOXHGCMSVCPARM paParms[], bool isGuest); 217 int delProperty(uint32_t cParms, VBOXHGCMSVCPARM paParms[], bool isGuest); 218 218 int enumProps(uint32_t cParms, VBOXHGCMSVCPARM paParms[]); 219 219 void notifyHost(const char *pszProperty); … … 451 451 * @thread HGCM 452 452 */ 453 int Service::setProperty(uint32_t cParms, VBOXHGCMSVCPARM paParms[], bool notify)453 int Service::setProperty(uint32_t cParms, VBOXHGCMSVCPARM paParms[], bool isGuest) 454 454 { 455 455 int rc = VINF_SUCCESS; … … 482 482 rc = VERR_INVALID_PARAMETER; 483 483 /* 484 * And check the values passed in the parameters for correctness.484 * Check the values passed in the parameters for correctness. 485 485 */ 486 486 if (RT_SUCCESS(rc)) … … 492 492 if (RT_SUCCESS(rc)) 493 493 rc = validateValue(pszValue, cchValue); 494 if (RT_SUCCESS(rc)) 495 { 496 /* We deal with flags as follows: 497 * 1) if flags are specified by the user, use them. 498 * 2) if no flags are specified, but the property exists, use the 499 * existing flags. 500 * 3) if no flags are specified and the property does not exist, 501 * start with empty flags (the default value of fFlags above). */ 502 if (3 == cParms) 503 { 504 char *pszFlags; 505 uint32_t cchFlags; 506 rc = VBoxHGCMParmPtrGet(&paParms[2], (void **) &pszFlags, &cchFlags); 507 if (RT_SUCCESS(rc)) 508 rc = validateFlags(pszFlags, &fFlags); 509 } 510 else 511 /* If this fails then fFlags will remain at zero, as per our spec. */ 512 CFGMR3QueryU32(mpFlagsNode, pszName, &fFlags); 494 495 /* 496 * If the property already exists, check its flags to see if we are allowed 497 * to change it. 498 */ 499 if (RT_SUCCESS(rc)) 500 { 501 CFGMR3QueryU32(mpFlagsNode, pszName, &fFlags); /* Failure is no problem here. */ 502 if ( (fFlags & READONLY) 503 || (isGuest && (fFlags & HOSTWRITE)) 504 || (!isGuest && (fFlags & GUESTWRITE)) 505 ) 506 rc = VERR_PERMISSION_DENIED; 507 } 508 509 /* 510 * Check whether the user supplied flags (if any) are valid. 511 */ 512 if (RT_SUCCESS(rc) && (3 == cParms)) 513 { 514 char *pszFlags; 515 uint32_t cchFlags; 516 rc = VBoxHGCMParmPtrGet(&paParms[2], (void **) &pszFlags, &cchFlags); 517 if (RT_SUCCESS(rc)) 518 rc = validateFlags(pszFlags, &fFlags); 513 519 } 514 520 /* … … 529 535 /* If anything goes wrong, make sure that we leave a clean state 530 536 * behind. */ 531 if ( !RT_SUCCESS(rc))537 if (RT_FAILURE(rc)) 532 538 { 533 539 CFGMR3RemoveValue(mpValueNode, pszName); … … 541 547 if (RT_SUCCESS(rc)) 542 548 { 543 if ( notify)549 if (isGuest) 544 550 notifyHost(pszName); 545 551 Log2(("Set string %s, rc=%Rrc, value=%s\n", pszName, rc, pszValue)); … … 559 565 * @thread HGCM 560 566 */ 561 int Service::delProperty(uint32_t cParms, VBOXHGCMSVCPARM paParms[], bool notify)567 int Service::delProperty(uint32_t cParms, VBOXHGCMSVCPARM paParms[], bool isGuest) 562 568 { 563 569 int rc = VINF_SUCCESS; … … 567 573 LogFlowThisFunc(("\n")); 568 574 AssertReturn(VALID_PTR(mpValueNode), VERR_WRONG_ORDER); /* a.k.a. VERR_NOT_INITIALIZED */ 575 576 /* 577 * Check the user-supplied parameters. 578 */ 569 579 if ( (cParms != 1) /* Hardcoded value as the next lines depend on it. */ 570 580 || (paParms[0].type != VBOX_HGCM_SVC_PARM_PTR) /* name */ … … 575 585 if (RT_SUCCESS(rc)) 576 586 rc = validateName(pszName, cbName); 587 588 /* 589 * If the property already exists, check its flags to see if we are allowed 590 * to change it. 591 */ 592 if (RT_SUCCESS(rc)) 593 { 594 uint32_t fFlags = NILFLAG; 595 CFGMR3QueryU32(mpFlagsNode, pszName, &fFlags); /* Failure is no problem here. */ 596 if ( (fFlags & READONLY) 597 || (isGuest && (fFlags & HOSTWRITE)) 598 || (!isGuest && (fFlags & GUESTWRITE)) 599 ) 600 rc = VERR_PERMISSION_DENIED; 601 } 602 603 /* 604 * And delete the property if all is well. 605 */ 577 606 if (RT_SUCCESS(rc)) 578 607 { 579 608 CFGMR3RemoveValue(mpValueNode, pszName); 580 if ( notify)609 if (isGuest) 581 610 notifyHost(pszName); 582 611 } … … 817 846 (uint32_t) RT_HIDWORD(u64Timestamp), 818 847 (uint32_t) RT_LODWORD(u64Timestamp), pszFlags); 819 if ( !RT_SUCCESS(rc)) /* clean up */848 if (RT_FAILURE(rc)) /* clean up */ 820 849 { 821 850 RTStrFree(pszName); … … 836 865 mpvHostData, pszName, NULL, 0, 0, NULL); 837 866 } 838 if ( !RT_SUCCESS(rc)) /* clean up if we failed somewhere */867 if (RT_FAILURE(rc)) /* clean up if we failed somewhere */ 839 868 { 840 869 RTStrFree(pszName); -
trunk/src/VBox/Main/ConsoleImpl.cpp
r13293 r13328 3688 3688 /* The returned string should never be able to be greater than our buffer */ 3689 3689 AssertLogRel (vrc != VERR_BUFFER_OVERFLOW); 3690 AssertLogRel ( !RT_SUCCESS(vrc) || VBOX_HGCM_SVC_PARM_64BIT == parm[2].type);3690 AssertLogRel (RT_FAILURE(vrc) || VBOX_HGCM_SVC_PARM_64BIT == parm[2].type); 3691 3691 if (RT_SUCCESS (vrc) || (VERR_NOT_FOUND == vrc)) 3692 3692 { … … 4477 4477 for (pValue = CFGMR3GetFirstValue (pValues); pValue != NULL; 4478 4478 pValue = CFGMR3GetNextValue (pValue)) 4479 ++cValues; 4479 { 4480 char szPropName[guestProp::MAX_NAME_LEN + 1]; 4481 vrc = CFGMR3GetValueName (pValue, szPropName, sizeof(szPropName)); 4482 if (RT_SUCCESS(vrc)) 4483 { 4484 /* Do not send transient properties unless we are saving state */ 4485 uint32_t fFlags = guestProp::NILFLAG; 4486 CFGMR3QueryU32 (pFlags, szPropName, &fFlags); 4487 if (!(fFlags & guestProp::TRANSIENT) || 4488 (mMachineState == MachineState_Saving)) 4489 ++cValues; 4490 } 4491 } 4480 4492 /* And pack them into safe arrays */ 4481 4493 com::SafeArray <BSTR> names(cValues); … … 4499 4511 if (RT_SUCCESS(vrc)) 4500 4512 { 4501 uint32_t fFlags ;4513 uint32_t fFlags = NILFLAG; 4502 4514 CFGMR3QueryU32 (pFlags, szPropName, &fFlags); 4503 writeFlags(fFlags, szPropFlags); 4504 CFGMR3QueryU64 (pTimestamps, szPropName, &u64Timestamp); 4505 Bstr(szPropName).cloneTo(&names[iProp]); 4506 Bstr(szPropValue).cloneTo(&values[iProp]); 4507 timestamps[iProp] = u64Timestamp; 4508 Bstr(szPropFlags).cloneTo(&flags[iProp]); 4515 /* Skip transient properties unless we are saving state */ 4516 if (!(fFlags & TRANSIENT) || 4517 (mMachineState == MachineState_Saving)) 4518 { 4519 writeFlags(fFlags, szPropFlags); 4520 CFGMR3QueryU64 (pTimestamps, szPropName, &u64Timestamp); 4521 Bstr(szPropName).cloneTo(&names[iProp]); 4522 Bstr(szPropValue).cloneTo(&values[iProp]); 4523 timestamps[iProp] = u64Timestamp; 4524 Bstr(szPropFlags).cloneTo(&flags[iProp]); 4525 ++iProp; 4526 if (iProp >= cValues) 4527 vrc = VERR_TOO_MUCH_DATA; 4528 } 4509 4529 pValue = CFGMR3GetNextValue (pValue); 4510 ++iProp;4511 if (iProp >= cValues)4512 vrc = VERR_TOO_MUCH_DATA;4513 4530 } 4514 4531 }
Note:
See TracChangeset
for help on using the changeset viewer.