Imported Upstream version 5.16.0.100

Former-commit-id: 38faa55fb9669e35e7d8448b15c25dc447f25767
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-08-07 15:19:03 +00:00
parent 0a9828183b
commit 7d7f676260
4419 changed files with 170950 additions and 90273 deletions

View File

@@ -30,10 +30,10 @@ Global
{A0356E61-19E1-4722-A53D-5D2616E16312}.Debug|Any CPU.Build.0 = netstandard-Windows_NT-Debug|Any CPU
{A0356E61-19E1-4722-A53D-5D2616E16312}.Release|Any CPU.ActiveCfg = netstandard-Windows_NT-Release|Any CPU
{A0356E61-19E1-4722-A53D-5D2616E16312}.Release|Any CPU.Build.0 = netstandard-Windows_NT-Release|Any CPU
{40059634-BB03-4A6F-8657-CCE2D376BC8B}.Debug|Any CPU.ActiveCfg = netstandard-Windows_NT-Debug|Any CPU
{40059634-BB03-4A6F-8657-CCE2D376BC8B}.Debug|Any CPU.Build.0 = netstandard-Windows_NT-Debug|Any CPU
{40059634-BB03-4A6F-8657-CCE2D376BC8B}.Release|Any CPU.ActiveCfg = netstandard-Windows_NT-Release|Any CPU
{40059634-BB03-4A6F-8657-CCE2D376BC8B}.Release|Any CPU.Build.0 = netstandard-Windows_NT-Release|Any CPU
{40059634-BB03-4A6F-8657-CCE2D376BC8B}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
{40059634-BB03-4A6F-8657-CCE2D376BC8B}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
{40059634-BB03-4A6F-8657-CCE2D376BC8B}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
{40059634-BB03-4A6F-8657-CCE2D376BC8B}.Release|Any CPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
{994DCE47-4CF6-479D-AB1D-4EA6A2809C34}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU
{994DCE47-4CF6-479D-AB1D-4EA6A2809C34}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU
{994DCE47-4CF6-479D-AB1D-4EA6A2809C34}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU

View File

@@ -4,5 +4,8 @@
<PropertyGroup>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
<AssemblyKey>MSFT</AssemblyKey>
<IsNETCoreApp>true</IsNETCoreApp>
<IsNETCoreAppRef>false</IsNETCoreAppRef>
<IsUAP>true</IsUAP>
</PropertyGroup>
</Project>

View File

@@ -3,7 +3,7 @@
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<ItemGroup>
<ProjectReference Include="..\ref\System.IO.Pipes.AccessControl.csproj">
<SupportedFramework>net461;netcoreapp2.0;$(AllXamarinFrameworks)</SupportedFramework>
<SupportedFramework>net461;netcoreapp2.0;$(UAPvNextTFM);$(AllXamarinFrameworks)</SupportedFramework>
</ProjectReference>
<ProjectReference Include="..\src\System.IO.Pipes.AccessControl.csproj" />
<HarvestIncludePaths Include="ref/net46;lib/net46;runtimes/win/lib/net46" />
@@ -11,6 +11,10 @@
<SupportedFramework>netcore50</SupportedFramework>
</HarvestIncludePaths>
<HarvestIncludePaths Include="runtimes/win/lib/netstandard1.3;lib/netstandard1.3" />
<InboxOnTargetFramework Include="$(UAPvNextTFM)" />
<File Include="$(PlaceHolderFile)">
<TargetPath>runtimes/win/lib/$(UAPvNextTFM)</TargetPath>
</File>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -1,10 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildConfigurations>
<PackageConfigurations>
netfx-Windows_NT;
netcoreapp-Windows_NT;
netstandard-Windows_NT;
netstandard;
</PackageConfigurations>
<BuildConfigurations>
$(PackageConfigurations);
uap-Windows_NT;
</BuildConfigurations>
</PropertyGroup>
</Project>
</Project>

View File

