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.

392 lines
9.6 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. #if 0
  31. STATIC
  32. NTSTATUS
  33. WsCreateLogonSupportObject(
  34. VOID
  35. );
  36. #endif
  37. //-------------------------------------------------------------------//
  38. // //
  39. // Global variables //
  40. // //
  41. //-------------------------------------------------------------------//
  42. //
  43. // Security descriptors of workstation objects to control user accesses
  44. // to the workstation configuration information, sending messages, and the
  45. // logon support functions.
  46. //
  47. PSECURITY_DESCRIPTOR ConfigurationInfoSd;
  48. PSECURITY_DESCRIPTOR MessageSendSd;
  49. #if 0
  50. PSECURITY_DESCRIPTOR LogonSupportSd;
  51. #endif
  52. //
  53. // Structure that describes the mapping of Generic access rights to
  54. // object specific access rights for the ConfigurationInfo object.
  55. //
  56. GENERIC_MAPPING WsConfigInfoMapping = {
  57. STANDARD_RIGHTS_READ | // Generic read
  58. WKSTA_CONFIG_GUEST_INFO_GET |
  59. WKSTA_CONFIG_USER_INFO_GET |
  60. WKSTA_CONFIG_ADMIN_INFO_GET,
  61. STANDARD_RIGHTS_WRITE | // Generic write
  62. WKSTA_CONFIG_INFO_SET,
  63. STANDARD_RIGHTS_EXECUTE, // Generic execute
  64. WKSTA_CONFIG_ALL_ACCESS // Generic all
  65. };
  66. //
  67. // Structure that describes the mapping of generic access rights to
  68. // object specific access rights for the MessageSend object.
  69. //
  70. GENERIC_MAPPING WsMessageSendMapping = {
  71. STANDARD_RIGHTS_READ, // Generic read
  72. STANDARD_RIGHTS_WRITE | // Generic write
  73. WKSTA_MESSAGE_SEND,
  74. STANDARD_RIGHTS_EXECUTE, // Generic execute
  75. WKSTA_MESSAGE_ALL_ACCESS // Generic all
  76. };
  77. #if 0
  78. //
  79. // Structure that describes the mapping of generic access rights to
  80. // object specific access rights for the LogonSupport object.
  81. //
  82. GENERIC_MAPPING WsLogonSupportMapping = {
  83. STANDARD_RIGHTS_READ, // Generic read
  84. STANDARD_RIGHTS_WRITE | // Generic write
  85. WKSTA_LOGON_REQUEST_BROADCAST |
  86. WKSTA_LOGON_DOMAIN_WRITE,
  87. STANDARD_RIGHTS_EXECUTE, // Generic execute
  88. WKSTA_LOGON_ALL_ACCESS // Generic all
  89. };
  90. #endif
  91. NET_API_STATUS
  92. WsCreateWkstaObjects(
  93. VOID
  94. )
  95. /*++
  96. Routine Description:
  97. This function creates the workstation user-mode objects which are
  98. represented by security descriptors.
  99. Arguments:
  100. None.
  101. Return Value:
  102. NET_API_STATUS - NERR_Success or reason for failure.
  103. --*/
  104. {
  105. NTSTATUS ntstatus;
  106. //
  107. // Create ConfigurationInfo object
  108. //
  109. if (! NT_SUCCESS (ntstatus = WsCreateConfigInfoObject())) {
  110. IF_DEBUG(UTIL) {
  111. NetpKdPrint(("[Wksta] Failure to create ConfigurationInfo object\n"));
  112. }
  113. return NetpNtStatusToApiStatus(ntstatus);
  114. }
  115. //
  116. // Create MessageSend object
  117. //
  118. if (! NT_SUCCESS (ntstatus = WsCreateMessageSendObject())) {
  119. IF_DEBUG(UTIL) {
  120. NetpKdPrint(("[Wksta] Failure to create MessageSend object\n"));
  121. }
  122. return NetpNtStatusToApiStatus(ntstatus);
  123. }
  124. #if 0
  125. //
  126. // Create LogonSupport object
  127. //
  128. if (! NT_SUCCESS (ntstatus = WsCreateLogonSupportObject())) {
  129. IF_DEBUG(UTIL) {
  130. NetpKdPrint(("[Wksta] Failure to create LogonSupport object\n"));
  131. }
  132. return NetpNtStatusToApiStatus(ntstatus);
  133. }
  134. #endif
  135. return NERR_Success;
  136. }
  137. STATIC
  138. NTSTATUS
  139. WsCreateConfigInfoObject(
  140. VOID
  141. )
  142. /*++
  143. Routine Description:
  144. This function creates the workstation configuration information object.
  145. Arguments:
  146. None.
  147. Return Value:
  148. NTSTATUS - status returned from NetpCreateSecurityObject.
  149. --*/
  150. {
  151. //
  152. // Order matters! These ACEs are inserted into the DACL in the
  153. // following order. Security access is granted or denied based on
  154. // the order of the ACEs in the DACL.
  155. //
  156. // Local users, admins, and operators are allowed to get all information.
  157. // Only admins are allowed to set information. Users are allowed to get
  158. // user and guest info; guests are allowed to get guest info only.
  159. //
  160. #define CONFIG_INFO_ACES 8 // Number of ACEs in this DACL
  161. ACE_DATA AceData[CONFIG_INFO_ACES] = {
  162. {ACCESS_ALLOWED_ACE_TYPE, 0, 0,
  163. WKSTA_CONFIG_GUEST_INFO_GET |
  164. WKSTA_CONFIG_USER_INFO_GET |
  165. WKSTA_CONFIG_ADMIN_INFO_GET, &WsLmsvcsGlobalData->LocalSid},
  166. {ACCESS_ALLOWED_ACE_TYPE, 0, 0,
  167. GENERIC_ALL, &WsLmsvcsGlobalData->AliasAdminsSid},
  168. {ACCESS_ALLOWED_ACE_TYPE, 0, 0,
  169. WKSTA_CONFIG_GUEST_INFO_GET |
  170. WKSTA_CONFIG_USER_INFO_GET |
  171. WKSTA_CONFIG_ADMIN_INFO_GET, &WsLmsvcsGlobalData->AliasAccountOpsSid},
  172. {ACCESS_ALLOWED_ACE_TYPE, 0, 0,
  173. WKSTA_CONFIG_GUEST_INFO_GET |
  174. WKSTA_CONFIG_USER_INFO_GET |
  175. WKSTA_CONFIG_ADMIN_INFO_GET, &WsLmsvcsGlobalData->AliasSystemOpsSid},
  176. {ACCESS_ALLOWED_ACE_TYPE, 0, 0,
  177. WKSTA_CONFIG_GUEST_INFO_GET |
  178. WKSTA_CONFIG_USER_INFO_GET |
  179. WKSTA_CONFIG_ADMIN_INFO_GET, &WsLmsvcsGlobalData->AliasPrintOpsSid},
  180. {ACCESS_ALLOWED_ACE_TYPE, 0, 0,
  181. WKSTA_CONFIG_GUEST_INFO_GET |
  182. WKSTA_CONFIG_USER_INFO_GET, &WsLmsvcsGlobalData->AliasUsersSid},
  183. {ACCESS_ALLOWED_ACE_TYPE, 0, 0,
  184. WKSTA_CONFIG_GUEST_INFO_GET, &WsLmsvcsGlobalData->WorldSid},
  185. {ACCESS_ALLOWED_ACE_TYPE, 0, 0,
  186. WKSTA_CONFIG_GUEST_INFO_GET, &WsLmsvcsGlobalData->AnonymousLogonSid}
  187. };
  188. return NetpCreateSecurityObject(
  189. AceData,
  190. CONFIG_INFO_ACES,
  191. WsLmsvcsGlobalData->LocalSystemSid,
  192. WsLmsvcsGlobalData->LocalSystemSid,
  193. &WsConfigInfoMapping,
  194. &ConfigurationInfoSd
  195. );
  196. }
  197. STATIC
  198. NTSTATUS
  199. WsCreateMessageSendObject(
  200. VOID
  201. )
  202. /*++
  203. Routine Description:
  204. This function creates the workstation message send object.
  205. Arguments:
  206. None.
  207. Return Value:
  208. NTSTATUS - status returned from NetpCreateSecurityObject.
  209. --*/
  210. {
  211. //
  212. // Order matters! These ACEs are inserted into the DACL in the
  213. // following order. Security access is granted or denied based on
  214. // the order of the ACEs in the DACL.
  215. //
  216. // Any local user, and domain admins and operators are allowed to
  217. // send messages. Remote users besides domain admins, and operators
  218. // are not allowed to send messages.
  219. //
  220. #define MESSAGE_SEND_ACES 5 // Number of ACEs in this DACL
  221. ACE_DATA AceData[MESSAGE_SEND_ACES] = {
  222. {ACCESS_ALLOWED_ACE_TYPE, 0, 0,
  223. GENERIC_ALL, &WsLmsvcsGlobalData->LocalSid},
  224. {ACCESS_ALLOWED_ACE_TYPE, 0, 0,
  225. GENERIC_ALL, &WsLmsvcsGlobalData->AliasAdminsSid},
  226. {ACCESS_ALLOWED_ACE_TYPE, 0, 0,
  227. WKSTA_MESSAGE_SEND, &WsLmsvcsGlobalData->AliasAccountOpsSid},
  228. {ACCESS_ALLOWED_ACE_TYPE, 0, 0,
  229. WKSTA_MESSAGE_SEND, &WsLmsvcsGlobalData->AliasSystemOpsSid},
  230. {ACCESS_ALLOWED_ACE_TYPE, 0, 0,
  231. WKSTA_MESSAGE_SEND, &WsLmsvcsGlobalData->AliasPrintOpsSid}
  232. };
  233. return NetpCreateSecurityObject(
  234. AceData,
  235. MESSAGE_SEND_ACES,
  236. WsLmsvcsGlobalData->LocalSystemSid,
  237. WsLmsvcsGlobalData->LocalSystemSid,
  238. &WsMessageSendMapping,
  239. &MessageSendSd
  240. );
  241. }
  242. #if 0
  243. STATIC
  244. NTSTATUS
  245. WsCreateLogonSupportObject(
  246. VOID
  247. )
  248. /*++
  249. Routine Description:
  250. This function creates the workstation logon support object.
  251. Arguments:
  252. None.
  253. Return Value:
  254. NTSTATUS - status returned from NetpCreateSecurityObject.
  255. --*/
  256. {
  257. //
  258. // These ACEs can be inserted into the DACL in any order.
  259. //
  260. #define LOGON_ACES 1 // Number of ACEs in this DACL
  261. ACE_DATA AceData[LOGON_ACES] = {
  262. {ACCESS_ALLOWED_ACE_TYPE, 0, 0,
  263. WKSTA_LOGON_REQUEST_BROADCAST | WKSTA_LOGON_DOMAIN_WRITE,
  264. &WsLmsvcsGlobalData->LocalSystemSid},
  265. };
  266. return NetpCreateSecurityObject(
  267. AceData,
  268. LOGON_ACES,
  269. WsLmsvcsGlobalData->LocalSystemSid,
  270. WsLmsvcsGlobalData->LocalSystemSid,
  271. &WsLogonSupportMapping,
  272. &LogonSupportSd
  273. );
  274. }
  275. #endif
  276. VOID
  277. WsDestroyWkstaObjects(
  278. VOID
  279. )
  280. /*++
  281. Routine Description:
  282. This function destroys the workstation user-mode objects which are
  283. represented by security descriptors.
  284. Arguments:
  285. None.
  286. Return Value:
  287. None.
  288. --*/
  289. {
  290. (void) NetpDeleteSecurityObject(&ConfigurationInfoSd);
  291. (void) NetpDeleteSecurityObject(&MessageSendSd);
  292. #if 0
  293. (void) NetpDeleteSecurityObject(&LogonSupportSd);
  294. #endif
  295. }