From: Marek Safar Date: Tue, 1 Jan 2019 22:15:36 +0000 (+0100) Subject: Tweaks permissions ifdefs in System.Diagnostics.Tracing (#21733) X-Git-Tag: accepted/tizen/unified/20190422.045933~244 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c6c48260173ab7d22d599e60f7ca98e0cfc06ec4;p=platform%2Fupstream%2Fcoreclr.git Tweaks permissions ifdefs in System.Diagnostics.Tracing (#21733) --- diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventDescriptor.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventDescriptor.cs index 0fed7b5..53017b7 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventDescriptor.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventDescriptor.cs @@ -22,9 +22,9 @@ namespace System.Diagnostics.Tracing #endif { [StructLayout(LayoutKind.Explicit, Size = 16)] -#if !CORECLR && !ES_BUILD_PN +#if ES_BUILD_STANDALONE [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] -#endif // !CORECLR && !ES_BUILD_PN +#endif /* EventDescriptor was public in the separate System.Diagnostics.Tracing assembly(pre NS2.0), diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventProvider.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventProvider.cs index 0624a17..d6e581e 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventProvider.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventProvider.cs @@ -55,9 +55,9 @@ namespace System.Diagnostics.Tracing /// Only here because System.Diagnostics.EventProvider needs one more extensibility hook (when it gets a /// controller callback) /// -#if !CORECLR && !ES_BUILD_PN +#if ES_BUILD_STANDALONE [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] -#endif // !CORECLR && !ES_BUILD_PN +#endif internal partial class EventProvider : IDisposable { // This is the windows EVENT_DATA_DESCRIPTOR structure. We expose it because this is what @@ -540,8 +540,10 @@ namespace System.Diagnostics.Tracing int etwSessionId; if (int.TryParse(strId, out etwSessionId)) { +#if ES_BUILD_STANDALONE // we need to assert this permission for partial trust scenarios (new RegistryPermission(RegistryPermissionAccess.Read, regKey)).Assert(); +#endif var data = key.GetValue(valueName) as byte[]; if (data != null) { @@ -608,7 +610,7 @@ namespace System.Diagnostics.Tracing string valueName = "ControllerData_Session_" + etwSessionId.ToString(CultureInfo.InvariantCulture); // we need to assert this permission for partial trust scenarios -#if !CORECLR +#if ES_BUILD_STANDALONE (new RegistryPermission(RegistryPermissionAccess.Read, regKey)).Assert(); #endif using (var key = Registry.LocalMachine.OpenSubKey(regKey)) diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs index e149a08..38f25cf 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs @@ -174,9 +174,9 @@ using System.Globalization; using System.Reflection; using System.Resources; using System.Security; -#if !CORECLR && !ES_BUILD_PN +#if ES_BUILD_STANDALONE using System.Security.Permissions; -#endif // !CORECLR && !ES_BUILD_PN +#endif using System.Text; using System.Threading; @@ -2740,7 +2740,7 @@ namespace System.Diagnostics.Tracing } if (s_currentPid == 0) { -#if ES_BUILD_STANDALONE && !ES_BUILD_PCL && !CORECLR +#if ES_BUILD_STANDALONE // for non-BCL EventSource we must assert SecurityPermission new SecurityPermission(PermissionState.Unrestricted).Assert(); #endif @@ -3508,7 +3508,7 @@ namespace System.Diagnostics.Tracing // RET // // If we find this pattern we return the XXX. Otherwise we return -1. -#if !CORECLR +#if ES_BUILD_STANDALONE (new ReflectionPermission(ReflectionPermissionFlag.MemberAccess)).Assert(); #endif byte[] instrs = method.GetMethodBody().GetILAsByteArray(); diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/StubEnvironment.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/StubEnvironment.cs index bd89f32..9773491 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/StubEnvironment.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/StubEnvironment.cs @@ -324,26 +324,6 @@ namespace Microsoft.Reflection } } -// Defining some no-ops in PCL builds -#if ES_BUILD_PCL -namespace System.Security -{ - class SuppressUnmanagedCodeSecurityAttribute : Attribute { } - - enum SecurityAction { Demand } -} - -namespace System.Security.Permissions -{ - class HostProtectionAttribute : Attribute { public bool MayLeakOnAbort { get; set; } } - class PermissionSetAttribute : Attribute - { - public PermissionSetAttribute(System.Security.SecurityAction action) { } - public bool Unrestricted { get; set; } - } -} -#endif - #if ES_BUILD_STANDALONE namespace Microsoft.Win32 {