Compare commits

..

1 Commits

Author SHA1 Message Date
778939d018 sys,dll,inc: implement user mode locking 2017-11-28 14:18:48 -08:00
147 changed files with 568 additions and 1810 deletions

View File

@ -1,12 +0,0 @@
(Enter your issue here.)
----
Before submitting this issue please review this checklist. Ideally all checkmarks should be checked upon submitting. (Use an x inside square brackets like so: [x])
- [ ] **Issue type**: Please consider posting only bug reports or enhancement requests. Questions are better in the [WinFsp Google Group](https://groups.google.com/forum/#!forum/winfsp).
- [ ] **No Duplicate**: Ensure that your issue has not been filed before. (Check open and closed issues.)
- [ ] **Description**: Provide a descriptive title and a detailed explanation of the problem you are experiencing (for a bug report) or you are trying to solve (for an enhancement request).
- [ ] **Reproduce**: For bug reports provide detailed information on how to reproduce the problem. For enhancement requests you do not need to provide this information, unless you find it relevant.
- [ ] **Behaviors**: Provide information on the expected and actual behaviors.
- [ ] **Environment**: For bug reports provide information about your OS version and build (e.g. 10.0.14393) and WinFsp version and build (e.g. 2017.2 or 1.2.17341). For enhancement requests you do not need to provide this information, unless you find it relevant.

View File

@ -1,12 +0,0 @@
(Enter your PR description here.)
----
Before submitting this PR please review this checklist. Ideally all checkmarks should be checked upon submitting. (Use an x inside square brackets like so: [x])
- [ ] **Contributing**: You MUST read and be willing to accept the [CONTRIBUTOR AGREEMENT](https://github.com/billziss-gh/winfsp/blob/master/Contributors.asciidoc). The agreement gives joint copyright interests in your contributions to you and the original WinFsp author. If you have already accepted the [CONTRIBUTOR AGREEMENT](https://github.com/billziss-gh/winfsp/blob/master/Contributors.asciidoc) you do not need to do so again.
- [ ] **Topic branch**: Avoid creating the PR off the master branch of your fork. Consider creating a topic branch and request a pull from that. This allows you to add commits to the master branch of your fork without affecting this PR.
- [ ] **No tabs**: Consistently use SPACES everywhere. NO TABS, unless the file format requires it (e.g. Makefile).
- [ ] **Style**: Follow the same code style as the rest of the project.
- [ ] **Tests**: Include tests to the extent that it is possible, especially if you add a new feature.
- [ ] **Quality**: Your design and code should be of high quality and something that you are proud of.

View File

@ -1,43 +1,6 @@
= Changelog
v1.3B1 (2018.1 B1)::
Changes since v1.2POST1:
- The WinFsp Launcher can now be controlled by the new `FspLaunch` API. File systems can be started, stopped, queried and listed using `FspLaunchStart`, `FspLaunchStop`, `FspLaunchGetInfo` and `FspLaunchGetNameList`.
- The WinFsp launcher now supports new registry settings `RunAs` and `WorkDirectory`. `RunAs` allows the laucher to launch a file system process under the service accounts LocalService and NetworkService. `WorkDirectory` can be used to specify the work directory for a newly launched file system process.
- The MEMFS sample file systems are now launched under the LocalService account.
- The WinFsp network provider is now added first in the provider order list. Previously it was added last. (GitHub PR #131; thanks @felfert.)
- The WinFsp installer now uses the Wix `Provides` dependency extension to provide a `WinFsp` dependency key. (GitHub PR #129; thanks @felfert.)
v1.2POST1 (2017.2; issue #127)::
Changes since v1.1:
- WinFsp-FUSE now supports BSD flags (Windows file attributes) during `getattr` and `fgetattr`. It also adds the `chflags` operation. BSD flags support requires use of the `FSP_FUSE_CAP_STAT_EX` capability and the new `struct fuse_stat_ex` which includes an `st_flags` field. If the preprocessor macro `FSP_FUSE_USE_STAT_EX` is defined before inclusion of `<fuse.h>` then `struct fuse_stat` will also be defined to include the `st_flags` field.
- WinFsp-FUSE also adds the following OSXFUSE operations: `setcrtime`, `setchgtime`. These can be used to set the creation (birth) time and change (ctime) time of a file.
- New `GetDirInfoByName` file system operation adds fast queries of directory info by file name rather than pattern [e.g. `FindFirstFileW(L"foobar", FindData)`]. Tests with fsbench showed that such queries are sped up by an order of magnitude when using `GetDirInfoByName` in MEMFS. Case-sensitive FUSE file systems get this optimization for free. The .NET layer also adds `GetDirInfoByName`.
- New `FspFileSystemOperationProcessId` API adds support for getting the originating process ID (PID) during `Create`, `Open` and `Rename` calls. FUSE file systems can now access `fuse_context::pid`. The .NET layer also adds `GetOperationProcessId`.
- New command line tool `fsptool` allows command line access to some WinFsp features.
- The WinFsp launcher now passes the name of the user who launched the file system as a special parameter %U. This is useful to file systems that use the launcher infrastructure, such as SSHFS-Win. [Please note that in earlier betas the user name was passed as parameter %3; the previous method was insecure and is no longer supported.]
- Important GitHub issues fixed: #96, #97, #103, #107, #127
v1.2 (2017.2)::
Changes since v1.1:
- WinFsp-FUSE now supports BSD flags (Windows file attributes) during `getattr` and `fgetattr`. It also adds the `chflags` operation. BSD flags support requires use of the `FSP_FUSE_CAP_STAT_EX` capability and the new `struct fuse_stat_ex` which includes an `st_flags` field. If the preprocessor macro `FSP_FUSE_USE_STAT_EX` is defined before inclusion of `<fuse.h>` then `struct fuse_stat` will also be defined to include the `st_flags` field.
- WinFsp-FUSE also adds the following OSXFUSE operations: `setcrtime`, `setchgtime`. These can be used to set the creation (birth) time and change (ctime) time of a file.
- New `GetDirInfoByName` file system operation adds fast queries of directory info by file name rather than pattern [e.g. `FindFirstFileW(L"foobar", FindData)`]. Tests with fsbench showed that such queries are sped up by an order of magnitude when using `GetDirInfoByName` in MEMFS. Case-sensitive FUSE file systems get this optimization for free. The .NET layer also adds `GetDirInfoByName`.
- New `FspFileSystemOperationProcessId` API adds support for getting the originating process ID (PID) during `Create`, `Open` and `Rename` calls. FUSE file systems can now access `fuse_context::pid`. The .NET layer also adds `GetOperationProcessId`.
- New command line tool `fsptool` allows command line access to some WinFsp features.
- The WinFsp launcher now passes the name of the user who launched the file system as a special parameter %U. This is useful to file systems that use the launcher infrastructure, such as SSHFS-Win. [Please note that in earlier betas the user name was passed as parameter %3; the previous method was insecure and is no longer supported.]
- Important GitHub issues fixed: #96, #97, #103, #107
v1.2B3 (2017.2 B3)::
Changes since v1.1:

View File

@ -55,7 +55,6 @@ CONTRIBUTOR LIST
----------------
|===
|Bill Zissimopoulos |billziss at navimatics.com
|Fritz Elfert |fritz-github at fritz-elfert.de
|John Oberschelp |john at oberschelp.net
|Sam Kelly (DuroSoft Technologies LLC, https://durosoft.com) |sam at durosoft.com
|Tobias Urlaub |saibotu at outlook.de

View File

@ -30,23 +30,21 @@ WinFsp consists of a kernel mode FSD (File System Driver) and a user mode DLL (D
The project source code is organized as follows:
* `build/VStudio`: WinFsp solution and project files.
* `doc`: The WinFsp design documents and additional documentation can be found here.
* `ext/tlib`: A small test library originally from the secfs (Secure Cloud File System) project.
* `ext/test`: Submodule pointing to the secfs.test project, which contains a number of tools for testing Windows and POSIX file systems.
* `inc/fuse`: Public headers for the FUSE compatibility layer.
* `inc/winfsp`: Public headers for the WinFsp API.
* `src/dll`: Source code to the WinFsp DLL.
* `src/dll/fuse`: Source code to the FUSE compatibility layer.
* `src/dotnet`: Source code to the .NET layer.
* `src/fsptool`: Source code to fsptool command line utility.
* `src/launcher`: Source code to the launcher service and the launchctl utility.
* `src/sys`: Source code to the WinFsp FSD.
* `opt/cygfuse`: Source code for the Cygwin FUSE package.
* `tst/memfs*`: Source code to an example file system written in C/C++ (memfs) or C# (memfs-dotnet).
* `tst/passthrough*`: Source code to additional example file systems.
* `tst/winfsp-tests`: WinFsp test suite.
* `tools`: Various tools for building and testing WinFsp.
* build/VStudio: WinFsp solution and project files.
* doc: The WinFsp design documents and additional documentation can be found here.
* ext/tlib: A small test library originally from the secfs (Secure Cloud File System) project.
* ext/test: Submodule pointing to the secfs.test project, which contains a number of tools for testing Windows and POSIX file systems.
* inc/winfsp: Public headers for the WinFsp API.
* inc/fuse: Public headers for the FUSE compatibility layer.
* src/dll: Source code to the WinFsp DLL.
* src/dll/fuse: Source code to the FUSE compatibility layer.
* src/dotnet: Source code to the .NET layer.
* src/launcher: Source code to the launcher service and the launchctl utility.
* src/sys: Source code to the WinFsp FSD.
* opt/cygfuse: Source code for the Cygwin FUSE package.
* tst/memfs*: Source code to an example file system written in C/C++ (memfs) or C# (memfs-dotnet).
* tst/passthrough*: Source code to additional example file systems.
* tst/winfsp-tests: WinFsp test suite.
## Building and Running

View File

@ -1,7 +1,7 @@
/**
* @file CustomActions.cpp
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:dep="http://schemas.microsoft.com/wix/DependencyExtension">
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product
Id="*"
Name="$(var.MyProductName) $(var.MyProductVersion)"
@ -54,8 +53,8 @@
Key="[P.RegistryKey]"
Name="InstallDir"
Type="string"
Value="[INSTALLDIR]" />
<dep:Provides Key="WinFsp" />
Value="[INSTALLDIR]"
KeyPath="yes" />
</Component>
<Component Id="C.License.txt">
<File Name="License.txt" Source="..\..\..\License.txt" KeyPath="yes" />
@ -188,10 +187,6 @@
Type="string"
Name="CommandLine"
Value="-i -F NTFS -n 65536 -s 67108864 -u %1 -m %2" />
<RegistryValue
Type="string"
Name="RunAs"
Value="LocalService" />
<RegistryValue
Type="string"
Name="Security"
@ -218,10 +213,6 @@
Type="string"
Name="CommandLine"
Value="-i -F NTFS -n 65536 -s 67108864 -u %1 -m %2" />
<RegistryValue
Type="string"
Name="RunAs"
Value="LocalService" />
<RegistryValue
Type="string"
Name="Security"
@ -248,10 +239,6 @@
Type="string"
Name="CommandLine"
Value="-i -F NTFS -n 65536 -s 67108864 -u %1 -m %2" />
<RegistryValue
Type="string"
Name="RunAs"
Value="LocalService" />
<RegistryValue
Type="string"
Name="Security"
@ -323,12 +310,12 @@
<Directory Id="OPTDIR.cygfuse" Name="cygfuse" FileSource="..\..\..\opt\cygfuse\dist">
<Directory Id="OPTDIR.cygfuse.x64" Name="x64">
<Component Id="C.fuse.tar.xz.x64">
<File Id="FILE.fuse.tar.xz.x64" Name="fuse-2.8-7.tar.xz" KeyPath="yes" />
<File Id="FILE.fuse.tar.xz.x64" Name="fuse-2.8-6.tar.xz" KeyPath="yes" />
</Component>
</Directory>
<Directory Id="OPTDIR.cygfuse.x86" Name="x86">
<Component Id="C.fuse.tar.xz.x86">
<File Id="FILE.fuse.tar.xz.x86" Name="fuse-2.8-7.tar.xz" KeyPath="yes" />
<File Id="FILE.fuse.tar.xz.x86" Name="fuse-2.8-6.tar.xz" KeyPath="yes" />
</Component>
</Directory>
<Component Id="C.fuse.install.sh">

View File

@ -39,10 +39,6 @@
<HintPath>$(WixExtDir)\WixUIExtension.dll</HintPath>
<Name>WixUIExtension</Name>
</WixExtension>
<WixExtension Include="WixDependencyExtension">
<HintPath>$(WixExtDir)\WixDependencyExtension.dll</HintPath>
<Name>WixDependencyExtension</Name>
</WixExtension>
</ItemGroup>
<Import Project="$(WixTargetsPath)" />
<!--

View File

@ -112,7 +112,7 @@
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<AdditionalDependencies>%(AdditionalDependencies);rpcrt4.lib;userenv.lib</AdditionalDependencies>
<AdditionalDependencies>%(AdditionalDependencies);rpcrt4.lib</AdditionalDependencies>
<StripPrivateSymbols>$(OutDir)$(TargetName).public.pdb</StripPrivateSymbols>
</Link>
</ItemDefinitionGroup>
@ -134,7 +134,7 @@
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<AdditionalDependencies>%(AdditionalDependencies);rpcrt4.lib;userenv.lib</AdditionalDependencies>
<AdditionalDependencies>%(AdditionalDependencies);rpcrt4.lib</AdditionalDependencies>
<StripPrivateSymbols>$(OutDir)$(TargetName).public.pdb</StripPrivateSymbols>
</Link>
</ItemDefinitionGroup>
@ -159,7 +159,7 @@
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<AdditionalDependencies>%(AdditionalDependencies);rpcrt4.lib;userenv.lib</AdditionalDependencies>
<AdditionalDependencies>%(AdditionalDependencies);rpcrt4.lib</AdditionalDependencies>
<StripPrivateSymbols>$(OutDir)$(TargetName).public.pdb</StripPrivateSymbols>
</Link>
</ItemDefinitionGroup>
@ -184,7 +184,7 @@
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<AdditionalDependencies>%(AdditionalDependencies);rpcrt4.lib;userenv.lib</AdditionalDependencies>
<AdditionalDependencies>%(AdditionalDependencies);rpcrt4.lib</AdditionalDependencies>
<StripPrivateSymbols>$(OutDir)$(TargetName).public.pdb</StripPrivateSymbols>
</Link>
</ItemDefinitionGroup>

View File

@ -16,9 +16,9 @@
<MyCompanyName>Navimatics Corporation</MyCompanyName>
<MyCopyright>2015-$([System.DateTime]::Now.ToString(`yyyy`)) Bill Zissimopoulos</MyCopyright>
<MyCanonicalVersion>1.3</MyCanonicalVersion>
<MyCanonicalVersion>1.2</MyCanonicalVersion>
<MyProductVersion>2018.1 B1</MyProductVersion>
<MyProductVersion>2017.2 B3</MyProductVersion>
<MyProductStage>Beta</MyProductStage>
<MyVersion>$(MyCanonicalVersion).$(MyBuildNumber)</MyVersion>

View File

@ -39,7 +39,6 @@
<ClCompile Include="..\..\src\dll\fuse\fuse_intf.c" />
<ClCompile Include="..\..\src\dll\fuse\fuse_main.c" />
<ClCompile Include="..\..\src\dll\fuse\fuse_opt.c" />
<ClCompile Include="..\..\src\dll\launch.c" />
<ClCompile Include="..\..\src\dll\np.c" />
<ClCompile Include="..\..\src\dll\posix.c" />
<ClCompile Include="..\..\src\dll\security.c" />
@ -52,7 +51,6 @@
<ClCompile Include="..\..\src\dll\path.c" />
<ClCompile Include="..\..\src\dll\service.c" />
<ClCompile Include="..\..\src\dll\util.c" />
<ClCompile Include="..\..\src\dll\wksid.c" />
</ItemGroup>
<ItemGroup>
<CustomBuild Include="..\..\src\dll\fuse\fuse.pc.in">

View File

@ -112,12 +112,6 @@
<ClCompile Include="..\..\src\dll\fuse\fuse_compat.c">
<Filter>Source\fuse</Filter>
</ClCompile>
<ClCompile Include="..\..\src\dll\wksid.c">
<Filter>Source</Filter>
</ClCompile>
<ClCompile Include="..\..\src\dll\launch.c">
<Filter>Source</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\..\src\dll\library.def">

View File

@ -28,7 +28,7 @@ if ($key.Count -eq 1) {
-File "$file"
}
} elseif ($key.Count -eq 0) {
# Write-Warning "$packageName is not installed"
Write-Warning "$packageName has already been uninstalled by other means."
} elseif ($key.Count -gt 1) {
Write-Warning "Too many matching packages found! Package may not be uninstalled."
Write-Warning "Please alert package maintainer the following packages were matched:"

View File

@ -1,14 +1,16 @@
$ErrorActionPreference = 'Stop';
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
. "$toolsdir\chocolateyHelper.ps1"
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$fileLocation = @(Get-ChildItem $toolsDir -filter winfsp-*.msi)[0].FullName
$packageArgs = @{
packageName = 'winfsp'
fileType = 'msi'
file = @(Get-ChildItem $toolsDir -filter winfsp-*.msi)[0].FullName
file = $fileLocation
silentArgs = "/qn /norestart INSTALLLEVEL=1000"
validExitCodes = @(0, 3010, 1641)
}
Install-ChocolateyInstallPackage @packageArgs
Remove-Item -Force $packageArgs.file

View File

@ -1,4 +0,0 @@
$ErrorActionPreference = 'Stop';
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
. "$toolsdir\chocolateyHelper.ps1"

View File

@ -50,8 +50,7 @@ To verify installation:
<file src="LICENSE.txt" target="tools" />
<file src="VERIFICATION.txt" target="tools" />
<file src="chocolateyInstall.ps1" target="tools" />
<file src="chocolateyUninstall.ps1" target="tools" />
<file src="chocolateyHelper.ps1" target="tools" />
<file src="chocolateyBeforeModify.ps1" target="tools" />
<file src="winfsp-$version$.msi" target="tools" />
</files>
</package>

View File

@ -4,8 +4,6 @@ This document contains a list of known file systems and file system libraries th
== File Systems
- https://github.com/ihaveamac/fuse-3ds[fuse-3ds] - FUSE Filesystem Python scripts for Nintendo 3DS files
- https://github.com/FrKaram/KS2.Drive[KS2.Drive] - Mount a webDAV/AOS server as a local drive
- https://github.com/billziss-gh/nfs-win[nfs-win] - NFS for Windows
- https://github.com/ncw/rclone[rclone] - rsync for cloud storage
- https://github.com/hasse69/rar2fs[rar2fs] - FUSE file system for reading RAR archives

View File

@ -1,7 +1,7 @@
/**
* @file tlib/callstack.c
*
* @copyright 2014-2018 Bill Zissimopoulos
* @copyright 2014-2017 Bill Zissimopoulos
*/
#include <tlib/callstack.h>

View File

@ -1,7 +1,7 @@
/**
* @file tlib/callstack.h
*
* @copyright 2014-2018 Bill Zissimopoulos
* @copyright 2014-2017 Bill Zissimopoulos
*/
#ifndef TLIB_CALLSTACK_H_INCLUDED

View File

@ -1,7 +1,7 @@
/**
* @file tlib/injected/allfunc.h
*
* @copyright 2014-2018 Bill Zissimopoulos
* @copyright 2014-2017 Bill Zissimopoulos
*/
#ifndef TLIB_INJECTED_ALLFUNC_H_INCLUDED

View File

@ -1,7 +1,7 @@
/**
* @file tlib/injected/curlfunc.c
*
* @copyright 2014-2018 Bill Zissimopoulos
* @copyright 2014-2017 Bill Zissimopoulos
*/
#include <tlib/injected/curlfunc.h>

View File

@ -1,7 +1,7 @@
/**
* @file tlib/injected/curlfunc.h
*
* @copyright 2014-2018 Bill Zissimopoulos
* @copyright 2014-2017 Bill Zissimopoulos
*/
#ifndef TLIB_INJECTED_CURLFUNC_H_INCLUDED

View File

@ -1,7 +1,7 @@
/**
* @file tlib/injected/stdfunc.c
*
* @copyright 2014-2018 Bill Zissimopoulos
* @copyright 2014-2017 Bill Zissimopoulos
*/
#include <tlib/injected/stdfunc.h>

View File

@ -1,7 +1,7 @@
/**
* @file tlib/injected/stdfunc.h
*
* @copyright 2014-2018 Bill Zissimopoulos
* @copyright 2014-2017 Bill Zissimopoulos
*/
#ifndef TLIB_INJECTED_STDFUNC_H_INCLUDED

View File

@ -1,7 +1,7 @@
/**
* @file tlib/injection.c
*
* @copyright 2014-2018 Bill Zissimopoulos
* @copyright 2014-2017 Bill Zissimopoulos
*/
#include <tlib/injection.h>

View File

@ -1,7 +1,7 @@
/**
* @file tlib/injection.h
*
* @copyright 2014-2018 Bill Zissimopoulos
* @copyright 2014-2017 Bill Zissimopoulos
*/
/* NOTE: This header may usefully be included multiple times.

View File

@ -1,7 +1,7 @@
/**
* @file tlib/testsuite.c
*
* @copyright 2014-2018 Bill Zissimopoulos
* @copyright 2014-2017 Bill Zissimopoulos
*/
#include <tlib/testsuite.h>

View File

@ -1,7 +1,7 @@
/**
* @file tlib/testsuite.h
*
* @copyright 2014-2018 Bill Zissimopoulos
* @copyright 2014-2017 Bill Zissimopoulos
*/
#ifndef TLIB_TESTSUITE_H_INCLUDED

View File

@ -6,7 +6,7 @@
* FUSE: Filesystem in Userspace
* Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -6,7 +6,7 @@
* FUSE: Filesystem in Userspace
* Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -6,7 +6,7 @@
* FUSE: Filesystem in Userspace
* Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -2,7 +2,7 @@
* @file fuse/winfsp_fuse.h
* WinFsp FUSE compatible API.
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/**
* @file winfsp/fsctl.h
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.
@ -153,7 +153,8 @@ typedef struct
UINT32 PassQueryDirectoryPattern:1; /* pass Pattern during QueryDirectory operations */
UINT32 AlwaysUseDoubleBuffering:1;
UINT32 PassQueryDirectoryFileName:1; /* pass FileName during QueryDirectory (GetDirInfoByName) */
UINT32 KmReservedFlags:2;
UINT32 UserModeFileLocking:1; /* pass file locking requests to user mode */
UINT32 KmReservedFlags:1;
/* user-mode flags */
UINT32 UmFileContextIsUserContext2:1; /* user mode: FileContext parameter is UserContext2 */
UINT32 UmFileContextIsFullContext:1; /* user mode: FileContext parameter is FullContext */
@ -259,6 +260,7 @@ typedef struct
UINT32 SetLastAccessTime:1;
UINT32 SetLastWriteTime:1;
UINT32 SetChangeTime:1;
UINT32 UnlockAll:1;
} Cleanup;
struct
{
@ -273,6 +275,7 @@ typedef struct
UINT64 Offset;
UINT32 Length;
UINT32 Key;
UINT32 ProcessId;
} Read;
struct
{
@ -283,6 +286,8 @@ typedef struct
UINT32 Length;
UINT32 Key;
UINT32 ConstrainedIo:1;
UINT32 ReservedFlags:31;
UINT32 ProcessId;
} Write;
struct
{
@ -359,6 +364,18 @@ typedef struct
UINT16 TargetOnFileSystem; /* the target of the symbolic link is on this file system */
} FileSystemControl;
struct
{
UINT64 UserContext;
UINT64 UserContext2;
UINT32 LockFunction;
UINT64 Offset;
UINT64 Length;
UINT32 Key;
UINT32 ProcessId;
UINT32 Exclusive:1;
UINT32 FailImmediately:1;
} LockControl;
struct
{
UINT64 UserContext;
UINT64 UserContext2;

View File

@ -5,7 +5,7 @@
* In order to use the WinFsp API the user mode file system must include &lt;winfsp/winfsp.h&gt;
* and link with the winfsp_x64.dll (or winfsp_x86.dll) library.
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.
@ -133,6 +133,7 @@ enum
FspCleanupSetLastAccessTime = 0x20,
FspCleanupSetLastWriteTime = 0x40,
FspCleanupSetChangeTime = 0x80,
FspCleanupUnlockAll = 0x0100,
};
/**
* @class FSP_FILE_SYSTEM
@ -822,12 +823,80 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
NTSTATUS (*GetDirInfoByName)(FSP_FILE_SYSTEM *FileSystem,
PVOID FileContext, PWSTR FileName,
FSP_FSCTL_DIR_INFO *DirInfo);
/**
* Lock a file range.
*
* At the time of this call the FSD has already done its own locking processing.
* Thus the kernel may fail a lock control request or a Read or Write without
* informing the user mode file system.
*
* @param FileSystem
* The file system on which this request is posted.
* @param FileContext
* The file context of the file to be locked.
* @param Offset
* Offset within the file to lock.
* @param Length
* Length of data to lock.
* @param Owner
* Lock owner. This 64-bit value consists of a PID in the high 32-bits and a "Key"
* in the low 32-bits. The PID is that of the process requesting the lock. The Key
* is an arbitrary value.
*
* The triplet (FileDesc,PID,Key) uniquely identifies the lock owner.
* @param Exclusive
* When TRUE an exclusive lock is requested. Otherwise a shared lock is requested.
* @param FailImmediately
* When TRUE the function should return immediately if it is unable to acquire the
* requested lock. Otherwise the function should wait until the lock can be granted.
* In this case the function may also return STATUS_PENDING.
* @return
* STATUS_SUCCESS or error code. STATUS_PENDING is supported allowing for asynchronous
* operation.
*/
NTSTATUS (*Lock)(FSP_FILE_SYSTEM *FileSystem,
PVOID FileContext, UINT64 Offset, UINT64 Length, UINT64 Owner,
BOOLEAN Exclusive, BOOLEAN FailImmediately);
/**
* Unlock file ranges.
*
* At the time of this call the FSD has already done its own locking processing.
* Thus the kernel may fail a lock control request or a Read or Write without
* informing the user mode file system.
*
* An Unlock operation with Offset == Length == -1 is a request to remove multiple locks.
* The set of possible locks to remove includes all locks made by the process described
* by the Owner parameter through the file descriptor described by the FileContext parameter.
* If the Key portion of the Owner parameter is 0, all the locks in the set are removed.
* If the Key portion of the Owner paramter is non-0, only locks that match the Key are
* removed.
*
* @param FileSystem
* The file system on which this request is posted.
* @param FileContext
* The file context of the file to be unlocked.
* @param Offset
* Offset within the file to unlock.
* @param Length
* Length of data to unlock.
* @param Owner
* Lock owner. This 64-bit value consists of a PID in the high 32-bits and a "Key"
* in the low 32-bits. The PID is that of the process requesting the lock. The Key
* is an arbitrary value.
*
* The triplet (FileDesc,PID,Key) uniquely identifies the lock owner.
* @return
* STATUS_SUCCESS or error code. STATUS_PENDING is supported allowing for asynchronous
* operation.
*/
NTSTATUS (*Unlock)(FSP_FILE_SYSTEM *FileSystem,
PVOID FileContext, UINT64 Offset, UINT64 Length, UINT64 Owner);
/*
* This ensures that this interface will always contain 64 function pointers.
* Please update when changing the interface as it is important for future compatibility.
*/
NTSTATUS (*Reserved[39])();
NTSTATUS (*Reserved[37])();
} FSP_FILE_SYSTEM_INTERFACE;
FSP_FSCTL_STATIC_ASSERT(sizeof(FSP_FILE_SYSTEM_INTERFACE) == 64 * sizeof(NTSTATUS (*)()),
"FSP_FILE_SYSTEM_INTERFACE must have 64 entries.");
@ -1086,7 +1155,7 @@ BOOLEAN FspFileSystemIsOperationCaseSensitive(VOID)
}
FSP_API BOOLEAN FspFileSystemIsOperationCaseSensitiveF(VOID);
/**
* Gets the originating process ID.
* Get the originating process ID.
*
* Valid only during Create, Open and Rename requests when the target exists.
*/
@ -1107,6 +1176,28 @@ UINT32 FspFileSystemOperationProcessId(VOID)
}
}
FSP_API UINT32 FspFileSystemOperationProcessIdF(VOID);
/**
* Get the lock owner.
*
* Valid only during Read, Write, Lock and Unlock requests.
*/
static inline
UINT64 FspFileSystemOperationLockOwner(VOID)
{
FSP_FSCTL_TRANSACT_REQ *Request = FspFileSystemGetOperationContext()->Request;
switch (Request->Kind)
{
case FspFsctlTransactReadKind:
return ((UINT64)Request->Req.Read.ProcessId << 32) | (UINT64)Request->Req.Read.Key;
case FspFsctlTransactWriteKind:
return ((UINT64)Request->Req.Write.ProcessId << 32) | (UINT64)Request->Req.Write.Key;
case FspFsctlTransactLockControlKind:
return ((UINT64)Request->Req.LockControl.ProcessId << 32) | (UINT64)Request->Req.LockControl.Key;
default:
return 0;
}
}
FSP_API UINT64 FspFileSystemOperationLockOwnerF(VOID);
/*
* Operations
@ -1141,6 +1232,8 @@ FSP_API NTSTATUS FspFileSystemOpQueryDirectory(FSP_FILE_SYSTEM *FileSystem,
FSP_FSCTL_TRANSACT_REQ *Request, FSP_FSCTL_TRANSACT_RSP *Response);
FSP_API NTSTATUS FspFileSystemOpFileSystemControl(FSP_FILE_SYSTEM *FileSystem,
FSP_FSCTL_TRANSACT_REQ *Request, FSP_FSCTL_TRANSACT_RSP *Response);
FSP_API NTSTATUS FspFileSystemOpLockControl(FSP_FILE_SYSTEM *FileSystem,
FSP_FSCTL_TRANSACT_REQ *Request, FSP_FSCTL_TRANSACT_RSP *Response);
FSP_API NTSTATUS FspFileSystemOpQuerySecurity(FSP_FILE_SYSTEM *FileSystem,
FSP_FSCTL_TRANSACT_REQ *Request, FSP_FSCTL_TRANSACT_RSP *Response);
FSP_API NTSTATUS FspFileSystemOpSetSecurity(FSP_FILE_SYSTEM *FileSystem,
@ -1675,19 +1768,6 @@ FSP_API VOID FspServiceStop(FSP_SERVICE *Service);
* TRUE if the process is running in running user interactive mode.
*/
FSP_API BOOLEAN FspServiceIsInteractive(VOID);
/**
* Check if the supplied token is from the service context.
*
* @param Token
* Token to check. Pass NULL to check the current process token.
* @param PIsLocalSystem
* Pointer to a boolean that will receive a TRUE value if the token belongs to LocalSystem
* and FALSE otherwise. May be NULL.
* @return
* STATUS_SUCCESS if the token is from the service context. STATUS_ACCESS_DENIED if it is not.
* Other error codes are possible.
*/
FSP_API NTSTATUS FspServiceContextCheck(HANDLE Token, PBOOLEAN PIsLocalSystem);
/**
* Log a service message.
*
@ -1703,133 +1783,6 @@ FSP_API NTSTATUS FspServiceContextCheck(HANDLE Token, PBOOLEAN PIsLocalSystem);
FSP_API VOID FspServiceLog(ULONG Type, PWSTR Format, ...);
FSP_API VOID FspServiceLogV(ULONG Type, PWSTR Format, va_list ap);
/**
* @group Launch Control
*/
/**
* Call launcher pipe.
*
* This function is used to send a command to the launcher and receive a response.
*
* @param Command
* Launcher command to send. For example, the 'L' launcher command instructs
* the launcher to list all running service instances.
* @param Argc
* Command argument count. May be 0.
* @param Argv
* Command argument array. May be NULL.
* @param Argl
* Command argument length array. May be NULL. If this is NULL all command arguments
* are assumed to be NULL-terminated strings. It is also possible for specific arguments
* to be NULL-terminated; in this case pass -1 in the corresponding Argl position.
* @param Buffer
* Buffer that receives the command response. May be NULL.
* @param PSize
* Pointer to a ULONG. On input it contains the size of the Buffer. On output it
* contains the number of bytes transferred. May be NULL.
* @param PLauncherError
* Receives the launcher error if any. This is always a Win32 error code. May not be NULL.
* @return
* STATUS_SUCCESS if the command is sent successfully to the launcher, even if the launcher
* returns an error. Other status codes indicate a communication error. Launcher errors are
* reported through PLauncherError.
*/
FSP_API NTSTATUS FspLaunchCallLauncherPipe(
WCHAR Command, ULONG Argc, PWSTR *Argv, ULONG *Argl,
PWSTR Buffer, PULONG PSize, PULONG PLauncherError);
/**
* Start a service instance.
*
* @param ClassName
* Class name of the service instance to start.
* @param InstanceName
* Instance name of the service instance to start.
* @param Argc
* Service instance argument count. May be 0.
* @param Argv
* Service instance argument array. May be NULL.
* @param HasSecret
* Whether the last argument in Argv is assumed to be a secret (e.g. password) or not.
* Secrets are passed to service instances through standard input rather than the command
* line.
* @param PLauncherError
* Receives the launcher error if any. This is always a Win32 error code. May not be NULL.
* @return
* STATUS_SUCCESS if the command is sent successfully to the launcher, even if the launcher
* returns an error. Other status codes indicate a communication error. Launcher errors are
* reported through PLauncherError.
*/
FSP_API NTSTATUS FspLaunchStart(
PWSTR ClassName, PWSTR InstanceName, ULONG Argc, PWSTR *Argv0,
BOOLEAN HasSecret,
PULONG PLauncherError);
/**
* Stop a service instance.
*
* @param ClassName
* Class name of the service instance to stop.
* @param InstanceName
* Instance name of the service instance to stop.
* @param PLauncherError
* Receives the launcher error if any. This is always a Win32 error code. May not be NULL.
* @return
* STATUS_SUCCESS if the command is sent successfully to the launcher, even if the launcher
* returns an error. Other status codes indicate a communication error. Launcher errors are
* reported through PLauncherError.
*/
FSP_API NTSTATUS FspLaunchStop(
PWSTR ClassName, PWSTR InstanceName,
PULONG PLauncherError);
/**
* Get information about a service instance.
*
* The information is a list of NULL-terminated strings: the class name of the service instance,
* the instance name of the service instance and the full command line used to start the service
* instance.
*
* @param ClassName
* Class name of the service instance to stop.
* @param InstanceName
* Instance name of the service instance to stop.
* @param Buffer
* Buffer that receives the command response. May be NULL.
* @param PSize
* Pointer to a ULONG. On input it contains the size of the Buffer. On output it
* contains the number of bytes transferred. May be NULL.
* @param PLauncherError
* Receives the launcher error if any. This is always a Win32 error code. May not be NULL.
* @return
* STATUS_SUCCESS if the command is sent successfully to the launcher, even if the launcher
* returns an error. Other status codes indicate a communication error. Launcher errors are
* reported through PLauncherError.
*/
FSP_API NTSTATUS FspLaunchGetInfo(
PWSTR ClassName, PWSTR InstanceName,
PWSTR Buffer, PULONG PSize,
PULONG PLauncherError);
/**
* List service instances.
*
* The information is a list of pairs of NULL-terminated strings. Each pair contains the class
* name and instance name of a service instance. All currently running service instances are
* listed.
*
* @param Buffer
* Buffer that receives the command response. May be NULL.
* @param PSize
* Pointer to a ULONG. On input it contains the size of the Buffer. On output it
* contains the number of bytes transferred. May be NULL.
* @param PLauncherError
* Receives the launcher error if any. This is always a Win32 error code. May not be NULL.
* @return
* STATUS_SUCCESS if the command is sent successfully to the launcher, even if the launcher
* returns an error. Other status codes indicate a communication error. Launcher errors are
* reported through PLauncherError.
*/
FSP_API NTSTATUS FspLaunchGetNameList(
PWSTR Buffer, PULONG PSize,
PULONG PLauncherError);
/*
* Utility
*/
@ -1840,7 +1793,6 @@ FSP_API VOID FspEventLogV(ULONG Type, PWSTR Format, va_list ap);
FSP_API VOID FspDebugLogSetHandle(HANDLE Handle);
FSP_API VOID FspDebugLog(const char *Format, ...);
FSP_API VOID FspDebugLogSD(const char *Format, PSECURITY_DESCRIPTOR SecurityDescriptor);
FSP_API VOID FspDebugLogSid(const char *format, PSID Sid);
FSP_API VOID FspDebugLogFT(const char *Format, PFILETIME FileTime);
FSP_API VOID FspDebugLogRequest(FSP_FSCTL_TRANSACT_REQ *Request);
FSP_API VOID FspDebugLogResponse(FSP_FSCTL_TRANSACT_RSP *Response);

View File

@ -2,7 +2,7 @@
* @file winfsp/winfsp.hpp
* WinFsp C++ Layer.
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -22,9 +22,7 @@ cygport:
dist: cygport
case $(shell uname -m) in \
x86_64)\
mkdir -p dist/x64 && \
cp fuse-*/dist/fuse/fuse-*[0-9].tar.xz dist/x64 ;;\
*)\
mkdir -p dist/x86 && \
cp fuse-*/dist/fuse/fuse-*[0-9].tar.xz dist/x86 ;;\
esac