@@ -4,32 +4,42 @@
<PropertyGroup>
<AssemblyName>System.IO.Pipes.AccessControl</AssemblyName>
<ProjectGuid>{40059634-BB03-4A6F-8657-CCE2D376BC8B}</ProjectGuid>
<AllowUnsafeBlocks Condition="'$(TargetGroup)'=='netstandard'">true</AllowUnsafeBlocks>
<IncludeDefaultReferences Condition="'$(TargetGroup)' == 'netcoreapp' OR '$(TargetGroup)' == 'uap'">false</IncludeDefaultReferences>
<AllowUnsafeBlocks Condition="'$(TargetGroup)' == 'netstandard'">true</AllowUnsafeBlocks>
<GeneratePlatformNotSupportedAssemblyMessage Condition="'$(TargetGroup)' == 'netstandard' AND '$(TargetsWindows)' != 'true'">SR.PlatformNotSupported_AccessControl</GeneratePlatformNotSupportedAssemblyMessage>
<IsPartialFacadeAssembly Condition="'$(TargetGroup)'=='netfx'">true</IsPartialFacadeAssembly>
<IsPartialFacadeAssembly Condition="'$(TargetGroup)' != 'netstandard'">true</IsPartialFacadeAssembly>
</PropertyGroup>
<!-- Default configurations to help VS understand the options -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Windows_NT-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Windows_NT-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Windows_NT-Release|AnyCPU'" />
<ItemGroup Condition="'$(IsPartialFacadeAssembly)'!='true' AND '$(TargetsWindows)'=='true'">
<Compile Include="System\IO\PipeSecurity.cs" />
<Compile Include="System\IO\PipeAccessRights.cs" />
<Compile Include="System\IO\PipeAccessRule.cs" />
<Compile Include="System\IO\PipeAuditRule.cs" />
<Compile Include="System\IO\PipesAclExtensions.cs" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Windows_NT-Release|AnyCPU'" />
<ItemGroup Condition="'$(TargetGroup)' == 'netstandard' AND '$(TargetsWindows)' == 'true'">
<Compile Include="..\..\System.IO.Pipes\src\System\IO\Pipes\PipeSecurity.cs" />
<Compile Include="..\..\System.IO.Pipes\src\System\IO\Pipes\PipeAccessRights.cs" />
<Compile Include="..\..\System.IO.Pipes\src\System\IO\Pipes\PipeAccessRule.cs" />
<Compile Include="..\..\System.IO.Pipes\src\System\IO\Pipes\PipeAuditRule.cs" />
<Compile Include="..\..\System.IO.Pipes\src\System\IO\Pipes\PipesAclExtensions.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)'=='netfx'">
<ItemGroup Condition="'$(TargetGroup)' == 'netfx'">
<Reference Include="mscorlib" />
<Reference Include="System.Core" />
<Compile Include="System\IO\PipesAclExtensions.net46.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)'!='netfx'">
<ItemGroup Condition="'$(TargetGroup)' == 'netstandard'">
<Reference Include="System.Security.AccessControl" />
<Reference Include="System.Security.Principal.Windows" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp' OR '$(TargetGroup)' == 'uap'">
<Reference Include="System.Runtime" />
<Reference Include="System.Resources.ResourceManager" />
<ProjectReference Include="..\..\System.IO.Pipes\src\System.IO.Pipes.csproj" />
<ProjectReference Include="..\..\System.Security.AccessControl\src\System.Security.AccessControl.csproj" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -1,52 +0,0 @@
// 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.
namespace System.IO.Pipes
{
[Flags]
public enum PipeAccessRights
{
// No None field - An ACE with the value 0 cannot grant nor deny.
ReadData = 0x000001,
WriteData = 0x000002,
// Note that all client named pipes require ReadAttributes access even if the user does not specify it.
// (This is because CreateFile slaps on the requirement before calling NTCreateFile (at least in WinXP SP2)).
ReadAttributes = 0x000080,
WriteAttributes = 0x000100,
// These aren't really needed since there is no operation that requires this access, but they are left here
// so that people can specify ACLs that others can open by specifying a PipeDirection rather than a
// PipeAccessRights (PipeDirection.In/Out maps to GENERIC_READ/WRITE access).
ReadExtendedAttributes = 0x000008,
WriteExtendedAttributes = 0x000010,
CreateNewInstance = 0x000004, // AppendData
// Again, this is not needed but it should be here so that our FullControl matches windows.
Delete = 0x010000,
ReadPermissions = 0x020000,
ChangePermissions = 0x040000,
TakeOwnership = 0x080000,
Synchronize = 0x100000,
FullControl = ReadData | WriteData | ReadAttributes | ReadExtendedAttributes |
WriteAttributes | WriteExtendedAttributes | CreateNewInstance |
Delete | ReadPermissions | ChangePermissions | TakeOwnership |
Synchronize,
Read = ReadData | ReadAttributes | ReadExtendedAttributes | ReadPermissions,
Write = WriteData | WriteAttributes | WriteExtendedAttributes, // | CreateNewInstance, For security, I really don't this CreateNewInstance belongs here.
ReadWrite = Read | Write,
// These are somewhat similar to what you get if you use PipeDirection:
//In = ReadData | ReadAttributes | ReadExtendedAttributes | ReadPermissions,
//Out = WriteData | WriteAttributes | WriteExtendedAttributes | ChangePermissions | CreateNewInstance | ReadAttributes, // NOTE: Not sure if ReadAttributes should really be here
//InOut = In | Out,
AccessSystemSecurity = 0x01000000, // Allow changes to SACL.
}
}

