Imported Upstream version 5.0.0.42

Former-commit-id: fd56571888259555122d8a0f58c68838229cea2b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-04-10 11:41:01 +00:00
parent 1190d13a04
commit 6bdd276d05
19939 changed files with 3099680 additions and 93811 deletions

View File

@@ -0,0 +1,81 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Security.AccessControl.Tests", "tests\System.Security.AccessControl.Tests.csproj", "{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}"
ProjectSection(ProjectDependencies) = postProject
{879C23DC-D828-4DFB-8E92-ABBC11B71035} = {879C23DC-D828-4DFB-8E92-ABBC11B71035}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Security.AccessControl", "src\System.Security.AccessControl.csproj", "{879C23DC-D828-4DFB-8E92-ABBC11B71035}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
DebugNETCoreAppnet463-Windows_NTnetstandard-Windows_NT|AnyCPU = DebugNETCoreAppnet463-Windows_NTnetstandard-Windows_NT|AnyCPU
ReleaseNETCoreAppnet463-Windows_NTnetstandard-Windows_NT|AnyCPU = ReleaseNETCoreAppnet463-Windows_NTnetstandard-Windows_NT|AnyCPU
DebugNETCoreAppnet463-Windows_NTnetstandard1.3-Windows_NT|AnyCPU = DebugNETCoreAppnet463-Windows_NTnetstandard1.3-Windows_NT|AnyCPU
ReleaseNETCoreAppnet463-Windows_NTnetstandard1.3-Windows_NT|AnyCPU = ReleaseNETCoreAppnet463-Windows_NTnetstandard1.3-Windows_NT|AnyCPU
DebugNETCoreAppnetstandard-Windows_NTnetstandard-Windows_NT|AnyCPU = DebugNETCoreAppnetstandard-Windows_NTnetstandard-Windows_NT|AnyCPU
ReleaseNETCoreAppnetstandard-Windows_NTnetstandard-Windows_NT|AnyCPU = ReleaseNETCoreAppnetstandard-Windows_NTnetstandard-Windows_NT|AnyCPU
DebugNETCoreAppnetstandard-Windows_NTnetstandard1.3-Windows_NT|AnyCPU = DebugNETCoreAppnetstandard-Windows_NTnetstandard1.3-Windows_NT|AnyCPU
ReleaseNETCoreAppnetstandard-Windows_NTnetstandard1.3-Windows_NT|AnyCPU = ReleaseNETCoreAppnetstandard-Windows_NTnetstandard1.3-Windows_NT|AnyCPU
DebugNETCoreAppnetstandard-Unixnetstandard-Windows_NT|AnyCPU = DebugNETCoreAppnetstandard-Unixnetstandard-Windows_NT|AnyCPU
ReleaseNETCoreAppnetstandard-Unixnetstandard-Windows_NT|AnyCPU = ReleaseNETCoreAppnetstandard-Unixnetstandard-Windows_NT|AnyCPU
DebugNETCoreAppnetstandard-Unixnetstandard1.3-Windows_NT|AnyCPU = DebugNETCoreAppnetstandard-Unixnetstandard1.3-Windows_NT|AnyCPU
ReleaseNETCoreAppnetstandard-Unixnetstandard1.3-Windows_NT|AnyCPU = ReleaseNETCoreAppnetstandard-Unixnetstandard1.3-Windows_NT|AnyCPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.DebugNETCoreAppnet463-Windows_NTnetstandard-Windows_NT|AnyCPU.ActiveCfg = netstandard-Windows_NT-Debug|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.DebugNETCoreAppnet463-Windows_NTnetstandard-Windows_NT|AnyCPU.Build.0 = netstandard-Windows_NT-Debug|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.ReleaseNETCoreAppnet463-Windows_NTnetstandard-Windows_NT|AnyCPU.ActiveCfg = netstandard-Windows_NT-Release|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.ReleaseNETCoreAppnet463-Windows_NTnetstandard-Windows_NT|AnyCPU.Build.0 = netstandard-Windows_NT-Release|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.DebugNETCoreAppnet463-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.ActiveCfg = netstandard1.3-Windows_NT-Debug|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.DebugNETCoreAppnet463-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.Build.0 = netstandard1.3-Windows_NT-Debug|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.ReleaseNETCoreAppnet463-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.ActiveCfg = netstandard1.3-Windows_NT-Release|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.ReleaseNETCoreAppnet463-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.Build.0 = netstandard1.3-Windows_NT-Release|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.DebugNETCoreAppnetstandard-Windows_NTnetstandard-Windows_NT|AnyCPU.ActiveCfg = netstandard-Windows_NT-Debug|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.DebugNETCoreAppnetstandard-Windows_NTnetstandard-Windows_NT|AnyCPU.Build.0 = netstandard-Windows_NT-Debug|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.ReleaseNETCoreAppnetstandard-Windows_NTnetstandard-Windows_NT|AnyCPU.ActiveCfg = netstandard-Windows_NT-Release|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.ReleaseNETCoreAppnetstandard-Windows_NTnetstandard-Windows_NT|AnyCPU.Build.0 = netstandard-Windows_NT-Release|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.DebugNETCoreAppnetstandard-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.ActiveCfg = netstandard1.3-Windows_NT-Debug|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.DebugNETCoreAppnetstandard-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.Build.0 = netstandard1.3-Windows_NT-Debug|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.ReleaseNETCoreAppnetstandard-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.ActiveCfg = netstandard1.3-Windows_NT-Release|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.ReleaseNETCoreAppnetstandard-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.Build.0 = netstandard1.3-Windows_NT-Release|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.DebugNETCoreAppnetstandard-Unixnetstandard-Windows_NT|AnyCPU.ActiveCfg = netstandard-Windows_NT-Debug|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.DebugNETCoreAppnetstandard-Unixnetstandard-Windows_NT|AnyCPU.Build.0 = netstandard-Windows_NT-Debug|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.ReleaseNETCoreAppnetstandard-Unixnetstandard-Windows_NT|AnyCPU.ActiveCfg = netstandard-Windows_NT-Release|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.ReleaseNETCoreAppnetstandard-Unixnetstandard-Windows_NT|AnyCPU.Build.0 = netstandard-Windows_NT-Release|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.DebugNETCoreAppnetstandard-Unixnetstandard1.3-Windows_NT|AnyCPU.ActiveCfg = netstandard1.3-Windows_NT-Debug|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.DebugNETCoreAppnetstandard-Unixnetstandard1.3-Windows_NT|AnyCPU.Build.0 = netstandard1.3-Windows_NT-Debug|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.ReleaseNETCoreAppnetstandard-Unixnetstandard1.3-Windows_NT|AnyCPU.ActiveCfg = netstandard1.3-Windows_NT-Release|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.ReleaseNETCoreAppnetstandard-Unixnetstandard1.3-Windows_NT|AnyCPU.Build.0 = netstandard1.3-Windows_NT-Release|Any CPU
{879C23DC-D828-4DFB-8E92-ABBC11B71035}.DebugNETCoreAppnet463-Windows_NTnetstandard-Windows_NT|AnyCPU.ActiveCfg = net463-Windows_NT-Debug|Any CPU
{879C23DC-D828-4DFB-8E92-ABBC11B71035}.DebugNETCoreAppnet463-Windows_NTnetstandard-Windows_NT|AnyCPU.Build.0 = net463-Windows_NT-Debug|Any CPU
{879C23DC-D828-4DFB-8E92-ABBC11B71035}.ReleaseNETCoreAppnet463-Windows_NTnetstandard-Windows_NT|AnyCPU.ActiveCfg = net463-Windows_NT-Release|Any CPU
{879C23DC-D828-4DFB-8E92-ABBC11B71035}.ReleaseNETCoreAppnet463-Windows_NTnetstandard-Windows_NT|AnyCPU.Build.0 = net463-Windows_NT-Release|Any CPU
{879C23DC-D828-4DFB-8E92-ABBC11B71035}.DebugNETCoreAppnet463-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.ActiveCfg = net463-Windows_NT-Debug|Any CPU
{879C23DC-D828-4DFB-8E92-ABBC11B71035}.DebugNETCoreAppnet463-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.Build.0 = net463-Windows_NT-Debug|Any CPU
{879C23DC-D828-4DFB-8E92-ABBC11B71035}.ReleaseNETCoreAppnet463-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.ActiveCfg = net463-Windows_NT-Release|Any CPU
{879C23DC-D828-4DFB-8E92-ABBC11B71035}.ReleaseNETCoreAppnet463-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.Build.0 = net463-Windows_NT-Release|Any CPU
{879C23DC-D828-4DFB-8E92-ABBC11B71035}.DebugNETCoreAppnetstandard-Windows_NTnetstandard-Windows_NT|AnyCPU.ActiveCfg = netstandard-Windows_NT-Debug|Any CPU
{879C23DC-D828-4DFB-8E92-ABBC11B71035}.DebugNETCoreAppnetstandard-Windows_NTnetstandard-Windows_NT|AnyCPU.Build.0 = netstandard-Windows_NT-Debug|Any CPU
{879C23DC-D828-4DFB-8E92-ABBC11B71035}.ReleaseNETCoreAppnetstandard-Windows_NTnetstandard-Windows_NT|AnyCPU.ActiveCfg = netstandard-Windows_NT-Release|Any CPU
{879C23DC-D828-4DFB-8E92-ABBC11B71035}.ReleaseNETCoreAppnetstandard-Windows_NTnetstandard-Windows_NT|AnyCPU.Build.0 = netstandard-Windows_NT-Release|Any CPU
{879C23DC-D828-4DFB-8E92-ABBC11B71035}.DebugNETCoreAppnetstandard-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.ActiveCfg = netstandard-Windows_NT-Debug|Any CPU
{879C23DC-D828-4DFB-8E92-ABBC11B71035}.DebugNETCoreAppnetstandard-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.Build.0 = netstandard-Windows_NT-Debug|Any CPU
{879C23DC-D828-4DFB-8E92-ABBC11B71035}.ReleaseNETCoreAppnetstandard-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.ActiveCfg = netstandard-Windows_NT-Release|Any CPU
{879C23DC-D828-4DFB-8E92-ABBC11B71035}.ReleaseNETCoreAppnetstandard-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.Build.0 = netstandard-Windows_NT-Release|Any CPU
{879C23DC-D828-4DFB-8E92-ABBC11B71035}.DebugNETCoreAppnetstandard-Unixnetstandard-Windows_NT|AnyCPU.ActiveCfg = netstandard-Unix-Debug|Any CPU
{879C23DC-D828-4DFB-8E92-ABBC11B71035}.DebugNETCoreAppnetstandard-Unixnetstandard-Windows_NT|AnyCPU.Build.0 = netstandard-Unix-Debug|Any CPU
{879C23DC-D828-4DFB-8E92-ABBC11B71035}.ReleaseNETCoreAppnetstandard-Unixnetstandard-Windows_NT|AnyCPU.ActiveCfg = netstandard-Unix-Release|Any CPU
{879C23DC-D828-4DFB-8E92-ABBC11B71035}.ReleaseNETCoreAppnetstandard-Unixnetstandard-Windows_NT|AnyCPU.Build.0 = netstandard-Unix-Release|Any CPU
{879C23DC-D828-4DFB-8E92-ABBC11B71035}.DebugNETCoreAppnetstandard-Unixnetstandard1.3-Windows_NT|AnyCPU.ActiveCfg = netstandard-Unix-Debug|Any CPU
{879C23DC-D828-4DFB-8E92-ABBC11B71035}.DebugNETCoreAppnetstandard-Unixnetstandard1.3-Windows_NT|AnyCPU.Build.0 = netstandard-Unix-Debug|Any CPU
{879C23DC-D828-4DFB-8E92-ABBC11B71035}.ReleaseNETCoreAppnetstandard-Unixnetstandard1.3-Windows_NT|AnyCPU.ActiveCfg = netstandard-Unix-Release|Any CPU
{879C23DC-D828-4DFB-8E92-ABBC11B71035}.ReleaseNETCoreAppnetstandard-Unixnetstandard1.3-Windows_NT|AnyCPU.Build.0 = netstandard-Unix-Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\dir.props" />
<PropertyGroup>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<IsNETCoreApp>true</IsNETCoreApp>
<IsNETCoreAppRef>false</IsNETCoreAppRef>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<ItemGroup>
<Project Include="System.Security.AccessControl.pkgproj" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.traversal.targets))\dir.traversal.targets" />
</Project>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<ItemGroup>
<ProjectReference Include="..\ref\System.Security.AccessControl.csproj">
<SupportedFramework>net463;netcoreapp2.0</SupportedFramework>
</ProjectReference>
<ProjectReference Include="..\src\System.Security.AccessControl.builds" />
<NotSupportedOnTargetFramework Include="netcore50">
<PackageTargetRuntime>win</PackageTargetRuntime>
</NotSupportedOnTargetFramework>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildConfigurations>
netstandard;
</BuildConfigurations>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,20 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// ------------------------------------------------------------------------------
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------
namespace System.Security.AccessControl
{
// Derive AuthorizationRuleCollection from ICollection since we removed the old ReadOnlyCollectionBase
// base type and replaced it with this.
public sealed partial class AuthorizationRuleCollection : System.Collections.ICollection, System.Collections.IEnumerable
{
public int Count { get { throw null; } }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
bool System.Collections.ICollection.IsSynchronized { get { throw null; } }
object System.Collections.ICollection.SyncRoot { get { throw null; } }
void System.Collections.ICollection.CopyTo(System.Array array, int index) { }
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
<ItemGroup>
<Compile Include="System.Security.AccessControl.cs" />
<Compile Include="System.Security.AccessControl.Manual.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\System.Security.Principal.Windows\ref\System.Security.Principal.Windows.csproj" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildConfigurations>
net463-Windows_NT;
netcoreapp-Windows_NT;
netcoreapp-Unix;
</BuildConfigurations>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,255 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="AccessControl_AclTooLong" xml:space="preserve">
<value>Length of the access control list exceed the allowed maximum.</value>
</data>
<data name="AccessControl_InvalidAccessRuleType" xml:space="preserve">
<value>The access rule is not the correct type.</value>
</data>
<data name="AccessControl_InvalidAuditRuleType" xml:space="preserve">
<value>The audit rule is not the correct type.</value>
</data>
<data name="AccessControl_InvalidOwner" xml:space="preserve">
<value>The security identifier is not allowed to be the owner of this object.</value>
</data>
<data name="AccessControl_InvalidGroup" xml:space="preserve">
<value>The security identifier is not allowed to be the primary group of this object.</value>
</data>
<data name="AccessControl_InvalidHandle" xml:space="preserve">
<value>The supplied handle is invalid. This can happen when trying to set an ACL on an anonymous kernel object.</value>
</data>
<data name="AccessControl_InvalidSecurityDescriptorRevision" xml:space="preserve">
<value>Security descriptor with revision other than '1' are not legal.</value>
</data>
<data name="AccessControl_InvalidSecurityDescriptorSelfRelativeForm" xml:space="preserve">
<value>Security descriptor must be in the self-relative form.</value>
</data>
<data name="AccessControl_InvalidSidInSDDLString" xml:space="preserve">
<value>The SDDL string contains an invalid sid or a sid that cannot be translated.</value>
</data>
<data name="AccessControl_MustSpecifyContainerAcl" xml:space="preserve">
<value>The named parameter must be a container ACL.</value>
</data>
<data name="AccessControl_MustSpecifyDirectoryObjectAcl" xml:space="preserve">
<value>The named parameter must be a directory-object ACL.</value>
</data>
<data name="AccessControl_MustSpecifyLeafObjectAcl" xml:space="preserve">
<value>The named parameter must be a non-container ACL.</value>
</data>
<data name="AccessControl_MustSpecifyNonDirectoryObjectAcl" xml:space="preserve">
<value>The named parameter must be a non-directory-object ACL.</value>
</data>
<data name="AccessControl_NoAssociatedSecurity" xml:space="preserve">
<value>Unable to perform a security operation on an object that has no associated security. This can happen when trying to get an ACL of an anonymous kernel object.</value>
</data>
<data name="AccessControl_UnexpectedError" xml:space="preserve">
<value>Method failed with unexpected error code {0}.</value>
</data>
<data name="Arg_EnumAtLeastOneFlag" xml:space="preserve">
<value>Must set at least one flag.</value>
</data>
<data name="Arg_EnumIllegalVal" xml:space="preserve">
<value>Illegal enum value: {0}.</value>
</data>
<data name="Arg_InvalidOperationException" xml:space="preserve">
<value>Operation is not valid due to the current state of the object.</value>
</data>
<data name="Arg_MustBeIdentityReferenceType" xml:space="preserve">
<value>Type must be an IdentityReference, such as NTAccount or SecurityIdentifier.</value>
</data>
<data name="Argument_ArgumentZero" xml:space="preserve">
<value>Argument cannot be zero.</value>
</data>
<data name="Argument_InvalidAnyFlag" xml:space="preserve">
<value>No flags can be set.</value>
</data>
<data name="Argument_InvalidEnumValue" xml:space="preserve">
<value>The value '{0}' is not valid for this usage of the type {1}.</value>
</data>
<data name="Argument_InvalidName" xml:space="preserve">
<value>Invalid name.</value>
</data>
<data name="Argument_InvalidPrivilegeName" xml:space="preserve">
<value>Privilege '{0}' is not valid on this system.</value>
</data>
<data name="Argument_InvalidSafeHandle" xml:space="preserve">
<value>The SafeHandle is invalid.</value>
</data>
<data name="ArgumentException_InvalidAceBinaryForm" xml:space="preserve">
<value>The binary form of an ACE object is invalid.</value>
</data>
<data name="ArgumentException_InvalidAclBinaryForm" xml:space="preserve">
<value>The binary form of an ACL object is invalid.</value>
</data>
<data name="ArgumentException_InvalidSDSddlForm" xml:space="preserve">
<value>The SDDL form of a security descriptor object is invalid.</value>
</data>
<data name="ArgumentOutOfRange_ArrayLength" xml:space="preserve">
<value>The length of the array must be between {0} and {1}, inclusive.</value>
</data>
<data name="ArgumentOutOfRange_ArrayLengthMultiple" xml:space="preserve">
<value>The length of the array must be a multiple of {0}.</value>
</data>
<data name="ArgumentOutOfRange_ArrayTooSmall" xml:space="preserve">
<value>Destination array is not long enough to copy all the required data. Check array length and offset.</value>
</data>
<data name="ArgumentOutOfRange_Enum" xml:space="preserve">
<value>Enum value was out of legal range.</value>
</data>
<data name="ArgumentOutOfRange_InvalidUserDefinedAceType" xml:space="preserve">
<value>User-defined ACEs must not have a well-known ACE type.</value>
</data>
<data name="ArgumentOutOfRange_NeedNonNegNum" xml:space="preserve">
<value>Non-negative number required.</value>
</data>
<data name="InvalidOperation_ModificationOfNonCanonicalAcl" xml:space="preserve">
<value>This access control list is not in canonical form and therefore cannot be modified.</value>
</data>
<data name="InvalidOperation_MustBeSameThread" xml:space="preserve">
<value>This operation must take place on the same thread on which the object was created.</value>
</data>
<data name="InvalidOperation_MustLockForReadOrWrite" xml:space="preserve">
<value>Object must be locked for read or write.</value>
</data>
<data name="InvalidOperation_MustLockForWrite" xml:space="preserve">
<value>Object must be locked for read.</value>
</data>
<data name="InvalidOperation_MustRevertPrivilege" xml:space="preserve">
<value>Must revert the privilege prior to attempting this operation.</value>
</data>
<data name="InvalidOperation_NoSecurityDescriptor" xml:space="preserve">
<value>The object does not contain a security descriptor.</value>
</data>
<data name="InvalidOperation_OnlyValidForDS" xml:space="preserve">
<value>Adding ACEs with Object Flags and Object GUIDs is only valid for directory-object ACLs.</value>
</data>
<data name="NotSupported_SetMethod" xml:space="preserve">
<value>The 'set' method is not supported on this property.</value>
</data>
<data name="PrivilegeNotHeld_Default" xml:space="preserve">
<value>The process does not possess some privilege required for this operation.</value>
</data>
<data name="PrivilegeNotHeld_Named" xml:space="preserve">
<value>The process does not possess the '{0}' privilege which is required for this operation.</value>
</data>
<data name="Rank_MultiDimNotSupported" xml:space="preserve">
<value>Only single dimension arrays are supported here.</value>
</data>
</root>

View File

@@ -0,0 +1,131 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<AssemblyName>System.Security.AccessControl</AssemblyName>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsPartialFacadeAssembly Condition="'$(TargetGroup)'=='net463'">true</IsPartialFacadeAssembly>
<GeneratePlatformNotSupportedAssembly Condition="'$(TargetsUnix)' == 'true'">true</GeneratePlatformNotSupportedAssembly>
</PropertyGroup>
<!-- Help VS understand available configurations -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='net463-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='net463-Windows_NT-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netcoreapp-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netcoreapp-Windows_NT-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netcoreapp-Unix-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netcoreapp-Unix-Release|AnyCPU'" />
<ItemGroup Condition="'$(TargetGroup)'=='net463'">
<TargetingPackReference Include="mscorlib" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)'=='netcoreapp' AND '$(TargetsWindows)'=='true'">
<Compile Include="System\Security\AccessControl\ACE.cs" />
<Compile Include="System\Security\AccessControl\ACL.cs" />
<Compile Include="System\Security\AccessControl\CommonObjectSecurity.cs" />
<Compile Include="System\Security\AccessControl\Enums.cs" />
<Compile Include="System\Security\AccessControl\NativeObjectSecurity.cs" />
<Compile Include="System\Security\AccessControl\ObjectSecurity.cs" />
<Compile Include="System\Security\AccessControl\ObjectSecurityT.cs" />
<Compile Include="System\Security\AccessControl\Privilege.cs" />
<Compile Include="System\Security\AccessControl\PrivilegeNotHeldException.cs" />
<Compile Include="System\Security\AccessControl\SecurityDescriptor.cs" />
<Compile Include="System\Security\AccessControl\Rules.cs" />
<Compile Include="System\Security\AccessControl\Win32.cs" />
<Compile Include="System\Security\Principal\Win32.cs" />
<Compile Include="System\Security\SafeSecurityHandles.cs" />
<!-- PInvoke sources -->
<Compile Include="$(CommonPath)\System\NotImplemented.cs">
<Link>Common\System\NotImplemented.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\Interop.Libraries.cs">
<Link>Common\Interop\Interop.Libraries.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\advapi32\Interop.LUID.cs">
<Link>Common\Interop\Interop.LUID.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\advapi32\Interop.LUIDAndAttributes.cs">
<Link>Common\Interop\Interop.LUIDAndAttributes.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\advapi32\Interop.LUIDAndAttributes1.cs">
<Link>Common\Interop\Interop.LUIDAndAttributes1.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\advapi32\Interop.TokenPrivilege.cs">
<Link>Common\Interop\Interop.TokenPrivilege.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\advapi32\Interop.SecurityImpersonationLevel.cs">
<Link>Common\Interop\Interop.SecurityImpersonationLevel.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\Interop.Errors.cs">
<Link>Common\Interop\Interop.Errors.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\advapi32\Interop.ProcessOptions.cs">
<Link>Common\Interop\Interop.ProcessOptions.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\advapi32\Interop.LookupPrivilegeValue.cs">
<Link>Common\Interop\Interop.LookupPrivilegeValue.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\advapi32\Interop.RevertToSelf.cs">
<Link>Common\Interop\Interop.RevertToSelf.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\kernel32\Interop.LocalFree.cs">
<Link>Common\Interop\Interop.LocalFree.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\advapi32\Interop.ConvertSdToStringSd.cs">
<Link>Common\Interop\Interop.ConvertSdToStringSd.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\advapi32\Interop.ConvertStringSdToSd.cs">
<Link>Common\Interop\Interop.ConvertStringSdToSd.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\advapi32\Interop.GetSecurityInfoByHandle.cs">
<Link>Common\Interop\Interop.GetSecurityInfoByHandle.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\advapi32\Interop.SetSecurityInfoByHandle.cs">
<Link>Common\Interop\Interop.SetSecurityInfoByHandle.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\advapi32\Interop.GetSecurityInfoByName.cs">
<Link>Common\Interop\Interop.GetSecurityInfoByName.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\advapi32\Interop.SetSecurityInfoByName.cs">
<Link>Common\Interop\Interop.SetSecurityInfoByName.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\advapi32\Interop.GetSecurityDescriptorLength.cs">
<Link>Common\Interop\Interop.GetSecurityDescriptorLength.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\kernel32\Interop.CloseHandle.cs">
<Link>Common\Interop\Interop.CloseHandle.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\advapi32\Interop.OpenThreadToken_SafeTokenHandle.cs">
<Link>Common\Interop\Interop.OpenThreadToken_SafeTokenHandle.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\advapi32\Interop.OpenProcessToken_IntPtr.cs">
<Link>Common\Interop\Interop.OpenProcessToken_IntPtrs.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\kernel32\Interop.GetCurrentProcess_IntPtr.cs">
<Link>Common\Interop\Interop.GetCurrentProcess_IntPtr.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\advapi32\Interop.SetThreadToken.cs">
<Link>Common\Interop\Interop.SetThreadToken.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\kernel32\Interop.GetCurrentThread.cs">
<Link>Common\Interop\Interop.GetCurrentThread.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\advapi32\Interop.AdjustTokenPrivileges_TokenPrivilege.cs">
<Link>Common\Interop\Interop.AdjustTokenPrivileges_TokenPrivilege.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\advapi32\Interop.DuplicateTokenEx_SafeTokenHandle.cs">
<Link>Common\Interop\Interop.DuplicateTokenEx_SafeTokenHandle.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<Reference Include="System.Collections" />
<Reference Include="System.Diagnostics.Contracts" />
<Reference Include="System.Diagnostics.Debug" />
<Reference Include="System.Resources.ResourceManager" />
<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.Extensions" />
<Reference Include="System.Runtime.InteropServices" />
<Reference Include="System.Security.Principal.Windows" />
<Reference Include="System.Threading" />
<Reference Include="System.Threading.Thread" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
2e06ae2e9741f264b2c72ea5a726997046dfe89a

View File

@@ -0,0 +1,78 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Runtime.InteropServices;
namespace System.Security.AccessControl
{
[Flags]
public enum InheritanceFlags
{
None = 0x00,
ContainerInherit = 0x01,
ObjectInherit = 0x02,
}
[Flags]
public enum PropagationFlags
{
None = 0x00,
NoPropagateInherit = 0x01,
InheritOnly = 0x02,
}
[Flags]
public enum AuditFlags
{
None = 0x00,
Success = 0x01,
Failure = 0x02,
}
[Flags]
public enum SecurityInfos
{
Owner = 0x00000001,
Group = 0x00000002,
DiscretionaryAcl = 0x00000004,
SystemAcl = 0x00000008,
}
public enum ResourceType
{
Unknown = 0x00,
FileObject = 0x01,
Service = 0x02,
Printer = 0x03,
RegistryKey = 0x04,
LMShare = 0x05,
KernelObject = 0x06,
WindowObject = 0x07,
DSObject = 0x08,
DSObjectAll = 0x09,
ProviderDefined = 0x0A,
WmiGuidObject = 0x0B,
RegistryWow6432Key = 0x0C,
}
[Flags]
public enum AccessControlSections
{
None = 0,
Audit = 0x1,
Access = 0x2,
Owner = 0x4,
Group = 0x8,
All = 0xF
}
[Flags]
public enum AccessControlActions
{
None = 0,
View = 1,
Change = 2
}
}

View File

@@ -0,0 +1,373 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
/*============================================================
**
** Classes: NativeObjectSecurity class
**
**
===========================================================*/
using Microsoft.Win32;
using System;
using System.Collections;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Principal;
using FileNotFoundException = System.IO.FileNotFoundException;
namespace System.Security.AccessControl
{
public abstract class NativeObjectSecurity : CommonObjectSecurity
{
#region Private Members
private readonly ResourceType _resourceType;
private ExceptionFromErrorCode _exceptionFromErrorCode = null;
private object _exceptionContext = null;
private readonly uint ProtectedDiscretionaryAcl = 0x80000000;
private readonly uint ProtectedSystemAcl = 0x40000000;
private readonly uint UnprotectedDiscretionaryAcl = 0x20000000;
private readonly uint UnprotectedSystemAcl = 0x10000000;
#endregion
#region Delegates
protected internal delegate System.Exception ExceptionFromErrorCode(int errorCode, string name, SafeHandle handle, object context);
#endregion
#region Constructors
protected NativeObjectSecurity(bool isContainer, ResourceType resourceType)
: base(isContainer)
{
_resourceType = resourceType;
}
protected NativeObjectSecurity(bool isContainer, ResourceType resourceType, ExceptionFromErrorCode exceptionFromErrorCode, object exceptionContext)
: this(isContainer, resourceType)
{
_exceptionContext = exceptionContext;
_exceptionFromErrorCode = exceptionFromErrorCode;
}
internal NativeObjectSecurity(ResourceType resourceType, CommonSecurityDescriptor securityDescriptor)
: this(resourceType, securityDescriptor, null)
{
}
internal NativeObjectSecurity(ResourceType resourceType, CommonSecurityDescriptor securityDescriptor, ExceptionFromErrorCode exceptionFromErrorCode)
: base(securityDescriptor)
{
_resourceType = resourceType;
_exceptionFromErrorCode = exceptionFromErrorCode;
}
protected NativeObjectSecurity(bool isContainer, ResourceType resourceType, string name, AccessControlSections includeSections, ExceptionFromErrorCode exceptionFromErrorCode, object exceptionContext)
: this(resourceType, CreateInternal(resourceType, isContainer, name, null, includeSections, true, exceptionFromErrorCode, exceptionContext), exceptionFromErrorCode)
{
}
protected NativeObjectSecurity(bool isContainer, ResourceType resourceType, string name, AccessControlSections includeSections)
: this(isContainer, resourceType, name, includeSections, null, null)
{
}
protected NativeObjectSecurity(bool isContainer, ResourceType resourceType, SafeHandle handle, AccessControlSections includeSections, ExceptionFromErrorCode exceptionFromErrorCode, object exceptionContext)
: this(resourceType, CreateInternal(resourceType, isContainer, null, handle, includeSections, false, exceptionFromErrorCode, exceptionContext), exceptionFromErrorCode)
{
}
protected NativeObjectSecurity(bool isContainer, ResourceType resourceType, SafeHandle handle, AccessControlSections includeSections)
: this(isContainer, resourceType, handle, includeSections, null, null)
{
}
#endregion
#region Private Methods
private static CommonSecurityDescriptor CreateInternal(ResourceType resourceType, bool isContainer, string name, SafeHandle handle, AccessControlSections includeSections, bool createByName, ExceptionFromErrorCode exceptionFromErrorCode, object exceptionContext)
{
int error;
RawSecurityDescriptor rawSD;
if (createByName && name == null)
{
throw new ArgumentNullException(nameof(name));
}
else if (!createByName && handle == null)
{
throw new ArgumentNullException(nameof(handle));
}
error = Win32.GetSecurityInfo(resourceType, name, handle, includeSections, out rawSD);
if (error != Interop.Errors.ERROR_SUCCESS)
{
System.Exception exception = null;
if (exceptionFromErrorCode != null)
{
exception = exceptionFromErrorCode(error, name, handle, exceptionContext);
}
if (exception == null)
{
if (error == Interop.Errors.ERROR_ACCESS_DENIED)
{
exception = new UnauthorizedAccessException();
}
else if (error == Interop.Errors.ERROR_INVALID_OWNER)
{
exception = new InvalidOperationException(SR.AccessControl_InvalidOwner);
}
else if (error == Interop.Errors.ERROR_INVALID_PRIMARY_GROUP)
{
exception = new InvalidOperationException(SR.AccessControl_InvalidGroup);
}
else if (error == Interop.Errors.ERROR_INVALID_PARAMETER)
{
exception = new InvalidOperationException(SR.Format(SR.AccessControl_UnexpectedError, error));
}
else if (error == Interop.Errors.ERROR_INVALID_NAME)
{
exception = new ArgumentException(
SR.Argument_InvalidName,
nameof(name));
}
else if (error == Interop.Errors.ERROR_FILE_NOT_FOUND)
{
exception = (name == null ? new FileNotFoundException() : new FileNotFoundException(name));
}
else if (error == Interop.Errors.ERROR_NO_SECURITY_ON_OBJECT)
{
exception = new NotSupportedException(SR.AccessControl_NoAssociatedSecurity);
}
else
{
Debug.Assert(false, string.Format(CultureInfo.InvariantCulture, "Win32GetSecurityInfo() failed with unexpected error code {0}", error));
exception = new InvalidOperationException(SR.Format(SR.AccessControl_UnexpectedError, error));
}
}
throw exception;
}
return new CommonSecurityDescriptor(isContainer, false /* isDS */, rawSD, true);
}
//
// Attempts to persist the security descriptor onto the object
//
private void Persist(string name, SafeHandle handle, AccessControlSections includeSections, object exceptionContext)
{
WriteLock();
try
{
int error;
SecurityInfos securityInfo = 0;
SecurityIdentifier owner = null, group = null;
SystemAcl sacl = null;
DiscretionaryAcl dacl = null;
if ((includeSections & AccessControlSections.Owner) != 0 && _securityDescriptor.Owner != null)
{
securityInfo |= SecurityInfos.Owner;
owner = _securityDescriptor.Owner;
}
if ((includeSections & AccessControlSections.Group) != 0 && _securityDescriptor.Group != null)
{
securityInfo |= SecurityInfos.Group;
group = _securityDescriptor.Group;
}
if ((includeSections & AccessControlSections.Audit) != 0)
{
securityInfo |= SecurityInfos.SystemAcl;
if (_securityDescriptor.IsSystemAclPresent &&
_securityDescriptor.SystemAcl != null &&
_securityDescriptor.SystemAcl.Count > 0)
{
sacl = _securityDescriptor.SystemAcl;
}
else
{
sacl = null;
}
if ((_securityDescriptor.ControlFlags & ControlFlags.SystemAclProtected) != 0)
{
securityInfo = (SecurityInfos)((uint)securityInfo | ProtectedSystemAcl);
}
else
{
securityInfo = (SecurityInfos)((uint)securityInfo | UnprotectedSystemAcl);
}
}
if ((includeSections & AccessControlSections.Access) != 0 && _securityDescriptor.IsDiscretionaryAclPresent)
{
securityInfo |= SecurityInfos.DiscretionaryAcl;
// if the DACL is in fact a crafted replaced for NULL replacement, then we will persist it as NULL
if (_securityDescriptor.DiscretionaryAcl.EveryOneFullAccessForNullDacl)
{
dacl = null;
}
else
{
dacl = _securityDescriptor.DiscretionaryAcl;
}
if ((_securityDescriptor.ControlFlags & ControlFlags.DiscretionaryAclProtected) != 0)
{
securityInfo = (SecurityInfos)((uint)securityInfo | ProtectedDiscretionaryAcl);
}
else
{
securityInfo = (SecurityInfos)((uint)securityInfo | UnprotectedDiscretionaryAcl);
}
}
if (securityInfo == 0)
{
//
// Nothing to persist
//
return;
}
error = Win32.SetSecurityInfo(_resourceType, name, handle, securityInfo, owner, group, sacl, dacl);
if (error != Interop.Errors.ERROR_SUCCESS)
{
System.Exception exception = null;
if (_exceptionFromErrorCode != null)
{
exception = _exceptionFromErrorCode(error, name, handle, exceptionContext);
}
if (exception == null)
{
if (error == Interop.Errors.ERROR_ACCESS_DENIED)
{
exception = new UnauthorizedAccessException();
}
else if (error == Interop.Errors.ERROR_INVALID_OWNER)
{
exception = new InvalidOperationException(SR.AccessControl_InvalidOwner);
}
else if (error == Interop.Errors.ERROR_INVALID_PRIMARY_GROUP)
{
exception = new InvalidOperationException(SR.AccessControl_InvalidGroup);
}
else if (error == Interop.Errors.ERROR_INVALID_NAME)
{
exception = new ArgumentException(
SR.Argument_InvalidName,
nameof(name));
}
else if (error == Interop.Errors.ERROR_INVALID_HANDLE)
{
exception = new NotSupportedException(SR.AccessControl_InvalidHandle);
}
else if (error == Interop.Errors.ERROR_FILE_NOT_FOUND)
{
exception = new FileNotFoundException();
}
else if (error == Interop.Errors.ERROR_NO_SECURITY_ON_OBJECT)
{
exception = new NotSupportedException(SR.AccessControl_NoAssociatedSecurity);
}
else
{
Debug.Assert(false, string.Format(CultureInfo.InvariantCulture, "Unexpected error code {0}", error));
exception = new InvalidOperationException(SR.Format(SR.AccessControl_UnexpectedError, error));
}
}
throw exception;
}
//
// Everything goes well, let us clean the modified flags.
// We are in proper write lock, so just go ahead
//
this.OwnerModified = false;
this.GroupModified = false;
this.AccessRulesModified = false;
this.AuditRulesModified = false;
}
finally
{
WriteUnlock();
}
}
#endregion
#region Protected Methods
//
// Persists the changes made to the object
// by calling the underlying Windows API
//
// This overloaded method takes a name of an existing object
//
protected sealed override void Persist(string name, AccessControlSections includeSections)
{
Persist(name, includeSections, _exceptionContext);
}
protected void Persist(string name, AccessControlSections includeSections, object exceptionContext)
{
if (name == null)
{
throw new ArgumentNullException(nameof(name));
}
Contract.EndContractBlock();
Persist(name, null, includeSections, exceptionContext);
}
//
// Persists the changes made to the object
// by calling the underlying Windows API
//
// This overloaded method takes a handle to an existing object
//
protected sealed override void Persist(SafeHandle handle, AccessControlSections includeSections)
{
Persist(handle, includeSections, _exceptionContext);
}
protected void Persist(SafeHandle handle, AccessControlSections includeSections, object exceptionContext)
{
if (handle == null)
{
throw new ArgumentNullException(nameof(handle));
}
Contract.EndContractBlock();
Persist(null, handle, includeSections, exceptionContext);
}
#endregion
}
}

View File

@@ -0,0 +1,421 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
/*============================================================
**
** Class: ObjectSecurity
**
** Purpose: Generic Managed ACL wrapper
**
** Date: February 7, 2007
**
===========================================================*/
using System;
using System.Runtime.InteropServices;
using System.Security.AccessControl;
using System.Security.Principal;
using Microsoft.Win32.SafeHandles;
namespace System.Security.AccessControl
{
public class AccessRule<T> : AccessRule where T : struct
{
#region Constructors
//
// Constructors for creating access rules for file objects
//
public AccessRule(
IdentityReference identity,
T rights,
AccessControlType type)
: this(
identity,
(int)(object)rights,
false,
InheritanceFlags.None,
PropagationFlags.None,
type)
{ }
public AccessRule(
String identity,
T rights,
AccessControlType type)
: this(
new NTAccount(identity),
(int)(object)rights,
false,
InheritanceFlags.None,
PropagationFlags.None,
type)
{ }
//
// Constructor for creating access rules for folder objects
//
public AccessRule(
IdentityReference identity,
T rights,
InheritanceFlags inheritanceFlags,
PropagationFlags propagationFlags,
AccessControlType type)
: this(
identity,
(int)(object)rights,
false,
inheritanceFlags,
propagationFlags,
type)
{ }
public AccessRule(
String identity,
T rights,
InheritanceFlags inheritanceFlags,
PropagationFlags propagationFlags,
AccessControlType type)
: this(
new NTAccount(identity),
(int)(object)rights,
false,
inheritanceFlags,
propagationFlags,
type)
{ }
//
// Internal constructor to be called by public constructors
// and the access rule factory methods of ObjectSecurity
//
internal AccessRule(
IdentityReference identity,
int accessMask,
bool isInherited,
InheritanceFlags inheritanceFlags,
PropagationFlags propagationFlags,
AccessControlType type)
: base(
identity,
accessMask,
isInherited,
inheritanceFlags,
propagationFlags,
type)
{ }
#endregion
#region Public properties
public T Rights
{
get { return (T)(object)base.AccessMask; }
}
#endregion
}
public class AuditRule<T> : AuditRule where T : struct
{
#region Constructors
public AuditRule(
IdentityReference identity,
T rights,
AuditFlags flags)
: this(
identity,
rights,
InheritanceFlags.None,
PropagationFlags.None,
flags)
{
}
public AuditRule(
IdentityReference identity,
T rights,
InheritanceFlags inheritanceFlags,
PropagationFlags propagationFlags,
AuditFlags flags)
: this(
identity,
(int)(object)rights,
false,
inheritanceFlags,
propagationFlags,
flags)
{
}
public AuditRule(
String identity,
T rights,
AuditFlags flags)
: this(
new NTAccount(identity),
rights,
InheritanceFlags.None,
PropagationFlags.None,
flags)
{
}
public AuditRule(
String identity,
T rights,
InheritanceFlags inheritanceFlags,
PropagationFlags propagationFlags,
AuditFlags flags)
: this(
new NTAccount(identity),
(int)(object)rights,
false,
inheritanceFlags,
propagationFlags,
flags)
{
}
internal AuditRule(
IdentityReference identity,
int accessMask,
bool isInherited,
InheritanceFlags inheritanceFlags,
PropagationFlags propagationFlags,
AuditFlags flags)
: base(
identity,
accessMask,
isInherited,
inheritanceFlags,
propagationFlags,
flags)
{
}
#endregion
#region Public properties
public T Rights
{
get { return (T)(object)base.AccessMask; }
}
#endregion
}
public abstract class ObjectSecurity<T> : NativeObjectSecurity where T : struct
{
#region Constructors
protected ObjectSecurity(bool isContainer, ResourceType resourceType)
: base(isContainer, resourceType, null, null)
{ }
protected ObjectSecurity(bool isContainer, ResourceType resourceType, string name, AccessControlSections includeSections)
: base(isContainer, resourceType, name, includeSections, null, null)
{ }
protected ObjectSecurity(bool isContainer, ResourceType resourceType, string name, AccessControlSections includeSections, ExceptionFromErrorCode exceptionFromErrorCode, object exceptionContext)
: base(isContainer, resourceType, name, includeSections, exceptionFromErrorCode, exceptionContext)
{ }
protected ObjectSecurity(bool isContainer, ResourceType resourceType, SafeHandle safeHandle, AccessControlSections includeSections)
: base(isContainer, resourceType, safeHandle, includeSections, null, null)
{ }
protected ObjectSecurity(bool isContainer, ResourceType resourceType, SafeHandle safeHandle, AccessControlSections includeSections, ExceptionFromErrorCode exceptionFromErrorCode, object exceptionContext)
: base(isContainer, resourceType, safeHandle, includeSections, exceptionFromErrorCode, exceptionContext)
{ }
#endregion
#region Factories
public override AccessRule AccessRuleFactory(
IdentityReference identityReference,
int accessMask,
bool isInherited,
InheritanceFlags inheritanceFlags,
PropagationFlags propagationFlags,
AccessControlType type)
{
return new AccessRule<T>(
identityReference,
accessMask,
isInherited,
inheritanceFlags,
propagationFlags,
type);
}
public override AuditRule AuditRuleFactory(
IdentityReference identityReference,
int accessMask,
bool isInherited,
InheritanceFlags inheritanceFlags,
PropagationFlags propagationFlags,
AuditFlags flags)
{
return new AuditRule<T>(
identityReference,
accessMask,
isInherited,
inheritanceFlags,
propagationFlags,
flags);
}
#endregion
#region Private Methods
private AccessControlSections GetAccessControlSectionsFromChanges()
{
AccessControlSections persistRules = AccessControlSections.None;
if (AccessRulesModified)
{
persistRules = AccessControlSections.Access;
}
if (AuditRulesModified)
{
persistRules |= AccessControlSections.Audit;
}
if (OwnerModified)
{
persistRules |= AccessControlSections.Owner;
}
if (GroupModified)
{
persistRules |= AccessControlSections.Group;
}
return persistRules;
}
#endregion
#region Protected Methods
// Use this in your own Persist after you have demanded any appropriate CAS permissions.
// Note that you will want your version to be internal and use a specialized Safe Handle.
// <SecurityKernel Critical="True" Ring="0">
// <Asserts Name="Declarative: [SecurityPermission(SecurityAction.Assert, UnmanagedCode = true)]" />
// </SecurityKernel>
protected internal void Persist(SafeHandle handle)
{
WriteLock();
try
{
AccessControlSections persistRules = GetAccessControlSectionsFromChanges();
base.Persist(handle, persistRules);
OwnerModified = GroupModified = AuditRulesModified = AccessRulesModified = false;
}
finally
{
WriteUnlock();
}
}
// Use this in your own Persist after you have demanded any appropriate CAS permissions.
// Note that you will want your version to be internal.
protected internal void Persist(String name)
{
WriteLock();
try
{
AccessControlSections persistRules = GetAccessControlSectionsFromChanges();
base.Persist(name, persistRules);
OwnerModified = GroupModified = AuditRulesModified = AccessRulesModified = false;
}
finally
{
WriteUnlock();
}
}
#endregion
#region Public Methods
// Override these if you need to do some custom bit remapping to hide any
// complexity from the user.
public virtual void AddAccessRule(AccessRule<T> rule)
{
base.AddAccessRule(rule);
}
public virtual void SetAccessRule(AccessRule<T> rule)
{
base.SetAccessRule(rule);
}
public virtual void ResetAccessRule(AccessRule<T> rule)
{
base.ResetAccessRule(rule);
}
public virtual bool RemoveAccessRule(AccessRule<T> rule)
{
return base.RemoveAccessRule(rule);
}
public virtual void RemoveAccessRuleAll(AccessRule<T> rule)
{
base.RemoveAccessRuleAll(rule);
}
public virtual void RemoveAccessRuleSpecific(AccessRule<T> rule)
{
base.RemoveAccessRuleSpecific(rule);
}
public virtual void AddAuditRule(AuditRule<T> rule)
{
base.AddAuditRule(rule);
}
public virtual void SetAuditRule(AuditRule<T> rule)
{
base.SetAuditRule(rule);
}
public virtual bool RemoveAuditRule(AuditRule<T> rule)
{
return base.RemoveAuditRule(rule);
}
public virtual void RemoveAuditRuleAll(AuditRule<T> rule)
{
base.RemoveAuditRuleAll(rule);
}
public virtual void RemoveAuditRuleSpecific(AuditRule<T> rule)
{
base.RemoveAuditRuleSpecific(rule);
}
#endregion
#region some overrides
public override Type AccessRightType
{
get { return typeof(T); }
}
public override Type AccessRuleType
{
get { return typeof(AccessRule<T>); }
}
public override Type AuditRuleType
{
get { return typeof(AuditRule<T>); }
}
#endregion
}
}

View File

@@ -0,0 +1,54 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Globalization;
using System.Runtime.Serialization;
namespace System.Security.AccessControl
{
[Serializable]
public sealed class PrivilegeNotHeldException : UnauthorizedAccessException, ISerializable
{
private readonly string _privilegeName = null;
public PrivilegeNotHeldException()
: base(SR.PrivilegeNotHeld_Default)
{
}
public PrivilegeNotHeldException(string privilege)
: base(string.Format(CultureInfo.CurrentCulture, SR.PrivilegeNotHeld_Named, privilege))
{
_privilegeName = privilege;
}
public PrivilegeNotHeldException(string privilege, Exception inner)
: base(string.Format(CultureInfo.CurrentCulture, SR.PrivilegeNotHeld_Named, privilege), inner)
{
_privilegeName = privilege;
}
private PrivilegeNotHeldException(SerializationInfo info, StreamingContext context) : base(info, context)
{
_privilegeName = info.GetString(nameof(PrivilegeName));
}
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
if (info == null)
{
throw new ArgumentNullException(nameof(info));
}
base.GetObjectData(info, context);
info.AddValue(nameof(PrivilegeName), _privilegeName, typeof(string));
}
public string PrivilegeName
{
get { return _privilegeName; }
}
}
}

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