mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 16:33:02 -05:00
winfsp-tests: posix_map_sid_test
This commit is contained in:
parent
9ccb394b04
commit
229c3f81fa
@ -191,6 +191,7 @@
|
|||||||
<ClCompile Include="..\..\..\tst\winfsp-tests\memfs-test.c" />
|
<ClCompile Include="..\..\..\tst\winfsp-tests\memfs-test.c" />
|
||||||
<ClCompile Include="..\..\..\tst\winfsp-tests\mount-test.c" />
|
<ClCompile Include="..\..\..\tst\winfsp-tests\mount-test.c" />
|
||||||
<ClCompile Include="..\..\..\tst\winfsp-tests\path-test.c" />
|
<ClCompile Include="..\..\..\tst\winfsp-tests\path-test.c" />
|
||||||
|
<ClCompile Include="..\..\..\tst\winfsp-tests\posix-test.c" />
|
||||||
<ClCompile Include="..\..\..\tst\winfsp-tests\rdwr-test.c" />
|
<ClCompile Include="..\..\..\tst\winfsp-tests\rdwr-test.c" />
|
||||||
<ClCompile Include="..\..\..\tst\winfsp-tests\security-test.c" />
|
<ClCompile Include="..\..\..\tst\winfsp-tests\security-test.c" />
|
||||||
<ClCompile Include="..\..\..\tst\winfsp-tests\timeout-test.c" />
|
<ClCompile Include="..\..\..\tst\winfsp-tests\timeout-test.c" />
|
||||||
|
@ -58,6 +58,9 @@
|
|||||||
<ClCompile Include="..\..\..\tst\winfsp-tests\fuse-opt-test.c">
|
<ClCompile Include="..\..\..\tst\winfsp-tests\fuse-opt-test.c">
|
||||||
<Filter>Source</Filter>
|
<Filter>Source</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\tst\winfsp-tests\posix-test.c">
|
||||||
|
<Filter>Source</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\..\ext\tlib\testsuite.h">
|
<ClInclude Include="..\..\..\ext\tlib\testsuite.h">
|
||||||
|
@ -41,6 +41,7 @@ BOOL WINAPI DllMain(HINSTANCE Instance, DWORD Reason, PVOID Reserved)
|
|||||||
*/
|
*/
|
||||||
Dynamic = 0 == Reserved;
|
Dynamic = 0 == Reserved;
|
||||||
FspNtStatusInitialize(Dynamic);
|
FspNtStatusInitialize(Dynamic);
|
||||||
|
FspPosixInitialize(Dynamic);
|
||||||
FspEventLogInitialize(Dynamic);
|
FspEventLogInitialize(Dynamic);
|
||||||
FspFileSystemInitialize(Dynamic);
|
FspFileSystemInitialize(Dynamic);
|
||||||
FspServiceInitialize(Dynamic);
|
FspServiceInitialize(Dynamic);
|
||||||
@ -62,6 +63,7 @@ BOOL WINAPI DllMain(HINSTANCE Instance, DWORD Reason, PVOID Reserved)
|
|||||||
FspServiceFinalize(Dynamic);
|
FspServiceFinalize(Dynamic);
|
||||||
FspFileSystemFinalize(Dynamic);
|
FspFileSystemFinalize(Dynamic);
|
||||||
FspEventLogFinalize(Dynamic);
|
FspEventLogFinalize(Dynamic);
|
||||||
|
FspPosixFinalize(Dynamic);
|
||||||
FspNtStatusFinalize(Dynamic);
|
FspNtStatusFinalize(Dynamic);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -38,6 +38,8 @@
|
|||||||
|
|
||||||
VOID FspNtStatusInitialize(BOOLEAN Dynamic);
|
VOID FspNtStatusInitialize(BOOLEAN Dynamic);
|
||||||
VOID FspNtStatusFinalize(BOOLEAN Dynamic);
|
VOID FspNtStatusFinalize(BOOLEAN Dynamic);
|
||||||
|
VOID FspPosixInitialize(BOOLEAN Dynamic);
|
||||||
|
VOID FspPosixFinalize(BOOLEAN Dynamic);
|
||||||
VOID FspEventLogInitialize(BOOLEAN Dynamic);
|
VOID FspEventLogInitialize(BOOLEAN Dynamic);
|
||||||
VOID FspEventLogFinalize(BOOLEAN Dynamic);
|
VOID FspEventLogFinalize(BOOLEAN Dynamic);
|
||||||
VOID FspFileSystemInitialize(BOOLEAN Dynamic);
|
VOID FspFileSystemInitialize(BOOLEAN Dynamic);
|
||||||
|
@ -160,6 +160,8 @@ FSP_API NTSTATUS FspPosixMapUidToSid(UINT32 Uid, PSID *PSid)
|
|||||||
*/
|
*/
|
||||||
else if (0x30000 <= Uid && Uid < 0x40000)
|
else if (0x30000 <= Uid && Uid < 0x40000)
|
||||||
{
|
{
|
||||||
|
InitOnceExecuteOnce(&FspPosixInitOnceV, FspPosixInitOnceF, 0, 0);
|
||||||
|
|
||||||
if (5 == FspAccountDomainSid->IdentifierAuthority.Value[5] &&
|
if (5 == FspAccountDomainSid->IdentifierAuthority.Value[5] &&
|
||||||
4 == FspAccountDomainSid->SubAuthorityCount)
|
4 == FspAccountDomainSid->SubAuthorityCount)
|
||||||
{
|
{
|
||||||
@ -173,6 +175,8 @@ FSP_API NTSTATUS FspPosixMapUidToSid(UINT32 Uid, PSID *PSid)
|
|||||||
}
|
}
|
||||||
else if (0x100000 <= Uid && Uid < 0x200000)
|
else if (0x100000 <= Uid && Uid < 0x200000)
|
||||||
{
|
{
|
||||||
|
InitOnceExecuteOnce(&FspPosixInitOnceV, FspPosixInitOnceF, 0, 0);
|
||||||
|
|
||||||
if (5 == FspPrimaryDomainSid->IdentifierAuthority.Value[5] &&
|
if (5 == FspPrimaryDomainSid->IdentifierAuthority.Value[5] &&
|
||||||
4 == FspPrimaryDomainSid->SubAuthorityCount)
|
4 == FspPrimaryDomainSid->SubAuthorityCount)
|
||||||
{
|
{
|
||||||
@ -194,21 +198,21 @@ FSP_API NTSTATUS FspPosixMapUidToSid(UINT32 Uid, PSID *PSid)
|
|||||||
* S-1-16-RID <=> uid/gid: 0x60000 + RID
|
* S-1-16-RID <=> uid/gid: 0x60000 + RID
|
||||||
*/
|
*/
|
||||||
else if (0x60000 <= Uid && Uid < 0x70000)
|
else if (0x60000 <= Uid && Uid < 0x70000)
|
||||||
*PSid = FspPosixCreateSid(5, 2, 16, Uid - 0x60000);
|
*PSid = FspPosixCreateSid(16, 1, Uid - 0x60000);
|
||||||
|
|
||||||
/* [IDMAP]
|
/* [IDMAP]
|
||||||
* Other well-known SIDs:
|
* Other well-known SIDs:
|
||||||
* S-1-X-Y <=> uid/gid: 0x10000 + 0x100 * X + Y
|
* S-1-X-Y <=> uid/gid: 0x10000 + 0x100 * X + Y
|
||||||
*/
|
*/
|
||||||
else if (0x10000 <= Uid && Uid < 0x11000)
|
else if (0x10000 <= Uid && Uid < 0x11000)
|
||||||
*PSid = FspPosixCreateSid(5, 2, (Uid - 0x10000) >> 8, (Uid - 0x10000) & 0xff);
|
*PSid = FspPosixCreateSid((Uid - 0x10000) >> 8, 1, (Uid - 0x10000) & 0xff);
|
||||||
|
|
||||||
/* [IDMAP]
|
/* [IDMAP]
|
||||||
* Other well-known SIDs in the NT_AUTHORITY domain (S-1-5-X-RID):
|
* Other well-known SIDs in the NT_AUTHORITY domain (S-1-5-X-RID):
|
||||||
* S-1-5-X-RID <=> uid/gid: 0x1000 * X + RID
|
* S-1-5-X-RID <=> uid/gid: 0x1000 * X + RID
|
||||||
*/
|
*/
|
||||||
else if (0x1000 <= Uid && Uid < 0x100000)
|
else if (0x1000 <= Uid && Uid < 0x100000)
|
||||||
*PSid = FspPosixCreateSid(5, 5, Uid >> 12, Uid & 0xfff);
|
*PSid = FspPosixCreateSid(5, 2, Uid >> 12, Uid & 0xfff);
|
||||||
|
|
||||||
if (0 == *PSid)
|
if (0 == *PSid)
|
||||||
return STATUS_NONE_MAPPED;
|
return STATUS_NONE_MAPPED;
|
||||||
@ -356,10 +360,12 @@ FSP_API NTSTATUS FspPosixMapPermissionsToSecurityDescriptor(
|
|||||||
UINT32 Uid, UINT32 Gid, UINT32 Mode,
|
UINT32 Uid, UINT32 Gid, UINT32 Mode,
|
||||||
PSECURITY_DESCRIPTOR *PSecurityDescriptor)
|
PSECURITY_DESCRIPTOR *PSecurityDescriptor)
|
||||||
{
|
{
|
||||||
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
FSP_API NTSTATUS FspPosixMapSecurityDescriptorToPermissions(
|
FSP_API NTSTATUS FspPosixMapSecurityDescriptorToPermissions(
|
||||||
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
PUINT32 PUid, PUINT32 PGid, PUINT32 PMode)
|
PUINT32 PUid, PUINT32 PGid, PUINT32 PMode)
|
||||||
{
|
{
|
||||||
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
43
tst/winfsp-tests/posix-test.c
Normal file
43
tst/winfsp-tests/posix-test.c
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#include <winfsp/winfsp.h>
|
||||||
|
#include <tlib/testsuite.h>
|
||||||
|
#include <sddl.h>
|
||||||
|
|
||||||
|
void posix_map_sid_test(void)
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
PWSTR SidStr;
|
||||||
|
UINT32 Uid;
|
||||||
|
} map[] =
|
||||||
|
{
|
||||||
|
{ L"S-1-0-0", 0x10000 },
|
||||||
|
{ L"S-1-1-0", 0x10100 },
|
||||||
|
{ L"S-1-2-0", 0x10200 },
|
||||||
|
{ L"S-1-2-1", 0x10201 },
|
||||||
|
};
|
||||||
|
NTSTATUS Result;
|
||||||
|
BOOL Success;
|
||||||
|
PSID Sid;
|
||||||
|
PWSTR SidStr;
|
||||||
|
|
||||||
|
for (size_t i = 0; sizeof map / sizeof map[0] > i; i++)
|
||||||
|
{
|
||||||
|
Result = FspPosixMapUidToSid(map[i].Uid, &Sid);
|
||||||
|
ASSERT(NT_SUCCESS(Result));
|
||||||
|
|
||||||
|
Success = ConvertSidToStringSidW(Sid, &SidStr);
|
||||||
|
ASSERT(Success);
|
||||||
|
ASSERT(0 == wcscmp(map[i].SidStr, SidStr));
|
||||||
|
LocalFree(SidStr);
|
||||||
|
|
||||||
|
Result = FspPosixMapSidToUid(Sid, &map[i].Uid);
|
||||||
|
ASSERT(NT_SUCCESS(Result));
|
||||||
|
|
||||||
|
FspDeleteSid(Sid, FspPosixMapUidToSid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void posix_tests(void)
|
||||||
|
{
|
||||||
|
TEST(posix_map_sid_test);
|
||||||
|
}
|
@ -7,6 +7,7 @@ int WinFspNetTests = 1;
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
TESTSUITE(fuse_opt_tests);
|
TESTSUITE(fuse_opt_tests);
|
||||||
|
TESTSUITE(posix_tests);
|
||||||
TESTSUITE(eventlog_tests);
|
TESTSUITE(eventlog_tests);
|
||||||
TESTSUITE(path_tests);
|
TESTSUITE(path_tests);
|
||||||
TESTSUITE(mount_tests);
|
TESTSUITE(mount_tests);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user