- Timestamp:
- Dec 14, 2009 10:15:38 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/GuestProperties/service.cpp
r25347 r25354 226 226 /** 227 227 * Check whether we have permission to change a property. 228 * @returns VINF_SUCCESS if we do, VERR_PERMISSION_DENIED otherwise 228 * 229 * @returns Strict VBox status code. 230 * @retval VINF_SUCCESS if we do. 231 * @retval VERR_PERMISSION_DENIED if the value is read-only for the requesting 232 * side. 233 * @retval VINF_PERMISSION_DENIED if the side is globally marked read-only. 234 * 229 235 * @param eFlags the flags on the property in question 230 236 * @param isGuest is the guest or the host trying to make the change? … … 232 238 int checkPermission(ePropFlags eFlags, bool isGuest) 233 239 { 234 if ( (isGuest && (eFlags & RDONLYGUEST)) 235 || (isGuest && (meGlobalFlags & RDONLYGUEST)) 236 || (!isGuest && (eFlags & RDONLYHOST)) 237 ) 240 if (eFlags & (isGuest ? RDONLYGUEST : RDONLYHOST)) 241 return VERR_PERMISSION_DENIED; 242 if (isGuest && (meGlobalFlags & RDONLYGUEST)) 238 243 return VINF_PERMISSION_DENIED; 239 240 244 return VINF_SUCCESS; 241 245 } … … 649 653 if ((3 == cParms) && RT_SUCCESS(rc)) 650 654 rc = validateFlags(pcszFlags, &fFlags); 651 652 /*653 * If the property already exists, check its flags to see if we are allowed654 * to change it.655 */656 PropertyList::iterator it;657 bool found = false;658 if (RT_SUCCESS(rc))655 if (RT_SUCCESS(rc)) 656 { 657 /* 658 * If the property already exists, check its flags to see if we are allowed 659 * to change it. 660 */ 661 PropertyList::iterator it; 662 bool found = false; 659 663 for (it = mProperties.begin(); it != mProperties.end(); ++it) 660 664 if (it->mName.compare(pcszName) == 0) … … 663 667 break; 664 668 } 665 if (RT_SUCCESS(rc)) 669 666 670 rc = checkPermission(found ? (ePropFlags)it->mFlags : NILFLAG, 667 671 isGuest); 668 669 if (rc == VINF_PERMISSION_DENIED) 670 return rc; 671 672 /* 673 * Set the actual value 674 */ 675 if (RT_SUCCESS(rc)) 676 { 677 if (found) 678 { 679 it->mValue = pcszValue; 680 it->mTimestamp = u64TimeNano; 681 it->mFlags = fFlags; 672 if (rc == VINF_SUCCESS) 673 { 674 /* 675 * Set the actual value 676 */ 677 if (found) 678 { 679 it->mValue = pcszValue; 680 it->mTimestamp = u64TimeNano; 681 it->mFlags = fFlags; 682 } 683 else /* This can throw. No problem as we have nothing to roll back. */ 684 mProperties.push_back(Property(pcszName, pcszValue, u64TimeNano, fFlags)); 685 686 /* 687 * Send a notification to the host and return. 688 */ 689 // if (isGuest) /* Notify the host even for properties that the host 690 // * changed. Less efficient, but ensures consistency. */ 691 doNotifications(pcszName, u64TimeNano); 692 Log2(("Set string %s, rc=%Rrc, value=%s\n", pcszName, rc, pcszValue)); 682 693 } 683 else /* This can throw. No problem as we have nothing to roll back. */ 684 mProperties.push_back(Property(pcszName, pcszValue, u64TimeNano, fFlags)); 685 } 686 687 /* 688 * Send a notification to the host and return. 689 */ 690 if (RT_SUCCESS(rc)) 691 { 692 // if (isGuest) /* Notify the host even for properties that the host 693 // * changed. Less efficient, but ensures consistency. */ 694 doNotifications(pcszName, u64TimeNano); 695 Log2(("Set string %s, rc=%Rrc, value=%s\n", pcszName, rc, pcszValue)); 696 } 694 } 695 697 696 LogFlowThisFunc(("rc = %Rrc\n", rc)); 698 697 return rc; … … 727 726 else 728 727 rc = VERR_INVALID_PARAMETER; 729 730 /*731 * If the property exists, check its flags to see if we are allowed732 * to change it.733 */734 PropertyList::iterator it;735 bool found = false;736 if (RT_SUCCESS(rc))728 if (RT_SUCCESS(rc)) 729 { 730 /* 731 * If the property exists, check its flags to see if we are allowed 732 * to change it. 733 */ 734 PropertyList::iterator it; 735 bool found = false; 737 736 for (it = mProperties.begin(); it != mProperties.end(); ++it) 738 737 if (it->mName.compare(pcszName) == 0) … … 741 740 break; 742 741 } 743 if (RT_SUCCESS(rc)) 744 rc = checkPermission(found ? (ePropFlags)it->mFlags : 745 NILFLAG, isGuest); 746 747 if (rc == VINF_PERMISSION_DENIED) 748 return rc; 749 750 /* 751 * And delete the property if all is well. 752 */ 753 if (RT_SUCCESS(rc) && found) 754 { 755 RTTIMESPEC time; 756 uint64_t u64Timestamp = RTTimeSpecGetNano(RTTimeNow(&time)); 757 mProperties.erase(it); 758 // if (isGuest) /* Notify the host even for properties that the host 759 // * changed. Less efficient, but ensures consistency. */ 760 doNotifications(pcszName, u64Timestamp); 761 } 742 rc = checkPermission(found ? (ePropFlags)it->mFlags : NILFLAG, 743 isGuest); 744 745 /* 746 * And delete the property if all is well. 747 */ 748 if (rc == VINF_SUCCESS && found) 749 { 750 RTTIMESPEC time; 751 uint64_t u64Timestamp = RTTimeSpecGetNano(RTTimeNow(&time)); 752 mProperties.erase(it); 753 // if (isGuest) /* Notify the host even for properties that the host 754 // * changed. Less efficient, but ensures consistency. */ 755 doNotifications(pcszName, u64Timestamp); 756 } 757 } 758 762 759 LogFlowThisFunc(("rc = %Rrc\n", rc)); 763 760 return rc; … … 1069 1066 if (prop.Matches(pszPatterns)) 1070 1067 { 1071 GuestCall c all = *it;1072 int rc2 = getNotificationWriteOut(c all.mParms, prop);1068 GuestCall curCall = *it; 1069 int rc2 = getNotificationWriteOut(curCall.mParms, prop); 1073 1070 if (RT_SUCCESS(rc2)) 1074 rc2 = c all.mRc;1075 mpHelpers->pfnCallComplete (call.mHandle, rc2);1071 rc2 = curCall.mRc; 1072 mpHelpers->pfnCallComplete(curCall.mHandle, rc2); 1076 1073 it = mGuestWaiters.erase(it); 1077 1074 }
Note:
See TracChangeset
for help on using the changeset viewer.