You've already forked linux-packaging-mono
Imported Upstream version 4.3.2.467
Former-commit-id: 9c2cb47f45fa221e661ab616387c9cda183f283d
This commit is contained in:
@@ -190,14 +190,18 @@ namespace System.Web.Hosting {
|
||||
_appManager.Close();
|
||||
}
|
||||
|
||||
internal static String ConstructSimpleAppName(string virtPath) {
|
||||
internal static String ConstructSimpleAppName(string virtPath, bool isDevEnvironment) {
|
||||
// devdiv 710164: Still repro - ctrl-f5 a WAP project might show "Cannot create/shadow copy when a file exists" error
|
||||
// since the hash file lists are different, IISExpress launched by VS cannot reuse the build result from VS build.
|
||||
// It deletes the build files generated by CBM and starts another round of build. This causes interruption between IISExpress and VS
|
||||
// and leads to this shallow copy exception.
|
||||
// fix: make the dev IISExpress build to a special drop location
|
||||
// devdiv 1038337: execution permission cannot be acquired under partial trust with ctrl-f5.
|
||||
// We previously use HostingEnvironment to determine whether it is under dev environment and the returned string. However,
|
||||
// for partial trust scenario, this method is called before HostingEnvironment has been initialized, we thus may return a wrong value.
|
||||
// To fix it, we requir the caller to pass in a flag indicating whether it is under dev environment.
|
||||
if (virtPath.Length <= 1) { // root?
|
||||
if (!BuildManagerHost.InClientBuildManager && HostingEnvironment.IsDevelopmentEnvironment)
|
||||
if (!BuildManagerHost.InClientBuildManager && isDevEnvironment)
|
||||
return "vs";
|
||||
else
|
||||
return "root";
|
||||
|
@@ -49,7 +49,8 @@ namespace System.Web.Hosting {
|
||||
|
||||
ApplicationManager appManager = ApplicationManager.GetApplicationManager();
|
||||
|
||||
String appId = (String.Concat(virtualDir, physicalDir).GetHashCode()).ToString("x");
|
||||
String appId = StringUtil.GetNonRandomizedHashCode(String.Concat(virtualDir, physicalDir)).ToString("x");
|
||||
|
||||
|
||||
ObjectHandle h = appManager.CreateInstanceInNewWorkerAppDomain(
|
||||
hostType, appId, VirtualPath.CreateNonRelative(virtualDir), physicalDir);
|
||||
|
@@ -57,6 +57,7 @@ namespace System.Web.Hosting {
|
||||
|
||||
public sealed class ApplicationManager : MarshalByRefObject {
|
||||
|
||||
private const string _clrQuirkAppSettingsAppContextPrefix = "AppContext.SetSwitch:";
|
||||
private const string _regexMatchTimeoutKey = "REGEX_DEFAULT_MATCH_TIMEOUT";
|
||||
private static readonly StrongName _mwiV1StrongName = GetMicrosoftWebInfrastructureV1StrongName();
|
||||
|
||||
@@ -734,6 +735,14 @@ namespace System.Web.Hosting {
|
||||
}
|
||||
}
|
||||
|
||||
// ApplicationManager is loaded into the default AppDomain
|
||||
// ASP.NET doesn't set string hash randomization for the defaul AppDomain, so we can assume the existing CLR implementation here is unchanged
|
||||
// Note, it won't work if <runtime/UseRandomizedStringHashAlgorithm enabled="1"> is used, because the entire process is subject to string hash randomization
|
||||
internal int GetNonRandomizedStringComparerHashCode(string s, bool ignoreCase) {
|
||||
StringComparer comparer = ignoreCase ? StringComparer.InvariantCultureIgnoreCase : StringComparer.InvariantCulture;
|
||||
return comparer.GetHashCode(s);
|
||||
}
|
||||
|
||||
//
|
||||
// communication with hosting environments
|
||||
//
|
||||
@@ -972,8 +981,10 @@ namespace System.Web.Hosting {
|
||||
customLoaderException.Throw();
|
||||
}
|
||||
|
||||
// DevDiv #392603 - disallow running applications when string hash code randomization is enabled
|
||||
if (EnvironmentInfo.IsStringHashCodeRandomizationEnabled) {
|
||||
// We support randomized string hash code, but not for the default AppDomain
|
||||
// Don't allow string hash randomization for the defaul AppDomain (i.e. <runtime/UseRandomizedStringHashAlgorithm enabled="1">)
|
||||
// Application should use AppSettings instead to opt-in.
|
||||
if (EnvironmentInfo.IsStringHashCodeRandomizationDetected) {
|
||||
throw new ConfigurationErrorsException(SR.GetString(SR.Require_stable_string_hash_codes));
|
||||
}
|
||||
|
||||
@@ -1009,7 +1020,7 @@ namespace System.Web.Hosting {
|
||||
// in the AppDomain data guarantees that it is available before the first call to the config system.
|
||||
FrameworkName targetFrameworkName = httpRuntimeSection.GetTargetFrameworkName();
|
||||
if (targetFrameworkName != null) {
|
||||
appDomainAdditionalData[BinaryCompatibility.TargetFrameworkKey] = targetFrameworkName;
|
||||
appDomainAdditionalData[System.Web.Util.BinaryCompatibility.TargetFrameworkKey] = targetFrameworkName;
|
||||
}
|
||||
|
||||
if (!skipAdditionalConfigChecks) {
|
||||
@@ -1028,7 +1039,39 @@ namespace System.Web.Hosting {
|
||||
AppSettingsSection appSettingsSection = appConfig.AppSettings;
|
||||
KeyValueConfigurationElement useTaskFriendlySynchronizationContextElement = appSettingsSection.Settings["aspnet:UseTaskFriendlySynchronizationContext"];
|
||||
if (!(useTaskFriendlySynchronizationContextElement != null && Boolean.TryParse(useTaskFriendlySynchronizationContextElement.Value, out requireHostExecutionContextManager))) {
|
||||
requireHostExecutionContextManager = new BinaryCompatibility(targetFrameworkName).TargetsAtLeastFramework45 ? true : false;
|
||||
requireHostExecutionContextManager = new System.Web.Util.BinaryCompatibility(targetFrameworkName).TargetsAtLeastFramework45 ? true : false;
|
||||
}
|
||||
|
||||
// DevDiv #390704 - Add support for randomized string hash algorithm
|
||||
KeyValueConfigurationElement useRandomizedStringHashAlgorithmElement = appSettingsSection.Settings["aspnet:UseRandomizedStringHashAlgorithm"];
|
||||
bool useRandomizedStringHashAlgorithm = false;
|
||||
if (useRandomizedStringHashAlgorithmElement != null && Boolean.TryParse(useRandomizedStringHashAlgorithmElement.Value, out useRandomizedStringHashAlgorithm)) {
|
||||
switches.UseRandomizedStringHashAlgorithm = useRandomizedStringHashAlgorithm;
|
||||
}
|
||||
|
||||
// DevDiv #1041102 - Allow specifying quirks via <appSettings> switches
|
||||
// The keys must begin with "AppContext.SetSwitch" and have a non-zero key name length,
|
||||
// and the values must be parseable as Booleans.
|
||||
Dictionary<string, bool> clrQuirks = null;
|
||||
foreach (KeyValueConfigurationElement element in appSettingsSection.Settings) {
|
||||
if (element.Key != null && element.Key.Length > _clrQuirkAppSettingsAppContextPrefix.Length && element.Key.StartsWith(_clrQuirkAppSettingsAppContextPrefix, StringComparison.OrdinalIgnoreCase)) {
|
||||
bool value;
|
||||
if (Boolean.TryParse(element.Value, out value)) {
|
||||
if (clrQuirks == null) {
|
||||
clrQuirks = new Dictionary<string, bool>();
|
||||
}
|
||||
|
||||
clrQuirks[element.Key.Substring(_clrQuirkAppSettingsAppContextPrefix.Length)] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (clrQuirks != null && clrQuirks.Count > 0) {
|
||||
if (hostingParameters == null) {
|
||||
hostingParameters = new HostingEnvironmentParameters();
|
||||
}
|
||||
|
||||
hostingParameters.ClrQuirksSwitches = clrQuirks.ToArray();
|
||||
}
|
||||
|
||||
// DevDiv #248126 - Allow configuration of FileChangeMonitor behavior
|
||||
@@ -1057,8 +1100,10 @@ namespace System.Web.Hosting {
|
||||
// we only do this check if <deployment retail="false" /> [the default value] is specified, since the
|
||||
// <deployment> element can only be set at machine-level in a hosted environment.
|
||||
DeploymentSection deploymentSection = (DeploymentSection)appConfig.GetSection("system.web/deployment");
|
||||
bool isDevEnvironment = false;
|
||||
if (deploymentSection != null && !deploymentSection.Retail && EnvironmentInfo.WasLaunchedFromDevelopmentEnvironment) {
|
||||
appDomainAdditionalData[".devEnvironment"] = true;
|
||||
isDevEnvironment = true;
|
||||
|
||||
// DevDiv #275724 - Allow LocalDB support in partial trust scenarios
|
||||
// Normally LocalDB requires full trust since it's the equivalent of unmanaged code execution. If this is
|
||||
@@ -1092,7 +1137,7 @@ namespace System.Web.Hosting {
|
||||
SecurityPolicySection securityPolicySection = (SecurityPolicySection)appConfig.GetSection("system.web/securityPolicy");
|
||||
CompilationSection compilationSection = (CompilationSection)appConfig.GetSection("system.web/compilation");
|
||||
FullTrustAssembliesSection fullTrustAssembliesSection = (FullTrustAssembliesSection)appConfig.GetSection("system.web/fullTrustAssemblies");
|
||||
policyLevel = GetPartialTrustPolicyLevel(trustSection, securityPolicySection, compilationSection, physicalPath, virtualPath);
|
||||
policyLevel = GetPartialTrustPolicyLevel(trustSection, securityPolicySection, compilationSection, physicalPath, virtualPath, isDevEnvironment);
|
||||
permissionSet = policyLevel.GetNamedPermissionSet(trustSection.PermissionSetName);
|
||||
if (permissionSet == null) {
|
||||
throw new ConfigurationErrorsException(SR.GetString(SR.Permission_set_not_found, trustSection.PermissionSetName));
|
||||
@@ -1331,10 +1376,14 @@ setup,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// devdiv 1038337: execution permission cannot be acquired under partial trust with ctrl-f5.
|
||||
// We build the codegen path in default domain. In order to build the right path,
|
||||
// caller must pass in a flag indicating whether it is under dev environment.
|
||||
[SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Justification = "We carefully control this method's caller.")]
|
||||
private static PolicyLevel GetPartialTrustPolicyLevel(
|
||||
TrustSection trustSection, SecurityPolicySection securityPolicySection,
|
||||
CompilationSection compilationSection, string physicalPath, VirtualPath virtualPath) {
|
||||
CompilationSection compilationSection, string physicalPath, VirtualPath virtualPath, bool isDevEnvironment) {
|
||||
if (securityPolicySection == null || securityPolicySection.TrustLevels[trustSection.Level] == null) {
|
||||
throw new ConfigurationErrorsException(SR.GetString(SR.Unable_to_get_policy_file, trustSection.Level), String.Empty, 0);
|
||||
}
|
||||
@@ -1405,7 +1454,7 @@ setup,
|
||||
tempDirectory = Path.Combine(tempDirectory, HttpRuntime.codegenDirName);
|
||||
}
|
||||
String simpleAppName = System.Web.Hosting.AppManagerAppDomainFactory.ConstructSimpleAppName(
|
||||
VirtualPath.GetVirtualPathStringNoTrailingSlash(virtualPath));
|
||||
VirtualPath.GetVirtualPathStringNoTrailingSlash(virtualPath), isDevEnvironment);
|
||||
String binDir = Path.Combine(tempDirectory, simpleAppName);
|
||||
binDir = FileUtil.RemoveTrailingDirectoryBackSlash(binDir);
|
||||
String binDirUrl = HttpRuntime.MakeFileUrl(binDir);
|
||||
@@ -1727,6 +1776,7 @@ setup,
|
||||
|
||||
private sealed class AppDomainSwitches {
|
||||
public bool UseLegacyCas;
|
||||
public bool UseRandomizedStringHashAlgorithm;
|
||||
|
||||
public void Apply(AppDomainSetup setup) {
|
||||
List<string> switches = new List<string>();
|
||||
@@ -1736,6 +1786,10 @@ setup,
|
||||
switches.Add("NetFx40_LegacySecurityPolicy");
|
||||
}
|
||||
|
||||
if (UseRandomizedStringHashAlgorithm) {
|
||||
switches.Add("UseRandomizedStringHashAlgorithm");
|
||||
}
|
||||
|
||||
if (switches.Count > 0) {
|
||||
setup.SetCompatibilitySwitches(switches);
|
||||
}
|
||||
@@ -1747,10 +1801,10 @@ setup,
|
||||
// This prevents accidental misuse of this type via querying the environment after user code has had a chance to
|
||||
// run, which could potentially affect the environment itself.
|
||||
private static class EnvironmentInfo {
|
||||
public static readonly bool IsStringHashCodeRandomizationEnabled = GetIsStringHashCodeRandomizationEnabled();
|
||||
public static readonly bool IsStringHashCodeRandomizationDetected = GetIsStringHashCodeRandomizationDetected();
|
||||
public static readonly bool WasLaunchedFromDevelopmentEnvironment = GetWasLaunchedFromDevelopmentEnvironmentValue();
|
||||
|
||||
private static bool GetIsStringHashCodeRandomizationEnabled() {
|
||||
private static bool GetIsStringHashCodeRandomizationDetected() {
|
||||
// known test vector
|
||||
return (StringComparer.InvariantCultureIgnoreCase.GetHashCode("The quick brown fox jumps over the lazy dog.") != 0x703e662e);
|
||||
}
|
||||
|
@@ -86,6 +86,11 @@ namespace System.Web.Hosting {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public KeyValuePair<string, bool>[] ClrQuirksSwitches {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class HostingEnvironment : MarshalByRefObject {
|
||||
@@ -279,6 +284,10 @@ namespace System.Web.Hosting {
|
||||
BuildManagerHost.SupportsMultiTargeting = true;
|
||||
}
|
||||
|
||||
// Set CLR quirks switches before the config system is initialized since config might depend on them
|
||||
if (_hostingParameters != null && _hostingParameters.ClrQuirksSwitches != null && _hostingParameters.ClrQuirksSwitches.Length > 0) {
|
||||
SetClrQuirksSwitches(_hostingParameters.ClrQuirksSwitches);
|
||||
}
|
||||
|
||||
//
|
||||
// init config system using private config if applicable
|
||||
@@ -434,6 +443,32 @@ namespace System.Web.Hosting {
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetClrQuirksSwitches(KeyValuePair<string, bool>[] switches) {
|
||||
// First, see if the static API AppContext.SetSwitch even exists.
|
||||
// Type.GetType will return null if the type doesn't exist; it will throw on catastrophic failure.
|
||||
|
||||
Type appContextType = Type.GetType("System.AppContext, " + AssemblyRef.Mscorlib);
|
||||
if (appContextType == null) {
|
||||
return; // wrong version of mscorlib - do nothing
|
||||
}
|
||||
|
||||
Action<string, bool> setter = (Action<string, bool>)Delegate.CreateDelegate(
|
||||
typeof(Action<string, bool>),
|
||||
appContextType,
|
||||
"SetSwitch",
|
||||
ignoreCase: false,
|
||||
throwOnBindFailure: false);
|
||||
if (setter == null) {
|
||||
return; // wrong version of mscorlib - do nothing
|
||||
}
|
||||
|
||||
// Finally, set each switch individually.
|
||||
|
||||
foreach (var sw in switches) {
|
||||
setter(sw.Key, sw.Value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If an exception was thrown during initialization, return it.
|
||||
public static Exception InitializationException {
|
||||
|
@@ -1 +1 @@
|
||||
104c2e5619eb888ddfb4a78df758a7759c7319be
|
||||
11db9517311df13fd3dac1b168d64148dc88a659
|
@@ -682,5 +682,30 @@ namespace System.Web.Hosting {
|
||||
[In, MarshalAs(UnmanagedType.BStr)] string sectionName,
|
||||
[In, MarshalAs(UnmanagedType.BStr)] string propertyName,
|
||||
[Out, MarshalAs(UnmanagedType.Struct)] out object value); // marshaled as VARIANT
|
||||
|
||||
[DllImport(_IIS_NATIVE_DLL)]
|
||||
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage", Justification = "We carefully control this method's callers.")]
|
||||
internal static extern int MgdPushPromise(
|
||||
[In] IntPtr context,
|
||||
[In, MarshalAs(UnmanagedType.LPWStr)] string path,
|
||||
[In, MarshalAs(UnmanagedType.LPWStr)] string queryString,
|
||||
[In, MarshalAs(UnmanagedType.LPStr)] string method,
|
||||
[In] int numHeaders,
|
||||
[In, MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPStr)] string[] headersNames,
|
||||
[In, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPStr)] string[] headersValues);
|
||||
|
||||
[DllImport(_IIS_NATIVE_DLL)]
|
||||
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage", Justification = "We carefully control this method's callers.")]
|
||||
internal static extern bool MgdIsAppPoolShuttingDown();
|
||||
|
||||
[DllImport(_IIS_NATIVE_DLL)]
|
||||
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage", Justification = "We carefully control this method's callers.")]
|
||||
internal static extern int MgdGetTlsTokenBindingIdentifiers(
|
||||
[In] IntPtr pHandler,
|
||||
[In, Out] ref IntPtr tokenBindingHandle,
|
||||
[Out] out IntPtr providedToken,
|
||||
[Out] out uint providedTokenSize,
|
||||
[Out] out IntPtr referredToken,
|
||||
[Out] out uint referredTokenSize);
|
||||
}
|
||||
}
|
||||
|
@@ -573,7 +573,17 @@ namespace System.Web.Hosting {
|
||||
}
|
||||
context.NotificationContext = new NotificationContext(flags /*CurrentNotificationFlags*/,
|
||||
isReEntry);
|
||||
|
||||
Action<RequestNotificationStatus> verifierCheck = null;
|
||||
if (AppVerifier.IsAppVerifierEnabled) {
|
||||
verifierCheck = AppVerifier.GetRequestNotificationStatusCheckDelegate(context, (RequestNotification)currentNotification, isPostNotification);
|
||||
}
|
||||
|
||||
status = HttpRuntime.ProcessRequestNotification(wr, context);
|
||||
|
||||
if (verifierCheck != null) {
|
||||
AppVerifier.InvokeVerifierCheck(verifierCheck, status);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
if (status != RequestNotificationStatus.Pending) {
|
||||
|
@@ -1 +1 @@
|
||||
6b26e37c0094170dda0b90f622c5fbe3165344f7
|
||||
ce3d178ea98df8349b79281a9f46ddb56a0a5d73
|
@@ -567,7 +567,7 @@ namespace System.Web.Hosting {
|
||||
|
||||
ISAPIApplicationHost appHost = CreateAppHost(appId, null);
|
||||
|
||||
// get app domaoin protocol handler type from config
|
||||
// get app domain protocol handler type from config
|
||||
Type handlerType = GetAppDomainProtocolHandlerType(protocolId);
|
||||
|
||||
AppDomainProtocolHandler handler = null;
|
||||
@@ -986,7 +986,7 @@ namespace System.Web.Hosting {
|
||||
|
||||
internal static void PreloadApplicationIfNotShuttingdown (string appId, LockableAppDomainContext ac) {
|
||||
// If GL_STOP_LISTENING wasn't triggered, the reset is likely due to a configuration change.
|
||||
if (ProcessHost.DefaultHost != null && !HostingEnvironment.StopListeningWasCalled) {
|
||||
if (ProcessHost.DefaultHost != null && !UnsafeIISMethods.MgdIsAppPoolShuttingDown()) {
|
||||
// Start the new app on another thread instead of hijacking the current app unloading thread
|
||||
ThreadPool.QueueUserWorkItem(new WaitCallback(delegate(object o) {
|
||||
lock (ac) {
|
||||
@@ -1007,7 +1007,7 @@ namespace System.Web.Hosting {
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// New for Dev10.
|
||||
// creates a new AppDomain, preloads and calls user code in it
|
||||
internal void PreloadApplicationIfRequired(
|
||||
|
31
external/referencesource/System.Web/Hosting/TlsTokenBindingInfo.cs
vendored
Normal file
31
external/referencesource/System.Web/Hosting/TlsTokenBindingInfo.cs
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="TlsTokenBindingInfo.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.Hosting {
|
||||
using System;
|
||||
|
||||
internal sealed class TlsTokenBindingInfo : ITlsTokenBindingInfo {
|
||||
private readonly byte[] _providedTokenBindingId;
|
||||
private readonly byte[] _referredTokenBindingId;
|
||||
|
||||
internal TlsTokenBindingInfo(byte[] providedTokenBindingId, byte[] referredTokenBindingId) {
|
||||
_providedTokenBindingId = providedTokenBindingId;
|
||||
_referredTokenBindingId = referredTokenBindingId;
|
||||
}
|
||||
|
||||
public byte[] GetProvidedTokenBindingId() {
|
||||
return (_providedTokenBindingId != null)
|
||||
? (byte[])_providedTokenBindingId.Clone()
|
||||
: null;
|
||||
}
|
||||
|
||||
public byte[] GetReferredTokenBindingId() {
|
||||
return (_referredTokenBindingId != null)
|
||||
? (byte[])_referredTokenBindingId.Clone()
|
||||
: null;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user