Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

505 lines
13 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. scope.cxx
  5. Abstract:
  6. Routines implementing the Application object
  7. Author:
  8. Cliff Van Dyke (cliffv) 11-Apr-2001
  9. --*/
  10. #include "pch.hxx"
  11. DWORD
  12. AzpApplicationInit(
  13. IN PGENERIC_OBJECT ParentGenericObject,
  14. IN PGENERIC_OBJECT ChildGenericObject
  15. )
  16. /*++
  17. Routine Description:
  18. This routine is a worker routine for AzApplicationCreate. It does any object specific
  19. initialization that needs to be done.
  20. On entry, AzGlResource must be locked exclusively.
  21. Arguments:
  22. ParentGenericObject - Specifies the parent object to add the child object onto.
  23. The reference count has been incremented on this object.
  24. ChildGenericObject - Specifies the newly allocated child object.
  25. The reference count has been incremented on this object.
  26. Return Value:
  27. NO_ERROR - The operation was successful
  28. ERROR_NOT_ENOUGH_MEMORY - not enough memory
  29. Other exception status codes
  30. --*/
  31. {
  32. PAZP_APPLICATION Application = (PAZP_APPLICATION) ChildGenericObject;
  33. PAZP_ADMIN_MANAGER AdminManager = (PAZP_ADMIN_MANAGER) ParentGenericObject;
  34. //
  35. // Initialization
  36. //
  37. ASSERT( AzpIsLockedExclusive( &AzGlResource ) );
  38. //
  39. // Sanity check the parent
  40. //
  41. ASSERT( ParentGenericObject->ObjectType == OBJECT_TYPE_ADMIN_MANAGER );
  42. //
  43. // Initialize the authz resource manager
  44. //
  45. if ( !AuthzInitializeResourceManager(
  46. AUTHZ_RM_FLAG_NO_AUDIT, // We don't yet support auditting
  47. NULL, // No Callback ace function ???
  48. NULL, // We compute our own dynamic groups
  49. NULL, // " "
  50. Application->GenericObject.ObjectName.String,
  51. &Application->AuthzResourceManager ) ) {
  52. return GetLastError();
  53. }
  54. //
  55. // Initialize the lists of child objects
  56. // Let the generic object manager know all of the types of children we support
  57. //
  58. ChildGenericObject->ChildGenericObjectHead = &Application->Operations;
  59. // List of child operations
  60. ObInitGenericHead( &Application->Operations,
  61. OBJECT_TYPE_OPERATION,
  62. ChildGenericObject,
  63. &Application->Tasks,
  64. NULL ); // Doesn't share namespace (YET)
  65. // List of child tasks
  66. ObInitGenericHead( &Application->Tasks,
  67. OBJECT_TYPE_TASK,
  68. ChildGenericObject,
  69. &Application->Scopes,
  70. &Application->Operations ); // Shares namespace with operations
  71. // List of child scopes
  72. ObInitGenericHead( &Application->Scopes,
  73. OBJECT_TYPE_SCOPE,
  74. ChildGenericObject,
  75. &Application->Groups,
  76. NULL ); // Doesn't share namespace
  77. // List of child groups
  78. ObInitGenericHead( &Application->Groups,
  79. OBJECT_TYPE_GROUP,
  80. ChildGenericObject,
  81. &Application->Roles,
  82. &AdminManager->Groups ); // Shares namespace with the groups of my parent object
  83. // List of child roles
  84. ObInitGenericHead( &Application->Roles,
  85. OBJECT_TYPE_ROLE,
  86. ChildGenericObject,
  87. &Application->JunctionPoints,
  88. NULL ); // Doesn't share namespace
  89. // List of child junction points
  90. ObInitGenericHead( &Application->JunctionPoints,
  91. OBJECT_TYPE_JUNCTION_POINT,
  92. ChildGenericObject,
  93. &Application->AzpSids,
  94. NULL ); // Doesn't share namespace
  95. // List of child AzpSids
  96. ObInitGenericHead( &Application->AzpSids,
  97. OBJECT_TYPE_SID,
  98. ChildGenericObject,
  99. &Application->ClientContexts,
  100. NULL ); // Doesn't share namespace
  101. // List of child ClientContexts
  102. ObInitGenericHead( &Application->ClientContexts,
  103. OBJECT_TYPE_CLIENT_CONTEXT,
  104. ChildGenericObject,
  105. NULL,
  106. NULL ); // Doesn't share namespace
  107. //
  108. // Applications are referenced by "JunctionPoints"
  109. // Let the generic object manager know all of the lists we support
  110. // This is a "back" link so we don't need to define which tasks can reference this operation.
  111. //
  112. ChildGenericObject->GenericObjectLists = &Application->backJunctionPoints;
  113. // Back link to junction points
  114. ObInitObjectList( &Application->backJunctionPoints,
  115. NULL,
  116. TRUE, // Backward link
  117. 0, // No link pair id
  118. NULL,
  119. NULL,
  120. NULL );
  121. return NO_ERROR;
  122. }
  123. VOID
  124. AzpApplicationFree(
  125. IN PGENERIC_OBJECT GenericObject
  126. )
  127. /*++
  128. Routine Description:
  129. This routine is a worker routine for Application object free. It does any object specific
  130. cleanup that needs to be done.
  131. On entry, AzGlResource must be locked exclusively.
  132. Arguments:
  133. GenericObject - Specifies a pointer to the object to be deleted.
  134. Return Value:
  135. None
  136. --*/
  137. {
  138. PAZP_APPLICATION Application = (PAZP_APPLICATION) GenericObject;
  139. //
  140. // Initialization
  141. //
  142. ASSERT( AzpIsLockedExclusive( &AzGlResource ) );
  143. //
  144. // Free any local strings
  145. //
  146. if ( Application->AuthzResourceManager != NULL ) {
  147. if ( !AuthzFreeResourceManager( Application->AuthzResourceManager ) ) {
  148. ASSERT( FALSE );
  149. }
  150. }
  151. }
  152. DWORD
  153. WINAPI
  154. AzApplicationCreate(
  155. IN AZ_HANDLE AdminManagerHandle,
  156. IN LPCWSTR ApplicationName,
  157. IN DWORD Reserved,
  158. OUT PAZ_HANDLE ApplicationHandle
  159. )
  160. /*++
  161. Routine Description:
  162. This routine adds an application into the scope of the specified AdminManager.
  163. Arguments:
  164. AdminManagerHandle - Specifies a handle to the AdminManager.
  165. ApplicationName - Specifies the name of the application to add.
  166. Reserved - Reserved. Must by zero.
  167. ApplicationHandle - Return a handle to the application.
  168. The caller must close this handle by calling AzCloseHandle.
  169. Return Value:
  170. NO_ERROR - The operation was successful
  171. ERROR_ALREADY_EXISTS - An object by that name already exists
  172. --*/
  173. {
  174. //
  175. // Call the common routine to do most of the work
  176. //
  177. return ObCommonCreateObject(
  178. (PGENERIC_OBJECT) AdminManagerHandle,
  179. OBJECT_TYPE_ADMIN_MANAGER,
  180. &(((PAZP_ADMIN_MANAGER)AdminManagerHandle)->Applications),
  181. OBJECT_TYPE_APPLICATION,
  182. ApplicationName,
  183. Reserved,
  184. (PGENERIC_OBJECT *) ApplicationHandle );
  185. }
  186. DWORD
  187. WINAPI
  188. AzApplicationOpen(
  189. IN AZ_HANDLE AdminManagerHandle,
  190. IN LPCWSTR ApplicationName,
  191. IN DWORD Reserved,
  192. OUT PAZ_HANDLE ApplicationHandle
  193. )
  194. /*++
  195. Routine Description:
  196. This routine opens an application into the scope of the specified AdminManager.
  197. Arguments:
  198. AdminManagerHandle - Specifies a handle to the AdminManager.
  199. ApplicationName - Specifies the name of the application to open
  200. Reserved - Reserved. Must by zero.
  201. ApplicationHandle - Return a handle to the application.
  202. The caller must close this handle by calling AzCloseHandle.
  203. Return Value:
  204. NO_ERROR - The operation was successful
  205. ERROR_NOT_FOUND - There is no application by that name
  206. --*/
  207. {
  208. //
  209. // Call the common routine to do most of the work
  210. //
  211. return ObCommonOpenObject(
  212. (PGENERIC_OBJECT) AdminManagerHandle,
  213. OBJECT_TYPE_ADMIN_MANAGER,
  214. &(((PAZP_ADMIN_MANAGER)AdminManagerHandle)->Applications),
  215. OBJECT_TYPE_APPLICATION,
  216. ApplicationName,
  217. Reserved,
  218. (PGENERIC_OBJECT *) ApplicationHandle );
  219. }
  220. DWORD
  221. WINAPI
  222. AzApplicationEnum(
  223. IN AZ_HANDLE AdminManagerHandle,
  224. IN DWORD Reserved,
  225. IN OUT PULONG EnumerationContext,
  226. OUT PAZ_HANDLE ApplicationHandle
  227. )
  228. /*++
  229. Routine Description:
  230. Enumerates all of the applications for the specified AdminManager.
  231. Arguments:
  232. AdminManagerHandle - Specifies a handle to the AdminManager.
  233. Reserved - Reserved. Must by zero.
  234. EnumerationContext - Specifies a context indicating the next application to return
  235. On input for the first call, should point to zero.
  236. On input for subsequent calls, should point to the value returned on the previous call.
  237. On output, returns a value to be passed on the next call.
  238. ApplicationHandle - Returns a handle to the next application object.
  239. The caller must close this handle by calling AzCloseHandle.
  240. Return Value:
  241. NO_ERROR - The operation was successful (a handle was returned)
  242. ERROR_NO_MORE_ITEMS - No more items were available for enumeration
  243. --*/
  244. {
  245. //
  246. // Call the common routine to do most of the work
  247. //
  248. return ObCommonEnumObjects(
  249. (PGENERIC_OBJECT) AdminManagerHandle,
  250. OBJECT_TYPE_ADMIN_MANAGER,
  251. &(((PAZP_ADMIN_MANAGER)AdminManagerHandle)->Applications),
  252. EnumerationContext,
  253. Reserved,
  254. (PGENERIC_OBJECT *) ApplicationHandle );
  255. }
  256. DWORD
  257. WINAPI
  258. AzApplicationGetProperty(
  259. IN AZ_HANDLE ApplicationHandle,
  260. IN ULONG PropertyId,
  261. IN DWORD Reserved,
  262. OUT PVOID *PropertyValue
  263. )
  264. /*++
  265. Routine Description:
  266. Returns the specified property for an application.
  267. Arguments:
  268. ApplicationHandle - Specifies a handle to the application
  269. PropertyId - Specifies which property to return.
  270. Reserved - Reserved. Must by zero.
  271. PropertyValue - Specifies a pointer to return the property in.
  272. The returned pointer must be freed using AzFreeMemory.
  273. The returned value and type depends in PropertyId. The valid values are:
  274. AZ_PROP_NAME LPWSTR - Object name of the object
  275. AZ_PROP_DESCRIPTION LPWSTR - Description of the object
  276. Return Value:
  277. NO_ERROR - The operation was successful
  278. ERROR_INVALID_PARAMETER - PropertyId isn't valid
  279. --*/
  280. {
  281. //
  282. // Call the common routine to do most of the work
  283. //
  284. return ObCommonGetProperty(
  285. (PGENERIC_OBJECT) ApplicationHandle,
  286. OBJECT_TYPE_APPLICATION,
  287. PropertyId,
  288. Reserved,
  289. PropertyValue );
  290. }
  291. DWORD
  292. WINAPI
  293. AzApplicationSetProperty(
  294. IN AZ_HANDLE ApplicationHandle,
  295. IN ULONG PropertyId,
  296. IN DWORD Reserved,
  297. IN PVOID PropertyValue
  298. )
  299. /*++
  300. Routine Description:
  301. Sets the specified property for an application.
  302. Arguments:
  303. ApplicationHandle - Specifies a handle to the application
  304. PropertyId - Specifies which property to set
  305. Reserved - Reserved. Must by zero.
  306. PropertyValue - Specifies a pointer to the property.
  307. The specified value and type depends in PropertyId. The valid values are:
  308. AZ_PROP_NAME LPWSTR - Object name of the object
  309. AZ_PROP_DESCRIPTION LPWSTR - Description of the object
  310. Return Value:
  311. NO_ERROR - The operation was successful
  312. ERROR_INVALID_PARAMETER - PropertyId isn't valid
  313. --*/
  314. {
  315. //
  316. // Call the common routine to do most of the work
  317. //
  318. return ObCommonSetProperty(
  319. (PGENERIC_OBJECT) ApplicationHandle,
  320. OBJECT_TYPE_APPLICATION,
  321. PropertyId,
  322. Reserved,
  323. PropertyValue );
  324. }
  325. DWORD
  326. WINAPI
  327. AzApplicationDelete(
  328. IN AZ_HANDLE AdminManagerHandle,
  329. IN LPCWSTR ApplicationName,
  330. IN DWORD Reserved
  331. )
  332. /*++
  333. Routine Description:
  334. This routine deletes an application from the scope of the specified AdminManager.
  335. Also deletes any child objects of ApplicationName.
  336. Arguments:
  337. AdminManagerHandle - Specifies a handle to the AdminManager.
  338. ApplicationName - Specifies the name of the application to delete.
  339. Reserved - Reserved. Must by zero.
  340. Return Value:
  341. NO_ERROR - The operation was successful
  342. ERROR_NOT_FOUND - An object by that name cannot be found
  343. --*/
  344. {
  345. //
  346. // Call the common routine to do most of the work
  347. //
  348. return ObCommonDeleteObject(
  349. (PGENERIC_OBJECT) AdminManagerHandle,
  350. OBJECT_TYPE_ADMIN_MANAGER,
  351. &(((PAZP_ADMIN_MANAGER)AdminManagerHandle)->Applications),
  352. OBJECT_TYPE_APPLICATION,
  353. ApplicationName,
  354. Reserved );
  355. }