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.

361 lines
9.1 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: xtcbpkg.c
  7. //
  8. // Contents: Xtcb Security Package
  9. //
  10. // Classes:
  11. //
  12. // Functions: Basic management
  13. //
  14. // History: 2-19-97 RichardW Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #include "xtcbpkg.h"
  18. SECPKG_FUNCTION_TABLE XtcbTable = {
  19. NULL, // InitializePackage
  20. NULL, // LogonUser
  21. XtcbCallPackage,
  22. XtcbLogonTerminated,
  23. XtcbCallPackageUntrusted,
  24. NULL, // CallPackagePassthrough
  25. NULL, // LogonUserEx
  26. NULL, // LogonUserEx2
  27. XtcbInitialize,
  28. XtcbShutdown,
  29. XtcbGetInfo,
  30. XtcbAcceptCredentials,
  31. XtcbAcquireCredentialsHandle,
  32. XtcbQueryCredentialsAttributes,
  33. XtcbFreeCredentialsHandle,
  34. NULL,
  35. NULL,
  36. NULL,
  37. XtcbInitLsaModeContext,
  38. XtcbAcceptLsaModeContext,
  39. XtcbDeleteContext,
  40. XtcbApplyControlToken,
  41. XtcbGetUserInfo,
  42. XtcbGetExtendedInformation,
  43. XtcbQueryLsaModeContext
  44. };
  45. ULONG_PTR XtcbPackageId;
  46. PLSA_SECPKG_FUNCTION_TABLE LsaTable ;
  47. TimeStamp XtcbNever = { 0xFFFFFFFF, 0x7FFFFFFF };
  48. TOKEN_SOURCE XtcbSource ;
  49. SECURITY_STRING XtcbComputerName ;
  50. SECURITY_STRING XtcbUnicodeDnsName ;
  51. SECURITY_STRING XtcbDomainName ;
  52. STRING XtcbDnsName ;
  53. PSID XtcbMachineSid ;
  54. ULONG ThunkedContextLevels[] = { SECPKG_ATTR_LIFESPAN };
  55. //+---------------------------------------------------------------------------
  56. //
  57. // Function: SpLsaModeInitialize
  58. //
  59. // Synopsis: Initializes connection with LSA. Allows the DLL to specify all the
  60. // packages contained within it, and their function tables.
  61. //
  62. // Arguments: [LsaVersion] -- Version of the LSA
  63. // [PackageVersion] -- Version of the package (out)
  64. // [Table] -- Table of package functions
  65. // [TableCount] -- Count of tables
  66. //
  67. // History: 2-19-97 RichardW Created
  68. //
  69. // Notes:
  70. //
  71. //----------------------------------------------------------------------------
  72. SECURITY_STATUS
  73. SEC_ENTRY
  74. SpLsaModeInitialize(
  75. IN ULONG LsaVersion,
  76. OUT PULONG PackageVersion,
  77. OUT PSECPKG_FUNCTION_TABLE * Table,
  78. OUT PULONG TableCount)
  79. {
  80. *PackageVersion = SECPKG_INTERFACE_VERSION ;
  81. *Table = &XtcbTable ;
  82. *TableCount = 1;
  83. #if DBG
  84. InitDebugSupport();
  85. #endif
  86. DebugLog(( DEB_TRACE, "XtcbPkg DLL Loaded\n" ));
  87. return( SEC_E_OK );
  88. }
  89. BOOL
  90. XtcbReadParameters(
  91. VOID
  92. )
  93. {
  94. MGroupReload();
  95. return TRUE ;
  96. }
  97. //+---------------------------------------------------------------------------
  98. //
  99. // Function: XtcbInitialize
  100. //
  101. // Synopsis: Actual initialization function for the security package
  102. //
  103. // Arguments: [dwPackageID] -- Assigned package ID
  104. // [pParameters] -- Initialization parameters
  105. // [Table] -- Table of callbacks into the LSA for support
  106. //
  107. // History: 2-19-97 RichardW Created
  108. //
  109. // Notes:
  110. //
  111. //----------------------------------------------------------------------------
  112. SECURITY_STATUS
  113. SEC_ENTRY
  114. XtcbInitialize(
  115. ULONG_PTR dwPackageID,
  116. PSECPKG_PARAMETERS Parameters,
  117. PLSA_SECPKG_FUNCTION_TABLE Table
  118. )
  119. {
  120. WCHAR ComputerName[ MAX_PATH ];
  121. DWORD Size ;
  122. XtcbPackageId = dwPackageID ;
  123. LsaTable = Table ;
  124. //
  125. // Initialize our control structures
  126. //
  127. XtcbInitCreds();
  128. XtcbInitializeContexts();
  129. //
  130. // Set up the source name that we will use for tokens
  131. //
  132. CopyMemory( XtcbSource.SourceName, "XTCBPKG", sizeof( "XTCBPKG" ) );
  133. AllocateLocallyUniqueId( &XtcbSource.SourceIdentifier );
  134. //
  135. // Get the names for the XTCB protocol.
  136. //
  137. Size = sizeof( ComputerName ) / sizeof( WCHAR );
  138. GetComputerName( ComputerName, &Size );
  139. XtcbDupStringToSecurityString( &XtcbComputerName, ComputerName );
  140. Size = MAX_PATH ;
  141. if ( GetComputerNameEx( ComputerNameDnsFullyQualified,
  142. ComputerName,
  143. &Size ) )
  144. {
  145. XtcbDupStringToSecurityString( &XtcbUnicodeDnsName, ComputerName );
  146. }
  147. XtcbDupSecurityString( &XtcbDomainName, &Parameters->DomainName );
  148. if ( !MGroupInitialize() )
  149. {
  150. return STATUS_UNSUCCESSFUL ;
  151. }
  152. //
  153. // Start a watch on our reg key to reload any parameter change
  154. //
  155. DebugLog(( DEB_TRACE_CALLS, "Initialized in LSA mode\n" ));
  156. return(S_OK);
  157. }
  158. //+---------------------------------------------------------------------------
  159. //
  160. // Function: XtcbGetInfo
  161. //
  162. // Synopsis: Returns information about the package to the LSA
  163. //
  164. // Arguments: [pInfo] --
  165. //
  166. // History: 2-19-97 RichardW Created
  167. //
  168. // Notes:
  169. //
  170. //----------------------------------------------------------------------------
  171. SECURITY_STATUS
  172. SEC_ENTRY
  173. XtcbGetInfo(PSecPkgInfo pInfo)
  174. {
  175. DebugLog(( DEB_TRACE_CALLS, "GetInfo\n" ));
  176. pInfo->wVersion = 1;
  177. pInfo->wRPCID = 0x15 ;
  178. pInfo->fCapabilities =
  179. SECPKG_FLAG_CONNECTION |
  180. SECPKG_FLAG_MULTI_REQUIRED |
  181. SECPKG_FLAG_EXTENDED_ERROR |
  182. SECPKG_FLAG_IMPERSONATION |
  183. SECPKG_FLAG_ACCEPT_WIN32_NAME |
  184. SECPKG_FLAG_NEGOTIABLE ;
  185. pInfo->cbMaxToken = 8000;
  186. pInfo->Name = L"XTCB";
  187. pInfo->Comment = L"Extended TCB package";
  188. return(S_OK);
  189. }
  190. //+---------------------------------------------------------------------------
  191. //
  192. // Function: XtcbGetExtendedInformation
  193. //
  194. // Synopsis: Return extended information to the LSA
  195. //
  196. // Arguments: [Class] -- Information Class
  197. // [pInfo] -- Returned Information Pointer
  198. //
  199. // History: 3-04-97 RichardW Created
  200. //
  201. // Notes:
  202. //
  203. //----------------------------------------------------------------------------
  204. SECURITY_STATUS
  205. SEC_ENTRY
  206. XtcbGetExtendedInformation(
  207. SECPKG_EXTENDED_INFORMATION_CLASS Class,
  208. PSECPKG_EXTENDED_INFORMATION * pInfo
  209. )
  210. {
  211. PSECPKG_EXTENDED_INFORMATION Info ;
  212. SECURITY_STATUS Status ;
  213. DebugLog(( DEB_TRACE_CALLS, "GetExtendedInfo( %d )\n", Class ));
  214. switch ( Class )
  215. {
  216. case SecpkgContextThunks:
  217. //
  218. // Which context information levels do we want
  219. // thunked over to the LSA, and which can we handle
  220. // in the user process?
  221. //
  222. Info = (PSECPKG_EXTENDED_INFORMATION) LsaTable->AllocateLsaHeap(
  223. sizeof( SECPKG_EXTENDED_INFORMATION ) +
  224. sizeof( ThunkedContextLevels ) );
  225. if ( Info )
  226. {
  227. Info->Class = Class ;
  228. Info->Info.ContextThunks.InfoLevelCount =
  229. sizeof( ThunkedContextLevels ) / sizeof( ULONG );
  230. CopyMemory( Info->Info.ContextThunks.Levels,
  231. ThunkedContextLevels,
  232. sizeof( ThunkedContextLevels ) );
  233. Status = SEC_E_OK ;
  234. }
  235. else
  236. {
  237. Status = SEC_E_INSUFFICIENT_MEMORY ;
  238. }
  239. break;
  240. default:
  241. Status = SEC_E_UNSUPPORTED_FUNCTION ;
  242. Info = NULL ;
  243. break;
  244. }
  245. *pInfo = Info ;
  246. return Status ;
  247. }
  248. NTSTATUS
  249. NTAPI
  250. XtcbCallPackage(
  251. IN PLSA_CLIENT_REQUEST ClientRequest,
  252. IN PVOID ProtocolSubmitBuffer,
  253. IN PVOID ClientBufferBase,
  254. IN ULONG SubmitBufferLength,
  255. OUT PVOID *ProtocolReturnBuffer,
  256. OUT PULONG ReturnBufferLength,
  257. OUT PNTSTATUS ProtocolStatus
  258. )
  259. {
  260. PULONG TagType ;
  261. NTSTATUS Status ;
  262. return( SEC_E_UNSUPPORTED_FUNCTION );
  263. }
  264. NTSTATUS
  265. NTAPI
  266. XtcbCallPackageUntrusted(
  267. IN PLSA_CLIENT_REQUEST ClientRequest,
  268. IN PVOID ProtocolSubmitBuffer,
  269. IN PVOID ClientBufferBase,
  270. IN ULONG SubmitBufferLength,
  271. OUT PVOID *ProtocolReturnBuffer,
  272. OUT PULONG ReturnBufferLength,
  273. OUT PNTSTATUS ProtocolStatus
  274. )
  275. {
  276. return( SEC_E_UNSUPPORTED_FUNCTION );
  277. }
  278. //+---------------------------------------------------------------------------
  279. //
  280. // Function: XtcbShutdown
  281. //
  282. // Synopsis: Called at shutdown to clean up state
  283. //
  284. // Arguments: (none)
  285. //
  286. // History: 8-15-98 RichardW Created
  287. //
  288. // Notes:
  289. //
  290. //----------------------------------------------------------------------------
  291. SECURITY_STATUS
  292. SEC_ENTRY
  293. XtcbShutdown(void)
  294. {
  295. return( STATUS_SUCCESS );
  296. }