mirror of
https://github.com/winfsp/winfsp.git
synced 2025-07-02 17:02:57 -05:00
Compare commits
31 Commits
Author | SHA1 | Date | |
---|---|---|---|
b9915dcaa7 | |||
a7febb8265 | |||
d6aaf0088a | |||
f05af124e7 | |||
886b7cf9f7 | |||
e111451475 | |||
0c38f92082 | |||
9bd9cf4fbd | |||
2f026cbc6f | |||
68d8ade667 | |||
d9c450ecf4 | |||
e6d2ef9274 | |||
299f371dee | |||
bb8aee8673 | |||
08bf8e14ce | |||
ef1912bd8a | |||
ff155694ce | |||
e6ed6dbf4f | |||
f13b98c880 | |||
5d3b37122c | |||
9d1c892d68 | |||
7008871ed7 | |||
2a3eabfab2 | |||
35255526d3 | |||
b2e474658d | |||
4fe85222b1 | |||
fd3e5bad43 | |||
ea873ece22 | |||
42e01a9b27 | |||
c1c9dca94b | |||
dcabdff422 |
12
.github/ISSUE_TEMPLATE.md
vendored
Normal file
12
.github/ISSUE_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
(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.
|
12
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
12
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
(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.
|
@ -1,6 +1,30 @@
|
||||
= 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:
|
||||
|
@ -55,6 +55,7 @@ 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
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file CustomActions.cpp
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
|
||||
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
|
||||
xmlns:dep="http://schemas.microsoft.com/wix/DependencyExtension">
|
||||
<Product
|
||||
Id="*"
|
||||
Name="$(var.MyProductName) $(var.MyProductVersion)"
|
||||
@ -53,8 +54,8 @@
|
||||
Key="[P.RegistryKey]"
|
||||
Name="InstallDir"
|
||||
Type="string"
|
||||
Value="[INSTALLDIR]"
|
||||
KeyPath="yes" />
|
||||
Value="[INSTALLDIR]" />
|
||||
<dep:Provides Key="WinFsp" />
|
||||
</Component>
|
||||
<Component Id="C.License.txt">
|
||||
<File Name="License.txt" Source="..\..\..\License.txt" KeyPath="yes" />
|
||||
@ -187,6 +188,10 @@
|
||||
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"
|
||||
@ -213,6 +218,10 @@
|
||||
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"
|
||||
@ -239,6 +248,10 @@
|
||||
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"
|
||||
|
@ -39,6 +39,10 @@
|
||||
<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)" />
|
||||
<!--
|
||||
|
@ -112,7 +112,7 @@
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
|
||||
<AdditionalDependencies>%(AdditionalDependencies);rpcrt4.lib</AdditionalDependencies>
|
||||
<AdditionalDependencies>%(AdditionalDependencies);rpcrt4.lib;userenv.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</AdditionalDependencies>
|
||||
<AdditionalDependencies>%(AdditionalDependencies);rpcrt4.lib;userenv.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</AdditionalDependencies>
|
||||
<AdditionalDependencies>%(AdditionalDependencies);rpcrt4.lib;userenv.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</AdditionalDependencies>
|
||||
<AdditionalDependencies>%(AdditionalDependencies);rpcrt4.lib;userenv.lib</AdditionalDependencies>
|
||||
<StripPrivateSymbols>$(OutDir)$(TargetName).public.pdb</StripPrivateSymbols>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
@ -16,10 +16,10 @@
|
||||
<MyCompanyName>Navimatics Corporation</MyCompanyName>
|
||||
<MyCopyright>2015-$([System.DateTime]::Now.ToString(`yyyy`)) Bill Zissimopoulos</MyCopyright>
|
||||
|
||||
<MyCanonicalVersion>1.2</MyCanonicalVersion>
|
||||
<MyCanonicalVersion>1.3</MyCanonicalVersion>
|
||||
|
||||
<MyProductVersion>2017.2</MyProductVersion>
|
||||
<MyProductStage>Gold</MyProductStage>
|
||||
<MyProductVersion>2018.1 B1</MyProductVersion>
|
||||
<MyProductStage>Beta</MyProductStage>
|
||||
|
||||
<MyVersion>$(MyCanonicalVersion).$(MyBuildNumber)</MyVersion>
|
||||
<MyVersionWithCommas>$(MyVersion.Replace('.',',')),0</MyVersionWithCommas>
|
||||
|
@ -39,6 +39,7 @@
|
||||
<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" />
|
||||
@ -51,6 +52,7 @@
|
||||
<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">
|
||||
|
@ -112,6 +112,12 @@
|
||||
<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">
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file tlib/callstack.c
|
||||
*
|
||||
* @copyright 2014-2017 Bill Zissimopoulos
|
||||
* @copyright 2014-2018 Bill Zissimopoulos
|
||||
*/
|
||||
|
||||
#include <tlib/callstack.h>
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file tlib/callstack.h
|
||||
*
|
||||
* @copyright 2014-2017 Bill Zissimopoulos
|
||||
* @copyright 2014-2018 Bill Zissimopoulos
|
||||
*/
|
||||
|
||||
#ifndef TLIB_CALLSTACK_H_INCLUDED
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file tlib/injected/allfunc.h
|
||||
*
|
||||
* @copyright 2014-2017 Bill Zissimopoulos
|
||||
* @copyright 2014-2018 Bill Zissimopoulos
|
||||
*/
|
||||
|
||||
#ifndef TLIB_INJECTED_ALLFUNC_H_INCLUDED
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file tlib/injected/curlfunc.c
|
||||
*
|
||||
* @copyright 2014-2017 Bill Zissimopoulos
|
||||
* @copyright 2014-2018 Bill Zissimopoulos
|
||||
*/
|
||||
|
||||
#include <tlib/injected/curlfunc.h>
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file tlib/injected/curlfunc.h
|
||||
*
|
||||
* @copyright 2014-2017 Bill Zissimopoulos
|
||||
* @copyright 2014-2018 Bill Zissimopoulos
|
||||
*/
|
||||
|
||||
#ifndef TLIB_INJECTED_CURLFUNC_H_INCLUDED
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file tlib/injected/stdfunc.c
|
||||
*
|
||||
* @copyright 2014-2017 Bill Zissimopoulos
|
||||
* @copyright 2014-2018 Bill Zissimopoulos
|
||||
*/
|
||||
|
||||
#include <tlib/injected/stdfunc.h>
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file tlib/injected/stdfunc.h
|
||||
*
|
||||
* @copyright 2014-2017 Bill Zissimopoulos
|
||||
* @copyright 2014-2018 Bill Zissimopoulos
|
||||
*/
|
||||
|
||||
#ifndef TLIB_INJECTED_STDFUNC_H_INCLUDED
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file tlib/injection.c
|
||||
*
|
||||
* @copyright 2014-2017 Bill Zissimopoulos
|
||||
* @copyright 2014-2018 Bill Zissimopoulos
|
||||
*/
|
||||
|
||||
#include <tlib/injection.h>
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file tlib/injection.h
|
||||
*
|
||||
* @copyright 2014-2017 Bill Zissimopoulos
|
||||
* @copyright 2014-2018 Bill Zissimopoulos
|
||||
*/
|
||||
|
||||
/* NOTE: This header may usefully be included multiple times.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file tlib/testsuite.c
|
||||
*
|
||||
* @copyright 2014-2017 Bill Zissimopoulos
|
||||
* @copyright 2014-2018 Bill Zissimopoulos
|
||||
*/
|
||||
|
||||
#include <tlib/testsuite.h>
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file tlib/testsuite.h
|
||||
*
|
||||
* @copyright 2014-2017 Bill Zissimopoulos
|
||||
* @copyright 2014-2018 Bill Zissimopoulos
|
||||
*/
|
||||
|
||||
#ifndef TLIB_TESTSUITE_H_INCLUDED
|
||||
|
@ -6,7 +6,7 @@
|
||||
* FUSE: Filesystem in Userspace
|
||||
* Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -6,7 +6,7 @@
|
||||
* FUSE: Filesystem in Userspace
|
||||
* Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -6,7 +6,7 @@
|
||||
* FUSE: Filesystem in Userspace
|
||||
* Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -2,7 +2,7 @@
|
||||
* @file fuse/winfsp_fuse.h
|
||||
* WinFsp FUSE compatible API.
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file winfsp/fsctl.h
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -5,7 +5,7 @@
|
||||
* In order to use the WinFsp API the user mode file system must include <winfsp/winfsp.h>
|
||||
* and link with the winfsp_x64.dll (or winfsp_x86.dll) library.
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
@ -1675,6 +1675,19 @@ 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.
|
||||
*
|
||||
@ -1690,6 +1703,133 @@ FSP_API BOOLEAN FspServiceIsInteractive(VOID);
|
||||
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
|
||||
*/
|
||||
@ -1700,6 +1840,7 @@ 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);
|
||||
|
@ -2,7 +2,7 @@
|
||||
* @file winfsp/winfsp.hpp
|
||||
* WinFsp C++ Layer.
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file cygfuse/cygfuse.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file dll/debug.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
@ -63,6 +63,21 @@ 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;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file dll/dirbuf.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file dll/eventlog.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
74
src/dll/fs.c
74
src/dll/fs.c
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file dll/fs.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
@ -187,17 +187,62 @@ 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;
|
||||
|
||||
if (!DefineDosDeviceW(DDD_RAW_TARGET_PATH, MountPoint, VolumeName))
|
||||
return FspNtStatusFromWin32(GetLastError());
|
||||
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 (0 != FspNtOpenSymbolicLinkObject)
|
||||
{
|
||||
NTSTATUS Result;
|
||||
WCHAR SymlinkBuf[6];
|
||||
UNICODE_STRING Symlink;
|
||||
OBJECT_ATTRIBUTES Obja;
|
||||
@ -224,6 +269,13 @@ 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;
|
||||
}
|
||||
|
||||
@ -411,8 +463,18 @@ exit:
|
||||
|
||||
static VOID FspFileSystemRemoveMountPoint_Drive(PWSTR MountPoint, PWSTR VolumeName, HANDLE MountHandle)
|
||||
{
|
||||
DefineDosDeviceW(DDD_RAW_TARGET_PATH | DDD_REMOVE_DEFINITION | DDD_EXACT_MATCH_ON_REMOVE,
|
||||
MountPoint, VolumeName);
|
||||
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);
|
||||
|
||||
if (0 != MountHandle)
|
||||
FspNtClose(MountHandle);
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file dll/fsctl.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 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 = 0;
|
||||
PSID WorldSid;
|
||||
PSECURITY_DESCRIPTOR SecurityDescriptor = 0;
|
||||
PSECURITY_DESCRIPTOR NewSecurityDescriptor = 0;
|
||||
EXPLICIT_ACCESSW AccessEntry;
|
||||
@ -296,18 +296,12 @@ static NTSTATUS FspFsctlFixServiceSecurity(HANDLE SvcHandle)
|
||||
NTSTATUS Result;
|
||||
|
||||
/* get the Everyone (World) SID */
|
||||
Size = SECURITY_MAX_SID_SIZE;
|
||||
WorldSid = MemAlloc(Size);
|
||||
WorldSid = FspWksidGet(WinWorldSid);
|
||||
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;
|
||||
@ -394,7 +388,6 @@ static NTSTATUS FspFsctlFixServiceSecurity(HANDLE SvcHandle)
|
||||
exit:
|
||||
LocalFree(NewSecurityDescriptor);
|
||||
MemFree(SecurityDescriptor);
|
||||
MemFree(WorldSid);
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file dll/fsop.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file dll/fuse/fuse.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file dll/fuse/fuse_compat.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file dll/fuse/fuse_intf.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file dll/fuse/fuse_main.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file dll/fuse/fuse_opt.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file dll/fuse/library.h
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
152
src/dll/launch.c
Normal file
152
src/dll/launch.c
Normal file
@ -0,0 +1,152 @@
|
||||
/**
|
||||
* @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);
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file dll/library.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
@ -44,6 +44,7 @@ BOOL WINAPI DllMain(HINSTANCE Instance, DWORD Reason, PVOID Reserved)
|
||||
FspServiceFinalize(Dynamic);
|
||||
FspEventLogFinalize(Dynamic);
|
||||
FspPosixFinalize(Dynamic);
|
||||
FspWksidFinalize(Dynamic);
|
||||
break;
|
||||
|
||||
case DLL_THREAD_DETACH:
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file dll/library.h
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
@ -31,11 +31,15 @@
|
||||
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);
|
||||
@ -49,6 +53,9 @@ 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,
|
||||
|
132
src/dll/np.c
132
src/dll/np.c
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file dll/np.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
@ -35,6 +35,12 @@
|
||||
*/
|
||||
#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,
|
||||
@ -168,39 +174,17 @@ static inline BOOLEAN FspNpParseRemoteUserName(PWSTR RemoteName,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static inline DWORD FspNpCallLauncherPipe(PWSTR PipeBuf, ULONG SendSize, ULONG RecvSize)
|
||||
static inline DWORD FspNpCallLauncherPipe(
|
||||
WCHAR Command, ULONG Argc, PWSTR *Argv, ULONG *Argl,
|
||||
PWSTR Buffer, PULONG PSize)
|
||||
{
|
||||
DWORD NpResult;
|
||||
NTSTATUS Result;
|
||||
DWORD BytesTransferred;
|
||||
ULONG ErrorCode;
|
||||
|
||||
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;
|
||||
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 NTSTATUS FspNpGetVolumeList(
|
||||
@ -490,7 +474,9 @@ DWORD APIENTRY NPAddConnection(LPNETRESOURCEW lpNetResource, LPWSTR lpPassword,
|
||||
PWSTR ClassName, InstanceName, RemoteName, P;
|
||||
ULONG ClassNameLen, InstanceNameLen;
|
||||
DWORD CredentialsKind;
|
||||
PWSTR PipeBuf = 0;
|
||||
ULONG Argc;
|
||||
PWSTR Argv[6];
|
||||
ULONG Argl[6];
|
||||
#if defined(FSP_NP_CREDENTIAL_MANAGER)
|
||||
PCREDENTIALW Credential = 0;
|
||||
#endif
|
||||
@ -556,32 +542,24 @@ DWORD APIENTRY NPAddConnection(LPNETRESOURCEW lpNetResource, LPWSTR lpPassword,
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
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++;
|
||||
if (FSP_NP_CREDENTIALS_USERPASS == CredentialsKind)
|
||||
{
|
||||
lstrcpyW(P, lpUserName); P += lstrlenW(lpUserName) + 1;
|
||||
Argv[Argc] = lpUserName; Argl[Argc] = -1; Argc++;
|
||||
}
|
||||
if (FSP_NP_CREDENTIALS_NONE != CredentialsKind)
|
||||
{
|
||||
lstrcpyW(P, lpPassword); P += lstrlenW(lpPassword) + 1;
|
||||
Argv[Argc] = lpPassword; Argl[Argc] = -1; Argc++;
|
||||
}
|
||||
|
||||
NpResult = FspNpCallLauncherPipe(
|
||||
PipeBuf, (ULONG)(P - PipeBuf) * sizeof(WCHAR), LAUNCHER_PIPE_BUFFER_SIZE);
|
||||
FSP_NP_CREDENTIALS_NONE != CredentialsKind ?
|
||||
LauncherSvcInstanceStartWithSecret : LauncherSvcInstanceStart,
|
||||
Argc, Argv, Argl, 0, 0);
|
||||
switch (NpResult)
|
||||
{
|
||||
case WN_SUCCESS:
|
||||
@ -627,13 +605,13 @@ DWORD APIENTRY NPAddConnection(LPNETRESOURCEW lpNetResource, LPWSTR lpPassword,
|
||||
break;
|
||||
}
|
||||
|
||||
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';
|
||||
Argc = 0;
|
||||
Argv[Argc] = ClassName; Argl[Argc] = ClassNameLen; Argc++;
|
||||
Argv[Argc] = InstanceName; Argl[Argc] = InstanceNameLen; Argc++;
|
||||
|
||||
if (WN_SUCCESS != FspNpCallLauncherPipe(
|
||||
PipeBuf, (ULONG)(P - PipeBuf) * sizeof(WCHAR), LAUNCHER_PIPE_BUFFER_SIZE))
|
||||
LauncherSvcInstanceInfo,
|
||||
Argc, Argv, Argl, 0, 0))
|
||||
{
|
||||
/* looks like the file system is gone! */
|
||||
NpResult = WN_NO_NETWORK;
|
||||
@ -677,8 +655,6 @@ DWORD APIENTRY NPAddConnection(LPNETRESOURCEW lpNetResource, LPWSTR lpPassword,
|
||||
}
|
||||
|
||||
exit:
|
||||
MemFree(PipeBuf);
|
||||
|
||||
#if defined(FSP_NP_CREDENTIAL_MANAGER)
|
||||
if (0 != Credential)
|
||||
CredFree(Credential);
|
||||
@ -767,9 +743,11 @@ 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, P;
|
||||
PWSTR ClassName, InstanceName, RemoteName;
|
||||
ULONG ClassNameLen, InstanceNameLen;
|
||||
PWSTR PipeBuf = 0;
|
||||
ULONG Argc;
|
||||
PWSTR Argv[2];
|
||||
ULONG Argl[2];
|
||||
|
||||
if (FspNpCheckLocalName(lpName))
|
||||
{
|
||||
@ -789,17 +767,13 @@ DWORD APIENTRY NPCancelConnection(LPWSTR lpName, BOOL fForce)
|
||||
&ClassName, &ClassNameLen, &InstanceName, &InstanceNameLen))
|
||||
return WN_BAD_NETNAME;
|
||||
|
||||
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';
|
||||
Argc = 0;
|
||||
Argv[Argc] = ClassName; Argl[Argc] = ClassNameLen; Argc++;
|
||||
Argv[Argc] = InstanceName; Argl[Argc] = InstanceNameLen; Argc++;
|
||||
|
||||
NpResult = FspNpCallLauncherPipe(
|
||||
PipeBuf, (ULONG)(P - PipeBuf) * sizeof(WCHAR), LAUNCHER_PIPE_BUFFER_SIZE);
|
||||
LauncherSvcInstanceStop,
|
||||
Argc, Argv, Argl, 0, 0);
|
||||
switch (NpResult)
|
||||
{
|
||||
case WN_SUCCESS:
|
||||
@ -812,8 +786,6 @@ DWORD APIENTRY NPCancelConnection(LPWSTR lpName, BOOL fForce)
|
||||
break;
|
||||
}
|
||||
|
||||
MemFree(PipeBuf);
|
||||
|
||||
return NpResult;
|
||||
}
|
||||
|
||||
@ -1016,7 +988,7 @@ NTSTATUS FspNpRegister(VOID)
|
||||
WCHAR ProviderPath[MAX_PATH];
|
||||
WCHAR RegBuffer[1024];
|
||||
PWSTR P, Part;
|
||||
DWORD RegResult, RegType, RegBufferSize;
|
||||
DWORD RegResult, RegType, RegBufferSize, RegBufferOffset;
|
||||
HKEY RegKey;
|
||||
BOOLEAN FoundProvider;
|
||||
|
||||
@ -1082,15 +1054,20 @@ 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, &RegBufferSize);
|
||||
L"ProviderOrder", 0, &RegType, (PVOID)&RegBuffer[RegBufferOffset], &RegBufferSize);
|
||||
if (ERROR_SUCCESS != RegResult)
|
||||
goto close_and_exit;
|
||||
RegBufferSize /= sizeof(WCHAR);
|
||||
|
||||
FoundProvider = FALSE;
|
||||
RegBuffer[RegBufferSize] = L'\0';
|
||||
P = RegBuffer, Part = P;
|
||||
RegBuffer[RegBufferSize + RegBufferOffset] = L'\0';
|
||||
P = &RegBuffer[RegBufferOffset], Part = P;
|
||||
do
|
||||
{
|
||||
if (L',' == *P || '\0' == *P)
|
||||
@ -1107,8 +1084,11 @@ NTSTATUS FspNpRegister(VOID)
|
||||
|
||||
if (!FoundProvider)
|
||||
{
|
||||
P--;
|
||||
memcpy(P, L"," FSP_NP_NAME, sizeof L"," FSP_NP_NAME);
|
||||
#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
|
||||
|
||||
RegBufferSize = lstrlenW(RegBuffer);
|
||||
RegBufferSize++;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file dll/ntstatus.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file dll/path.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -14,7 +14,7 @@
|
||||
* [SNAME]
|
||||
* https://www.cygwin.com/cygwin-ug-net/using-specialnames.html
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
@ -453,9 +453,12 @@ FSP_API NTSTATUS FspPosixMapPermissionsToSecurityDescriptor(
|
||||
if (!NT_SUCCESS(Result))
|
||||
goto exit;
|
||||
|
||||
Result = FspPosixMapUidToSid(0x10100, &WorldSid);
|
||||
if (!NT_SUCCESS(Result))
|
||||
WorldSid = FspWksidGet(WinWorldSid);
|
||||
if (0 == WorldSid)
|
||||
{
|
||||
Result = STATUS_INSUFFICIENT_RESOURCES;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
OwnerPerm = (Mode & 0700) >> 6;
|
||||
GroupPerm = (Mode & 0070) >> 3;
|
||||
@ -579,9 +582,6 @@ exit:
|
||||
|
||||
MemFree(Acl);
|
||||
|
||||
if (0 != WorldSid)
|
||||
FspDeleteSid(WorldSid, FspPosixMapUidToSid);
|
||||
|
||||
if (0 != GroupSid)
|
||||
FspDeleteSid(GroupSid, FspPosixMapUidToSid);
|
||||
|
||||
@ -649,13 +649,19 @@ FSP_API NTSTATUS FspPosixMapSecurityDescriptorToPermissions(
|
||||
|
||||
if (0 != Acl)
|
||||
{
|
||||
Result = FspPosixMapUidToSid(0x10100, &WorldSid);
|
||||
if (!NT_SUCCESS(Result))
|
||||
WorldSid = FspWksidGet(WinWorldSid);
|
||||
if (0 == WorldSid)
|
||||
{
|
||||
Result = STATUS_INSUFFICIENT_RESOURCES;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
Result = FspPosixMapUidToSid(11, &AuthUsersSid);
|
||||
if (!NT_SUCCESS(Result))
|
||||
AuthUsersSid = FspWksidGet(WinAuthenticatedUserSid);
|
||||
if (0 == AuthUsersSid)
|
||||
{
|
||||
Result = STATUS_INSUFFICIENT_RESOURCES;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
OwnerAllow = OwnerDeny = GroupAllow = GroupDeny = WorldAllow = WorldDeny = 0;
|
||||
|
||||
@ -771,12 +777,6 @@ FSP_API NTSTATUS FspPosixMapSecurityDescriptorToPermissions(
|
||||
Result = STATUS_SUCCESS;
|
||||
|
||||
exit:
|
||||
if (0 != AuthUsersSid)
|
||||
FspDeleteSid(AuthUsersSid, FspPosixMapUidToSid);
|
||||
|
||||
if (0 != WorldSid)
|
||||
FspDeleteSid(WorldSid, FspPosixMapUidToSid);
|
||||
|
||||
return Result;
|
||||
|
||||
lasterror:
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file dll/security.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file dll/service.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
@ -566,6 +566,106 @@ 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;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file dll/util.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
@ -97,24 +97,14 @@ FSP_API NTSTATUS FspCallNamedPipeSecurely(PWSTR PipeName,
|
||||
{
|
||||
PSECURITY_DESCRIPTOR SecurityDescriptor = 0;
|
||||
PSID OwnerSid, WellKnownSid = 0;
|
||||
DWORD SidSize, LastError;
|
||||
DWORD LastError;
|
||||
|
||||
/* if it is a small number treat it like a well known SID */
|
||||
if (1024 > (INT_PTR)Sid)
|
||||
{
|
||||
SidSize = SECURITY_MAX_SID_SIZE;
|
||||
WellKnownSid = MemAlloc(SidSize);
|
||||
WellKnownSid = FspWksidNew((INT_PTR)Sid, &Result);
|
||||
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,
|
||||
|
108
src/dll/wksid.c
Normal file
108
src/dll/wksid.c
Normal file
@ -0,0 +1,108 @@
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* dotnet/FileSystemBase+Const.cs
|
||||
*
|
||||
* Copyright 2015-2017 Bill Zissimopoulos
|
||||
* Copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* dotnet/FileSystemBase.cs
|
||||
*
|
||||
* Copyright 2015-2017 Bill Zissimopoulos
|
||||
* Copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* dotnet/FileSystemHost.cs
|
||||
*
|
||||
* Copyright 2015-2017 Bill Zissimopoulos
|
||||
* Copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* dotnet/Interop.cs
|
||||
*
|
||||
* Copyright 2015-2017 Bill Zissimopoulos
|
||||
* Copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* dotnet/Service.cs
|
||||
*
|
||||
* Copyright 2015-2017 Bill Zissimopoulos
|
||||
* Copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file fsptool/fsptool.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file launcher/launchctl.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file launcher/launcher.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
@ -16,17 +16,30 @@
|
||||
*/
|
||||
|
||||
#include <launcher/launcher.h>
|
||||
#include <aclapi.h>
|
||||
#include <sddl.h>
|
||||
#include <userenv.h>
|
||||
|
||||
#define PROGNAME "WinFsp.Launcher"
|
||||
|
||||
BOOL CreateOverlappedPipe(
|
||||
PHANDLE PReadPipe, PHANDLE PWritePipe, PSECURITY_ATTRIBUTES SecurityAttributes, DWORD Size,
|
||||
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,
|
||||
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;
|
||||
|
||||
@ -46,13 +59,13 @@ 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, SecurityAttributes);
|
||||
1, Size, Size, 120 * 1000, &ReadSecurityAttributes);
|
||||
if (INVALID_HANDLE_VALUE == ReadPipe)
|
||||
return FALSE;
|
||||
|
||||
WritePipe = CreateFileW(PipeNameBuf,
|
||||
GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
SecurityAttributes, OPEN_EXISTING, WriteMode, 0);
|
||||
&WriteSecurityAttributes, OPEN_EXISTING, WriteMode, 0);
|
||||
if (INVALID_HANDLE_VALUE == WritePipe)
|
||||
{
|
||||
LastError = GetLastError();
|
||||
@ -69,7 +82,12 @@ BOOL CreateOverlappedPipe(
|
||||
|
||||
static NTSTATUS GetTokenUserName(HANDLE Token, PWSTR *PUserName)
|
||||
{
|
||||
TOKEN_USER *User = 0;
|
||||
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;
|
||||
@ -78,33 +96,31 @@ static NTSTATUS GetTokenUserName(HANDLE Token, PWSTR *PUserName)
|
||||
|
||||
*PUserName = 0;
|
||||
|
||||
if (GetTokenInformation(Token, TokenUser, 0, 0, &UserSize))
|
||||
if (!GetTokenInformation(Token, TokenUser, UserInfo, sizeof UserInfoBuf, &UserSize))
|
||||
{
|
||||
Result = STATUS_INVALID_PARAMETER;
|
||||
goto exit;
|
||||
}
|
||||
if (ERROR_INSUFFICIENT_BUFFER != GetLastError())
|
||||
{
|
||||
Result = FspNtStatusFromWin32(GetLastError());
|
||||
goto exit;
|
||||
}
|
||||
if (ERROR_INSUFFICIENT_BUFFER != GetLastError())
|
||||
{
|
||||
Result = FspNtStatusFromWin32(GetLastError());
|
||||
goto exit;
|
||||
}
|
||||
|
||||
User = MemAlloc(UserSize);
|
||||
if (0 == User)
|
||||
{
|
||||
Result = STATUS_INSUFFICIENT_RESOURCES;
|
||||
goto exit;
|
||||
}
|
||||
UserInfo = MemAlloc(UserSize);
|
||||
if (0 == UserInfo)
|
||||
{
|
||||
Result = STATUS_INSUFFICIENT_RESOURCES;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (!GetTokenInformation(Token, TokenUser, User, UserSize, &UserSize))
|
||||
{
|
||||
Result = FspNtStatusFromWin32(GetLastError());
|
||||
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, User->User.Sid, Name, &NameSize, Domn, &DomnSize, &Use))
|
||||
if (!LookupAccountSidW(0, UserInfo->User.Sid, Name, &NameSize, Domn, &DomnSize, &Use))
|
||||
{
|
||||
Result = FspNtStatusFromWin32(GetLastError());
|
||||
goto exit;
|
||||
@ -132,11 +148,211 @@ static NTSTATUS GetTokenUserName(HANDLE Token, PWSTR *PUserName)
|
||||
Result = STATUS_SUCCESS;
|
||||
|
||||
exit:
|
||||
MemFree(User);
|
||||
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;
|
||||
@ -145,7 +361,7 @@ typedef struct
|
||||
|
||||
static VOID CALLBACK KillProcessWait(PVOID Context, BOOLEAN Timeout);
|
||||
|
||||
VOID KillProcess(ULONG ProcessId, HANDLE Process, ULONG Timeout)
|
||||
static VOID KillProcess(ULONG ProcessId, HANDLE Process, ULONG Timeout)
|
||||
{
|
||||
if (GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, ProcessId))
|
||||
{
|
||||
@ -348,6 +564,67 @@ 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)
|
||||
{
|
||||
@ -376,18 +653,35 @@ static NTSTATUS SvcInstanceAccessCheck(HANDLE ClientToken, ULONG DesiredAccess,
|
||||
return Result;
|
||||
}
|
||||
|
||||
NTSTATUS SvcInstanceCreateProcess(PWSTR Executable, PWSTR CommandLine,
|
||||
static NTSTATUS SvcInstanceCreateProcess(PWSTR UserName,
|
||||
PWSTR Executable, PWSTR CommandLine, PWSTR WorkDirectory,
|
||||
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;
|
||||
|
||||
@ -401,16 +695,16 @@ NTSTATUS SvcInstanceCreateProcess(PWSTR Executable, PWSTR CommandLine,
|
||||
*/
|
||||
|
||||
/* create stdin read/write ends; make them inheritable */
|
||||
if (!CreateOverlappedPipe(&ChildHandles[0], &ParentHandles[0], &PipeAttributes, 0,
|
||||
0, 0))
|
||||
if (!CreateOverlappedPipe(&ChildHandles[0], &ParentHandles[0],
|
||||
0, TRUE, FALSE, 0, 0))
|
||||
{
|
||||
Result = FspNtStatusFromWin32(GetLastError());
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* create stdout read/write ends; make them inheritable */
|
||||
if (!CreateOverlappedPipe(&ParentHandles[1], &ChildHandles[1], &PipeAttributes, 0,
|
||||
FILE_FLAG_OVERLAPPED, 0))
|
||||
if (!CreateOverlappedPipe(&ParentHandles[1], &ChildHandles[1],
|
||||
0, FALSE, TRUE, FILE_FLAG_OVERLAPPED, 0))
|
||||
{
|
||||
Result = FspNtStatusFromWin32(GetLastError());
|
||||
goto exit;
|
||||
@ -454,18 +748,44 @@ NTSTATUS SvcInstanceCreateProcess(PWSTR Executable, PWSTR CommandLine,
|
||||
StartupInfoEx.StartupInfo.hStdOutput = ChildHandles[1];
|
||||
StartupInfoEx.StartupInfo.hStdError = ChildHandles[2];
|
||||
|
||||
if (!CreateProcessW(Executable, CommandLine, 0, 0, TRUE,
|
||||
CREATE_SUSPENDED | CREATE_NEW_PROCESS_GROUP | EXTENDED_STARTUPINFO_PRESENT, 0, 0,
|
||||
if (!LogonCreateProcess(UserName,
|
||||
Executable, CommandLine, 0, 0, TRUE,
|
||||
CREATE_SUSPENDED | CREATE_NEW_PROCESS_GROUP | EXTENDED_STARTUPINFO_PRESENT,
|
||||
0, WorkDirectory,
|
||||
&StartupInfoEx.StartupInfo, ProcessInfo))
|
||||
{
|
||||
Result = FspNtStatusFromWin32(GetLastError());
|
||||
goto exit;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!CreateProcessW(Executable, CommandLine, 0, 0, FALSE,
|
||||
CREATE_SUSPENDED | CREATE_NEW_PROCESS_GROUP, 0, 0,
|
||||
if (!LogonCreateProcess(UserName,
|
||||
Executable, CommandLine, 0, 0, FALSE,
|
||||
CREATE_SUSPENDED | CREATE_NEW_PROCESS_GROUP,
|
||||
0, WorkDirectory,
|
||||
&StartupInfoEx.StartupInfo, ProcessInfo))
|
||||
{
|
||||
Result = FspNtStatusFromWin32(GetLastError());
|
||||
@ -508,10 +828,11 @@ NTSTATUS SvcInstanceCreate(HANDLE ClientToken,
|
||||
HKEY RegKey = 0;
|
||||
DWORD RegResult, RegSize;
|
||||
DWORD ClassNameSize, InstanceNameSize;
|
||||
WCHAR Executable[MAX_PATH], CommandLineBuf[512], SecurityBuf[512];
|
||||
WCHAR Executable[MAX_PATH], CommandLineBuf[512], WorkDirectory[MAX_PATH],
|
||||
SecurityBuf[512], RunAsBuf[64];
|
||||
PWSTR CommandLine, Security;
|
||||
DWORD JobControl, Credentials;
|
||||
PSECURITY_DESCRIPTOR SecurityDescriptor = 0;
|
||||
PSECURITY_DESCRIPTOR SecurityDescriptor = 0, NewSecurityDescriptor;
|
||||
PWSTR Argv[10];
|
||||
PROCESS_INFORMATION ProcessInfo;
|
||||
NTSTATUS Result;
|
||||
@ -585,6 +906,16 @@ 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,
|
||||
@ -595,6 +926,16 @@ 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,
|
||||
@ -626,6 +967,14 @@ 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);
|
||||
|
||||
@ -650,7 +999,8 @@ NTSTATUS SvcInstanceCreate(HANDLE ClientToken,
|
||||
if (!NT_SUCCESS(Result))
|
||||
goto exit;
|
||||
|
||||
Result = SvcInstanceCreateProcess(Executable, SvcInstance->CommandLine,
|
||||
Result = SvcInstanceCreateProcess(L'\0' != RunAsBuf[0] ? RunAsBuf : 0,
|
||||
Executable, SvcInstance->CommandLine, L'\0' != WorkDirectory[0] ? WorkDirectory : 0,
|
||||
RedirectStdio ? SvcInstance->StdioHandles : 0, &ProcessInfo);
|
||||
if (!NT_SUCCESS(Result))
|
||||
goto exit;
|
||||
@ -721,6 +1071,9 @@ exit:
|
||||
|
||||
LeaveCriticalSection(&SvcInstanceLock);
|
||||
|
||||
FspServiceLog(EVENTLOG_INFORMATION_TYPE,
|
||||
L"create %s\\%s = %lx", ClassName, InstanceName, Result);
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
@ -754,6 +1107,9 @@ 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);
|
||||
}
|
||||
|
||||
@ -849,6 +1205,10 @@ exit:
|
||||
|
||||
SvcInstanceRelease(SvcInstance);
|
||||
|
||||
if (STATUS_TIMEOUT == Result)
|
||||
/* convert to an error! */
|
||||
Result = 0x80070000 | ERROR_TIMEOUT;
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
@ -982,6 +1342,53 @@ 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;
|
||||
@ -1302,6 +1709,7 @@ static VOID SvcPipeTransact(HANDLE ClientToken, PWSTR PipeBuf, PULONG PSize)
|
||||
|
||||
PWSTR P = PipeBuf, PipeBufEnd = PipeBuf + *PSize / sizeof(WCHAR);
|
||||
PWSTR ClassName, InstanceName, UserName;
|
||||
PWSTR DeviceName, TargetPath;
|
||||
ULONG Argc; PWSTR Argv[9];
|
||||
BOOLEAN HasSecret = FALSE;
|
||||
NTSTATUS Result;
|
||||
@ -1363,6 +1771,17 @@ 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);
|
||||
@ -1381,6 +1800,19 @@ static VOID SvcPipeTransact(HANDLE ClientToken, PWSTR PipeBuf, PULONG PSize)
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file launcher/launcher.h
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 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 3000
|
||||
#define LAUNCHER_PIPE_DEFAULT_TIMEOUT (2 * 15000 + 1000)
|
||||
|
||||
#define LAUNCHER_START_WITH_SECRET_TIMEOUT 15000
|
||||
|
||||
@ -62,6 +62,7 @@ enum
|
||||
LauncherSvcInstanceStop = 'T', /* requires: SERVICE_STOP */
|
||||
LauncherSvcInstanceInfo = 'I', /* requires: SERVICE_QUERY_STATUS */
|
||||
LauncherSvcInstanceList = 'L', /* requires: none*/
|
||||
LauncherDefineDosDevice = 'D',
|
||||
LauncherQuit = 'Q', /* DEBUG version only */
|
||||
|
||||
LauncherSuccess = '$',
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file shared/minimal.h
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -2,7 +2,7 @@
|
||||
* @file sys/callbacks.c
|
||||
* Fast I/O and resource acquisition callbacks.
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file sys/cleanup.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file sys/close.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file sys/create.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file sys/debug.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file sys/devctl.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file sys/device.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file sys/dirctl.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file sys/driver.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file sys/driver.h
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file sys/ea.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file sys/file.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file sys/fileinfo.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file sys/flush.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file sys/fsctl.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file sys/iop.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file sys/ioq.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file sys/lockctl.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file sys/meta.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file sys/name.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file sys/psbuffer.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file sys/read.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file sys/security.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file sys/shutdown.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file sys/statistics.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file sys/util.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file sys/volinfo.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file sys/volume.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file sys/wq.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file sys/write.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
17
tools/fix-source-copyright
Normal file
17
tools/fix-source-copyright
Normal file
@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
OWNER="Bill Zissimopoulos"
|
||||
MATCH="(@c|C)opyright ([0-9]+)(-[0-9]+)? ${OWNER}(. All rights reserved.)?"
|
||||
SUBST="\1opyright \2-$(date +%Y) ${OWNER}\4"
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
echo "usage: $(basename $0) tree" 1>&2
|
||||
echo "WARNING: this will in-place edit your source files!" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$(uname -s)" == Darwin* ]]; then
|
||||
git grep -lz "$@" | xargs -0 sed -E -i "" -e "s/$MATCH/$SUBST/"
|
||||
else
|
||||
git grep -lz "$@" | xargs -0 sed -E -i"" -e "s/$MATCH/$SUBST/"
|
||||
fi
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file fsbench.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file fscrash-main.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file fscrash.c
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file fscrash.h
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file Program.cs
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
@ -6,7 +6,7 @@
|
||||
*
|
||||
* Please note that this file is no longer maintained.
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
* @copyright 2015-2018 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user