From 7e8d9fb98689a3c86a101cb7c0edca28a73da678 Mon Sep 17 00:00:00 2001 From: Bill Zissimopoulos Date: Fri, 24 Jun 2016 16:28:38 -0700 Subject: [PATCH] dll: posix: map unmapped UID to S-1-5-7 (Anonymous) --- src/dll/posix.c | 20 ++++++++++---------- tst/winfsp-tests/posix-test.c | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/dll/posix.c b/src/dll/posix.c index a72c0def..7fd296bb 100644 --- a/src/dll/posix.c +++ b/src/dll/posix.c @@ -40,18 +40,18 @@ union { SID V; UINT8 B[sizeof(SID) - sizeof(DWORD) + (1 * sizeof(DWORD))]; -} FspNullSidBuf = +} FspUnmappedSidBuf = { - /* S-1-0-0 */ + /* S-1-5-7 (Anonymous) */ .V.Revision = SID_REVISION, .V.SubAuthorityCount = 1, - .V.IdentifierAuthority.Value[5] = 0, - .V.SubAuthority[0] = 0, + .V.IdentifierAuthority.Value[5] = 5, + .V.SubAuthority[0] = 7, }; static PISID FspAccountDomainSid, FspPrimaryDomainSid; -#define FspNullSid (&FspNullSidBuf.V) -#define FspNullUid -1 +#define FspUnmappedSid (&FspUnmappedSidBuf.V) +#define FspUnmappedUid (7) static BOOL WINAPI FspPosixInitialize( PINIT_ONCE InitOnce, PVOID Parameter, PVOID *Context) @@ -227,7 +227,7 @@ FSP_API NTSTATUS FspPosixMapUidToSid(UINT32 Uid, PSID *PSid) *PSid = FspPosixCreateSid(5, 2, Uid >> 12, Uid & 0xfff); if (0 == *PSid) - *PSid = FspNullSid; + *PSid = FspUnmappedSid; return STATUS_SUCCESS; } @@ -325,7 +325,7 @@ FSP_API NTSTATUS FspPosixMapSidToUid(PSID Sid, PUINT32 PUid) */ *PUid = 0x60000 + Rid; } - else if (0 != Authority) + else { /* [IDMAP] * Other well-known SIDs: @@ -335,7 +335,7 @@ FSP_API NTSTATUS FspPosixMapSidToUid(PSID Sid, PUINT32 PUid) } if (-1 == *PUid) - *PUid = FspNullUid; + *PUid = FspUnmappedUid; return STATUS_SUCCESS; } @@ -364,7 +364,7 @@ static PISID FspPosixCreateSid(BYTE Authority, ULONG Count, ...) FSP_API VOID FspDeleteSid(PSID Sid, NTSTATUS (*CreateFunc)()) { - if (FspNullSid == Sid) + if (FspUnmappedSid == Sid) ; else if ((NTSTATUS (*)())FspPosixMapUidToSid == CreateFunc) MemFree(Sid); diff --git a/tst/winfsp-tests/posix-test.c b/tst/winfsp-tests/posix-test.c index eacdea05..03c3df14 100644 --- a/tst/winfsp-tests/posix-test.c +++ b/tst/winfsp-tests/posix-test.c @@ -10,7 +10,7 @@ void posix_map_sid_test(void) UINT32 Uid; } map[] = { - { L"S-1-0-0", -1 }, + { L"S-1-0-0", 0x10000 }, { L"S-1-1-0", 0x10100 }, { L"S-1-2-0", 0x10200 }, { L"S-1-2-1", 0x10201 },