Leaked source code of windows server 2003
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.

305 lines
8.0 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. wssec.c
  5. Abstract:
  6. This module contains the Workstation service support routines
  7. which create security objects and enforce security _access checking.
  8. Author:
  9. Rita Wong (ritaw) 19-Feb-1991
  10. Revision History:
  11. --*/
  12. #include "wsutil.h"
  13. #include "wsmain.h"
  14. #include "wssec.h"
  15. //-------------------------------------------------------------------//
  16. // //
  17. // Local function prototypes //
  18. // //
  19. //-------------------------------------------------------------------//
  20. STATIC
  21. NTSTATUS
  22. WsCreateConfigInfoObject(
  23. VOID
  24. );
  25. STATIC
  26. NTSTATUS
  27. WsCreateMessageSendObject(
  28. VOID
  29. );
  30. //-------------------------------------------------------------------//
  31. // //
  32. // Global variables //
  33. // //
  34. //-------------------------------------------------------------------//
  35. //
  36. // Security descriptors of workstation objects to control user accesses
  37. // to the workstation configuration information, sending messages, and the
  38. // logon support functions.
  39. //
  40. PSECURITY_DESCRIPTOR ConfigurationInfoSd;
  41. PSECURITY_DESCRIPTOR MessageSendSd;
  42. //
  43. // Structure that describes the mapping of Generic access rights to
  44. // object specific access rights for the ConfigurationInfo object.
  45. //
  46. GENERIC_MAPPING WsConfigInfoMapping = {
  47. STANDARD_RIGHTS_READ | // Generic read
  48. WKSTA_CONFIG_GUEST_INFO_GET |
  49. WKSTA_CONFIG_USER_INFO_GET |
  50. WKSTA_CONFIG_ADMIN_INFO_GET,
  51. STANDARD_RIGHTS_WRITE | // Generic write
  52. WKSTA_CONFIG_INFO_SET,
  53. STANDARD_RIGHTS_EXECUTE, // Generic execute
  54. WKSTA_CONFIG_ALL_ACCESS // Generic all
  55. };
  56. //
  57. // Structure that describes the mapping of generic access rights to
  58. // object specific access rights for the MessageSend object.
  59. //
  60. GENERIC_MAPPING WsMessageSendMapping = {
  61. STANDARD_RIGHTS_READ, // Generic read
  62. STANDARD_RIGHTS_WRITE | // Generic write
  63. WKSTA_MESSAGE_SEND,
  64. STANDARD_RIGHTS_EXECUTE, // Generic execute
  65. WKSTA_MESSAGE_ALL_ACCESS // Generic all
  66. };
  67. NET_API_STATUS
  68. WsCreateWkstaObjects(
  69. VOID
  70. )
  71. /*++
  72. Routine Description:
  73. This function creates the workstation user-mode objects which are
  74. represented by security descriptors.
  75. Arguments:
  76. None.
  77. Return Value:
  78. NET_API_STATUS - NERR_Success or reason for failure.
  79. --*/
  80. {
  81. NTSTATUS ntstatus;
  82. //
  83. // Create ConfigurationInfo object
  84. //
  85. if (! NT_SUCCESS (ntstatus = WsCreateConfigInfoObject())) {
  86. IF_DEBUG(UTIL) {
  87. NetpKdPrint(("[Wksta] Failure to create ConfigurationInfo object\n"));
  88. }
  89. return NetpNtStatusToApiStatus(ntstatus);
  90. }
  91. //
  92. // Create MessageSend object
  93. //
  94. if (! NT_SUCCESS (ntstatus = WsCreateMessageSendObject())) {
  95. IF_DEBUG(UTIL) {
  96. NetpKdPrint(("[Wksta] Failure to create MessageSend object\n"));
  97. }
  98. return NetpNtStatusToApiStatus(ntstatus);
  99. }
  100. return NERR_Success;
  101. }
  102. STATIC
  103. NTSTATUS
  104. WsCreateConfigInfoObject(
  105. VOID
  106. )
  107. /*++
  108. Routine Description:
  109. This function creates the workstation configuration information object.
  110. Arguments:
  111. None.
  112. Return Value:
  113. NTSTATUS - status returned from NetpCreateSecurityObject.
  114. --*/
  115. {
  116. //
  117. // Order matters! These ACEs are inserted into the DACL in the
  118. // following order. Security access is granted or denied based on
  119. // the order of the ACEs in the DACL.
  120. //
  121. // Local users, admins, and operators are allowed to get all information.
  122. // Only admins are allowed to set information. Users are allowed to get
  123. // user and guest info; guests are allowed to get guest info only.
  124. //
  125. #define CONFIG_INFO_ACES 8 // Number of ACEs in this DACL
  126. ACE_DATA AceData[CONFIG_INFO_ACES] = {
  127. {ACCESS_ALLOWED_ACE_TYPE, 0, 0,
  128. WKSTA_CONFIG_GUEST_INFO_GET |
  129. WKSTA_CONFIG_USER_INFO_GET |
  130. WKSTA_CONFIG_ADMIN_INFO_GET, &WsLmsvcsGlobalData->LocalSid},
  131. {ACCESS_ALLOWED_ACE_TYPE, 0, 0,
  132. GENERIC_ALL, &WsLmsvcsGlobalData->AliasAdminsSid},
  133. {ACCESS_ALLOWED_ACE_TYPE, 0, 0,
  134. WKSTA_CONFIG_GUEST_INFO_GET |
  135. WKSTA_CONFIG_USER_INFO_GET |
  136. WKSTA_CONFIG_ADMIN_INFO_GET, &WsLmsvcsGlobalData->AliasAccountOpsSid},
  137. {ACCESS_ALLOWED_ACE_TYPE, 0, 0,
  138. WKSTA_CONFIG_GUEST_INFO_GET |
  139. WKSTA_CONFIG_USER_INFO_GET |
  140. WKSTA_CONFIG_ADMIN_INFO_GET, &WsLmsvcsGlobalData->AliasSystemOpsSid},
  141. {ACCESS_ALLOWED_ACE_TYPE, 0, 0,
  142. WKSTA_CONFIG_GUEST_INFO_GET |
  143. WKSTA_CONFIG_USER_INFO_GET |
  144. WKSTA_CONFIG_ADMIN_INFO_GET, &WsLmsvcsGlobalData->AliasPrintOpsSid},
  145. {ACCESS_ALLOWED_ACE_TYPE, 0, 0,
  146. WKSTA_CONFIG_GUEST_INFO_GET |
  147. WKSTA_CONFIG_USER_INFO_GET, &WsLmsvcsGlobalData->AliasUsersSid},
  148. {ACCESS_ALLOWED_ACE_TYPE, 0, 0,
  149. WKSTA_CONFIG_GUEST_INFO_GET, &WsLmsvcsGlobalData->WorldSid},
  150. {ACCESS_ALLOWED_ACE_TYPE, 0, 0,
  151. WKSTA_CONFIG_GUEST_INFO_GET, &WsLmsvcsGlobalData->AnonymousLogonSid}
  152. };
  153. return NetpCreateSecurityObject(
  154. AceData,
  155. CONFIG_INFO_ACES,
  156. WsLmsvcsGlobalData->LocalSystemSid,
  157. WsLmsvcsGlobalData->LocalSystemSid,
  158. &WsConfigInfoMapping,
  159. &ConfigurationInfoSd
  160. );
  161. }
  162. STATIC
  163. NTSTATUS
  164. WsCreateMessageSendObject(
  165. VOID
  166. )
  167. /*++
  168. Routine Description:
  169. This function creates the workstation message send object.
  170. Arguments:
  171. None.
  172. Return Value:
  173. NTSTATUS - status returned from NetpCreateSecurityObject.
  174. --*/
  175. {
  176. //
  177. // Order matters! These ACEs are inserted into the DACL in the
  178. // following order. Security access is granted or denied based on
  179. // the order of the ACEs in the DACL.
  180. //
  181. // Any local user, and domain admins and operators are allowed to
  182. // send messages. Remote users besides domain admins, and operators
  183. // are not allowed to send messages.
  184. //
  185. #define MESSAGE_SEND_ACES 5 // Number of ACEs in this DACL
  186. ACE_DATA AceData[MESSAGE_SEND_ACES] = {
  187. {ACCESS_ALLOWED_ACE_TYPE, 0, 0,
  188. GENERIC_ALL, &WsLmsvcsGlobalData->LocalSid},
  189. {ACCESS_ALLOWED_ACE_TYPE, 0, 0,
  190. GENERIC_ALL, &WsLmsvcsGlobalData->AliasAdminsSid},
  191. {ACCESS_ALLOWED_ACE_TYPE, 0, 0,
  192. WKSTA_MESSAGE_SEND, &WsLmsvcsGlobalData->AliasAccountOpsSid},
  193. {ACCESS_ALLOWED_ACE_TYPE, 0, 0,
  194. WKSTA_MESSAGE_SEND, &WsLmsvcsGlobalData->AliasSystemOpsSid},
  195. {ACCESS_ALLOWED_ACE_TYPE, 0, 0,
  196. WKSTA_MESSAGE_SEND, &WsLmsvcsGlobalData->AliasPrintOpsSid}
  197. };
  198. return NetpCreateSecurityObject(
  199. AceData,
  200. MESSAGE_SEND_ACES,
  201. WsLmsvcsGlobalData->LocalSystemSid,
  202. WsLmsvcsGlobalData->LocalSystemSid,
  203. &WsMessageSendMapping,
  204. &MessageSendSd
  205. );
  206. }
  207. VOID
  208. WsDestroyWkstaObjects(
  209. VOID
  210. )
  211. /*++
  212. Routine Description:
  213. This function destroys the workstation user-mode objects which are
  214. represented by security descriptors.
  215. Arguments:
  216. None.
  217. Return Value:
  218. None.
  219. --*/
  220. {
  221. (void) NetpDeleteSecurityObject(&ConfigurationInfoSd);
  222. (void) NetpDeleteSecurityObject(&MessageSendSd);
  223. }