Changeset 44097 in vbox for trunk/src/VBox/Additions/common/VBoxService/VBoxServiceUtils.cpp
- Timestamp:
- Dec 11, 2012 5:06:02 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceUtils.cpp
r33540 r44097 5 5 6 6 /* 7 * Copyright (C) 2009-201 0Oracle Corporation7 * Copyright (C) 2009-2012 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 48 48 * on success. Optional. 49 49 */ 50 int VBoxServiceReadProp(uint32_t u32ClientId, const char *pszPropName, char **ppszValue, char **ppszFlags, uint64_t *puTimestamp) 51 { 50 int VBoxServiceReadProp(uint32_t u32ClientId, const char *pszPropName, 51 char **ppszValue, char **ppszFlags, uint64_t *puTimestamp) 52 { 53 AssertPtrReturn(pszPropName, VERR_INVALID_POINTER); 54 AssertPtrReturn(ppszValue, VERR_INVALID_POINTER); 55 52 56 uint32_t cbBuf = _1K; 53 57 void *pvBuf = NULL; … … 122 126 * 123 127 */ 124 int VBoxServiceReadPropUInt32(uint32_t u32ClientId, const char *pszPropName, uint32_t *pu32, uint32_t u32Min, uint32_t u32Max) 128 int VBoxServiceReadPropUInt32(uint32_t u32ClientId, const char *pszPropName, 129 uint32_t *pu32, uint32_t u32Min, uint32_t u32Max) 125 130 { 126 131 char *pszValue; 127 132 int rc = VBoxServiceReadProp(u32ClientId, pszPropName, &pszValue, 128 NULL /* ppszFlags */, NULL /* puTimestamp */);133 NULL /* ppszFlags */, NULL /* puTimestamp */); 129 134 if (RT_SUCCESS(rc)) 130 135 { 131 AssertPtr(pu32);132 136 char *pszNext; 133 137 rc = RTStrToUInt32Ex(pszValue, &pszNext, 0, pu32); … … 140 144 RTStrFree(pszValue); 141 145 } 146 return rc; 147 } 148 149 150 /** 151 * Reads a guest property from the host side. 152 * 153 * @returns VBox status code, fully bitched. 154 * 155 * @param u32ClientId The HGCM client ID for the guest property session. 156 * @param pszPropName The property name. 157 * @param fReadOnly Whether or not this property needs to be read only 158 * by the guest side. Otherwise VERR_ACCESS_DENIED will 159 * be returned. 160 * @param ppszValue Where to return the value. This is always set 161 * to NULL. Free it using RTStrFree(). 162 * @param ppszFlags Where to return the value flags. Free it 163 * using RTStrFree(). Optional. 164 * @param puTimestamp Where to return the timestamp. This is only set 165 * on success. Optional. 166 */ 167 int VBoxServiceReadHostProp(uint32_t u32ClientId, const char *pszPropName, bool fReadOnly, 168 char **ppszValue, char **ppszFlags, uint64_t *puTimestamp) 169 { 170 char *pszFlags; 171 int rc = VBoxServiceReadProp(u32ClientId, pszPropName, ppszValue, &pszFlags, puTimestamp); 172 if (RT_SUCCESS(rc)) 173 { 174 /* Check security bits. */ 175 if ( fReadOnly /* Do we except a guest read-only property */ 176 && !RTStrStr(pszFlags, "RDONLYGUEST")) 177 { 178 /* If we want a property which is read-only on the guest 179 * and it is *not* marked as such, deny access! */ 180 rc = VERR_ACCESS_DENIED; 181 } 182 183 if (ppszFlags) 184 *ppszFlags = pszFlags; 185 else 186 RTStrFree(pszFlags); 187 } 188 142 189 return rc; 143 190 }
Note:
See TracChangeset
for help on using the changeset viewer.