[FORMATTING] No code changes!

svn path=/trunk/; revision=36357
This commit is contained in:
Eric Kohl 2008-09-20 20:28:23 +00:00
parent 8c33fab48b
commit aa46f44e50
3 changed files with 635 additions and 614 deletions

View file

@ -405,8 +405,7 @@ AppendRidToSid(PSID SrcSid,
static PTOKEN_GROUPS static PTOKEN_GROUPS
AllocateGroupSids( AllocateGroupSids(OUT PSID *PrimaryGroupSid,
OUT PSID *PrimaryGroupSid,
OUT PSID *OwnerSid) OUT PSID *OwnerSid)
{ {
SID_IDENTIFIER_AUTHORITY WorldAuthority = {SECURITY_WORLD_SID_AUTHORITY}; SID_IDENTIFIER_AUTHORITY WorldAuthority = {SECURITY_WORLD_SID_AUTHORITY};
@ -442,13 +441,13 @@ AllocateGroupSids(
/* Member of the domain */ /* Member of the domain */
TokenGroups->Groups[GroupCount].Sid = Sid; TokenGroups->Groups[GroupCount].Sid = Sid;
TokenGroups->Groups[GroupCount].Attributes = SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY; TokenGroups->Groups[GroupCount].Attributes =
SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY;
*PrimaryGroupSid = Sid; *PrimaryGroupSid = Sid;
GroupCount++; GroupCount++;
/* Member of 'Everyone' */ /* Member of 'Everyone' */
RtlAllocateAndInitializeSid( RtlAllocateAndInitializeSid(&WorldAuthority,
&WorldAuthority,
1, 1,
SECURITY_WORLD_RID, SECURITY_WORLD_RID,
SECURITY_NULL_RID, SECURITY_NULL_RID,
@ -460,13 +459,13 @@ AllocateGroupSids(
SECURITY_NULL_RID, SECURITY_NULL_RID,
&Sid); &Sid);
TokenGroups->Groups[GroupCount].Sid = Sid; TokenGroups->Groups[GroupCount].Sid = Sid;
TokenGroups->Groups[GroupCount].Attributes = SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY; TokenGroups->Groups[GroupCount].Attributes =
SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY;
GroupCount++; GroupCount++;
#if 1 #if 1
/* Member of 'Administrators' */ /* Member of 'Administrators' */
RtlAllocateAndInitializeSid( RtlAllocateAndInitializeSid(&SystemAuthority,
&SystemAuthority,
2, 2,
SECURITY_BUILTIN_DOMAIN_RID, SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS, DOMAIN_ALIAS_RID_ADMINS,
@ -478,15 +477,15 @@ AllocateGroupSids(
SECURITY_NULL_RID, SECURITY_NULL_RID,
&Sid); &Sid);
TokenGroups->Groups[GroupCount].Sid = Sid; TokenGroups->Groups[GroupCount].Sid = Sid;
TokenGroups->Groups[GroupCount].Attributes = SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY; TokenGroups->Groups[GroupCount].Attributes =
SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY;
GroupCount++; GroupCount++;
#else #else
TRACE("Not adding user to Administrators group\n"); TRACE("Not adding user to Administrators group\n");
#endif #endif
/* Member of 'Users' */ /* Member of 'Users' */
RtlAllocateAndInitializeSid( RtlAllocateAndInitializeSid(&SystemAuthority,
&SystemAuthority,
2, 2,
SECURITY_BUILTIN_DOMAIN_RID, SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_USERS, DOMAIN_ALIAS_RID_USERS,
@ -498,12 +497,12 @@ AllocateGroupSids(
SECURITY_NULL_RID, SECURITY_NULL_RID,
&Sid); &Sid);
TokenGroups->Groups[GroupCount].Sid = Sid; TokenGroups->Groups[GroupCount].Sid = Sid;
TokenGroups->Groups[GroupCount].Attributes = SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY; TokenGroups->Groups[GroupCount].Attributes =
SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY;
GroupCount++; GroupCount++;
/* Logon SID */ /* Logon SID */
RtlAllocateAndInitializeSid( RtlAllocateAndInitializeSid(&SystemAuthority,
&SystemAuthority,
SECURITY_LOGON_IDS_RID_COUNT, SECURITY_LOGON_IDS_RID_COUNT,
SECURITY_LOGON_IDS_RID, SECURITY_LOGON_IDS_RID,
Luid.HighPart, Luid.HighPart,
@ -515,13 +514,13 @@ AllocateGroupSids(
SECURITY_NULL_RID, SECURITY_NULL_RID,
&Sid); &Sid);
TokenGroups->Groups[GroupCount].Sid = Sid; TokenGroups->Groups[GroupCount].Sid = Sid;
TokenGroups->Groups[GroupCount].Attributes = SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY | SE_GROUP_LOGON_ID; TokenGroups->Groups[GroupCount].Attributes =
SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY | SE_GROUP_LOGON_ID;
GroupCount++; GroupCount++;
*OwnerSid = Sid; *OwnerSid = Sid;
/* Member of 'Local users */ /* Member of 'Local users */
RtlAllocateAndInitializeSid( RtlAllocateAndInitializeSid(&LocalAuthority,
&LocalAuthority,
1, 1,
SECURITY_LOCAL_RID, SECURITY_LOCAL_RID,
SECURITY_NULL_RID, SECURITY_NULL_RID,
@ -533,12 +532,12 @@ AllocateGroupSids(
SECURITY_NULL_RID, SECURITY_NULL_RID,
&Sid); &Sid);
TokenGroups->Groups[GroupCount].Sid = Sid; TokenGroups->Groups[GroupCount].Sid = Sid;
TokenGroups->Groups[GroupCount].Attributes = SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY; TokenGroups->Groups[GroupCount].Attributes =
SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY;
GroupCount++; GroupCount++;
/* Member of 'Interactive users' */ /* Member of 'Interactive users' */
RtlAllocateAndInitializeSid( RtlAllocateAndInitializeSid(&SystemAuthority,
&SystemAuthority,
1, 1,
SECURITY_INTERACTIVE_RID, SECURITY_INTERACTIVE_RID,
SECURITY_NULL_RID, SECURITY_NULL_RID,
@ -550,12 +549,12 @@ AllocateGroupSids(
SECURITY_NULL_RID, SECURITY_NULL_RID,
&Sid); &Sid);
TokenGroups->Groups[GroupCount].Sid = Sid; TokenGroups->Groups[GroupCount].Sid = Sid;
TokenGroups->Groups[GroupCount].Attributes = SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY; TokenGroups->Groups[GroupCount].Attributes =
SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY;
GroupCount++; GroupCount++;
/* Member of 'Authenticated users' */ /* Member of 'Authenticated users' */
RtlAllocateAndInitializeSid( RtlAllocateAndInitializeSid(&SystemAuthority,
&SystemAuthority,
1, 1,
SECURITY_AUTHENTICATED_USER_RID, SECURITY_AUTHENTICATED_USER_RID,
SECURITY_NULL_RID, SECURITY_NULL_RID,
@ -567,7 +566,8 @@ AllocateGroupSids(
SECURITY_NULL_RID, SECURITY_NULL_RID,
&Sid); &Sid);
TokenGroups->Groups[GroupCount].Sid = Sid; TokenGroups->Groups[GroupCount].Sid = Sid;
TokenGroups->Groups[GroupCount].Attributes = SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY; TokenGroups->Groups[GroupCount].Attributes =
SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY;
GroupCount++; GroupCount++;
TokenGroups->GroupCount = GroupCount; TokenGroups->GroupCount = GroupCount;
@ -670,6 +670,7 @@ LogonUserW (LPWSTR lpszUsername,
{ {
return FALSE; return FALSE;
} }
ExpirationTime.QuadPart = -1; ExpirationTime.QuadPart = -1;
/* Get the user SID from the registry */ /* Get the user SID from the registry */
@ -708,7 +709,8 @@ LogonUserW (LPWSTR lpszUsername,
TokenPrivileges->PrivilegeCount = 0; TokenPrivileges->PrivilegeCount = 0;
for (i = 0; i < sizeof(DefaultPrivs) / sizeof(DefaultPrivs[0]); i++) for (i = 0; i < sizeof(DefaultPrivs) / sizeof(DefaultPrivs[0]); i++)
{ {
if (! LookupPrivilegeValueW(NULL, DefaultPrivs[i].PrivName, if (! LookupPrivilegeValueW(NULL,
DefaultPrivs[i].PrivName,
&TokenPrivileges->Privileges[TokenPrivileges->PrivilegeCount].Luid)) &TokenPrivileges->Privileges[TokenPrivileges->PrivilegeCount].Luid))
{ {
WARN("Can't set privilege %S\n", DefaultPrivs[i].PrivName); WARN("Can't set privilege %S\n", DefaultPrivs[i].PrivName);
@ -723,7 +725,6 @@ LogonUserW (LPWSTR lpszUsername,
TokenOwner.Owner = OwnerSid; TokenOwner.Owner = OwnerSid;
TokenPrimaryGroup.PrimaryGroup = PrimaryGroupSid; TokenPrimaryGroup.PrimaryGroup = PrimaryGroupSid;
Dacl = RtlAllocateHeap(GetProcessHeap(), 0, 1024); Dacl = RtlAllocateHeap(GetProcessHeap(), 0, 1024);
if (Dacl == NULL) if (Dacl == NULL)
{ {
@ -773,6 +774,7 @@ LogonUserW (LPWSTR lpszUsername,
memcpy(TokenSource.SourceName, memcpy(TokenSource.SourceName,
"User32 ", "User32 ",
8); 8);
Status = NtAllocateLocallyUniqueId(&TokenSource.SourceIdentifier); Status = NtAllocateLocallyUniqueId(&TokenSource.SourceIdentifier);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {

View file

@ -43,10 +43,12 @@ AbortSystemShutdownA(LPCSTR lpMachineName)
RtlInitAnsiString(&MachineNameA, (LPSTR)lpMachineName); RtlInitAnsiString(&MachineNameA, (LPSTR)lpMachineName);
Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA, TRUE); Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA, TRUE);
if (STATUS_SUCCESS != Status) { if (STATUS_SUCCESS != Status)
{
SetLastError(RtlNtStatusToDosError(Status)); SetLastError(RtlNtStatusToDosError(Status));
return FALSE; return FALSE;
} }
rv = AbortSystemShutdownW(MachineNameW.Buffer); rv = AbortSystemShutdownW(MachineNameW.Buffer);
RtlFreeUnicodeString(&MachineNameW); RtlFreeUnicodeString(&MachineNameW);
SetLastError(ERROR_SUCCESS); SetLastError(ERROR_SUCCESS);
@ -60,8 +62,7 @@ AbortSystemShutdownA(LPCSTR lpMachineName)
* @unimplemented * @unimplemented
*/ */
BOOL STDCALL BOOL STDCALL
InitiateSystemShutdownW( InitiateSystemShutdownW(LPWSTR lpMachineName,
LPWSTR lpMachineName,
LPWSTR lpMessage, LPWSTR lpMessage,
DWORD dwTimeout, DWORD dwTimeout,
BOOL bForceAppsClosed, BOOL bForceAppsClosed,
@ -70,13 +71,17 @@ InitiateSystemShutdownW(
SHUTDOWN_ACTION Action = ShutdownNoReboot; SHUTDOWN_ACTION Action = ShutdownNoReboot;
NTSTATUS Status; NTSTATUS Status;
if (lpMachineName) { if (lpMachineName)
{
/* FIXME: remote machine shutdown not supported yet */ /* FIXME: remote machine shutdown not supported yet */
SetLastError(ERROR_CALL_NOT_IMPLEMENTED); SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE; return FALSE;
} }
if (dwTimeout) {
if (dwTimeout)
{
} }
Status = NtShutdownSystem(Action); Status = NtShutdownSystem(Action);
SetLastError(RtlNtStatusToDosError(Status)); SetLastError(RtlNtStatusToDosError(Status));
return FALSE; return FALSE;
@ -90,8 +95,7 @@ InitiateSystemShutdownW(
*/ */
BOOL BOOL
STDCALL STDCALL
InitiateSystemShutdownA( InitiateSystemShutdownA(LPSTR lpMachineName,
LPSTR lpMachineName,
LPSTR lpMessage, LPSTR lpMessage,
DWORD dwTimeout, DWORD dwTimeout,
BOOL bForceAppsClosed, BOOL bForceAppsClosed,
@ -105,38 +109,49 @@ InitiateSystemShutdownA(
INT LastError; INT LastError;
BOOL rv; BOOL rv;
if (lpMachineName) { if (lpMachineName)
{
RtlInitAnsiString(&MachineNameA, lpMachineName); RtlInitAnsiString(&MachineNameA, lpMachineName);
Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA, TRUE); Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA, TRUE);
if (STATUS_SUCCESS != Status) { if (STATUS_SUCCESS != Status)
{
SetLastError(RtlNtStatusToDosError(Status)); SetLastError(RtlNtStatusToDosError(Status));
return FALSE; return FALSE;
} }
} }
if (lpMessage) {
if (lpMessage)
{
RtlInitAnsiString(&MessageA, lpMessage); RtlInitAnsiString(&MessageA, lpMessage);
Status = RtlAnsiStringToUnicodeString(&MessageW, &MessageA, TRUE); Status = RtlAnsiStringToUnicodeString(&MessageW, &MessageA, TRUE);
if (STATUS_SUCCESS != Status) { if (STATUS_SUCCESS != Status)
if (MachineNameW.Length) { {
if (MachineNameW.Length)
{
RtlFreeUnicodeString(&MachineNameW); RtlFreeUnicodeString(&MachineNameW);
} }
SetLastError(RtlNtStatusToDosError(Status)); SetLastError(RtlNtStatusToDosError(Status));
return FALSE; return FALSE;
} }
} }
rv = InitiateSystemShutdownW(
MachineNameW.Buffer, rv = InitiateSystemShutdownW(MachineNameW.Buffer,
MessageW.Buffer, MessageW.Buffer,
dwTimeout, dwTimeout,
bForceAppsClosed, bForceAppsClosed,
bRebootAfterShutdown); bRebootAfterShutdown);
LastError = GetLastError(); LastError = GetLastError();
if (lpMachineName) { if (lpMachineName)
{
RtlFreeUnicodeString(&MachineNameW); RtlFreeUnicodeString(&MachineNameW);
} }
if (lpMessage) {
if (lpMessage)
{
RtlFreeUnicodeString(&MessageW); RtlFreeUnicodeString(&MessageW);
} }
SetLastError(LastError); SetLastError(LastError);
return rv; return rv;
} }
@ -146,8 +161,12 @@ InitiateSystemShutdownA(
* *
* see InitiateSystemShutdownExA * see InitiateSystemShutdownExA
*/ */
BOOL WINAPI InitiateSystemShutdownExW( LPWSTR lpMachineName, LPWSTR lpMessage, BOOL WINAPI
DWORD dwTimeout, BOOL bForceAppsClosed, BOOL bRebootAfterShutdown, InitiateSystemShutdownExW(LPWSTR lpMachineName,
LPWSTR lpMessage,
DWORD dwTimeout,
BOOL bForceAppsClosed,
BOOL bRebootAfterShutdown,
DWORD dwReason) DWORD dwReason)
{ {
UNIMPLEMENTED; UNIMPLEMENTED;