View File

@@ -1,74 +0,0 @@
// 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.Security.AccessControl;
using System.Security.Principal;
namespace System.IO.Pipes
{
// [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)]
public sealed class PipeAccessRule : AccessRule
{
//
// Constructor for creating access rules for pipe objects
//
public PipeAccessRule( String identity, PipeAccessRights rights, AccessControlType type)
: this( new NTAccount(identity), AccessMaskFromRights(rights, type), false, type)
{
}
public PipeAccessRule( IdentityReference identity, PipeAccessRights rights, AccessControlType type)
: this(identity, AccessMaskFromRights(rights, type), false, type)
{
}
//
// Internal constructor to be called by public constructors
// and the access rights factory methods
//
internal PipeAccessRule( IdentityReference identity, int accessMask, bool isInherited, AccessControlType type)
: base( identity, accessMask, isInherited, InheritanceFlags.None, PropagationFlags.None, type)
{
}
public PipeAccessRights PipeAccessRights
{
get
{
return RightsFromAccessMask(base.AccessMask);
}
}
// ACL's on pipes have a SYNCHRONIZE bit, and CreateFile ALWAYS asks for it.
// So for allows, let's always include this bit, and for denies, let's never
// include this bit unless we're denying full control. This is the right
// thing for users, even if it does make the model look asymmetrical from a
// purist point of view.
internal static int AccessMaskFromRights(PipeAccessRights rights, AccessControlType controlType)
{
if (rights < (PipeAccessRights)0 || rights > (PipeAccessRights.FullControl | PipeAccessRights.AccessSystemSecurity))
throw new ArgumentOutOfRangeException(nameof(rights), SR.ArgumentOutOfRange_NeedValidPipeAccessRights);
if (controlType == AccessControlType.Allow)
{
rights |= PipeAccessRights.Synchronize;
}
else if (controlType == AccessControlType.Deny)
{
if (rights != PipeAccessRights.FullControl)
{
rights &= ~PipeAccessRights.Synchronize;
}
}
return (int)rights;
}
internal static PipeAccessRights RightsFromAccessMask(int accessMask)
{
return (PipeAccessRights)accessMask;
}
}
}

View File

@@ -1,71 +0,0 @@
// 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.Security.AccessControl;
using System.Security.Principal;
namespace System.IO.Pipes
{
//[System.Security.Permissions.HostProtection(MayLeakOnAbort = true)]
public sealed class PipeAuditRule : AuditRule
{
public PipeAuditRule(
IdentityReference identity,
PipeAccessRights rights,
AuditFlags flags)
: this(
identity,
AccessMaskFromRights(rights),
false,
flags)
{
}
public PipeAuditRule(
String identity,
PipeAccessRights rights,
AuditFlags flags)
: this(
new NTAccount(identity),
AccessMaskFromRights(rights),
false,
flags)
{
}
internal PipeAuditRule(
IdentityReference identity,
int accessMask,
bool isInherited,
AuditFlags flags)
: base(
identity,
accessMask,
isInherited,
InheritanceFlags.None,
PropagationFlags.None,
flags)
{
}
private static int AccessMaskFromRights(PipeAccessRights rights)
{
if (rights < (PipeAccessRights)0 || rights > (PipeAccessRights.FullControl | PipeAccessRights.AccessSystemSecurity))
{
throw new ArgumentOutOfRangeException(nameof(rights), SR.ArgumentOutOfRange_NeedValidPipeAccessRights);
}
return (int)rights;
}
public PipeAccessRights PipeAccessRights
{
get
{
return PipeAccessRule.RightsFromAccessMask(base.AccessMask);
}
}
}
}

