ReactOS  0.4.13-dev-259-g5ca9c9c
lsasrv.c
Go to the documentation of this file.
1 /*
2  * PROJECT: Local Security Authority Server DLL
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: dll/win32/lsasrv/lsasrv.c
5  * PURPOSE: Main file
6  * COPYRIGHT: Copyright 2006-2009 Eric Kohl
7  */
8 
9 /* INCLUDES ****************************************************************/
10 
11 #include "lsasrv.h"
12 
14 
15 /* FUNCTIONS ***************************************************************/
16 
17 VOID
18 NTAPI
21 {
22  ULONG i;
23 
24  if (Ptr == NULL)
25  return;
26 
27  if (Ptr->Information != NULL)
28  {
29  for (i = 0; i < Ptr->EntriesRead; i++)
30  midl_user_free(Ptr->Information[i].Sid);
31 
32  midl_user_free(Ptr->Information);
33  }
34 
36 }
37 
38 
39 VOID
40 NTAPI
43 {
44  if (Ptr != NULL)
46 }
47 
48 
49 VOID
50 NTAPI
52  IN PLSAPR_POLICY_INFORMATION PolicyInformation)
53 {
54  if (PolicyInformation != NULL)
55  {
56  switch (InformationClass)
57  {
58  case PolicyAuditLogInformation: /* 1 */
59  break;
60 
61  case PolicyAuditEventsInformation: /* 2 */
62  if (PolicyInformation->PolicyAuditEventsInfo.EventAuditingOptions != NULL)
63  midl_user_free(PolicyInformation->PolicyAuditEventsInfo.EventAuditingOptions);
64  break;
65 
66  case PolicyPrimaryDomainInformation: /* 3 */
67  if (PolicyInformation->PolicyPrimaryDomInfo.Name.Buffer != NULL)
68  midl_user_free(PolicyInformation->PolicyPrimaryDomInfo.Name.Buffer);
69 
70  if (PolicyInformation->PolicyPrimaryDomInfo.Sid != NULL)
71  midl_user_free(PolicyInformation->PolicyPrimaryDomInfo.Sid);
72  break;
73 
74  case PolicyPdAccountInformation: /* 4 */
75  if (PolicyInformation->PolicyPdAccountInfo.Name.Buffer != NULL)
76  midl_user_free(PolicyInformation->PolicyPdAccountInfo.Name.Buffer);
77  break;
78 
79  case PolicyAccountDomainInformation: /* 5 */
80  if (PolicyInformation->PolicyAccountDomainInfo.DomainName.Buffer != NULL)
81  midl_user_free(PolicyInformation->PolicyAccountDomainInfo.DomainName.Buffer);
82 
83  if (PolicyInformation->PolicyAccountDomainInfo.Sid != NULL)
84  midl_user_free(PolicyInformation->PolicyAccountDomainInfo.Sid);
85  break;
86 
87  case PolicyLsaServerRoleInformation: /* 6 */
88  break;
89 
90  case PolicyReplicaSourceInformation: /* 7 */
91  if (PolicyInformation->PolicyReplicaSourceInfo.ReplicaSource.Buffer != NULL)
92  midl_user_free(PolicyInformation->PolicyReplicaSourceInfo.ReplicaSource.Buffer);
93 
94  if (PolicyInformation->PolicyReplicaSourceInfo.ReplicaAccountName.Buffer != NULL)
95  midl_user_free(PolicyInformation->PolicyReplicaSourceInfo.ReplicaAccountName.Buffer);
96  break;
97 
98  case PolicyDefaultQuotaInformation: /* 8 */
99  break;
100 
101  case PolicyModificationInformation: /* 9 */
102  break;
103 
104  case PolicyAuditFullSetInformation: /* 10 (0xA) */
105  break;
106 
107  case PolicyAuditFullQueryInformation: /* 11 (0xB) */
108  break;
109 
110  case PolicyDnsDomainInformation: /* 12 (0xC) */
111  if (PolicyInformation->PolicyDnsDomainInfo.Name.Buffer != NULL)
112  midl_user_free(PolicyInformation->PolicyDnsDomainInfo.Name.Buffer);
113 
114  if (PolicyInformation->PolicyDnsDomainInfo.DnsDomainName.Buffer != NULL)
115  midl_user_free(PolicyInformation->PolicyDnsDomainInfo.DnsDomainName.Buffer);
116 
117  if (PolicyInformation->PolicyDnsDomainInfo.DnsForestName.Buffer != NULL)
118  midl_user_free(PolicyInformation->PolicyDnsDomainInfo.DnsForestName.Buffer);
119 
120  if (PolicyInformation->PolicyDnsDomainInfo.Sid != NULL)
121  midl_user_free(PolicyInformation->PolicyDnsDomainInfo.Sid);
122  break;
123 
124  case PolicyDnsDomainInformationInt: /* 13 (0xD) */
125  if (PolicyInformation->PolicyDnsDomainInfoInt.Name.Buffer != NULL)
126  midl_user_free(PolicyInformation->PolicyDnsDomainInfoInt.Name.Buffer);
127 
128  if (PolicyInformation->PolicyDnsDomainInfoInt.DnsDomainName.Buffer != NULL)
129  midl_user_free(PolicyInformation->PolicyDnsDomainInfoInt.DnsDomainName.Buffer);
130 
131  if (PolicyInformation->PolicyDnsDomainInfoInt.DnsForestName.Buffer != NULL)
132  midl_user_free(PolicyInformation->PolicyDnsDomainInfoInt.DnsForestName.Buffer);
133 
134  if (PolicyInformation->PolicyDnsDomainInfoInt.Sid != NULL)
135  midl_user_free(PolicyInformation->PolicyDnsDomainInfoInt.Sid);
136  break;
137 
138  case PolicyLocalAccountDomainInformation: /* 14 (0xE) */
139  if (PolicyInformation->PolicyLocalAccountDomainInfo.DomainName.Buffer != NULL)
140  midl_user_free(PolicyInformation->PolicyLocalAccountDomainInfo.DomainName.Buffer);
141 
142  if (PolicyInformation->PolicyLocalAccountDomainInfo.Sid != NULL)
143  midl_user_free(PolicyInformation->PolicyLocalAccountDomainInfo.Sid);
144  break;
145 
146  default:
147  ERR("Invalid InformationClass: %lu\n", InformationClass);
148  break;
149  }
150 
151  midl_user_free(PolicyInformation);
152  }
153 }
154 
155 
156 VOID
157 NTAPI
160 {
161  ULONG i;
162 
163  if (Ptr != NULL)
164  {
165  if (Ptr->Privileges != NULL)
166  {
167  for (i = 0; i < Ptr->Entries; i++)
168  {
169  if (Ptr->Privileges[i].Name.Buffer != NULL)
170  midl_user_free(Ptr->Privileges[i].Name.Buffer);
171  }
172 
173  midl_user_free(Ptr->Privileges);
174  }
175  }
176 }
177 
178 
179 VOID
180 NTAPI
182 {
183  if (Ptr != NULL)
184  {
186  }
187 }
188 
189 
190 VOID
191 NTAPI
194 {
195  ULONG i;
196 
197  if (Ptr != NULL)
198  {
199  if (Ptr->Domains != NULL)
200  {
201  for (i = 0; i < Ptr->Entries; i++)
202  {
203  if (Ptr->Domains[i].Name.Buffer != NULL)
204  midl_user_free(Ptr->Domains[i].Name.Buffer);
205 
206  if (Ptr->Domains[i].Sid != NULL)
207  midl_user_free(Ptr->Domains[i].Sid);
208  }
209 
210  midl_user_free(Ptr->Domains);
211  }
212 
214  }
215 }
216 
217 
218 VOID
219 NTAPI
222 {
223  if (Ptr != NULL)
224  {
225  if (Ptr->SecurityDescriptor != NULL)
226  midl_user_free(Ptr->SecurityDescriptor);
227 
229  }
230 }
231 
232 
233 VOID
234 NTAPI
237 {
238  ULONG i;
239 
240  if (Ptr != NULL)
241  {
242  if (Ptr->Names != NULL)
243  {
244  for (i = 0; i < Ptr->Entries; i++)
245  {
246  if (Ptr->Names[i].Name.Buffer != NULL)
247  midl_user_free(Ptr->Names[i].Name.Buffer);
248  }
249 
250  midl_user_free(Ptr->Names);
251  }
252 
254  }
255 }
256 
257 
258 VOID
259 NTAPI
262 {
263  if (Ptr != NULL)
264  {
265  if (Ptr->Sids != NULL)
266  midl_user_free(Ptr->Sids);
267 
269  }
270 }
271 
272 
273 NTSTATUS
274 WINAPI
276 {
278  BOOLEAN PrivilegeEnabled;
279 
280  TRACE("LsapInitLsa()\n");
281 
282  /* Get the product type */
284 
285  /* Initialize the well known SIDs */
286  LsapInitSids();
287 
288  /* Initialize the SRM server */
290  if (!NT_SUCCESS(Status))
291  {
292  ERR("LsapRmInitializeServer() failed (Status 0x%08lx)\n", Status);
293  return Status;
294  }
295 
296  /* Initialize the LSA database */
298 
299  /* Initialize logon sessions */
301 
302  /* Initialize the notification list */
304 
305  /* Initialize registered authentication packages */
307  if (!NT_SUCCESS(Status))
308  {
309  ERR("LsapInitAuthPackages() failed (Status 0x%08lx)\n", Status);
310  return Status;
311  }
312 
313  /* Enable the token creation privilege for the rest of our lifetime */
315  if (!NT_SUCCESS(Status))
316  {
317  ERR("RtlAdjustPrivilege(SE_CREATE_TOKEN_PRIVILEGE) failed, ignoring (Status 0x%08lx)\n", Status);
318  }
319 
320  /* Start the authentication LPC port thread */
322  if (!NT_SUCCESS(Status))
323  {
324  ERR("StartAuthenticationPort() failed (Status 0x%08lx)\n", Status);
325  return Status;
326  }
327 
328  /* Start the RPC server */
330  if (!NT_SUCCESS(Status))
331  {
332  ERR("LsarStartRpcServer() failed (Status 0x%08lx)\n", Status);
333  return Status;
334  }
335 
336  return STATUS_SUCCESS;
337 }
338 
339 
341 {
342  return RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, len);
343 }
344 
345 
347 {
348  RtlFreeHeap(RtlGetProcessHeap(), 0, ptr);
349 }
350 
351 /* EOF */
NTSTATUS LsapRmInitializeServer(VOID)
Definition: srm.c:167
#define IN
Definition: typedefs.h:38
#define TRUE
Definition: types.h:120
#define SE_CREATE_TOKEN_PRIVILEGE
Definition: security.c:656
NTSTATUS StartAuthenticationPort(VOID)
Definition: authport.c:265
VOID LsapInitNotificationList(VOID)
Definition: notify.c:26
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
NTSTATUS WINAPI LsapInitLsa(VOID)
Definition: lsasrv.c:275
VOID NTAPI LsaIFree_LSAPR_POLICY_INFORMATION(IN POLICY_INFORMATION_CLASS InformationClass, IN PLSAPR_POLICY_INFORMATION PolicyInformation)
Definition: lsasrv.c:51
NTSYSAPI NTSTATUS NTAPI RtlAdjustPrivilege(_In_ ULONG Privilege, _In_ BOOLEAN NewValue, _In_ BOOLEAN ForThread, _Out_ PBOOLEAN OldValue)
VOID NTAPI LsaIFree_LSAPR_TRANSLATED_SIDS(IN PLSAPR_TRANSLATED_SIDS Ptr)
Definition: lsasrv.c:260
NTSTATUS LsapInitDatabase(VOID)
Definition: database.c:537
VOID NTAPI LsaIFree_LSAPR_SR_SECURITY_DESCRIPTOR(IN PLSAPR_SR_SECURITY_DESCRIPTOR Ptr)
Definition: lsasrv.c:220
BOOLEAN NTAPI RtlGetNtProductType(PNT_PRODUCT_TYPE ProductType)
Definition: version.c:96
NT_PRODUCT_TYPE LsapProductType
Definition: lsasrv.c:13
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
VOID NTAPI LsaIFree_LSAPR_TRANSLATED_NAMES(IN PLSAPR_TRANSLATED_NAMES Ptr)
Definition: lsasrv.c:235
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
static PVOID ptr
Definition: dispmode.c:27
void __RPC_FAR *__RPC_USER midl_user_allocate(SIZE_T len)
Definition: lsasrv.c:340
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI LsaIFree_LSAPR_PRIVILEGE_ENUM_BUFFER(IN PLSAPR_PRIVILEGE_ENUM_BUFFER Ptr)
Definition: lsasrv.c:158
void __RPC_USER midl_user_free(void __RPC_FAR *ptr)
Definition: lsasrv.c:346
NTSTATUS LsarStartRpcServer(VOID)
Definition: lsarpc.c:40
#define __RPC_FAR
Definition: rpc.h:56
#define __RPC_USER
Definition: rpc.h:65
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
NTSTATUS LsapInitAuthPackages(VOID)
Definition: authpackage.c:474
#define TRACE(s)
Definition: solgame.cpp:4
VOID NTAPI LsaIFree_LSAPR_REFERENCED_DOMAIN_LIST(IN PLSAPR_REFERENCED_DOMAIN_LIST Ptr)
Definition: lsasrv.c:192
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define WINAPI
Definition: msvc.h:8
enum _POLICY_INFORMATION_CLASS POLICY_INFORMATION_CLASS
VOID NTAPI LsaIFree_LSAPR_CR_CIPHER_VALUE(IN PLSAPR_CR_CIPHER_VALUE Ptr)
Definition: lsasrv.c:41
VOID LsapInitLogonSessions(VOID)
Definition: session.c:36
NTSTATUS LsapInitSids(VOID)
Definition: lookup.c:173
GLenum GLsizei len
Definition: glext.h:6722
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
VOID NTAPI LsaIFree_LSAPR_PRIVILEGE_SET(IN PLSAPR_PRIVILEGE_SET Ptr)
Definition: lsasrv.c:181
ULONG_PTR SIZE_T
Definition: typedefs.h:78
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
enum _NT_PRODUCT_TYPE NT_PRODUCT_TYPE
unsigned int ULONG
Definition: retypes.h:1
_In_ FILTER_INFORMATION_CLASS InformationClass
Definition: fltkernel.h:1714
return STATUS_SUCCESS
Definition: btrfs.c:2745
VOID NTAPI LsaIFree_LSAPR_ACCOUNT_ENUM_BUFFER(IN PLSAPR_ACCOUNT_ENUM_BUFFER Ptr)
Definition: lsasrv.c:19