View File

@ -1,7 +1,7 @@
/**
* @file cygfuse/cygfuse.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

BIN
opt/cygfuse/dist/x64/fuse-2.8-6.tar.xz vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
opt/cygfuse/dist/x86/fuse-2.8-6.tar.xz vendored Normal file

Binary file not shown.

Binary file not shown.

View File

@ -1,6 +1,6 @@
NAME="fuse"
VERSION=2.8
RELEASE=7
RELEASE=6
CATEGORY="Utils"
SUMMARY="WinFsp-FUSE compatibility layer"
DESCRIPTION="WinFsp-FUSE enables FUSE file systems to be run on Cygwin."

View File

@ -1,7 +1,7 @@
/**
* @file dll/debug.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.
@ -63,21 +63,6 @@ FSP_API VOID FspDebugLogSD(const char *format, PSECURITY_DESCRIPTOR SecurityDesc
FspDebugLog(format, "invalid security descriptor");
}
FSP_API VOID FspDebugLogSid(const char *format, PSID Sid)
{
char *S;
if (0 == Sid)
FspDebugLog(format, "null SID");
else if (ConvertSidToStringSidA(Sid, &S))
{
FspDebugLog(format, S);
LocalFree(S);
}
else
FspDebugLog(format, "invalid SID");
}
FSP_API VOID FspDebugLogFT(const char *format, PFILETIME FileTime)
{
SYSTEMTIME SystemTime;

View File

@ -1,7 +1,7 @@
/**
* @file dll/dirbuf.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/**
* @file dll/eventlog.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/**
* @file dll/fs.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.
@ -162,6 +162,7 @@ FSP_API NTSTATUS FspFileSystemCreate(PWSTR DevicePath,
FileSystem->Operations[FspFsctlTransactSetVolumeInformationKind] = FspFileSystemOpSetVolumeInformation;
FileSystem->Operations[FspFsctlTransactQueryDirectoryKind] = FspFileSystemOpQueryDirectory;
FileSystem->Operations[FspFsctlTransactFileSystemControlKind] = FspFileSystemOpFileSystemControl;
FileSystem->Operations[FspFsctlTransactLockControlKind] = FspFileSystemOpLockControl;
FileSystem->Operations[FspFsctlTransactQuerySecurityKind] = FspFileSystemOpQuerySecurity;
FileSystem->Operations[FspFsctlTransactSetSecurityKind] = FspFileSystemOpSetSecurity;
FileSystem->Operations[FspFsctlTransactQueryStreamInformationKind] = FspFileSystemOpQueryStreamInformation;
@ -187,62 +188,17 @@ FSP_API VOID FspFileSystemDelete(FSP_FILE_SYSTEM *FileSystem)
MemFree(FileSystem);
}
static NTSTATUS FspFileSystemLauncherDefineDosDevice(
WCHAR Sign, PWSTR MountPoint, PWSTR VolumeName)
{
if (2 != lstrlenW(MountPoint) ||
FSP_FSCTL_VOLUME_NAME_SIZEMAX / sizeof(WCHAR) <= lstrlenW(VolumeName))
return STATUS_INVALID_PARAMETER;
WCHAR Argv0[4];
PWSTR Argv[2];
NTSTATUS Result;
ULONG ErrorCode;
Argv0[0] = Sign;
Argv0[1] = MountPoint[0];
Argv0[2] = MountPoint[1];
Argv0[3] = L'\0';
Argv[0] = Argv0;
Argv[1] = VolumeName;
Result = FspLaunchCallLauncherPipe('D', 2, Argv, 0, 0, 0, &ErrorCode);
return !NT_SUCCESS(Result) ? Result : FspNtStatusFromWin32(ErrorCode);
}
static NTSTATUS FspFileSystemSetMountPoint_Drive(PWSTR MountPoint, PWSTR VolumeName,
PHANDLE PMountHandle)
{
NTSTATUS Result;
BOOLEAN IsLocalSystem, IsServiceContext;
*PMountHandle = 0;
Result = FspServiceContextCheck(0, &IsLocalSystem);
IsServiceContext = NT_SUCCESS(Result) && !IsLocalSystem;
if (IsServiceContext)
{
/*
* If the current process is in the service context but not LocalSystem,
* ask the launcher to DefineDosDevice for us. This is because the launcher
* runs in the LocalSystem context and can create global drives.
*
* In this case the launcher will also add DELETE access to the drive symlink
* for us, so that we can make it temporary below.
*/
Result = FspFileSystemLauncherDefineDosDevice(L'+', MountPoint, VolumeName);
if (!NT_SUCCESS(Result))
return Result;
}
else
{
if (!DefineDosDeviceW(DDD_RAW_TARGET_PATH, MountPoint, VolumeName))
return FspNtStatusFromWin32(GetLastError());
}
if (!DefineDosDeviceW(DDD_RAW_TARGET_PATH, MountPoint, VolumeName))
return FspNtStatusFromWin32(GetLastError());
if (0 != FspNtOpenSymbolicLinkObject)
{
NTSTATUS Result;
WCHAR SymlinkBuf[6];
UNICODE_STRING Symlink;
OBJECT_ATTRIBUTES Obja;
@ -269,13 +225,6 @@ static NTSTATUS FspFileSystemSetMountPoint_Drive(PWSTR MountPoint, PWSTR VolumeN
}
}
/* HACK:
*
* Handles do not use the low 2 bits (unless they are console handles).
* Abuse this fact to remember that we are running in the service context.
*/
*PMountHandle = (HANDLE)(UINT_PTR)((DWORD)(UINT_PTR)*PMountHandle | IsServiceContext);
return STATUS_SUCCESS;
}
@ -463,18 +412,8 @@ exit:
static VOID FspFileSystemRemoveMountPoint_Drive(PWSTR MountPoint, PWSTR VolumeName, HANDLE MountHandle)
{
BOOLEAN IsServiceContext = 0 != ((DWORD)(UINT_PTR)MountHandle & 1);
MountHandle = (HANDLE)(UINT_PTR)((DWORD)(UINT_PTR)MountHandle & ~1);
if (IsServiceContext)
/*
* If the current process is in the service context but not LocalSystem,
* ask the launcher to DefineDosDevice for us. This is because the launcher
* runs in the LocalSystem context and can remove global drives.
*/
FspFileSystemLauncherDefineDosDevice(L'-', MountPoint, VolumeName);
else
DefineDosDeviceW(DDD_RAW_TARGET_PATH | DDD_REMOVE_DEFINITION | DDD_EXACT_MATCH_ON_REMOVE,
MountPoint, VolumeName);
DefineDosDeviceW(DDD_RAW_TARGET_PATH | DDD_REMOVE_DEFINITION | DDD_EXACT_MATCH_ON_REMOVE,
MountPoint, VolumeName);
if (0 != MountHandle)
FspNtClose(MountHandle);
@ -750,3 +689,8 @@ FSP_API UINT32 FspFileSystemOperationProcessIdF(VOID)
{
return FspFileSystemOperationProcessId();
}
FSP_API UINT64 FspFileSystemOperationLockOwnerF(VOID)
{
return FspFileSystemOperationLockOwner();
}

View File

@ -1,7 +1,7 @@
/**
* @file dll/fsctl.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.
@ -284,7 +284,7 @@ static NTSTATUS FspFsctlFixServiceSecurity(HANDLE SvcHandle)
* This function adds an ACE that allows Everyone to start a service.
*/
PSID WorldSid;
PSID WorldSid = 0;
PSECURITY_DESCRIPTOR SecurityDescriptor = 0;
PSECURITY_DESCRIPTOR NewSecurityDescriptor = 0;
EXPLICIT_ACCESSW AccessEntry;
@ -296,12 +296,18 @@ static NTSTATUS FspFsctlFixServiceSecurity(HANDLE SvcHandle)
NTSTATUS Result;
/* get the Everyone (World) SID */
WorldSid = FspWksidGet(WinWorldSid);
Size = SECURITY_MAX_SID_SIZE;
WorldSid = MemAlloc(Size);
if (0 == WorldSid)
{
Result = STATUS_INSUFFICIENT_RESOURCES;
goto exit;
}
if (!CreateWellKnownSid(WinWorldSid, 0, WorldSid, &Size))
{
Result = FspNtStatusFromWin32(GetLastError());
goto exit;
}
/* get the service security descriptor DACL */
Size = 0;
@ -388,6 +394,7 @@ static NTSTATUS FspFsctlFixServiceSecurity(HANDLE SvcHandle)
exit:
LocalFree(NewSecurityDescriptor);
MemFree(SecurityDescriptor);
MemFree(WorldSid);
return Result;
}

