00188 :
00189
00190 Perform phase 1 security initialization.
00191
00192 This includes:
00193
00194 -
Create an object directory
for security related objects.
00195 (\Security).
00196
00197 -
Create an event to be signalled after
the LSA has initialized.
00198 (\Security\LSA_Initialized)
00199
00200
00201
00202
00203 Arguments:
00204
00205 None.
00206
00207 Return Value:
00208
00209
TRUE - Initialization was successful.
00210
00211
FALSE - Initialization Failed.
00212
00213 --*/
00214
00215 {
00216
00217
NTSTATUS Status;
00218 STRING
Name;
00219 UNICODE_STRING UnicodeName;
00220 OBJECT_ATTRIBUTES
ObjectAttributes;
00221 HANDLE SecurityRoot, TemporaryHandle;
00222 PSECURITY_DESCRIPTOR SD ;
00223 UCHAR SDBuffer[ SECURITY_DESCRIPTOR_MIN_LENGTH ];
00224 PACL
Dacl ;
00225
00226
PAGED_CODE();
00227
00228
SeAnonymousLogonToken =
SeMakeAnonymousLogonToken();
00229
ASSERT(SeAnonymousLogonToken != NULL);
00230
00231
00232
00233
00234
00235
RtlInitString( &Name,
"\\Security" );
00236
Status =
RtlAnsiStringToUnicodeString(
00237 &UnicodeName,
00238 &Name,
00239 TRUE );
ASSERT(
NT_SUCCESS(Status) );
00240
00241
00242
00243
00244
00245 SD = (PSECURITY_DESCRIPTOR) SDBuffer ;
00246
00247
RtlCreateSecurityDescriptor( SD,
00248 SECURITY_DESCRIPTOR_REVISION );
00249
00250
Dacl =
ExAllocatePool(
00251 NonPagedPool,
00252 256 );
00253
00254
if ( !
Dacl )
00255 {
00256
return FALSE ;
00257 }
00258
00259
RtlCreateAcl( Dacl, 256, ACL_REVISION );
00260
00261
RtlAddAccessAllowedAce( Dacl,
00262 ACL_REVISION,
00263 DIRECTORY_ALL_ACCESS,
00264 SeLocalSystemSid );
00265
00266
RtlAddAccessAllowedAce( Dacl,
00267 ACL_REVISION,
00268 DIRECTORY_QUERY | DIRECTORY_TRAVERSE |
00269 READ_CONTROL,
00270 SeAliasAdminsSid );
00271
00272
RtlAddAccessAllowedAce( Dacl,
00273 ACL_REVISION,
00274 DIRECTORY_TRAVERSE,
00275 SeWorldSid );
00276
00277
RtlSetDaclSecurityDescriptor(
00278 SD,
00279 TRUE,
00280 Dacl,
00281 FALSE );
00282
00283 InitializeObjectAttributes(
00284 &ObjectAttributes,
00285 &UnicodeName,
00286 (OBJ_PERMANENT | OBJ_CASE_INSENSITIVE),
00287 NULL,
00288 SD
00289 );
00290
00291
Status =
NtCreateDirectoryObject(
00292 &SecurityRoot,
00293 DIRECTORY_ALL_ACCESS,
00294 &ObjectAttributes
00295 );
00296
RtlFreeUnicodeString( &UnicodeName );
00297
ASSERTMSG(
"Security root object directory creation failed.",
NT_SUCCESS(Status));
00298
00299
ExFreePool( Dacl );
00300
00301
00302
00303
00304
00305
RtlInitString( &Name,
"LSA_AUTHENTICATION_INITIALIZED" );
00306
Status =
RtlAnsiStringToUnicodeString(
00307 &UnicodeName,
00308 &Name,
00309 TRUE );
ASSERT(
NT_SUCCESS(Status) );
00310 InitializeObjectAttributes(
00311 &ObjectAttributes,
00312 &UnicodeName,
00313 (OBJ_PERMANENT | OBJ_CASE_INSENSITIVE),
00314 SecurityRoot,
00315 SePublicDefaultSd
00316 );
00317
00318
Status =
NtCreateEvent(
00319 &TemporaryHandle,
00320 GENERIC_WRITE,
00321 &ObjectAttributes,
00322 NotificationEvent,
00323 FALSE
00324 );
00325
RtlFreeUnicodeString( &UnicodeName );
00326
ASSERTMSG(
"LSA Initialization Event Creation Failed.",
NT_SUCCESS(Status));
00327
00328
Status =
NtClose( SecurityRoot );
00329
ASSERTMSG(
"Security object directory handle closure Failed.",
NT_SUCCESS(Status));
00330
Status =
NtClose( TemporaryHandle );
00331
ASSERTMSG(
"LSA Initialization Event handle closure Failed.",
NT_SUCCESS(Status));
00332
00333
00334
00335
00336
00337
if (!
SepAdtInitializePhase1()) {
00338 KdPrint((
"Security: Auditing initialization failed.\n"));
00339
return FALSE;
00340 }
00341
00342
00343
#ifndef SETEST
00344
00345
return TRUE;
00346
00347
#else
00348
00349
return SepDevelopmentTest();
00350
00351
#endif //SETEST
00352
00353 }
}