Robert Shearman : advapi32: Support well-knowns SIDs in string SIDs.
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Jun 13 05:58:44 CDT 2006
Module: wine
Branch: refs/heads/master
Commit: 84019596beea8620aba27432b499ace865af4ba9
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=84019596beea8620aba27432b499ace865af4ba9
Author: Robert Shearman <rob at codeweavers.com>
Date: Mon Jun 12 16:37:07 2006 +0100
advapi32: Support well-knowns SIDs in string SIDs.
---
dlls/advapi32/security.c | 92 ++++++++++++++++++++++++++++++++--------------
1 files changed, 64 insertions(+), 28 deletions(-)
diff --git a/dlls/advapi32/security.c b/dlls/advapi32/security.c
index 96a93b8..8f70186 100644
--- a/dlls/advapi32/security.c
+++ b/dlls/advapi32/security.c
@@ -59,6 +59,14 @@ typedef struct _ACEFLAG
DWORD value;
} ACEFLAG, *LPACEFLAG;
+typedef struct WELLKNOWNSID
+{
+ WCHAR wstr[2];
+ SID_IDENTIFIER_AUTHORITY auth;
+ BYTE nSubAuthorityCount;
+ DWORD SubAuthority[8];
+} WELLKNOWNSID;
+
static SID const sidWorld = { SID_REVISION, 1, { SECURITY_WORLD_SID_AUTHORITY} , { SECURITY_WORLD_RID } };
/*
@@ -3217,27 +3225,6 @@ BOOL WINAPI CreateProcessAsUserW(
return TRUE;
}
-/******************************************************************************
- * ComputeStringSidSize
- */
-static DWORD ComputeStringSidSize(LPCWSTR StringSid)
-{
- int ctok = 0;
- DWORD size = sizeof(SID);
-
- while (*StringSid)
- {
- if (*StringSid == '-')
- ctok++;
- StringSid++;
- }
-
- if (ctok > 3)
- size += (ctok - 3) * sizeof(DWORD);
-
- return size;
-}
-
BOOL WINAPI DuplicateTokenEx(
HANDLE ExistingTokenHandle, DWORD dwDesiredAccess,
LPSECURITY_ATTRIBUTES lpTokenAttributes,
@@ -3303,6 +3290,49 @@ BOOL WINAPI EnumDependentServicesW(
return FALSE;
}
+static const WELLKNOWNSID WellKnownSids[] =
+{
+ { {'W','D'}, { SECURITY_WORLD_SID_AUTHORITY }, 1, { SECURITY_WORLD_RID } },
+ { {'B','A'}, { SECURITY_NT_AUTHORITY }, 2, { SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_GROUP_RID_ADMINS } },
+ { {'B','G'}, { SECURITY_NT_AUTHORITY }, 2, { SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_GROUP_RID_GUESTS } },
+ { {'B','U'}, { SECURITY_NT_AUTHORITY }, 2, { SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_GROUP_RID_USERS } },
+ { {'I','U'}, { SECURITY_NT_AUTHORITY }, 1, { SECURITY_INTERACTIVE_RID } },
+ { {'L','S'}, { SECURITY_NT_AUTHORITY }, 1, { SECURITY_SERVICE_RID } },
+ { {'S','Y'}, { SECURITY_NT_AUTHORITY }, 1, { SECURITY_LOCAL_SYSTEM_RID } },
+};
+
+/******************************************************************************
+ * ComputeStringSidSize
+ */
+static DWORD ComputeStringSidSize(LPCWSTR StringSid)
+{
+ DWORD size = sizeof(SID);
+
+ if (StringSid[0] == 'S' && StringSid[1] == '-') /* S-R-I-S-S */
+ {
+ int ctok = 0;
+ while (*StringSid)
+ {
+ if (*StringSid == '-')
+ ctok++;
+ StringSid++;
+ }
+
+ if (ctok > 3)
+ size += (ctok - 3) * sizeof(DWORD);
+ }
+ else /* String constant format - Only available in winxp and above */
+ {
+ int i;
+
+ for (i = 0; i < sizeof(WellKnownSids)/sizeof(WellKnownSids[0]); i++)
+ if (!strncmpW(WellKnownSids[i].wstr, StringSid, 2))
+ size += (WellKnownSids[i].nSubAuthorityCount - 1) * sizeof(DWORD);
+ }
+
+ return size;
+}
+
/******************************************************************************
* ParseStringSidToSid
*/
@@ -3385,16 +3415,22 @@ static BOOL ParseStringSidToSid(LPCWSTR
}
else /* String constant format - Only available in winxp and above */
{
+ int i;
pisid->Revision = SDDL_REVISION;
- pisid->SubAuthorityCount = 1;
-
- FIXME("String constant not supported: %s\n", debugstr_wn(StringSid, 2));
- /* TODO: Lookup string of well-known SIDs in table */
- pisid->IdentifierAuthority.Value[5] = 0;
- pisid->SubAuthority[0] = 0;
+ for (i = 0; i < sizeof(WellKnownSids)/sizeof(WellKnownSids[0]); i++)
+ if (!strncmpW(WellKnownSids[i].wstr, StringSid, 2))
+ {
+ DWORD j;
+ pisid->SubAuthorityCount = WellKnownSids[i].nSubAuthorityCount;
+ pisid->IdentifierAuthority = WellKnownSids[i].auth;
+ for (j = 0; j < WellKnownSids[i].nSubAuthorityCount; j++)
+ pisid->SubAuthority[j] = WellKnownSids[i].SubAuthority[j];
+ bret = TRUE;
+ }
- bret = TRUE;
+ if (!bret)
+ FIXME("String constant not supported: %s\n", debugstr_wn(StringSid, 2));
}
lend:
More information about the wine-cvs
mailing list