View File

@ -1,7 +1,7 @@
/**
* @file dll/fsop.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.
@ -886,6 +886,7 @@ FSP_API NTSTATUS FspFileSystemOpCleanup(FSP_FILE_SYSTEM *FileSystem,
(0 != Request->Req.Cleanup.SetArchiveBit ? FspCleanupSetArchiveBit : 0) |
(0 != Request->Req.Cleanup.SetLastAccessTime ? FspCleanupSetLastAccessTime : 0) |
(0 != Request->Req.Cleanup.SetLastWriteTime ? FspCleanupSetLastWriteTime : 0) |
(0 != Request->Req.Cleanup.UnlockAll ? FspCleanupUnlockAll : 0) |
(0 != Request->Req.Cleanup.SetChangeTime ? FspCleanupSetChangeTime : 0));
return STATUS_SUCCESS;
@ -1247,6 +1248,43 @@ FSP_API NTSTATUS FspFileSystemOpFileSystemControl(FSP_FILE_SYSTEM *FileSystem,
return Result;
}
FSP_API NTSTATUS FspFileSystemOpLockControl(FSP_FILE_SYSTEM *FileSystem,
FSP_FSCTL_TRANSACT_REQ *Request, FSP_FSCTL_TRANSACT_RSP *Response)
{
NTSTATUS Result;
Result = STATUS_INVALID_DEVICE_REQUEST;
switch (Request->Req.LockControl.LockFunction)
{
case 0x01/*IRP_MN_LOCK*/:
if (0 != FileSystem->Interface->Lock)
Result = FileSystem->Interface->Lock(FileSystem,
(PVOID)ValOfFileContext(Request->Req.LockControl),
Request->Req.LockControl.Offset, Request->Req.LockControl.Length,
((UINT64)Request->Req.LockControl.ProcessId << 32) | (UINT64)Request->Req.LockControl.Key,
0 != Request->Req.LockControl.Exclusive,
0 != Request->Req.LockControl.FailImmediately);
break;
case 0x02/*IRP_MN_UNLOCK_SINGLE*/:
if (0 != FileSystem->Interface->Unlock)
Result = FileSystem->Interface->Unlock(FileSystem,
(PVOID)ValOfFileContext(Request->Req.LockControl),
Request->Req.LockControl.Offset, Request->Req.LockControl.Length,
((UINT64)Request->Req.LockControl.ProcessId << 32) | (UINT64)Request->Req.LockControl.Key);
break;
case 0x03/*IRP_MN_UNLOCK_ALL*/:
case 0x04/*IRP_MN_UNLOCK_ALL_BY_KEY*/:
if (0 != FileSystem->Interface->Unlock)
Result = FileSystem->Interface->Unlock(FileSystem,
(PVOID)ValOfFileContext(Request->Req.LockControl),
(UINT64)-1LL, (UINT64)-1LL,
((UINT64)Request->Req.LockControl.ProcessId << 32) | (UINT64)Request->Req.LockControl.Key);
break;
}
return Result;
}
FSP_API NTSTATUS FspFileSystemOpQuerySecurity(FSP_FILE_SYSTEM *FileSystem,
FSP_FSCTL_TRANSACT_REQ *Request, FSP_FSCTL_TRANSACT_RSP *Response)
{

View File

@ -1,7 +1,7 @@
/**
* @file dll/fuse/fuse.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/**
* @file dll/fuse/fuse_compat.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/**
* @file dll/fuse/fuse_intf.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.
@ -765,9 +765,9 @@ static NTSTATUS fsp_fuse_intf_Create(FSP_FILE_SYSTEM *FileSystem,
memset(&fi, 0, sizeof fi);
if ('C' == f->env->environment) /* Cygwin */
fi.flags = 0x0200 | 0x0800 | 2 /*O_CREAT|O_EXCL|O_RDWR*/;
fi.flags = 0x0200 | 2 /*O_CREAT|O_RDWR*/;
else
fi.flags = 0x0100 | 0x0400 | 2 /*O_CREAT|O_EXCL|O_RDWR*/;
fi.flags = 0x0100 | 2 /*O_CREAT|O_RDWR*/;
if (CreateOptions & FILE_DIRECTORY_FILE)
{
@ -821,25 +821,16 @@ static NTSTATUS fsp_fuse_intf_Create(FSP_FILE_SYSTEM *FileSystem,
Opened = TRUE;
if (0 != FileAttributes &&
0 != (f->conn_want & FSP_FUSE_CAP_STAT_EX) && 0 != f->ops.chflags)
{
err = f->ops.chflags(contexthdr->PosixPath,
fsp_fuse_intf_MapFileAttributesToFlags(CreateOptions & FILE_DIRECTORY_FILE ?
FileAttributes : FileAttributes | FILE_ATTRIBUTE_ARCHIVE));
Result = fsp_fuse_ntstatus_from_errno(f->env, err);
if (!NT_SUCCESS(Result) && STATUS_INVALID_DEVICE_REQUEST != Result)
goto exit;
}
if ((Uid != context->uid || Gid != context->gid) &&
0 != f->ops.chown)
{
err = f->ops.chown(contexthdr->PosixPath, Uid, Gid);
Result = fsp_fuse_ntstatus_from_errno(f->env, err);
if (!NT_SUCCESS(Result) && STATUS_INVALID_DEVICE_REQUEST != Result)
goto exit;
}
if (Uid != context->uid || Gid != context->gid)
if (0 != f->ops.chown)
{
err = f->ops.chown(contexthdr->PosixPath, Uid, Gid);
if (0 != err)
{
Result = fsp_fuse_ntstatus_from_errno(f->env, err);
goto exit;
}
}
/*
* Ignore fuse_file_info::direct_io, fuse_file_info::keep_cache.
@ -1024,22 +1015,6 @@ static NTSTATUS fsp_fuse_intf_Overwrite(FSP_FILE_SYSTEM *FileSystem,
if (!NT_SUCCESS(Result))
return Result;
if (0 != FileAttributes &&
0 != (f->conn_want & FSP_FUSE_CAP_STAT_EX) && 0 != f->ops.chflags)
{
/*
* The code below is not strictly correct. File attributes should be
* replaced when ReplaceFileAttributes is TRUE and merged (or'ed) when
* ReplaceFileAttributes is FALSE. I am punting on this detail for now.
*/
err = f->ops.chflags(filedesc->PosixPath,
fsp_fuse_intf_MapFileAttributesToFlags(FileAttributes | FILE_ATTRIBUTE_ARCHIVE));
Result = fsp_fuse_ntstatus_from_errno(f->env, err);
if (!NT_SUCCESS(Result) && STATUS_INVALID_DEVICE_REQUEST != Result)
return Result;
}
return fsp_fuse_intf_GetFileInfoEx(FileSystem, filedesc->PosixPath, &fi,
&Uid, &Gid, &Mode, FileInfo);
}

View File

@ -1,7 +1,7 @@
/**
* @file dll/fuse/fuse_main.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/**
* @file dll/fuse/fuse_opt.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/**
* @file dll/fuse/library.h
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,152 +0,0 @@
/**
* @file dll/launch.c
*
* @copyright 2015-2018 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.
*
* You can redistribute it and/or modify it under the terms of the GNU
* General Public License version 3 as published by the Free Software
* Foundation.
*
* Licensees holding a valid commercial license may use this file in
* accordance with the commercial license agreement provided with the
* software.
*/
#include <dll/library.h>
#include <launcher/launcher.h>
FSP_API NTSTATUS FspLaunchCallLauncherPipe(
WCHAR Command, ULONG Argc, PWSTR *Argv, ULONG *Argl,
PWSTR Buffer, PULONG PSize, PULONG PLauncherError)
{
PWSTR PipeBuf = 0, P;
ULONG Length, BytesTransferred;
NTSTATUS Result;
ULONG ErrorCode;
if (0 != PSize)
*PSize = 0;
*PLauncherError = 0;
PipeBuf = MemAlloc(LAUNCHER_PIPE_BUFFER_SIZE);
if (0 == PipeBuf)
{
Result = STATUS_INSUFFICIENT_RESOURCES;
goto exit;
}
P = PipeBuf;
*P++ = Command;
for (ULONG I = 0; Argc > I; I++)
if (0 != Argv[I])
{
Length = 0 == Argl || -1 == Argl[I] ? lstrlenW(Argv[I]) : Argl[I];
if (LAUNCHER_PIPE_BUFFER_SIZE < ((ULONG)(P - PipeBuf) + Length + 1) * sizeof(WCHAR))
{
Result = STATUS_INVALID_PARAMETER;
goto exit;
}
memcpy(P, Argv[I], Length * sizeof(WCHAR)); P += Length; *P++ = L'\0';
}
Result = FspCallNamedPipeSecurely(L"" LAUNCHER_PIPE_NAME,
PipeBuf, (ULONG)(P - PipeBuf) * sizeof(WCHAR), PipeBuf, LAUNCHER_PIPE_BUFFER_SIZE,
&BytesTransferred, NMPWAIT_USE_DEFAULT_WAIT, LAUNCHER_PIPE_OWNER);
if (!NT_SUCCESS(Result))
goto exit;
Result = STATUS_SUCCESS;
ErrorCode = ERROR_BROKEN_PIPE; /* protocol error! */
if (sizeof(WCHAR) <= BytesTransferred)
{
if (LauncherSuccess == PipeBuf[0])
{
ErrorCode = 0;
if (0 != PSize)
{
BytesTransferred -= sizeof(WCHAR);
memcpy(Buffer, PipeBuf, *PSize < BytesTransferred ? *PSize : BytesTransferred);
*PSize = BytesTransferred;
}
}
else if (LauncherFailure == PipeBuf[0])
{
ErrorCode = 0;
for (PWSTR P = PipeBuf + 1, EndP = PipeBuf + BytesTransferred / sizeof(WCHAR); EndP > P; P++)
{
if (L'0' > *P || *P > L'9')
break;
ErrorCode = 10 * ErrorCode + (*P - L'0');
}
if (0 == ErrorCode)
ErrorCode = ERROR_BROKEN_PIPE; /* protocol error! */
}
}
*PLauncherError = ErrorCode;
exit:
MemFree(PipeBuf);
return Result;
}
FSP_API NTSTATUS FspLaunchStart(
PWSTR ClassName, PWSTR InstanceName, ULONG Argc, PWSTR *Argv0,
BOOLEAN HasSecret,
PULONG PLauncherError)
{
PWSTR Argv[9 + 2];
if (9 < Argc)
return STATUS_INVALID_PARAMETER;
Argv[0] = ClassName;
Argv[1] = InstanceName;
memcpy(Argv + 2, Argv, Argc * sizeof(PWSTR));
return FspLaunchCallLauncherPipe(
HasSecret ? LauncherSvcInstanceStartWithSecret : LauncherSvcInstanceStart,
Argc + 2, Argv, 0, 0, 0, PLauncherError);
}
FSP_API NTSTATUS FspLaunchStop(
PWSTR ClassName, PWSTR InstanceName,
PULONG PLauncherError)
{
PWSTR Argv[2];
Argv[0] = ClassName;
Argv[1] = InstanceName;
return FspLaunchCallLauncherPipe(LauncherSvcInstanceStop,
2, Argv, 0, 0, 0, PLauncherError);
}
FSP_API NTSTATUS FspLaunchGetInfo(
PWSTR ClassName, PWSTR InstanceName,
PWSTR Buffer, PULONG PSize,
PULONG PLauncherError)
{
PWSTR Argv[2];
Argv[0] = ClassName;
Argv[1] = InstanceName;
return FspLaunchCallLauncherPipe(LauncherSvcInstanceInfo,
2, Argv, 0, Buffer, PSize, PLauncherError);
}
FSP_API NTSTATUS FspLaunchGetNameList(
PWSTR Buffer, PULONG PSize,
PULONG PLauncherError)
{
return FspLaunchCallLauncherPipe(LauncherSvcInstanceList,
0, 0, 0, Buffer, PSize, PLauncherError);
}

View File

@ -1,7 +1,7 @@
/**
* @file dll/library.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.
@ -44,7 +44,6 @@ BOOL WINAPI DllMain(HINSTANCE Instance, DWORD Reason, PVOID Reserved)
FspServiceFinalize(Dynamic);
FspEventLogFinalize(Dynamic);
FspPosixFinalize(Dynamic);
FspWksidFinalize(Dynamic);
break;
case DLL_THREAD_DETACH:

View File

@ -1,7 +1,7 @@
/**
* @file dll/library.h
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.
@ -31,15 +31,11 @@
FspDebugLog("[U] " LIBRARY_NAME "!" __FUNCTION__ ": " fmt "\n", __VA_ARGS__)
#define DEBUGLOGSD(fmt, SD) \
FspDebugLogSD("[U] " LIBRARY_NAME "!" __FUNCTION__ ": " fmt "\n", SD)
#define DEBUGLOGSID(fmt, Sid) \
FspDebugLogSid("[U] " LIBRARY_NAME "!" __FUNCTION__ ": " fmt "\n", Sid)
#else
#define DEBUGLOG(fmt, ...) ((void)0)
#define DEBUGLOGSD(fmt, SD) ((void)0)
#define DEBUGLOGSID(fmt, Sid) ((void)0)
#endif
VOID FspWksidFinalize(BOOLEAN Dynamic);
VOID FspPosixFinalize(BOOLEAN Dynamic);
VOID FspEventLogFinalize(BOOLEAN Dynamic);
VOID FspServiceFinalize(BOOLEAN Dynamic);
@ -53,9 +49,6 @@ NTSTATUS FspNpUnregister(VOID);
NTSTATUS FspEventLogRegister(VOID);
NTSTATUS FspEventLogUnregister(VOID);
PSID FspWksidNew(WELL_KNOWN_SID_TYPE WellKnownSidType, PNTSTATUS PResult);
PSID FspWksidGet(WELL_KNOWN_SID_TYPE WellKnownSidType);
PWSTR FspDiagIdent(VOID);
VOID FspFileSystemPeekInDirectoryBuffer(PVOID *PDirBuffer,

View File

@ -1,7 +1,7 @@
/**
* @file dll/np.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.
@ -17,6 +17,7 @@
#include <dll/library.h>
#include <launcher/launcher.h>
#include <lmcons.h>
#include <npapi.h>
#include <wincred.h>
@ -35,12 +36,6 @@
*/
#define FSP_NP_CREDENTIAL_MANAGER
/*
* Define the following macro to register ourselves as the first network provider.
* Otherwise we will be registered as the last network provider.
*/
#define FSP_NP_ORDER_FIRST
enum
{
FSP_NP_CREDENTIALS_NONE = 0,
@ -174,17 +169,45 @@ static inline BOOLEAN FspNpParseRemoteUserName(PWSTR RemoteName,
return FALSE;
}
static inline DWORD FspNpCallLauncherPipe(
WCHAR Command, ULONG Argc, PWSTR *Argv, ULONG *Argl,
PWSTR Buffer, PULONG PSize)
static inline BOOLEAN FspNpGetLocalUserName(
PWSTR UserName, ULONG UserNameSize/* in chars */)
{
NTSTATUS Result;
ULONG ErrorCode;
return GetUserName(UserName, &UserNameSize);
}
Result = FspLaunchCallLauncherPipe(Command, Argc, Argv, Argl, Buffer, PSize, &ErrorCode);
return !NT_SUCCESS(Result) ?
WN_NO_NETWORK :
(ERROR_BROKEN_PIPE == ErrorCode ? WN_NO_NETWORK : ErrorCode);
static inline DWORD FspNpCallLauncherPipe(PWSTR PipeBuf, ULONG SendSize, ULONG RecvSize)
{
DWORD NpResult;
NTSTATUS Result;
DWORD BytesTransferred;
Result = FspCallNamedPipeSecurely(L"" LAUNCHER_PIPE_NAME, PipeBuf, SendSize, PipeBuf, RecvSize,
&BytesTransferred, NMPWAIT_USE_DEFAULT_WAIT, LAUNCHER_PIPE_OWNER);
if (!NT_SUCCESS(Result))
NpResult = WN_NO_NETWORK;
else if (sizeof(WCHAR) > BytesTransferred)
NpResult = WN_NO_NETWORK;
else if (LauncherSuccess == PipeBuf[0])
NpResult = WN_SUCCESS;
else if (LauncherFailure == PipeBuf[0])
{
NpResult = 0;
for (PWSTR P = PipeBuf + 1, EndP = PipeBuf + BytesTransferred / sizeof(WCHAR); EndP > P; P++)
{
if (L'0' > *P || *P > L'9')
break;
NpResult = 10 * NpResult + (*P - L'0');
}
if (0 == NpResult)
NpResult = WN_NO_NETWORK;
}
else
NpResult = WN_NO_NETWORK;
return NpResult;
}
static NTSTATUS FspNpGetVolumeList(
@ -473,10 +496,9 @@ DWORD APIENTRY NPAddConnection(LPNETRESOURCEW lpNetResource, LPWSTR lpPassword,
WCHAR LocalNameBuf[3];
PWSTR ClassName, InstanceName, RemoteName, P;
ULONG ClassNameLen, InstanceNameLen;
WCHAR LocalUserName[UNLEN + 1];
DWORD CredentialsKind;
ULONG Argc;
PWSTR Argv[6];
ULONG Argl[6];
PWSTR PipeBuf = 0;
#if defined(FSP_NP_CREDENTIAL_MANAGER)
PCREDENTIALW Credential = 0;
#endif
@ -503,6 +525,9 @@ DWORD APIENTRY NPAddConnection(LPNETRESOURCEW lpNetResource, LPWSTR lpPassword,
return WN_ALREADY_CONNECTED;
}
if (!FspNpGetLocalUserName(LocalUserName, sizeof LocalUserName / sizeof LocalUserName[0]))
LocalUserName[0] = L'\0';
FspNpGetCredentialsKind(lpRemoteName, &CredentialsKind);
#if defined(FSP_NP_CREDENTIAL_MANAGER)
@ -542,24 +567,33 @@ DWORD APIENTRY NPAddConnection(LPNETRESOURCEW lpNetResource, LPWSTR lpPassword,
}
}
Argc = 0;
Argv[Argc] = ClassName; Argl[Argc] = ClassNameLen; Argc++;
Argv[Argc] = InstanceName; Argl[Argc] = InstanceNameLen; Argc++;
Argv[Argc] = RemoteName; Argl[Argc] = -1; Argc++;
Argv[Argc] = LocalNameBuf; Argl[Argc] = -1; Argc++;
PipeBuf = MemAlloc(LAUNCHER_PIPE_BUFFER_SIZE);
if (0 == PipeBuf)
{
NpResult = WN_OUT_OF_MEMORY;
goto exit;
}
/* we do not explicitly check, but assumption is it all fits in LAUNCHER_PIPE_BUFFER_SIZE */
P = PipeBuf;
*P++ = FSP_NP_CREDENTIALS_NONE != CredentialsKind ?
LauncherSvcInstanceStartWithSecret : LauncherSvcInstanceStart;
memcpy(P, ClassName, ClassNameLen * sizeof(WCHAR)); P += ClassNameLen; *P++ = L'\0';
memcpy(P, InstanceName, InstanceNameLen * sizeof(WCHAR)); P += InstanceNameLen; *P++ = L'\0';
lstrcpyW(P, RemoteName); P += lstrlenW(RemoteName) + 1;
lstrcpyW(P, LocalNameBuf); P += lstrlenW(LocalNameBuf) + 1;
lstrcpyW(P, LocalUserName); P += lstrlenW(LocalUserName) + 1;
if (FSP_NP_CREDENTIALS_USERPASS == CredentialsKind)
{
Argv[Argc] = lpUserName; Argl[Argc] = -1; Argc++;
lstrcpyW(P, lpUserName); P += lstrlenW(lpUserName) + 1;
}
if (FSP_NP_CREDENTIALS_NONE != CredentialsKind)
{
Argv[Argc] = lpPassword; Argl[Argc] = -1; Argc++;
lstrcpyW(P, lpPassword); P += lstrlenW(lpPassword) + 1;
}
NpResult = FspNpCallLauncherPipe(
FSP_NP_CREDENTIALS_NONE != CredentialsKind ?
LauncherSvcInstanceStartWithSecret : LauncherSvcInstanceStart,
Argc, Argv, Argl, 0, 0);
PipeBuf, (ULONG)(P - PipeBuf) * sizeof(WCHAR), LAUNCHER_PIPE_BUFFER_SIZE);
switch (NpResult)
{
case WN_SUCCESS:
@ -605,13 +639,13 @@ DWORD APIENTRY NPAddConnection(LPNETRESOURCEW lpNetResource, LPWSTR lpPassword,
break;
}
Argc = 0;
Argv[Argc] = ClassName; Argl[Argc] = ClassNameLen; Argc++;
Argv[Argc] = InstanceName; Argl[Argc] = InstanceNameLen; Argc++;
P = PipeBuf;
*P++ = LauncherSvcInstanceInfo;
memcpy(P, ClassName, ClassNameLen * sizeof(WCHAR)); P += ClassNameLen; *P++ = L'\0';
memcpy(P, InstanceName, InstanceNameLen * sizeof(WCHAR)); P += InstanceNameLen; *P++ = L'\0';
if (WN_SUCCESS != FspNpCallLauncherPipe(
LauncherSvcInstanceInfo,
Argc, Argv, Argl, 0, 0))
PipeBuf, (ULONG)(P - PipeBuf) * sizeof(WCHAR), LAUNCHER_PIPE_BUFFER_SIZE))
{
/* looks like the file system is gone! */
NpResult = WN_NO_NETWORK;
@ -655,6 +689,8 @@ DWORD APIENTRY NPAddConnection(LPNETRESOURCEW lpNetResource, LPWSTR lpPassword,
}
exit:
MemFree(PipeBuf);
#if defined(FSP_NP_CREDENTIAL_MANAGER)
if (0 != Credential)
CredFree(Credential);
@ -743,11 +779,9 @@ DWORD APIENTRY NPCancelConnection(LPWSTR lpName, BOOL fForce)
DWORD NpResult;
WCHAR RemoteNameBuf[sizeof(((FSP_FSCTL_VOLUME_PARAMS *)0)->Prefix) / sizeof(WCHAR)];
DWORD RemoteNameSize;
PWSTR ClassName, InstanceName, RemoteName;
PWSTR ClassName, InstanceName, RemoteName, P;
ULONG ClassNameLen, InstanceNameLen;
ULONG Argc;
PWSTR Argv[2];
ULONG Argl[2];
PWSTR PipeBuf = 0;
if (FspNpCheckLocalName(lpName))
{
@ -767,13 +801,17 @@ DWORD APIENTRY NPCancelConnection(LPWSTR lpName, BOOL fForce)
&ClassName, &ClassNameLen, &InstanceName, &InstanceNameLen))
return WN_BAD_NETNAME;
Argc = 0;
Argv[Argc] = ClassName; Argl[Argc] = ClassNameLen; Argc++;
Argv[Argc] = InstanceName; Argl[Argc] = InstanceNameLen; Argc++;
PipeBuf = MemAlloc(LAUNCHER_PIPE_BUFFER_SIZE);
if (0 == PipeBuf)
return WN_OUT_OF_MEMORY;
P = PipeBuf;
*P++ = LauncherSvcInstanceStop;
memcpy(P, ClassName, ClassNameLen * sizeof(WCHAR)); P += ClassNameLen; *P++ = L'\0';
memcpy(P, InstanceName, InstanceNameLen * sizeof(WCHAR)); P += InstanceNameLen; *P++ = L'\0';
NpResult = FspNpCallLauncherPipe(
LauncherSvcInstanceStop,
Argc, Argv, Argl, 0, 0);
PipeBuf, (ULONG)(P - PipeBuf) * sizeof(WCHAR), LAUNCHER_PIPE_BUFFER_SIZE);
switch (NpResult)
{
case WN_SUCCESS:
@ -786,6 +824,8 @@ DWORD APIENTRY NPCancelConnection(LPWSTR lpName, BOOL fForce)
break;
}
MemFree(PipeBuf);
return NpResult;
}
@ -988,7 +1028,7 @@ NTSTATUS FspNpRegister(VOID)
WCHAR ProviderPath[MAX_PATH];
WCHAR RegBuffer[1024];
PWSTR P, Part;
DWORD RegResult, RegType, RegBufferSize, RegBufferOffset;
DWORD RegResult, RegType, RegBufferSize;
HKEY RegKey;
BOOLEAN FoundProvider;
@ -1054,20 +1094,15 @@ NTSTATUS FspNpRegister(VOID)
return FspNtStatusFromWin32(RegResult);
RegBufferSize = sizeof RegBuffer - sizeof L"," FSP_NP_NAME;
#ifdef FSP_NP_ORDER_FIRST
RegBufferOffset = sizeof "" FSP_NP_NAME;
#else
RegBufferOffset = 0;
#endif
RegResult = RegQueryValueExW(RegKey,
L"ProviderOrder", 0, &RegType, (PVOID)&RegBuffer[RegBufferOffset], &RegBufferSize);
L"ProviderOrder", 0, &RegType, (PVOID)RegBuffer, &RegBufferSize);
if (ERROR_SUCCESS != RegResult)
goto close_and_exit;
RegBufferSize /= sizeof(WCHAR);
FoundProvider = FALSE;
RegBuffer[RegBufferSize + RegBufferOffset] = L'\0';
P = &RegBuffer[RegBufferOffset], Part = P;
RegBuffer[RegBufferSize] = L'\0';
P = RegBuffer, Part = P;
do
{
if (L',' == *P || '\0' == *P)
@ -1084,11 +1119,8 @@ NTSTATUS FspNpRegister(VOID)
if (!FoundProvider)
{
#ifdef FSP_NP_ORDER_FIRST
memcpy((PWSTR)RegBuffer, L"" FSP_NP_NAME ",", sizeof L"" FSP_NP_NAME);
#else
memcpy(--P, L"," FSP_NP_NAME, sizeof L"," FSP_NP_NAME);
#endif
P--;
memcpy(P, L"," FSP_NP_NAME, sizeof L"," FSP_NP_NAME);
RegBufferSize = lstrlenW(RegBuffer);
RegBufferSize++;

View File

@ -1,7 +1,7 @@
/**
* @file dll/ntstatus.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/**
* @file dll/path.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -14,7 +14,7 @@
* [SNAME]
* https://www.cygwin.com/cygwin-ug-net/using-specialnames.html
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.
@ -453,12 +453,9 @@ FSP_API NTSTATUS FspPosixMapPermissionsToSecurityDescriptor(
if (!NT_SUCCESS(Result))
goto exit;
WorldSid = FspWksidGet(WinWorldSid);
if (0 == WorldSid)
{
Result = STATUS_INSUFFICIENT_RESOURCES;
Result = FspPosixMapUidToSid(0x10100, &WorldSid);
if (!NT_SUCCESS(Result))
goto exit;
}
OwnerPerm = (Mode & 0700) >> 6;
GroupPerm = (Mode & 0070) >> 3;
@ -582,6 +579,9 @@ exit:
MemFree(Acl);
if (0 != WorldSid)
FspDeleteSid(WorldSid, FspPosixMapUidToSid);
if (0 != GroupSid)
FspDeleteSid(GroupSid, FspPosixMapUidToSid);
@ -649,19 +649,13 @@ FSP_API NTSTATUS FspPosixMapSecurityDescriptorToPermissions(
if (0 != Acl)
{
WorldSid = FspWksidGet(WinWorldSid);
if (0 == WorldSid)
{
Result = STATUS_INSUFFICIENT_RESOURCES;
Result = FspPosixMapUidToSid(0x10100, &WorldSid);
if (!NT_SUCCESS(Result))
goto exit;
}
AuthUsersSid = FspWksidGet(WinAuthenticatedUserSid);
if (0 == AuthUsersSid)
{
Result = STATUS_INSUFFICIENT_RESOURCES;
Result = FspPosixMapUidToSid(11, &AuthUsersSid);
if (!NT_SUCCESS(Result))
goto exit;
}
OwnerAllow = OwnerDeny = GroupAllow = GroupDeny = WorldAllow = WorldDeny = 0;
@ -777,6 +771,12 @@ FSP_API NTSTATUS FspPosixMapSecurityDescriptorToPermissions(
Result = STATUS_SUCCESS;
exit:
if (0 != AuthUsersSid)
FspDeleteSid(AuthUsersSid, FspPosixMapUidToSid);
if (0 != WorldSid)
FspDeleteSid(WorldSid, FspPosixMapUidToSid);
return Result;
lasterror:

View File

@ -1,7 +1,7 @@
/**
* @file dll/security.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/**
* @file dll/service.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.
@ -566,106 +566,6 @@ FSP_API BOOLEAN FspServiceIsInteractive(VOID)
return IsInteractive;
}
FSP_API NTSTATUS FspServiceContextCheck(HANDLE Token, PBOOLEAN PIsLocalSystem)
{
NTSTATUS Result;
PSID LocalSystemSid, ServiceSid;
BOOLEAN IsLocalSystem = FALSE;
BOOL HasServiceSid = FALSE;
HANDLE ProcessToken = 0, ImpersonationToken = 0;
DWORD SessionId, Size;
union
{
TOKEN_USER V;
UINT8 B[128];
} UserInfoBuf;
PTOKEN_USER UserInfo = &UserInfoBuf.V;
LocalSystemSid = FspWksidGet(WinLocalSystemSid);
ServiceSid = FspWksidGet(WinServiceSid);
if (0 == LocalSystemSid || 0 == ServiceSid)
{
Result = STATUS_INSUFFICIENT_RESOURCES;
goto exit;
}
if (0 == Token)
{
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY | TOKEN_DUPLICATE, &ProcessToken) ||
!DuplicateToken(ProcessToken, SecurityImpersonation, &ImpersonationToken))
{
Result = FspNtStatusFromWin32(GetLastError());
goto exit;
}
Token = ImpersonationToken;
}
if (!GetTokenInformation(Token, TokenSessionId, &SessionId, sizeof SessionId, &Size))
{
Result = FspNtStatusFromWin32(GetLastError());
goto exit;
}
if (0 != SessionId)
{
Result = STATUS_ACCESS_DENIED;
goto exit;
}
if (!GetTokenInformation(Token, TokenUser, UserInfo, sizeof UserInfoBuf, &Size))
{
if (ERROR_INSUFFICIENT_BUFFER != GetLastError())
{
Result = FspNtStatusFromWin32(GetLastError());
goto exit;
}
UserInfo = MemAlloc(Size);
if (0 == UserInfo)
{
Result = STATUS_INSUFFICIENT_RESOURCES;
goto exit;
}
if (!GetTokenInformation(Token, TokenUser, UserInfo, Size, &Size))
{
Result = FspNtStatusFromWin32(GetLastError());
goto exit;
}
}
IsLocalSystem = EqualSid(LocalSystemSid, UserInfo->User.Sid);
if (IsLocalSystem)
{
Result = STATUS_SUCCESS;
goto exit;
}
if (!CheckTokenMembership(Token, ServiceSid, &HasServiceSid))
{
Result = FspNtStatusFromWin32(GetLastError());
goto exit;
}
Result = HasServiceSid ? STATUS_SUCCESS : STATUS_ACCESS_DENIED;
exit:
if (0 != PIsLocalSystem)
*PIsLocalSystem = NT_SUCCESS(Result) ? IsLocalSystem : FALSE;
if (UserInfo != &UserInfoBuf.V)
MemFree(UserInfo);
if (0 != ImpersonationToken)
CloseHandle(ImpersonationToken);
if (0 != ProcessToken)
CloseHandle(ProcessToken);
return Result;
}
FSP_API VOID FspServiceLog(ULONG Type, PWSTR Format, ...)
{
va_list ap;

View File

@ -1,7 +1,7 @@
/**
* @file dll/util.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.
@ -97,14 +97,24 @@ FSP_API NTSTATUS FspCallNamedPipeSecurely(PWSTR PipeName,
{
PSECURITY_DESCRIPTOR SecurityDescriptor = 0;
PSID OwnerSid, WellKnownSid = 0;
DWORD LastError;
DWORD SidSize, LastError;
/* if it is a small number treat it like a well known SID */
if (1024 > (INT_PTR)Sid)
{
WellKnownSid = FspWksidNew((INT_PTR)Sid, &Result);
SidSize = SECURITY_MAX_SID_SIZE;
WellKnownSid = MemAlloc(SidSize);
if (0 == WellKnownSid)
{
Result = STATUS_INSUFFICIENT_RESOURCES;
goto sid_exit;
}
if (!CreateWellKnownSid((INT_PTR)Sid, 0, WellKnownSid, &SidSize))
{
Result = FspNtStatusFromWin32(GetLastError());
goto sid_exit;
}
}
LastError = GetSecurityInfo(Pipe, SE_FILE_OBJECT,

View File

@ -1,108 +0,0 @@
/**
* @file dll/wksid.c
*
* @copyright 2015-2018 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.
*
* You can redistribute it and/or modify it under the terms of the GNU
* General Public License version 3 as published by the Free Software
* Foundation.
*
* Licensees holding a valid commercial license may use this file in
* accordance with the commercial license agreement provided with the
* software.
*/
#include <dll/library.h>
static INIT_ONCE FspWksidInitOnce = INIT_ONCE_STATIC_INIT;
static PSID FspWksidWorld;
static PSID FspWksidAuthenticatedUser;
static PSID FspWksidLocalSystem;
static PSID FspWksidService;
static BOOL WINAPI FspWksidInitialize(
PINIT_ONCE InitOnce, PVOID Parameter, PVOID *Context)
{
FspWksidWorld = FspWksidNew(WinWorldSid, 0);
FspWksidAuthenticatedUser = FspWksidNew(WinAuthenticatedUserSid, 0);
FspWksidLocalSystem = FspWksidNew(WinLocalSystemSid, 0);
FspWksidService = FspWksidNew(WinServiceSid, 0);
//DEBUGLOGSID("FspWksidWorld=%s", FspWksidWorld);
//DEBUGLOGSID("FspWksidAuthenticatedUser=%s", FspWksidAuthenticatedUser);
//DEBUGLOGSID("FspWksidLocalSystem=%s", FspWksidLocalSystem);
//DEBUGLOGSID("FspWksidService=%s", FspWksidService);
return TRUE;
}
VOID FspWksidFinalize(BOOLEAN Dynamic)
{
/*
* This function is called during DLL_PROCESS_DETACH. We must therefore keep
* finalization tasks to a minimum.
*
* We must deregister our event source (if any). We only do so if the library
* is being explicitly unloaded (rather than the process exiting).
*/
if (Dynamic)
{
MemFree(FspWksidWorld); FspWksidWorld = 0;
MemFree(FspWksidAuthenticatedUser); FspWksidAuthenticatedUser = 0;
MemFree(FspWksidLocalSystem); FspWksidLocalSystem = 0;
MemFree(FspWksidService); FspWksidService = 0;
}
}
PSID FspWksidNew(WELL_KNOWN_SID_TYPE WellKnownSidType, PNTSTATUS PResult)
{
NTSTATUS Result;
PSID Sid;
DWORD Size;
Size = SECURITY_MAX_SID_SIZE;
Sid = MemAlloc(Size);
if (0 == Sid)
{
Result = STATUS_INSUFFICIENT_RESOURCES;
goto exit;
}
if (!CreateWellKnownSid(WellKnownSidType, 0, Sid, &Size))
{
Result = FspNtStatusFromWin32(GetLastError());
MemFree(Sid); Sid = 0;
goto exit;
}
Result = STATUS_SUCCESS;
exit:
if (0 != PResult)
*PResult = Result;
return Sid;
}
PSID FspWksidGet(WELL_KNOWN_SID_TYPE WellKnownSidType)
{
InitOnceExecuteOnce(&FspWksidInitOnce, FspWksidInitialize, 0, 0);
switch (WellKnownSidType)
{
case WinWorldSid:
return FspWksidWorld;
case WinAuthenticatedUserSid:
return FspWksidAuthenticatedUser;
case WinLocalSystemSid:
return FspWksidLocalSystem;
case WinServiceSid:
return FspWksidService;
default:
return 0;
}
}

View File

@ -1,7 +1,7 @@
/*
* dotnet/FileSystemBase+Const.cs
*
* Copyright 2015-2018 Bill Zissimopoulos
* Copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/*
* dotnet/FileSystemBase.cs
*
* Copyright 2015-2018 Bill Zissimopoulos
* Copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/*
* dotnet/FileSystemHost.cs
*
* Copyright 2015-2018 Bill Zissimopoulos
* Copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/*
* dotnet/Interop.cs
*
* Copyright 2015-2018 Bill Zissimopoulos
* Copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/*
* dotnet/Service.cs
*
* Copyright 2015-2018 Bill Zissimopoulos
* Copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/**
* @file fsptool/fsptool.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/**
* @file launcher/launchctl.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/**
* @file launcher/launcher.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.
@ -16,30 +16,17 @@
*/
#include <launcher/launcher.h>
#include <aclapi.h>
#include <sddl.h>
#include <userenv.h>
#define PROGNAME "WinFsp.Launcher"
static NTSTATUS (NTAPI *SvcNtOpenSymbolicLinkObject)(
PHANDLE LinkHandle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes);
static NTSTATUS (NTAPI *SvcNtClose)(
HANDLE Handle);
static BOOL CreateOverlappedPipe(
PHANDLE PReadPipe, PHANDLE PWritePipe,
DWORD Size,
BOOL ReadInherit, BOOL WriteInherit,
BOOL CreateOverlappedPipe(
PHANDLE PReadPipe, PHANDLE PWritePipe, PSECURITY_ATTRIBUTES SecurityAttributes, DWORD Size,
DWORD ReadMode, DWORD WriteMode)
{
RPC_STATUS RpcStatus;
UUID Uuid;
WCHAR PipeNameBuf[MAX_PATH];
SECURITY_ATTRIBUTES ReadSecurityAttributes = { sizeof(SECURITY_ATTRIBUTES), 0, ReadInherit };
SECURITY_ATTRIBUTES WriteSecurityAttributes = { sizeof(SECURITY_ATTRIBUTES), 0, WriteInherit };
HANDLE ReadPipe, WritePipe;
DWORD LastError;
@ -59,13 +46,13 @@ static BOOL CreateOverlappedPipe(
ReadPipe = CreateNamedPipeW(PipeNameBuf,
PIPE_ACCESS_INBOUND | FILE_FLAG_FIRST_PIPE_INSTANCE | ReadMode,
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT | PIPE_REJECT_REMOTE_CLIENTS,
1, Size, Size, 120 * 1000, &ReadSecurityAttributes);
1, Size, Size, 120 * 1000, SecurityAttributes);
if (INVALID_HANDLE_VALUE == ReadPipe)
return FALSE;
WritePipe = CreateFileW(PipeNameBuf,
GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
&WriteSecurityAttributes, OPEN_EXISTING, WriteMode, 0);
SecurityAttributes, OPEN_EXISTING, WriteMode, 0);
if (INVALID_HANDLE_VALUE == WritePipe)
{
LastError = GetLastError();
@ -80,279 +67,6 @@ static BOOL CreateOverlappedPipe(
return TRUE;
}
static NTSTATUS GetTokenUserName(HANDLE Token, PWSTR *PUserName)
{
union
{
TOKEN_USER V;
UINT8 B[128];
} UserInfoBuf;
PTOKEN_USER UserInfo = &UserInfoBuf.V;
WCHAR Name[256], Domn[256];
DWORD UserSize, NameSize, DomnSize;
SID_NAME_USE Use;
PWSTR P;
NTSTATUS Result;
*PUserName = 0;
if (!GetTokenInformation(Token, TokenUser, UserInfo, sizeof UserInfoBuf, &UserSize))
{
if (ERROR_INSUFFICIENT_BUFFER != GetLastError())
{
Result = FspNtStatusFromWin32(GetLastError());
goto exit;
}
UserInfo = MemAlloc(UserSize);
if (0 == UserInfo)
{
Result = STATUS_INSUFFICIENT_RESOURCES;
goto exit;
}
if (!GetTokenInformation(Token, TokenUser, UserInfo, UserSize, &UserSize))
{
Result = FspNtStatusFromWin32(GetLastError());
goto exit;
}
}
NameSize = sizeof Name / sizeof Name[0];
DomnSize = sizeof Domn / sizeof Domn[0];
if (!LookupAccountSidW(0, UserInfo->User.Sid, Name, &NameSize, Domn, &DomnSize, &Use))
{
Result = FspNtStatusFromWin32(GetLastError());
goto exit;
}
NameSize = lstrlenW(Name);
DomnSize = lstrlenW(Domn);
P = *PUserName = MemAlloc((DomnSize + 1 + NameSize + 1) * sizeof(WCHAR));
if (0 == P)
{
Result = STATUS_INSUFFICIENT_RESOURCES;
goto exit;
}
if (0 < DomnSize)
{
memcpy(P, Domn, DomnSize * sizeof(WCHAR));
P[DomnSize] = L'\\';
P += DomnSize + 1;
}
memcpy(P, Name, NameSize * sizeof(WCHAR));
P[NameSize] = L'\0';
Result = STATUS_SUCCESS;
exit:
if (UserInfo != &UserInfoBuf.V)
MemFree(UserInfo);
return Result;
}
static NTSTATUS AddAccessForTokenUser(HANDLE Handle, DWORD Access, HANDLE Token)
{
union
{
TOKEN_USER V;
UINT8 B[128];
} UserInfoBuf;
PTOKEN_USER UserInfo = &UserInfoBuf.V;
PSECURITY_DESCRIPTOR SecurityDescriptor = 0;
PSECURITY_DESCRIPTOR NewSecurityDescriptor = 0;
EXPLICIT_ACCESSW AccessEntry;
DWORD Size, LastError;
NTSTATUS Result;
if (!GetTokenInformation(Token, TokenUser, UserInfo, sizeof UserInfoBuf, &Size))
{
if (ERROR_INSUFFICIENT_BUFFER != GetLastError())
{
Result = FspNtStatusFromWin32(GetLastError());
goto exit;
}
UserInfo = MemAlloc(Size);
if (0 == UserInfo)
{
Result = STATUS_INSUFFICIENT_RESOURCES;
goto exit;
}
if (!GetTokenInformation(Token, TokenUser, UserInfo, Size, &Size))
{
Result = FspNtStatusFromWin32(GetLastError());
goto exit;
}
}
if (GetKernelObjectSecurity(Handle, DACL_SECURITY_INFORMATION, 0, 0, &Size))
{
Result = STATUS_INVALID_PARAMETER;
goto exit;
}
if (ERROR_INSUFFICIENT_BUFFER != GetLastError())
{
Result = FspNtStatusFromWin32(GetLastError());
goto exit;
}
SecurityDescriptor = MemAlloc(Size);
if (0 == SecurityDescriptor)
{
Result = STATUS_INSUFFICIENT_RESOURCES;
goto exit;
}
if (!GetKernelObjectSecurity(Handle, DACL_SECURITY_INFORMATION, SecurityDescriptor, Size, &Size))
{
Result = FspNtStatusFromWin32(GetLastError());
goto exit;
}
AccessEntry.grfAccessPermissions = Access;
AccessEntry.grfAccessMode = GRANT_ACCESS;
AccessEntry.grfInheritance = NO_INHERITANCE;
AccessEntry.Trustee.pMultipleTrustee = 0;
AccessEntry.Trustee.MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
AccessEntry.Trustee.TrusteeForm = TRUSTEE_IS_SID;
AccessEntry.Trustee.TrusteeType = TRUSTEE_IS_UNKNOWN;
AccessEntry.Trustee.ptstrName = UserInfo->User.Sid;
LastError = BuildSecurityDescriptorW(0, 0, 1, &AccessEntry, 0, 0, SecurityDescriptor,
&Size, &NewSecurityDescriptor);
if (0 != LastError)
{
Result = FspNtStatusFromWin32(LastError);
goto exit;
}
if (!SetKernelObjectSecurity(Handle, DACL_SECURITY_INFORMATION, NewSecurityDescriptor))
{
Result = FspNtStatusFromWin32(GetLastError());
goto exit;
}
Result = STATUS_SUCCESS;
exit:
LocalFree(NewSecurityDescriptor);
MemFree(SecurityDescriptor);
if (UserInfo != &UserInfoBuf.V)
MemFree(UserInfo);
return Result;
}
static BOOL LogonCreateProcess(
PWSTR UserName,
LPCWSTR ApplicationName,
LPWSTR CommandLine,
LPSECURITY_ATTRIBUTES ProcessAttributes,
LPSECURITY_ATTRIBUTES ThreadAttributes,
BOOL InheritHandles,
DWORD CreationFlags,
LPVOID Environment,
LPCWSTR CurrentDirectory,
LPSTARTUPINFOW StartupInfo,
LPPROCESS_INFORMATION ProcessInformation)
{
PWSTR DomainName = 0;
if (0 != UserName)
{
if (0 == invariant_wcsicmp(UserName, L"LocalSystem"))
UserName = 0;
else
if (0 == invariant_wcsicmp(UserName, L"LocalService") ||
0 == invariant_wcsicmp(UserName, L"NetworkService"))
DomainName = L"NT AUTHORITY";
else
{
SetLastError(ERROR_ACCESS_DENIED);
return FALSE;
}
}
if (0 == UserName)
/* without a user name go ahead and call CreateProcessW */
return CreateProcessW(
ApplicationName,
CommandLine,
ProcessAttributes,
ThreadAttributes,
InheritHandles,
CreationFlags,
Environment,
CurrentDirectory,
StartupInfo,
ProcessInformation);
HANDLE LogonToken = 0;
PVOID EnvironmentBlock = 0;
DWORD LastError;
BOOL Success;
Success = LogonUserW(
UserName,
DomainName,
0,
LOGON32_LOGON_SERVICE,
LOGON32_PROVIDER_DEFAULT,
&LogonToken);
if (!Success)
goto exit;
if (0 == Environment)
{
Success = CreateEnvironmentBlock(&EnvironmentBlock, LogonToken, FALSE);
if (!Success)
goto exit;
CreationFlags |= CREATE_UNICODE_ENVIRONMENT;
Environment = EnvironmentBlock;
}
Success = ImpersonateLoggedOnUser(LogonToken);
if (!Success)
goto exit;
Success = CreateProcessAsUserW(
LogonToken,
ApplicationName,
CommandLine,
ProcessAttributes,
ThreadAttributes,
InheritHandles,
CreationFlags,
Environment,
CurrentDirectory,
StartupInfo,
ProcessInformation);
if (!RevertToSelf())
/* should not happen! */
ExitProcess(GetLastError());
exit:
if (!Success)
LastError = GetLastError();
if (0 != EnvironmentBlock)
DestroyEnvironmentBlock(EnvironmentBlock);
if (0 != LogonToken)
CloseHandle(LogonToken);
if (!Success)
SetLastError(LastError);
return Success;
}
typedef struct
{
HANDLE Process;
@ -361,7 +75,7 @@ typedef struct
static VOID CALLBACK KillProcessWait(PVOID Context, BOOLEAN Timeout);
static VOID KillProcess(ULONG ProcessId, HANDLE Process, ULONG Timeout)
VOID KillProcess(ULONG ProcessId, HANDLE Process, ULONG Timeout)
{
if (GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, ProcessId))
{
@ -428,17 +142,6 @@ typedef struct
static CRITICAL_SECTION SvcInstanceLock;
static HANDLE SvcInstanceEvent;
static LIST_ENTRY SvcInstanceList = { &SvcInstanceList, &SvcInstanceList };
static DWORD SvcInstanceTlsKey = TLS_OUT_OF_INDEXES;
static inline PWSTR SvcInstanceUserName(VOID)
{
return TlsGetValue(SvcInstanceTlsKey);
}
static inline VOID SvcInstanceSetUserName(PWSTR UserName)
{
TlsSetValue(SvcInstanceTlsKey, UserName);
}
static VOID CALLBACK SvcInstanceTerminated(PVOID Context, BOOLEAN Timeout);
@ -507,14 +210,6 @@ static NTSTATUS SvcInstanceReplaceArguments(PWSTR String, ULONG Argc, PWSTR *Arg
else
Length += SvcInstanceArgumentLength(EmptyArg);
}
else
if (L'U' == *P)
{
if (0 != SvcInstanceUserName())
Length += SvcInstanceArgumentLength(SvcInstanceUserName());
else
Length += SvcInstanceArgumentLength(EmptyArg);
}
else
Length++;
break;
@ -541,14 +236,6 @@ static NTSTATUS SvcInstanceReplaceArguments(PWSTR String, ULONG Argc, PWSTR *Arg
else
Q = SvcInstanceArgumentCopy(Q, EmptyArg);
}
else
if (L'U' == *P)
{
if (0 != SvcInstanceUserName())
Q = SvcInstanceArgumentCopy(Q, SvcInstanceUserName());
else
Q = SvcInstanceArgumentCopy(Q, EmptyArg);
}
else
*Q++ = *P;
break;
@ -564,67 +251,6 @@ static NTSTATUS SvcInstanceReplaceArguments(PWSTR String, ULONG Argc, PWSTR *Arg
return STATUS_SUCCESS;
}
static NTSTATUS SvcInstanceAddUserRights(HANDLE Token,
PSECURITY_DESCRIPTOR SecurityDescriptor, PSECURITY_DESCRIPTOR *PNewSecurityDescriptor)
{
PSECURITY_DESCRIPTOR NewSecurityDescriptor;
TOKEN_USER *User = 0;
EXPLICIT_ACCESSW AccessEntry;
DWORD Size, LastError;
NTSTATUS Result;
*PNewSecurityDescriptor = 0;
if (GetTokenInformation(Token, TokenUser, 0, 0, &Size))
{
Result = STATUS_INVALID_PARAMETER;
goto exit;
}
if (ERROR_INSUFFICIENT_BUFFER != GetLastError())
{
Result = FspNtStatusFromWin32(GetLastError());
goto exit;
}
User = MemAlloc(Size);
if (0 == User)
{
Result = STATUS_INSUFFICIENT_RESOURCES;
goto exit;
}
if (!GetTokenInformation(Token, TokenUser, User, Size, &Size))
{
Result = FspNtStatusFromWin32(GetLastError());
goto exit;
}
AccessEntry.grfAccessPermissions = SERVICE_QUERY_STATUS | SERVICE_STOP;
AccessEntry.grfAccessMode = GRANT_ACCESS;
AccessEntry.grfInheritance = NO_INHERITANCE;
AccessEntry.Trustee.pMultipleTrustee = 0;
AccessEntry.Trustee.MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
AccessEntry.Trustee.TrusteeForm = TRUSTEE_IS_SID;
AccessEntry.Trustee.TrusteeType = TRUSTEE_IS_UNKNOWN;
AccessEntry.Trustee.ptstrName = User->User.Sid;
LastError = BuildSecurityDescriptorW(0, 0, 1, &AccessEntry, 0, 0, SecurityDescriptor,
&Size, &NewSecurityDescriptor);
if (0 != LastError)
{
Result = FspNtStatusFromWin32(LastError);
goto exit;
}
*PNewSecurityDescriptor = NewSecurityDescriptor;
Result = STATUS_SUCCESS;
exit:
MemFree(User);
return Result;
}
static NTSTATUS SvcInstanceAccessCheck(HANDLE ClientToken, ULONG DesiredAccess,
PSECURITY_DESCRIPTOR SecurityDescriptor)
{
@ -653,35 +279,18 @@ static NTSTATUS SvcInstanceAccessCheck(HANDLE ClientToken, ULONG DesiredAccess,
return Result;
}
static NTSTATUS SvcInstanceCreateProcess(PWSTR UserName,
PWSTR Executable, PWSTR CommandLine, PWSTR WorkDirectory,
NTSTATUS SvcInstanceCreateProcess(PWSTR Executable, PWSTR CommandLine,
HANDLE StdioHandles[2],
PPROCESS_INFORMATION ProcessInfo)
{
WCHAR WorkDirectoryBuf[MAX_PATH];
STARTUPINFOEXW StartupInfoEx;
HANDLE ChildHandles[3] = { INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE, 0/* DO NOT CLOSE!*/ };
HANDLE ParentHandles[2] = { INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE };
SECURITY_ATTRIBUTES PipeAttributes = { sizeof(SECURITY_ATTRIBUTES), 0, TRUE };
PPROC_THREAD_ATTRIBUTE_LIST AttrList = 0;
SIZE_T Size;
NTSTATUS Result;
if (0 != WorkDirectory && L'.' == WorkDirectory[0] && L'\0' == WorkDirectory[1])
{
PWSTR Backslash = 0, P;
if (0 == GetModuleFileNameW(0, WorkDirectoryBuf, MAX_PATH))
return FspNtStatusFromWin32(GetLastError());
for (P = WorkDirectoryBuf; *P; P++)
if (L'\\' == *P)
Backslash = P;
if (0 != Backslash && WorkDirectoryBuf < Backslash && L':' != Backslash[-1])
*Backslash = L'\0';
WorkDirectory = WorkDirectoryBuf;
}
memset(&StartupInfoEx, 0, sizeof StartupInfoEx);
StartupInfoEx.StartupInfo.cb = sizeof StartupInfoEx.StartupInfo;
@ -695,16 +304,16 @@ static NTSTATUS SvcInstanceCreateProcess(PWSTR UserName,
*/
/* create stdin read/write ends; make them inheritable */
if (!CreateOverlappedPipe(&ChildHandles[0], &ParentHandles[0],
0, TRUE, FALSE, 0, 0))
if (!CreateOverlappedPipe(&ChildHandles[0], &ParentHandles[0], &PipeAttributes, 0,
0, 0))
{
Result = FspNtStatusFromWin32(GetLastError());
goto exit;
}
/* create stdout read/write ends; make them inheritable */
if (!CreateOverlappedPipe(&ParentHandles[1], &ChildHandles[1],
0, FALSE, TRUE, FILE_FLAG_OVERLAPPED, 0))
if (!CreateOverlappedPipe(&ParentHandles[1], &ChildHandles[1], &PipeAttributes, 0,
FILE_FLAG_OVERLAPPED, 0))
{
Result = FspNtStatusFromWin32(GetLastError());
goto exit;
@ -748,44 +357,18 @@ static NTSTATUS SvcInstanceCreateProcess(PWSTR UserName,
StartupInfoEx.StartupInfo.hStdOutput = ChildHandles[1];
StartupInfoEx.StartupInfo.hStdError = ChildHandles[2];
if (!LogonCreateProcess(UserName,
Executable, CommandLine, 0, 0, TRUE,
CREATE_SUSPENDED | CREATE_NEW_PROCESS_GROUP | EXTENDED_STARTUPINFO_PRESENT,
0, WorkDirectory,
if (!CreateProcessW(Executable, CommandLine, 0, 0, TRUE,
CREATE_SUSPENDED | CREATE_NEW_PROCESS_GROUP | EXTENDED_STARTUPINFO_PRESENT, 0, 0,
&StartupInfoEx.StartupInfo, ProcessInfo))
{
if (ERROR_NO_SYSTEM_RESOURCES != GetLastError())
{
Result = FspNtStatusFromWin32(GetLastError());
goto exit;
}
/*
* On Win7 CreateProcessW with EXTENDED_STARTUPINFO_PRESENT
* may fail with ERROR_NO_SYSTEM_RESOURCES.
*
* In that case go ahead and retry with a CreateProcessW with
* bInheritHandles==TRUE, but without EXTENDED_STARTUPINFO_PRESENT.
* Not ideal, but...
*/
StartupInfoEx.StartupInfo.cb = sizeof StartupInfoEx.StartupInfo;
if (!LogonCreateProcess(UserName,
Executable, CommandLine, 0, 0, TRUE,
CREATE_SUSPENDED | CREATE_NEW_PROCESS_GROUP,
0, WorkDirectory,
&StartupInfoEx.StartupInfo, ProcessInfo))
{
Result = FspNtStatusFromWin32(GetLastError());
goto exit;
}
Result = FspNtStatusFromWin32(GetLastError());
goto exit;
}
}
else
{
if (!LogonCreateProcess(UserName,
Executable, CommandLine, 0, 0, FALSE,
CREATE_SUSPENDED | CREATE_NEW_PROCESS_GROUP,
0, WorkDirectory,
if (!CreateProcessW(Executable, CommandLine, 0, 0, FALSE,
CREATE_SUSPENDED | CREATE_NEW_PROCESS_GROUP, 0, 0,
&StartupInfoEx.StartupInfo, ProcessInfo))
{
Result = FspNtStatusFromWin32(GetLastError());
@ -828,11 +411,10 @@ NTSTATUS SvcInstanceCreate(HANDLE ClientToken,
HKEY RegKey = 0;
DWORD RegResult, RegSize;
DWORD ClassNameSize, InstanceNameSize;
WCHAR Executable[MAX_PATH], CommandLineBuf[512], WorkDirectory[MAX_PATH],
SecurityBuf[512], RunAsBuf[64];
WCHAR Executable[MAX_PATH], CommandLineBuf[512], SecurityBuf[512];
PWSTR CommandLine, Security;
DWORD JobControl, Credentials;
PSECURITY_DESCRIPTOR SecurityDescriptor = 0, NewSecurityDescriptor;
PSECURITY_DESCRIPTOR SecurityDescriptor = 0;
PWSTR Argv[10];
PROCESS_INFORMATION ProcessInfo;
NTSTATUS Result;
@ -906,16 +488,6 @@ NTSTATUS SvcInstanceCreate(HANDLE ClientToken,
CommandLine[-1] = L'\0';
CommandLine = CommandLineBuf;
RegSize = sizeof WorkDirectory;
WorkDirectory[0] = L'\0';
RegResult = RegGetValueW(RegKey, ClassName, L"WorkDirectory", RRF_RT_REG_SZ, 0,
WorkDirectory, &RegSize);
if (ERROR_SUCCESS != RegResult && ERROR_FILE_NOT_FOUND != RegResult)
{
Result = FspNtStatusFromWin32(RegResult);
goto exit;
}
Security = SecurityBuf + lstrlenW(SecurityBuf);
RegSize = (DWORD)(sizeof SecurityBuf - (Security - SecurityBuf) * sizeof(WCHAR));
RegResult = RegGetValueW(RegKey, ClassName, L"Security", RRF_RT_REG_SZ, 0,
@ -926,16 +498,6 @@ NTSTATUS SvcInstanceCreate(HANDLE ClientToken,
goto exit;
}
RegSize = sizeof RunAsBuf;
RunAsBuf[0] = L'\0';
RegResult = RegGetValueW(RegKey, ClassName, L"RunAs", RRF_RT_REG_SZ, 0,
RunAsBuf, &RegSize);
if (ERROR_SUCCESS != RegResult && ERROR_FILE_NOT_FOUND != RegResult)
{
Result = FspNtStatusFromWin32(RegResult);
goto exit;
}
RegSize = sizeof JobControl;
JobControl = 1; /* default is YES! */
RegResult = RegGetValueW(RegKey, ClassName, L"JobControl", RRF_RT_REG_DWORD, 0,
@ -967,14 +529,6 @@ NTSTATUS SvcInstanceCreate(HANDLE ClientToken,
if (!NT_SUCCESS(Result))
goto exit;
Result = SvcInstanceAddUserRights(ClientToken, SecurityDescriptor, &NewSecurityDescriptor);
if (!NT_SUCCESS(Result))
goto exit;
LocalFree(SecurityDescriptor);
SecurityDescriptor = NewSecurityDescriptor;
//FspDebugLogSD(__FUNCTION__ ": SDDL = %s\n", SecurityDescriptor);
ClassNameSize = (lstrlenW(ClassName) + 1) * sizeof(WCHAR);
InstanceNameSize = (lstrlenW(InstanceName) + 1) * sizeof(WCHAR);
@ -999,8 +553,7 @@ NTSTATUS SvcInstanceCreate(HANDLE ClientToken,
if (!NT_SUCCESS(Result))
goto exit;
Result = SvcInstanceCreateProcess(L'\0' != RunAsBuf[0] ? RunAsBuf : 0,
Executable, SvcInstance->CommandLine, L'\0' != WorkDirectory[0] ? WorkDirectory : 0,
Result = SvcInstanceCreateProcess(Executable, SvcInstance->CommandLine,
RedirectStdio ? SvcInstance->StdioHandles : 0, &ProcessInfo);
if (!NT_SUCCESS(Result))
goto exit;
@ -1071,9 +624,6 @@ exit:
LeaveCriticalSection(&SvcInstanceLock);
FspServiceLog(EVENTLOG_INFORMATION_TYPE,
L"create %s\\%s = %lx", ClassName, InstanceName, Result);
return Result;
}
@ -1107,9 +657,6 @@ static VOID CALLBACK SvcInstanceTerminated(PVOID Context, BOOLEAN Timeout)
{
SVC_INSTANCE *SvcInstance = Context;
FspServiceLog(EVENTLOG_INFORMATION_TYPE,
L"terminated %s\\%s", SvcInstance->ClassName, SvcInstance->InstanceName);
SvcInstanceRelease(SvcInstance);
}
@ -1205,10 +752,6 @@ exit:
SvcInstanceRelease(SvcInstance);
if (STATUS_TIMEOUT == Result)
/* convert to an error! */
Result = 0x80070000 | ERROR_TIMEOUT;
return Result;
}
@ -1342,53 +885,6 @@ NTSTATUS SvcInstanceStopAndWaitAll(VOID)
return STATUS_SUCCESS;
}
NTSTATUS SvcDefineDosDevice(HANDLE ClientToken,
PWSTR DeviceName, PWSTR TargetPath)
{
NTSTATUS Result;
if (L'+' != DeviceName[0] && L'-' != DeviceName[0])
return STATUS_INVALID_PARAMETER;
Result = FspServiceContextCheck(ClientToken, 0);
if (!NT_SUCCESS(Result))
return Result;
if (!DefineDosDeviceW(
DDD_RAW_TARGET_PATH |
(L'+' == DeviceName[0] ? 0 : DDD_REMOVE_DEFINITION | DDD_EXACT_MATCH_ON_REMOVE),
DeviceName + 1, TargetPath))
return FspNtStatusFromWin32(GetLastError());
if (L'+' == DeviceName[0] && 0 != SvcNtOpenSymbolicLinkObject)
{
/* The drive symlink now exists; add DELETE access to it for the ClientToken. */
WCHAR SymlinkBuf[6];
UNICODE_STRING Symlink;
OBJECT_ATTRIBUTES Obja;
HANDLE MountHandle;
memcpy(SymlinkBuf, L"\\??\\X:", sizeof SymlinkBuf);
SymlinkBuf[4] = DeviceName[1];
Symlink.Length = Symlink.MaximumLength = sizeof SymlinkBuf;
Symlink.Buffer = SymlinkBuf;
memset(&Obja, 0, sizeof Obja);
Obja.Length = sizeof Obja;
Obja.ObjectName = &Symlink;
Obja.Attributes = OBJ_CASE_INSENSITIVE;
Result = SvcNtOpenSymbolicLinkObject(&MountHandle, READ_CONTROL | WRITE_DAC, &Obja);
if (NT_SUCCESS(Result))
{
AddAccessForTokenUser(MountHandle, DELETE, ClientToken);
SvcNtClose(MountHandle);
}
}
return STATUS_SUCCESS;
}
static HANDLE SvcJob, SvcThread, SvcEvent;
static DWORD SvcThreadId;
static HANDLE SvcPipe = INVALID_HANDLE_VALUE;
@ -1422,10 +918,6 @@ static NTSTATUS SvcStart(FSP_SERVICE *Service, ULONG argc, PWSTR *argv)
if (0 == SvcInstanceEvent)
goto fail;
SvcInstanceTlsKey = TlsAlloc();
if (TLS_OUT_OF_INDEXES == SvcInstanceTlsKey)
goto fail;
SvcJob = CreateJobObjectW(0, 0);
if (0 != SvcJob)
{
@ -1488,9 +980,6 @@ fail:
if (0 != SvcJob)
CloseHandle(SvcJob);
if (TLS_OUT_OF_INDEXES != SvcInstanceTlsKey)
TlsFree(SvcInstanceTlsKey);
if (0 != SvcInstanceEvent)
CloseHandle(SvcInstanceEvent);
@ -1534,9 +1023,6 @@ static NTSTATUS SvcStop(FSP_SERVICE *Service)
if (0 != SvcJob)
CloseHandle(SvcJob);
if (TLS_OUT_OF_INDEXES != SvcInstanceTlsKey)
TlsFree(SvcInstanceTlsKey);
if (0 != SvcInstanceEvent)
CloseHandle(SvcInstanceEvent);
@ -1708,17 +1194,13 @@ static VOID SvcPipeTransact(HANDLE ClientToken, PWSTR PipeBuf, PULONG PSize)
return;
PWSTR P = PipeBuf, PipeBufEnd = PipeBuf + *PSize / sizeof(WCHAR);
PWSTR ClassName, InstanceName, UserName;
PWSTR DeviceName, TargetPath;
PWSTR ClassName, InstanceName;
ULONG Argc; PWSTR Argv[9];
BOOLEAN HasSecret = FALSE;
NTSTATUS Result;
*PSize = 0;
GetTokenUserName(ClientToken, &UserName);
SvcInstanceSetUserName(UserName);
switch (*P++)
{
case LauncherSvcInstanceStartWithSecret:
@ -1771,17 +1253,6 @@ static VOID SvcPipeTransact(HANDLE ClientToken, PWSTR PipeBuf, PULONG PSize)
SvcPipeTransactResult(Result, PipeBuf, PSize);
break;
case LauncherDefineDosDevice:
DeviceName = SvcPipeTransactGetPart(&P, PipeBufEnd);
TargetPath = SvcPipeTransactGetPart(&P, PipeBufEnd);
Result = STATUS_INVALID_PARAMETER;
if (0 != DeviceName && 0 != TargetPath)
Result = SvcDefineDosDevice(ClientToken, DeviceName, TargetPath);
SvcPipeTransactResult(Result, PipeBuf, PSize);
break;
#if !defined(NDEBUG)
case LauncherQuit:
SetEvent(SvcEvent);
@ -1793,26 +1264,10 @@ static VOID SvcPipeTransact(HANDLE ClientToken, PWSTR PipeBuf, PULONG PSize)
SvcPipeTransactResult(STATUS_INVALID_PARAMETER, PipeBuf, PSize);
break;
}
SvcInstanceSetUserName(0);
MemFree(UserName);
}
int wmain(int argc, wchar_t **argv)
{
HANDLE Handle = GetModuleHandleW(L"ntdll.dll");
if (0 != Handle)
{
SvcNtOpenSymbolicLinkObject = (PVOID)GetProcAddress(Handle, "NtOpenSymbolicLinkObject");
SvcNtClose = (PVOID)GetProcAddress(Handle, "NtClose");
if (0 == SvcNtOpenSymbolicLinkObject || 0 == SvcNtClose)
{
SvcNtOpenSymbolicLinkObject = 0;
SvcNtClose = 0;
}
}
return FspServiceRun(L"" PROGNAME, SvcStart, SvcStop, 0);
}

View File

@ -1,7 +1,7 @@
/**
* @file launcher/launcher.h
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.
@ -29,7 +29,7 @@
#define LAUNCHER_PIPE_NAME "\\\\.\\pipe\\WinFsp.{14E7137D-22B4-437A-B0C1-D21D1BDF3767}"
#define LAUNCHER_PIPE_BUFFER_SIZE 4096
#define LAUNCHER_PIPE_DEFAULT_TIMEOUT (2 * 15000 + 1000)
#define LAUNCHER_PIPE_DEFAULT_TIMEOUT 3000
#define LAUNCHER_START_WITH_SECRET_TIMEOUT 15000
@ -62,7 +62,6 @@ enum
LauncherSvcInstanceStop = 'T', /* requires: SERVICE_STOP */
LauncherSvcInstanceInfo = 'I', /* requires: SERVICE_QUERY_STATUS */
LauncherSvcInstanceList = 'L', /* requires: none*/
LauncherDefineDosDevice = 'D',
LauncherQuit = 'Q', /* DEBUG version only */
LauncherSuccess = '$',

View File

@ -1,7 +1,7 @@
/**
* @file shared/minimal.h
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -2,7 +2,7 @@
* @file sys/callbacks.c
* Fast I/O and resource acquisition callbacks.
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/**
* @file sys/cleanup.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.
@ -117,6 +117,8 @@ static NTSTATUS FspFsvolCleanup(
Request->Req.Cleanup.SetLastWriteTime = FileModified && !FileDesc->DidSetLastWriteTime;
Request->Req.Cleanup.SetChangeTime = (FileModified || FileDesc->DidSetMetadata) &&
!FileDesc->DidSetChangeTime;
Request->Req.Cleanup.UnlockAll = FsvolDeviceExtension->VolumeParams.UserModeFileLocking &&
FsRtlAreThereCurrentOrInProgressFileLocks(&FileNode->FileLock);
FspFileNodeAcquireExclusive(FileNode, Pgio);
@ -128,6 +130,7 @@ static NTSTATUS FspFsvolCleanup(
Request->Req.Cleanup.SetArchiveBit ||
Request->Req.Cleanup.SetLastWriteTime ||
Request->Req.Cleanup.SetChangeTime ||
Request->Req.Cleanup.UnlockAll ||
!FsvolDeviceExtension->VolumeParams.PostCleanupWhenModifiedOnly)
/*
* Note that it is still possible for this request to not be delivered,

View File

@ -1,7 +1,7 @@
/**
* @file sys/close.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/**
* @file sys/create.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/**
* @file sys/debug.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/**
* @file sys/devctl.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/**
* @file sys/device.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/**
* @file sys/dirctl.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.
@ -611,7 +611,7 @@ static NTSTATUS FspFsvolQueryDirectoryRetry(
if (0 != FileDesc->DirectoryMarker.Buffer)
{
ASSERT(
FsvolDeviceExtension->VolumeParams.MaxComponentLength * sizeof(WCHAR) >=
FsvolDeviceExtension->VolumeParams.MaxComponentLength >=
FileDesc->DirectoryMarker.Length);
Request->Req.QueryDirectory.Marker.Offset =
@ -921,7 +921,7 @@ NTSTATUS FspFsvolDirectoryControlComplete(
if (0 != FileDesc->DirectoryMarker.Buffer)
{
ASSERT(
FsvolDeviceExtension->VolumeParams.MaxComponentLength * sizeof(WCHAR) >=
FsvolDeviceExtension->VolumeParams.MaxComponentLength >=
FileDesc->DirectoryMarker.Length);
Request->Req.QueryDirectory.Marker.Offset =

View File

@ -1,7 +1,7 @@
/**
* @file sys/driver.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.
@ -128,6 +128,7 @@ NTSTATUS DriverEntry(
FspIopCompleteFunction[IRP_MJ_FILE_SYSTEM_CONTROL] = FspFsvolFileSystemControlComplete;
FspIopCompleteFunction[IRP_MJ_DEVICE_CONTROL] = FspFsvolDeviceControlComplete;
FspIopCompleteFunction[IRP_MJ_SHUTDOWN] = FspFsvolShutdownComplete;
FspFileNodeCompleteLockIrp = FspFsvolLockControlForward;
FspIopCompleteFunction[IRP_MJ_LOCK_CONTROL] = FspFsvolLockControlComplete;
FspIopCompleteFunction[IRP_MJ_CLEANUP] = FspFsvolCleanupComplete;
FspIopCompleteFunction[IRP_MJ_QUERY_SECURITY] = FspFsvolQuerySecurityComplete;

View File

@ -1,7 +1,7 @@
/**
* @file sys/driver.h
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.
@ -316,6 +316,7 @@ FSP_IOPREP_DISPATCH FspFsvolDirectoryControlPrepare;
FSP_IOCMPL_DISPATCH FspFsvolDirectoryControlComplete;
FSP_IOCMPL_DISPATCH FspFsvolFileSystemControlComplete;
FSP_IOCMPL_DISPATCH FspFsvolFlushBuffersComplete;
NTSTATUS FspFsvolLockControlForward(PVOID Context, PIRP Irp);
FSP_IOCMPL_DISPATCH FspFsvolLockControlComplete;
FSP_IOCMPL_DISPATCH FspFsvolQueryEaComplete;
FSP_IOCMPL_DISPATCH FspFsvolQueryInformationComplete;
@ -1564,6 +1565,7 @@ extern CACHE_MANAGER_CALLBACKS FspCacheManagerCallbacks;
extern FSP_IOPREP_DISPATCH *FspIopPrepareFunction[];
extern FSP_IOCMPL_DISPATCH *FspIopCompleteFunction[];
extern ERESOURCE FspDeviceGlobalResource;
extern PCOMPLETE_LOCK_IRP_ROUTINE FspFileNodeCompleteLockIrp;
extern WCHAR FspFileDescDirectoryPatternMatchAll[];
extern const GUID FspMainFileOpenEcpGuid;
extern ULONG FspProcessorCount;

View File

@ -1,7 +1,7 @@
/**
* @file sys/ea.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/**
* @file sys/file.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.
@ -83,7 +83,6 @@ VOID FspFileNodeInvalidateStreamInfo(FSP_FILE_NODE *FileNode);
VOID FspFileNodeNotifyChange(FSP_FILE_NODE *FileNode, ULONG Filter, ULONG Action,
BOOLEAN InvalidateCaches);
NTSTATUS FspFileNodeProcessLockIrp(FSP_FILE_NODE *FileNode, PIRP Irp);
static NTSTATUS FspFileNodeCompleteLockIrp(PVOID Context, PIRP Irp);
NTSTATUS FspFileDescCreate(FSP_FILE_DESC **PFileDesc);
VOID FspFileDescDelete(FSP_FILE_DESC *FileDesc);
NTSTATUS FspFileDescResetDirectory(FSP_FILE_DESC *FileDesc,
@ -149,7 +148,6 @@ VOID FspFileNodeOplockComplete(PVOID Context, PIRP Irp);
// !#pragma alloc_text(PAGE, FspFileNodeInvalidateStreamInfo)
#pragma alloc_text(PAGE, FspFileNodeNotifyChange)
#pragma alloc_text(PAGE, FspFileNodeProcessLockIrp)
#pragma alloc_text(PAGE, FspFileNodeCompleteLockIrp)
#pragma alloc_text(PAGE, FspFileDescCreate)
#pragma alloc_text(PAGE, FspFileDescDelete)
#pragma alloc_text(PAGE, FspFileDescResetDirectory)
@ -2030,19 +2028,6 @@ NTSTATUS FspFileNodeProcessLockIrp(FSP_FILE_NODE *FileNode, PIRP Irp)
return Result;
}
static NTSTATUS FspFileNodeCompleteLockIrp(PVOID Context, PIRP Irp)
{
PAGED_CODE();
NTSTATUS Result = Irp->IoStatus.Status;
DEBUGLOGIRP(Irp, Result);
FspIopCompleteIrp(Irp, Result);
return Result;
}
NTSTATUS FspFileDescCreate(FSP_FILE_DESC **PFileDesc)
{
PAGED_CODE();
@ -2166,7 +2151,7 @@ NTSTATUS FspFileDescSetDirectoryMarker(FSP_FILE_DESC *FileDesc,
FspFsvolDeviceExtension(FileDesc->FileNode->FsvolDeviceObject);
UNICODE_STRING DirectoryMarker;
if (FsvolDeviceExtension->VolumeParams.MaxComponentLength * sizeof(WCHAR) < FileName->Length)
if (FsvolDeviceExtension->VolumeParams.MaxComponentLength < FileName->Length)
return STATUS_OBJECT_NAME_INVALID;
DirectoryMarker.Length = DirectoryMarker.MaximumLength = FileName->Length;
@ -2379,6 +2364,7 @@ VOID FspFileNodeOplockComplete(PVOID Context, PIRP Irp)
FspIopCompleteIrp(Irp, Irp->IoStatus.Status);
}
PCOMPLETE_LOCK_IRP_ROUTINE FspFileNodeCompleteLockIrp;
WCHAR FspFileDescDirectoryPatternMatchAll[] = L"*";
// {904862B4-EB3F-461E-ACB2-4DF2B3FC898B}

View File

@ -1,7 +1,7 @@
/**
* @file sys/fileinfo.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/**
* @file sys/flush.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/**
* @file sys/fsctl.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/**
* @file sys/iop.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/**
* @file sys/ioq.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/**
* @file sys/lockctl.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.
@ -22,12 +22,14 @@ static NTSTATUS FspFsvolLockControlRetry(
BOOLEAN CanWait);
static NTSTATUS FspFsvolLockControl(
PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp);
NTSTATUS FspFsvolLockControlForward(PVOID Context, PIRP Irp);
FSP_IOCMPL_DISPATCH FspFsvolLockControlComplete;
FSP_DRIVER_DISPATCH FspLockControl;
#ifdef ALLOC_PRAGMA
#pragma alloc_text(PAGE, FspFsvolLockControlRetry)
#pragma alloc_text(PAGE, FspFsvolLockControl)
#pragma alloc_text(PAGE, FspFsvolLockControlForward)
#pragma alloc_text(PAGE, FspFsvolLockControlComplete)
#pragma alloc_text(PAGE, FspLockControl)
#endif
@ -94,6 +96,57 @@ static NTSTATUS FspFsvolLockControl(
return Result;
}
NTSTATUS FspFsvolLockControlForward(PVOID Context, PIRP Irp)
{
/*
* At this point the FSRTL package has processed the lock IRP.
* Either complete the IRP or if we are supposed to forward to
* user mode do so now.
*/
PAGED_CODE();
PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
PDEVICE_OBJECT FsvolDeviceObject = IrpSp->DeviceObject;
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(FsvolDeviceObject);
NTSTATUS Result = Irp->IoStatus.Status;
if (!NT_SUCCESS(Result) || !FsvolDeviceExtension->VolumeParams.UserModeFileLocking)
goto complete;
PFILE_OBJECT FileObject = IrpSp->FileObject;
FSP_FILE_NODE *FileNode = FileObject->FsContext;
FSP_FILE_DESC *FileDesc = FileObject->FsContext2;
FSP_FSCTL_TRANSACT_REQ *Request;
ASSERT(FileNode == FileDesc->FileNode);
Result = FspIopCreateRequest(Irp, 0, 0, &Request);
if (!NT_SUCCESS(Result))
goto complete;
Request->Kind = FspFsctlTransactLockControlKind;
Request->Req.LockControl.UserContext = FileNode->UserContext;
Request->Req.LockControl.UserContext2 = FileDesc->UserContext2;
Request->Req.LockControl.LockFunction = IrpSp->MinorFunction;
Request->Req.LockControl.Offset = IrpSp->Parameters.LockControl.ByteOffset.QuadPart;
Request->Req.LockControl.Length = IrpSp->Parameters.LockControl.Length->QuadPart;
Request->Req.LockControl.Key = IrpSp->Parameters.LockControl.Key;
Request->Req.LockControl.ProcessId = IoGetRequestorProcessId(Irp);
Request->Req.LockControl.Exclusive = 0 != (IrpSp->Flags & SL_EXCLUSIVE_LOCK);
Request->Req.LockControl.FailImmediately = 0 != (IrpSp->Flags & SL_FAIL_IMMEDIATELY);
if (!FspIoqPostIrp(FsvolDeviceExtension->Ioq, Irp, &Result))
goto complete;
return Result;
complete:
DEBUGLOGIRP(Irp, Result);
FspIopCompleteIrp(Irp, Result);
return Result;
}
NTSTATUS FspFsvolLockControlComplete(
PIRP Irp, const FSP_FSCTL_TRANSACT_RSP *Response)
{

View File

@ -1,7 +1,7 @@
/**
* @file sys/meta.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/**
* @file sys/name.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/**
* @file sys/psbuffer.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/**
* @file sys/read.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.
@ -228,7 +228,6 @@ static NTSTATUS FspFsvolReadNonCached(
FSP_FILE_DESC *FileDesc = FileObject->FsContext2;
LARGE_INTEGER ReadOffset = IrpSp->Parameters.Read.ByteOffset;
ULONG ReadLength = IrpSp->Parameters.Read.Length;
ULONG ReadKey = IrpSp->Parameters.Read.Key;
BOOLEAN PagingIo = BooleanFlagOn(Irp->Flags, IRP_PAGING_IO);
FSP_FSCTL_TRANSACT_REQ *Request;
BOOLEAN Success;
@ -321,7 +320,11 @@ static NTSTATUS FspFsvolReadNonCached(
Request->Req.Read.UserContext2 = FileDesc->UserContext2;
Request->Req.Read.Offset = ReadOffset.QuadPart;
Request->Req.Read.Length = ReadLength;
Request->Req.Read.Key = ReadKey;
if (!PagingIo)
{
Request->Req.Read.Key = IrpSp->Parameters.Read.Key;
Request->Req.Read.ProcessId = IoGetRequestorProcessId(Irp);
}
FspFileNodeSetOwner(FileNode, Full, Request);
FspIopRequestContext(Request, RequestIrp) = Irp;

View File

@ -1,7 +1,7 @@
/**
* @file sys/security.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/**
* @file sys/shutdown.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

View File

@ -1,7 +1,7 @@
/**
* @file sys/statistics.c
*
* @copyright 2015-2018 Bill Zissimopoulos
* @copyright 2015-2017 Bill Zissimopoulos
*/
/*
* This file is part of WinFsp.

Some files were not shown because too many files have changed in this diff Show More