From 5aa6af26534c3bdf511c1c72e2b743e1637fc940 Mon Sep 17 00:00:00 2001 From: Bill Zissimopoulos Date: Mon, 30 Nov 2015 15:10:54 -0800 Subject: [PATCH] dll: FspFsctlCreateVolume: compute default security descriptor --- src/dll/fsctl.c | 34 ++++++++++++++++++++++++++++++++++ tst/winfsp-tests/mount-test.c | 12 ++++++++++++ 2 files changed, 46 insertions(+) diff --git a/src/dll/fsctl.c b/src/dll/fsctl.c index 3a5466cc..71e309cb 100644 --- a/src/dll/fsctl.c +++ b/src/dll/fsctl.c @@ -23,12 +23,45 @@ FSP_API NTSTATUS FspFsctlCreateVolume(PWSTR DevicePath, NTSTATUS Result = STATUS_SUCCESS; WCHAR DevicePathBuf[MAX_PATH]; FSP_FSCTL_VOLUME_PARAMS *ParamsBuf; + HANDLE Token; + PVOID DaclBuf = 0; + SECURITY_DESCRIPTOR SecurityDescriptorStruct; PSECURITY_DESCRIPTOR SecurityDescriptorBuf = 0; DWORD SecurityDescriptorSize, Bytes; HANDLE DeviceHandle = INVALID_HANDLE_VALUE; VolumePathBuf[0] = L'\0'; + if (0 == SecurityDescriptor) + { + if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &Token)) + { + Result = FspNtStatusFromWin32(GetLastError()); + goto exit; + } + GetTokenInformation(Token, TokenDefaultDacl, 0, 0, &Bytes); + DaclBuf = malloc(Bytes); + if (0 == DaclBuf) + { + CloseHandle(Token); + Result = STATUS_INSUFFICIENT_RESOURCES; + goto exit; + } + if (GetTokenInformation(Token, TokenDefaultDacl, DaclBuf, Bytes, &Bytes) && + InitializeSecurityDescriptor(&SecurityDescriptorStruct, SECURITY_DESCRIPTOR_REVISION) && + SetSecurityDescriptorDacl(&SecurityDescriptorStruct, TRUE, DaclBuf, FALSE)) + { + SecurityDescriptor = &SecurityDescriptorStruct; + CloseHandle(Token); + } + else + { + Result = FspNtStatusFromWin32(GetLastError()); + CloseHandle(Token); + goto exit; + } + } + SecurityDescriptorSize = GetSecurityDescriptorLength(SecurityDescriptor); ParamsBuf = malloc(sizeof *ParamsBuf + SecurityDescriptorSize); if (0 == ParamsBuf) @@ -65,6 +98,7 @@ exit: if (INVALID_HANDLE_VALUE != DeviceHandle) CloseHandle(DeviceHandle); free(SecurityDescriptorBuf); + free(DaclBuf); return Result; } diff --git a/tst/winfsp-tests/mount-test.c b/tst/winfsp-tests/mount-test.c index a0852ac9..f565e775 100644 --- a/tst/winfsp-tests/mount-test.c +++ b/tst/winfsp-tests/mount-test.c @@ -1,8 +1,20 @@ #include +#include #include +void mount_dotest(PWSTR DeviceName) +{ + NTSTATUS Result; + FSP_FSCTL_VOLUME_PARAMS Params; + + Params.SectorSize = 65536; + //Result = FspFsctlCreateVolume(DeviceName, &Params, ); +} + void mount_test(void) { + mount_dotest("WinFsp.Disk"); + mount_dotest("WinFsp.Net"); } void mount_tests(void)