dll: FspFsctlCreateVolume: compute default security descriptor

This commit is contained in:
Bill Zissimopoulos 2015-11-30 15:10:54 -08:00
parent dce40d03b2
commit 5aa6af2653
2 changed files with 46 additions and 0 deletions

View File

@ -23,12 +23,45 @@ FSP_API NTSTATUS FspFsctlCreateVolume(PWSTR DevicePath,
NTSTATUS Result = STATUS_SUCCESS; NTSTATUS Result = STATUS_SUCCESS;
WCHAR DevicePathBuf[MAX_PATH]; WCHAR DevicePathBuf[MAX_PATH];
FSP_FSCTL_VOLUME_PARAMS *ParamsBuf; FSP_FSCTL_VOLUME_PARAMS *ParamsBuf;
HANDLE Token;
PVOID DaclBuf = 0;
SECURITY_DESCRIPTOR SecurityDescriptorStruct;
PSECURITY_DESCRIPTOR SecurityDescriptorBuf = 0; PSECURITY_DESCRIPTOR SecurityDescriptorBuf = 0;
DWORD SecurityDescriptorSize, Bytes; DWORD SecurityDescriptorSize, Bytes;
HANDLE DeviceHandle = INVALID_HANDLE_VALUE; HANDLE DeviceHandle = INVALID_HANDLE_VALUE;
VolumePathBuf[0] = L'\0'; 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); SecurityDescriptorSize = GetSecurityDescriptorLength(SecurityDescriptor);
ParamsBuf = malloc(sizeof *ParamsBuf + SecurityDescriptorSize); ParamsBuf = malloc(sizeof *ParamsBuf + SecurityDescriptorSize);
if (0 == ParamsBuf) if (0 == ParamsBuf)
@ -65,6 +98,7 @@ exit:
if (INVALID_HANDLE_VALUE != DeviceHandle) if (INVALID_HANDLE_VALUE != DeviceHandle)
CloseHandle(DeviceHandle); CloseHandle(DeviceHandle);
free(SecurityDescriptorBuf); free(SecurityDescriptorBuf);
free(DaclBuf);
return Result; return Result;
} }

View File

@ -1,8 +1,20 @@
#include <winfsp/winfsp.h> #include <winfsp/winfsp.h>
#include <winfsp/fsctl.h>
#include <tlib/testsuite.h> #include <tlib/testsuite.h>
void mount_dotest(PWSTR DeviceName)
{
NTSTATUS Result;
FSP_FSCTL_VOLUME_PARAMS Params;
Params.SectorSize = 65536;
//Result = FspFsctlCreateVolume(DeviceName, &Params, );
}
void mount_test(void) void mount_test(void)
{ {
mount_dotest("WinFsp.Disk");
mount_dotest("WinFsp.Net");
} }
void mount_tests(void) void mount_tests(void)