View File

@@ -1,276 +0,0 @@
// 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 Microsoft.Win32.SafeHandles;
using System.Security.AccessControl;
using System.Security.Principal;
using System.Runtime.InteropServices;
namespace System.IO.Pipes
{
//[System.Security.Permissions.HostProtection(MayLeakOnAbort = true)]
public class PipeSecurity : NativeObjectSecurity
{
public PipeSecurity()
: base(false, ResourceType.KernelObject) { }
// Used by PipeStream.GetAccessControl
internal PipeSecurity(SafePipeHandle safeHandle, AccessControlSections includeSections)
: base(false, ResourceType.KernelObject, safeHandle, includeSections) { }
public void AddAccessRule(PipeAccessRule rule)
{
if (rule == null)
throw new ArgumentNullException(nameof(rule));
base.AddAccessRule(rule);
}
public void SetAccessRule(PipeAccessRule rule)
{
if (rule == null)
throw new ArgumentNullException(nameof(rule));
base.SetAccessRule(rule);
}
public void ResetAccessRule(PipeAccessRule rule)
{
if (rule == null)
throw new ArgumentNullException(nameof(rule));
base.ResetAccessRule(rule);
}
public bool RemoveAccessRule(PipeAccessRule rule)
{
if (rule == null)
{
throw new ArgumentNullException(nameof(rule));
}
// If the rule to be removed matches what is there currently then
// remove it unaltered. That is, don't mask off the Synchronize bit.
AuthorizationRuleCollection rules = GetAccessRules(true, true, rule.IdentityReference.GetType());
for (int i = 0; i < rules.Count; i++)
{
PipeAccessRule fsrule = rules[i] as PipeAccessRule;
if ((fsrule != null) && (fsrule.PipeAccessRights == rule.PipeAccessRights)
&& (fsrule.IdentityReference == rule.IdentityReference)
&& (fsrule.AccessControlType == rule.AccessControlType))
{
return base.RemoveAccessRule(rule);
}
}
// It didn't exactly match any of the current rules so remove this way:
// mask off the synchronize bit (that is automatically added for Allow)
// before removing the ACL. The logic here should be same as Deny and hence
// fake a call to AccessMaskFromRights as though the ACL is for Deny
if (rule.PipeAccessRights != PipeAccessRights.FullControl)
{
return base.RemoveAccessRule(new PipeAccessRule(
rule.IdentityReference,
PipeAccessRule.AccessMaskFromRights(rule.PipeAccessRights, AccessControlType.Deny),
false,
rule.AccessControlType));
}
else
{
return base.RemoveAccessRule(rule);
}
}
public void RemoveAccessRuleSpecific(PipeAccessRule rule)
{
if (rule == null)
{
throw new ArgumentNullException(nameof(rule));
}
// If the rule to be removed matches what is there currently then
// remove it unaltered. That is, don't mask off the Synchronize bit
AuthorizationRuleCollection rules = GetAccessRules(true, true,
rule.IdentityReference.GetType());
for (int i = 0; i < rules.Count; i++)
{
PipeAccessRule fsrule = rules[i] as PipeAccessRule;
if ((fsrule != null) && (fsrule.PipeAccessRights == rule.PipeAccessRights)
&& (fsrule.IdentityReference == rule.IdentityReference)
&& (fsrule.AccessControlType == rule.AccessControlType))
{
base.RemoveAccessRuleSpecific(rule);
return;
}
}
// It wasn't an exact match so try masking the sychronize bit (that is
// automatically added for Allow) before removing the ACL. The logic
// here should be same as Deny and hence fake a call to
// AccessMaskFromRights as though the ACL is for Deny
if (rule.PipeAccessRights != PipeAccessRights.FullControl)
{
base.RemoveAccessRuleSpecific(new PipeAccessRule(rule.IdentityReference,
PipeAccessRule.AccessMaskFromRights(rule.PipeAccessRights, AccessControlType.Deny),
false,
rule.AccessControlType));
}
else
{
base.RemoveAccessRuleSpecific(rule);
}
}
public void AddAuditRule(PipeAuditRule rule)
{
base.AddAuditRule(rule);
}
public void SetAuditRule(PipeAuditRule rule)
{
base.SetAuditRule(rule);
}
public bool RemoveAuditRule(PipeAuditRule rule)
{
return base.RemoveAuditRule(rule);
}
public void RemoveAuditRuleAll(PipeAuditRule rule)
{
base.RemoveAuditRuleAll(rule);
}
public void RemoveAuditRuleSpecific(PipeAuditRule rule)
{
base.RemoveAuditRuleSpecific(rule);
}
public override AccessRule AccessRuleFactory(IdentityReference identityReference,
int accessMask, bool isInherited, InheritanceFlags inheritanceFlags,
PropagationFlags propagationFlags, AccessControlType type)
{
// Throw if inheritance flags or propagation flags set. Have to include in signature
// since this is an override
if (inheritanceFlags != InheritanceFlags.None)
{
throw new ArgumentException(SR.Argument_NonContainerInvalidAnyFlag, nameof(inheritanceFlags));
}
if (propagationFlags != PropagationFlags.None)
{
throw new ArgumentException(SR.Argument_NonContainerInvalidAnyFlag, nameof(propagationFlags));
}
return new PipeAccessRule(
identityReference,
accessMask,
isInherited,
type);
}
public sealed override AuditRule AuditRuleFactory(
IdentityReference identityReference,
int accessMask,
bool isInherited,
InheritanceFlags inheritanceFlags,
PropagationFlags propagationFlags,
AuditFlags flags)
{
// Throw if inheritance flags or propagation flags set. Have to include in signature
// since this is an override
if (inheritanceFlags != InheritanceFlags.None)
{
throw new ArgumentException(SR.Argument_NonContainerInvalidAnyFlag, nameof(inheritanceFlags));
}
if (propagationFlags != PropagationFlags.None)
{
throw new ArgumentException(SR.Argument_NonContainerInvalidAnyFlag, nameof(propagationFlags));
}
return new PipeAuditRule(
identityReference,
accessMask,
isInherited,
flags);
}
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;
}
protected internal void Persist(SafeHandle handle)
{
WriteLock();
try
{
AccessControlSections persistRules = GetAccessControlSectionsFromChanges();
base.Persist(handle, persistRules);
OwnerModified = GroupModified = AuditRulesModified = AccessRulesModified = false;
}
finally
{
WriteUnlock();
}
}
protected internal void Persist(String name)
{
WriteLock();
try
{
AccessControlSections persistRules = GetAccessControlSectionsFromChanges();
base.Persist(name, persistRules);
OwnerModified = GroupModified = AuditRulesModified = AccessRulesModified = false;
}
finally
{
WriteUnlock();
}
}
public override Type AccessRightType
{
get
{
return typeof(PipeAccessRights);
}
}
public override Type AccessRuleType
{
get
{
return typeof(PipeAccessRule);
}
}
public override Type AuditRuleType
{
get
{
return typeof(PipeAuditRule);
}
}
}
}

View File

@@ -1,41 +0,0 @@
// 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.IO;
using System.Security.AccessControl;
namespace System.IO.Pipes
{
public static class PipesAclExtensions
{
public static PipeSecurity GetAccessControl(this PipeStream stream)
{
// Checks that State != WaitingToConnect and State != Closed
var handle = stream.SafePipeHandle;
// PipeState must be Disconnected, Connected, or Broken
return new PipeSecurity(handle, AccessControlSections.Access | AccessControlSections.Owner | AccessControlSections.Group);
}
public static void SetAccessControl(this PipeStream stream, PipeSecurity pipeSecurity)
{
if (pipeSecurity == null)
{
throw new ArgumentNullException(nameof(pipeSecurity));
}
// Checks that State != WaitingToConnect and State != Closed
var handle = stream.SafePipeHandle;
// Checks that State != Broken
if (stream is NamedPipeClientStream && !stream.IsConnected)
{
throw new IOException(SR.IO_IO_PipeBroken);
}
// PipeState must be either Disconected or Connected
pipeSecurity.Persist(handle);
}
}
}