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.

481 lines
17 KiB

  1. 13-Aug-1991
  2. Generic Graphical Security Editor API
  3. =====================================
  4. This document describes the data structures and APIs for access to the
  5. Generic Graphical Secuirty Editor (GGSED). These APIs will allow
  6. a consistent way to edit access and audit permissions for NT ACLs on
  7. any type of resource.
  8. Most of the text is taken directly from the notes by JimK in a meeting
  9. between JimK, JohnL and ChuckC when the initial design was proposed.
  10. The GGSED API is a private API and will not be exposed for external use
  11. (i.e., outside of MS). The APIs will be available on both Win16 and
  12. Win32 in a dll called NTNET.DRV (this will also be the "winnet" driver for
  13. Lanman).
  14. Note: The UI for the Security Editor is still in the design process, thus
  15. the APIs may change.
  16. Please flag any areas of functionality that you need that are not provided
  17. or if too much functionality is provided by sending mail to JohnL.
  18. Executive Summary:
  19. The client passes information that contains the following:
  20. Strings for object specific titles
  21. Flag indicating if the object is a container object or not
  22. Localized names representing access masks
  23. Callback function for applying the ACL
  24. A context value which is passed back in the callback function
  25. Security descriptor for object (this is manipulated by user)
  26. The user will manipulate the permissions, when the user applies the
  27. permissions, the callback that was passed will be called,
  28. thus the client will receive the following information in the callback:
  29. Context value the client passed in
  30. Security descriptor containing the user modified DACL/SACL
  31. Two flags indicating whether the security descriptor should be
  32. applied to sub-containers and/or sub-objects. The callback
  33. is responsible for traversing the objects etc. if
  34. appropriate.
  35. The client will then apply the security descriptor as appropriate
  36. to the specified objects and return a status code indicating
  37. whether all, some or none of the security descriptors were applied
  38. successfully.
  39. The same process is used whether the DACL is being editted, or the SACL
  40. is being editted.
  41. Note that due to the use of NT data structures under Win16, Large model
  42. maybe a requirement (due to no FAR keywords in NT P* typedefs).
  43. -----------------------------------------------------------------------
  44. Major decisions:
  45. 1) Since this is no longer a FILE security editor, we must
  46. ensure that the UI and API are applicable/tailorable to
  47. any number of object types. The client applications and
  48. object types we know about in the first release of NT
  49. are:
  50. File Browser (JohnL)
  51. Directories (container)
  52. Files (non-container)
  53. Print Manager (DaveSn)
  54. Print Queues (container)
  55. Print Jobs (non-container)
  56. Registry Browser (DaveGi & Jaimes)
  57. keys (container)
  58. 2) The security editor must also support viewing/modifying
  59. a default discretionary ACL (DACL). A DACL is comprised
  60. entirely of generic and standard access types.
  61. 3) We want to support the concept of "Application Defined
  62. Groupings" of access types into a name that makes sense
  63. to a user of the particular application's object types.
  64. For example, "Submit Print Jobs" might be an application
  65. defined grouping of accesses that the print manager would
  66. like to have displayed when security of print objects is
  67. viewed.
  68. 4) In order for the user to have some way to relate what their
  69. default DACL means when applied to an object type, displays
  70. of security for an object type will also include displaying
  71. generic and standard access types. For this reason, application
  72. defined groupings may only include generic and standard access
  73. types. Specific and other special access types will be ignored.
  74. Since we need to support win16, the data structures are expressed in
  75. standard windows types. Hungarian was omitted for clarity.
  76. //
  77. // This data type defines information related to a single class of object.
  78. // For example, a FILE object, or PRINT_QUEUE object would have a structure
  79. // like this defined.
  80. //
  81. typedef struct _SED_OBJECT_TYPE_DESCRIPTOR {
  82. //
  83. // Defines whether the object is a container or not.
  84. // TRUE indicates the object may contain other objects.
  85. //
  86. BOOL IsContainer;
  87. //
  88. // A mask containing all valid access types for the object type.
  89. // This mask may not contain any special access types (generic,
  90. // MaximumAllowed, or AccessSystemSecurity).
  91. //
  92. ACCESS_MASK ValidAccessMask;
  93. //
  94. // The (localized) name of the object type.
  95. // For example, "File" or "Print Job".
  96. //
  97. LPSTR ObjectTypeName;
  98. //
  99. // The (localized) title to display if protection can be displayed to
  100. // sub-containers.
  101. //
  102. // This string will be presented with a checkbox before it.
  103. // If checked when asked to apply the protection, the application will
  104. // be called at it's callback entry point to apply the security to
  105. // sub-containers.
  106. //
  107. // This field is ignored if the IsContainer field is FALSE.
  108. //
  109. // As an example of how this field is used, the file browser may
  110. // specify the following string in the DIRECTORY object's
  111. // descriptor:
  112. //
  113. // "Subdirectories"
  114. //
  115. LPSTR ApplyToSubContainerTitle;
  116. //
  117. // The (localized) title to display if protection can be displayed to
  118. // sub-NONcontainers. For example, a FILE is a sub-NON-container of
  119. // a DIRECTORY object.
  120. //
  121. // This string will be presented with a checkbox before it.
  122. // If checked when asked to apply the protection, the application will
  123. // be called at it's callback entry point to apply the security to
  124. // sub-NONcontainers.
  125. //
  126. // This field is ignored if the IsContainer field is FALSE.
  127. //
  128. // As an example of how this field is used, the file browser may
  129. // specify the following string in the DIRECTORY object's
  130. // descriptor:
  131. //
  132. // "Files in Directory and Subdirectories"
  133. //
  134. LPSTR ApplyToSubObjectTitle;
  135. //
  136. // The (localized) title to display next to the check box that controls
  137. // whether new subobjects created in this container object inherit the
  138. // container object's permissions.
  139. //
  140. // This field is ignored if the IsContainer field is FALSE.
  141. //
  142. // For example, in the file browser, new files can inherit the directory
  143. // permissions. The text in the file browser would be:
  144. //
  145. // "New Files Inherit Directory Permissions"
  146. //
  147. LPSTR NewObjInhContPerm;
  148. //
  149. // The generic mapping for the object type.
  150. //
  151. GENERIC_MAPPING GenericMapping;
  152. //
  153. // An array of 4 (localized) names. These names are the names of the
  154. // generic access types, with entry N defining the name of the
  155. // corresponding generic access type in the GenericMapping field.
  156. //
  157. // For example, for English this should contain:
  158. //
  159. // GenericName[0] = "Read"
  160. // GenericName[1] = "Write"
  161. // GenericName[2] = "Execute"
  162. // GenericName[3] = "All"
  163. //
  164. LPSTR GenericNames[4];
  165. //
  166. // An array of 8 (localized) names. These names are the names of
  167. // the standard access types. For English this should contain:
  168. //
  169. // StandardName[0] = "Delete"
  170. // StandardName[1] = "Read Control"
  171. // StandardName[2] = "Change Permissions"
  172. // StandardName[3] = "Take Ownership"
  173. // StandardName[4] = "Synchronize"
  174. //
  175. // If "Synchronize" is not supported by the object type, then it does
  176. // not need to be passed and will not be referenced. This is indicated
  177. // by the ValidAccessMask.
  178. //
  179. // Names 5, 6, and 7 are reserved for future use and should either be
  180. // a NULL string or have no string passed at all.
  181. LPSTR StandardNames[8];
  182. } SED_OBJECT_TYPE_DESCRIPTOR, FAR * PSED_OBJECT_TYPE_DESCRIPTOR;
  183. /*-------------------------------------------------------------------*/
  184. //
  185. // In some cases, it is desirable to display access names that are
  186. // meaningful in the context of the type of object whose ACL
  187. // is being worked on. For example, for a PRINT_QUEUE object type,
  188. // it may be desirable to display an access type named "Submit Print Jobs".
  189. // The following structures are used for defining these application defined
  190. // access groupings.
  191. //
  192. typedef struct _SED_APPLICATION_ACCESS {
  193. //
  194. // An application defined access grouping consists of an access mask
  195. // and a name by which that combination of access types is to be known.
  196. // The access mask may only contain generic and standard access types.
  197. // Specific access types and other Special access types are ignored.
  198. //
  199. ACCESS_MASK AccessMask;
  200. LPSTR Name;
  201. } SED_APPLICATION_ACCESS, FAR * PSED_APPLICATION_ACCESS;
  202. typedef struct _SED_APPLICATION_ACCESSES {
  203. //
  204. // The count field indicates how many application defined access groupings
  205. // are defined by this data structure. The AccessGroup[] array then
  206. // contains that number of elements.
  207. //
  208. ULONG Count;
  209. SED_APPLICATION_ACCESS AccessGroup[ANYSIZE_ARRAY];
  210. }
  211. /*-------------------------------------------------------------------*/
  212. NTSTATUS
  213. SedDiscretionaryAclEditor(
  214. HWND hwndOwner,
  215. SED_OBJECT_TYPE_DESCRIPTOR FAR * ObjectType,
  216. SED_APPLICATION_ACCESSES FAR * ApplicationAccesses,
  217. LPSTR ObjectName,
  218. SED_APPLY_ACL_CALLBACK ApplySecurityCallbackRoutine,
  219. DWORD CallbackContext,
  220. SECURITY_DESCRIPTOR FAR * SecurityDescriptor,
  221. BOOL CouldntReadDacl
  222. )
  223. /*++
  224. Routine Description:
  225. This routine invokes the graphical Discretionary ACL editor DLL. The
  226. graphical DACL editor may be used to modify or create:
  227. - A default Discretionary ACL
  228. - A Discretionary ACL for a particular type of object.
  229. - A Discretionary ACL for a particular named instance of an
  230. object.
  231. Additionally, in the case where the ACL is that of a named object
  232. instance, and that object may contain other object instances, the
  233. user will be presented with the opportunity to apply the protection
  234. to the entire sub-tree of objects.
  235. Parameters:
  236. ObjectType - This optional parameter is used to specify information
  237. about the type of object whose security is being edited. If the
  238. security does not relate to an instance of an object (such as for
  239. when default protection is being established), then NULL should be
  240. passed.
  241. ApplicationAccesses - This optional parameter may be used to specify
  242. groupings of access types that are particularly useful when operating
  243. on security for the specified object type. For example, it may be
  244. useful to define an access type called "Submit Print Job" for a
  245. PRINT_QUEUE class of object. This parameter is ignored if the
  246. ObjectType parameter is not passed.
  247. ObjectName - This optional parameter is used to pass the name of the
  248. object whose security is being edited. If the security does not
  249. relate to an instance of an object (such as for when default
  250. protection is being established), then NULL should be passed.
  251. This parameter is ignored if the ObjectType parameter is not passed.
  252. ApplySecurityCallbackRoutine - This parameter is used to provide the
  253. address of a routine to be called to apply security to either the
  254. object specified, or, in the case that the object is a container,
  255. to sub-containers or sub-non-containers of that object.
  256. CallbackContext - This value is opaque to the DACL editor. Its only
  257. purpose is so that a context value may be passed back to the
  258. application via the ApplySecurityCallbackRoutine when that routine
  259. is invoked. This may be used by the application to re-locate
  260. context related to the edit session. For example, it may be a
  261. handle to the object whose security is being edited.
  262. SecurityDescriptor - This parameter points to a security descriptor
  263. containing the current discretionary ACL of the object. This
  264. security descriptor may, but does not have to, contain the owner
  265. and group of that object as well. Note that the security descriptor's
  266. DaclPresent flag may be FALSE, indicating either that the object
  267. had no protection, or that the user couldn't read the protection.
  268. CouldntReadDacl - This boolean flag may be used to indicate that the
  269. user does not have read access to the target object's discretionary
  270. acl. In this case, a warning
  271. to the user will be presented along with the option to continue
  272. or cancel.
  273. Presumably the user does have write access to the DACL or
  274. there is no point in activating the editor.
  275. Return Status:
  276. STATUS_MODIFIED - This (success) status code indicates the editor has
  277. been exited and protection has successfully been modified.
  278. STATUS_NOT_MODIFIED - This (success) status code indicates the editor
  279. has been exited without attempting to modify the protection.
  280. STATUS_NOT_ALL_MODIFIED - This (warning) status code indicates the user
  281. requested the protection to be modified, but an attempt to do so
  282. only partially succeeded. The user has been notified of this
  283. situation.
  284. STATUS_FAILED_TO_MODIFY - This (error) status code indicates the user
  285. requested the protection to be modified, but an attempt to do so
  286. has failed. The user has been notified of this situation.
  287. --*/
  288. /*-------------------------------------------------------------------*/
  289. NTSTATUS
  290. SedSystemAclEditor(
  291. IN SED_OBJECT_TYPE_DESCRIPTOR FAR * ObjectType (OPTIONAL),
  292. IN LPSTR ObjectName (OPTIONAL),
  293. IN SED_APPLY_ACL_CALLBACK ApplySecurityCallbackRoutine,
  294. IN ULONG CallbackContext,
  295. IN SECURITY_DESCRIPTOR FAR * SecurityDescriptor,
  296. IN BOOL CouldntReadSacl
  297. )
  298. /*++
  299. Routine Description:
  300. SedSystemAclEditor is nearly identical to SedDiscretionaryAclEditor
  301. except for the following points:
  302. 1) Operations affect only the System ACL and not the Discretionary
  303. ACL.
  304. 2) The generic and standard names in the SED_OBJECT_TYPE_DESCRIPTOR
  305. now represent the attributes that can be auditted (which will
  306. generally be the same as the permission strings). It is assumed
  307. that each auditting string can be auditted for both success and
  308. failure.
  309. 3) No application defined grouping is allowed since it doesn't
  310. make sense for auditting, thus no ApplicationAccess parameter
  311. is needed.
  312. Parameters:
  313. See SedSystemAclEditor for a description of each parameter.
  314. --*/
  315. /*-------------------------------------------------------------------*/
  316. typedef
  317. NTSTATUS (FAR *SED_APPLY_ACL_CALLBACK)(
  318. IN ULONG CallbackContext,
  319. IN SECURITY_DESCRIPTOR FAR * SecurityDescriptor,
  320. BOOL ApplyToSubContainers,
  321. BOOL ApplyToSubObjects
  322. ) ;
  323. /*++
  324. Routine Description:
  325. This routine is provided by a caller of the graphical DACL editor.
  326. It is called by the Graphical DACL editor to apply security to
  327. target object(s) when requested by the user.
  328. Parameters:
  329. CallbackContext - This is the value passed as the CallbackContext argument
  330. to the SedDiscretionaryAclEditor() api when the graphical editor
  331. was invoked.
  332. SecurityDescriptor - This parameter points to a security descriptor
  333. containing a new discretionary ACL of either the object (and
  334. optionally the object's sub-containers) or the object's sub-objects.
  335. If the DaclPresent flag of this security descriptor is FALSE, then
  336. security is to be removed from the target object(s).
  337. ApplyToSubContainers - When TRUE, indicates that Dacl is to be applied to
  338. sub-containers of the target object as well as the target object.
  339. This will only be TRUE if the target object is a container object.
  340. ApplyToSubObjects - When TRUE, indicates the Dacl is to be applied to
  341. sub-objects of the target object, but not to the target object
  342. itself or sub-containers of the object. This will only be TRUE if
  343. the target object is a container object.
  344. Return Status:
  345. STATUS_MODIFIED - This (success) status code indicates the protection
  346. has successfully been applied.
  347. STATUS_NOT_ALL_MODIFIED - This (warning) status code indicates that
  348. the protection could not be applied to all of the target objects.
  349. STATUS_FAILED_TO_MODIFY - This (error) status code indicates the
  350. protection could not be applied to any target objects.
  351. --*/