Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,7 @@ private bool VerifyTemplate(EventMetadata emd)
IgnoreProcessingInstructions = true,
MaxCharactersInDocument = 0, // no limit
ConformanceLevel = ConformanceLevel.Fragment,
#if !CORECLR
XmlResolver = null,
#endif
XmlResolver = null
};

int definedParameterCount = 0;
Expand Down
39 changes: 2 additions & 37 deletions src/Microsoft.WSMan.Management/CredSSP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,15 +330,6 @@ private void DeleteDelegateSettings(string applicationname, RegistryKey rootKey,
/// </summary>
protected override void BeginProcessing()
{
#if !CORECLR
if (Environment.OSVersion.Version.Major < 6)
{
//OS is XP/Win2k3. Throw error.
WSManHelper helper = new WSManHelper(this);
string message = helper.FormatResourceMsgFromResourcetext("CmdletNotAvailable");
throw new InvalidOperationException(message);
}
#endif
//If not running elevated, then throw an "elevation required" error message.
WSManHelper.ThrowIfNotAdministrator();

Expand Down Expand Up @@ -440,14 +431,6 @@ protected override void BeginProcessing()
//If not running elevated, then throw an "elevation required" error message.
WSManHelper.ThrowIfNotAdministrator();
helper = new WSManHelper(this);
#if !CORECLR
if (Environment.OSVersion.Version.Major < 6)
{
//OS is XP/Win2k3. Throw error.
string message = helper.FormatResourceMsgFromResourcetext("CmdletNotAvailable");
throw new InvalidOperationException(message);
}
#endif

// DelegateComputer cannot be specified when Role is other than client
if ((delegatecomputer != null) && !Role.Equals(Client, StringComparison.OrdinalIgnoreCase))
Expand Down Expand Up @@ -671,23 +654,15 @@ private void UpdateGPORegistrySettings(string applicationname, string[] delegate
//open the registry key.If key is not present,create a new one
Credential_Delegation_Key = rootKey.OpenSubKey(Registry_Path_Credentials_Delegation, true);
if (Credential_Delegation_Key == null)
Credential_Delegation_Key = rootKey.CreateSubKey(Registry_Path_Credentials_Delegation
#if !CORECLR
, RegistryKeyPermissionCheck.ReadWriteSubTree
#endif
);
Credential_Delegation_Key = rootKey.CreateSubKey(Registry_Path_Credentials_Delegation, RegistryKeyPermissionCheck.ReadWriteSubTree);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you decide to add RegistryKeyPermissionCheck parameter here?
It looks like the macro was removing it previously...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it was removed because CoreFX had not support. Now we have this and we can enable the check.


Credential_Delegation_Key.SetValue(helper.Key_Allow_Fresh_Credentials, 1, RegistryValueKind.DWord);
Credential_Delegation_Key.SetValue(helper.Key_Concatenate_Defaults_AllowFresh, 1, RegistryValueKind.DWord);

// add the delegate value
Allow_Fresh_Credential_Key = rootKey.OpenSubKey(Registry_Path_Credentials_Delegation + @"\" + helper.Key_Allow_Fresh_Credentials, true);
if (Allow_Fresh_Credential_Key == null)
Allow_Fresh_Credential_Key = rootKey.CreateSubKey(Registry_Path_Credentials_Delegation + @"\" + helper.Key_Allow_Fresh_Credentials
#if !CORECLR
, RegistryKeyPermissionCheck.ReadWriteSubTree
#endif
);
Allow_Fresh_Credential_Key = rootKey.CreateSubKey(Registry_Path_Credentials_Delegation + @"\" + helper.Key_Allow_Fresh_Credentials, RegistryKeyPermissionCheck.ReadWriteSubTree);

if (Allow_Fresh_Credential_Key != null)
{
Expand Down Expand Up @@ -833,17 +808,7 @@ protected override void BeginProcessing()
{
//If not running elevated, then throw an "elevation required" error message.
WSManHelper.ThrowIfNotAdministrator();

helper = new WSManHelper(this);
#if !CORECLR
if (Environment.OSVersion.Version.Major < 6)
{
//OS is XP/Win2k3. Throw error.
string message = helper.FormatResourceMsgFromResourcetext("CmdletNotAvailable");
throw new InvalidOperationException(message);
}
#endif

IWSManSession m_SessionObj = null;
try
{
Expand Down
7 changes: 2 additions & 5 deletions src/Microsoft.WSMan.Management/WsManHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -987,17 +987,14 @@ internal bool ValidateCredSSPRegistry(bool AllowFreshCredentialsValueShouldBePre
{
RegistryKey rGPOLocalMachineKey = Registry.LocalMachine.OpenSubKey(
Registry_Path_Credentials_Delegation + @"\CredentialsDelegation",
#if !CORECLR
RegistryKeyPermissionCheck.ReadWriteSubTree,
#endif
System.Security.AccessControl.RegistryRights.FullControl);

if (rGPOLocalMachineKey != null)
{
rGPOLocalMachineKey = rGPOLocalMachineKey.OpenSubKey(Key_Allow_Fresh_Credentials,
#if !CORECLR
rGPOLocalMachineKey = rGPOLocalMachineKey.OpenSubKey(
Key_Allow_Fresh_Credentials,
RegistryKeyPermissionCheck.ReadWriteSubTree,
#endif
System.Security.AccessControl.RegistryRights.FullControl);
if (rGPOLocalMachineKey == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
<ItemGroup>
<Compile Remove="cimSupport\cmdletization\xml\cmdlets-over-objects.objectModel.autogen.cs" />
<Compile Remove="cimSupport\cmdletization\xml\cmdlets-over-objects.xmlSerializer.autogen.cs" />
<Compile Remove="engine\CodeMethods.cs" />
<Compile Remove="engine\ComInterop\ArgBuilder.cs" />
<Compile Remove="engine\ComInterop\BoolArgBuilder.cs" />
<Compile Remove="engine\ComInterop\BoundDispEvent.cs" />
Expand Down
2 changes: 2 additions & 0 deletions src/System.Management.Automation/engine/CodeMethods.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#if !UNIX
using System;
using System.Collections;
using System.Reflection;
Expand Down Expand Up @@ -130,3 +131,4 @@ public static string ConvertDNWithBinaryToString(PSObject deInstance, PSObject d
#endregion
}
}
#endif
139 changes: 0 additions & 139 deletions src/System.Management.Automation/engine/InitialSessionState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3720,14 +3720,6 @@ internal PSSnapInInfo ImportPSSnapIn(PSSnapInInfo psSnapInInfo, out PSSnapInExce
throw e;
}

#if !CORECLR // CustomPSSnapIn Not Supported On CSS.
if (!String.IsNullOrEmpty(psSnapInInfo.CustomPSSnapInType))
{
LoadCustomPSSnapIn(psSnapInInfo);
warning = null;
return psSnapInInfo;
}
#endif
Assembly assembly = null;
string helpFile = null;

Expand Down Expand Up @@ -3875,137 +3867,6 @@ internal List<PSSnapInInfo> GetPSSnapIn(string psSnapinName)
return loadedSnapins;
}

#if !CORECLR // CustomPSSnapIn Not Supported On CSS.
/// <summary>
/// This is a "proxy" snapin that loads a subset of cmdlets from another snapin...
/// </summary>
/// <remarks>
/// CustomPSSnapIn derives from System.Configuration.Install, which is not in CoreCLR.
/// So CustomPSSnapIn is not supported on CSS.
/// </remarks>
/// <param name="psSnapInInfo">The snapin to examine.</param>
private void LoadCustomPSSnapIn(PSSnapInInfo psSnapInInfo)
{
if (psSnapInInfo == null)
return;

if (String.IsNullOrEmpty(psSnapInInfo.CustomPSSnapInType))
{
return;
}

Dictionary<string, SessionStateCmdletEntry> cmdlets = null;
Dictionary<string, SessionStateProviderEntry> providers = null;
Assembly assembly = null;

s_PSSnapInTracer.WriteLine("Loading assembly for mshsnapin {0}", psSnapInInfo.Name);

assembly = PSSnapInHelpers.LoadPSSnapInAssembly(psSnapInInfo, out cmdlets, out providers);

if (assembly == null)
{
s_PSSnapInTracer.TraceError("Loading assembly for mshsnapin {0} failed", psSnapInInfo.Name);
return;
}

CustomPSSnapIn customPSSnapIn = null;
try
{
Type type = assembly.GetType(psSnapInInfo.CustomPSSnapInType, true);

if (type != null)
{
customPSSnapIn = (CustomPSSnapIn)assembly.CreateInstance(psSnapInInfo.CustomPSSnapInType);
}

s_PSSnapInTracer.WriteLine("Loading assembly for mshsnapin {0} succeeded", psSnapInInfo.Name);
}
catch (TypeLoadException tle)
{
throw new PSSnapInException(psSnapInInfo.Name, tle.Message);
}
catch (ArgumentException ae)
{
throw new PSSnapInException(psSnapInInfo.Name, ae.Message);
}
catch (MissingMethodException mme)
{
throw new PSSnapInException(psSnapInInfo.Name, mme.Message);
}
catch (InvalidCastException ice)
{
throw new PSSnapInException(psSnapInInfo.Name, ice.Message);
}
catch (TargetInvocationException tie)
{
if (tie.InnerException != null)
{
throw new PSSnapInException(psSnapInInfo.Name, tie.InnerException.Message);
}

throw new PSSnapInException(psSnapInInfo.Name, tie.Message);
}

MergeCustomPSSnapIn(psSnapInInfo, customPSSnapIn);
}

private void MergeCustomPSSnapIn(PSSnapInInfo psSnapInInfo, CustomPSSnapIn customPSSnapIn)
{
if (psSnapInInfo == null || customPSSnapIn == null)
return;

s_PSSnapInTracer.WriteLine("Merging configuration from custom mshsnapin {0}", psSnapInInfo.Name);

if (customPSSnapIn.Cmdlets != null)
{
foreach (CmdletConfigurationEntry entry in customPSSnapIn.Cmdlets)
{
SessionStateCmdletEntry cmdlet = new SessionStateCmdletEntry(entry.Name, entry.ImplementingType, entry.HelpFileName);
cmdlet.SetPSSnapIn(psSnapInInfo);
this.Commands.Add(cmdlet);
}
}

if (customPSSnapIn.Providers != null)
{
foreach (ProviderConfigurationEntry entry in customPSSnapIn.Providers)
{
SessionStateProviderEntry provider = new SessionStateProviderEntry(entry.Name, entry.ImplementingType, entry.HelpFileName);
provider.SetPSSnapIn(psSnapInInfo);
this.Providers.Add(provider);
}
}

if (customPSSnapIn.Types != null)
{
foreach (TypeConfigurationEntry entry in customPSSnapIn.Types)
{
string path = Path.Combine(psSnapInInfo.ApplicationBase, entry.FileName);

SessionStateTypeEntry typeEntry = new SessionStateTypeEntry(path);
typeEntry.SetPSSnapIn(psSnapInInfo);
this.Types.Add(typeEntry);
}
}

if (customPSSnapIn.Formats != null)
{
foreach (FormatConfigurationEntry entry in customPSSnapIn.Formats)
{
string path = Path.Combine(psSnapInInfo.ApplicationBase, entry.FileName);

SessionStateFormatEntry formatEntry = new SessionStateFormatEntry(path);
formatEntry.SetPSSnapIn(psSnapInInfo);
this.Formats.Add(formatEntry);
}
}

SessionStateAssemblyEntry assemblyEntry = new SessionStateAssemblyEntry(psSnapInInfo.AssemblyName, psSnapInInfo.AbsoluteModulePath);

this.Assemblies.Add(assemblyEntry);
}
#endif

[SuppressMessage("Microsoft.Reliability", "CA2001:AvoidCallingProblematicMethods", MessageId = "System.Reflection.Assembly.LoadFrom")]
internal static Assembly LoadAssemblyFromFile(string fileName)
{
Expand Down
8 changes: 4 additions & 4 deletions src/System.Management.Automation/engine/Types_Ps1Xml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ public static IEnumerable<TypeData> Get()
}"), null));
yield return td4;

#if !CORECLR
#if !UNIX
var td5 = new TypeData(@"System.DirectoryServices.PropertyValueCollection", true);
td5.Members.Add("ToString",
new CodeMethodData("ToString", GetMethodInfo(typeof(Microsoft.PowerShell.ToStringCodeMethods), @"PropertyValueCollection")));
yield return td5;
#endif // !CORECLR
#endif

var td6 = new TypeData(@"System.Drawing.Printing.PrintDocument", true);
td6.Members.Add("Name",
Expand Down Expand Up @@ -169,7 +169,7 @@ public static IEnumerable<TypeData> Get()
}"), null));
yield return td17;

#if !CORECLR
#if !UNIX
var td18 = new TypeData(@"System.DirectoryServices.DirectoryEntry", true);
td18.Members.Add("ConvertLargeIntegerToInt64",
new CodeMethodData("ConvertLargeIntegerToInt64", GetMethodInfo(typeof(Microsoft.PowerShell.AdapterCodeMethods), @"ConvertLargeIntegerToInt64")));
Expand All @@ -178,7 +178,7 @@ public static IEnumerable<TypeData> Get()
td18.DefaultDisplayPropertySet =
new PropertySetData(new [] { "distinguishedName", "Path" }) { Name = "DefaultDisplayPropertySet" };
yield return td18;
#endif // !CORECLR
#endif

var td19 = new TypeData(@"System.IO.DirectoryInfo", true);
td19.Members.Add("Mode",
Expand Down
Loading