Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

SSH remoting cmdlet parameter set changes based on RFC 0010#2710

Merged
mirichmo merged 11 commits into
PowerShell:masterPowerShell/PowerShell:masterfrom
PaulHigin:RFCRemoteCmdletsCopy head branch name to clipboard
Dec 2, 2016
Merged

SSH remoting cmdlet parameter set changes based on RFC 0010#2710
mirichmo merged 11 commits into
PowerShell:masterPowerShell/PowerShell:masterfrom
PaulHigin:RFCRemoteCmdletsCopy head branch name to clipboard

Conversation

@PaulHigin

Copy link
Copy Markdown
Contributor

These changes implement the SSH remoting cmdlet parameter set changes as discussed in RFC 0010 and comments (https://github.com/PowerShell/PowerShell-RFC/blob/master/1-Draft/RFC0010-SSH-Remoting-Cmdlets.md).

These changes also include a fix that prevented built-in Windows PowerShell (FullCLR) from hosting a SSH remoting endpoint. The issue was with the managed code entry point attempting to update the console font before knowing if PowerShell is being run in console or server mode. SSH hosts PowerShell in server mode without a console handle and this was preventing PowerShell from starting as an endpoint. Fix is to move the font update code to console start where it knows what mode is running.

@PaulHigin PaulHigin added WG-Remoting PSRP issues with any transport layer and removed cla-not-required labels Nov 17, 2016
@mirichmo mirichmo self-assigned this Nov 18, 2016

It "New-PSSession SSHTransport parameter cannot have false value" {

[System.Management.Automation.ErrorRecord] $paramError = $null

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It is a good candidate for BeforeEach.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, will change.


Describe "SSHConnection parameter hashtable error conditions" -Tags 'CI' {

It "SSHConnection parameter hashtable cannot contain empty parameter names" {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Perhaps it would be better to use -Testcase in the Describe block.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, will change.

// For NanoServer:
// 1. There is no GetCurrentConsoleFontEx / SetCurrentConsoleFontEx on NanoServer;
// 2. We don't handle CJK locales on NanoServer due to lack of win32 API supports on NanoServer.
#if !CORECLR

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The comment doesn't match the specified environment. Nano Server (and IoT) are (Platform.IsInbox && Platform.IsCoreCLR) aka Platform.IsNanoServer() and Platform.IsIoT(). However, line 285 indicates that the code is for Windows PowerShell on full SKUs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't understand your comment. This code was simply moved from one place to another. Please feel free to update the comment as needed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

My request is for you to improve the existing comment since you are touching that bit of code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

#endregion
}

internal struct SSHConnection

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please comment this struct

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

/// Parse the Connection parameter HashTable array.
/// </summary>
/// <returns>Array of SSHConnection objects</returns>
private const string ComputerNameParameter = "ComputerName";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These should have their own region

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

{
connectionInfo.UserName = paramValue;
}
else if (paramName.Equals(KeyFilePathParameter, StringComparison.OrdinalIgnoreCase) || paramName.Equals(IdentityFilePathAlias, StringComparison.OrdinalIgnoreCase))

@mirichmo mirichmo Nov 21, 2016

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There are a lot of string comparisons here. I'm wondering about techniques to optimize the matching and if they are worth the perf gain.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What do you have in mind? Computer names, User names, and file paths cannot be made into enums since they are not known before hand. I am open to any suggestions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

After talking offline I think this is Ok as is. This parameter set is intended to support fan-out remoting where it is possible that 100s of target machines are specified in the hashtable. But I feel the parsing of these connection info objects is insignificant compared to setting up the remote runspaces needed for each connection. But this is something we can revisit if it turns out to be a perf problem.

}
}

if (string.IsNullOrEmpty(connectionInfo.ComputerName))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Based on the checks of lines 829 and 835, the only way this can be true is if it is not provided via ComputerName or HostName. What about just checking for that condition as a separate IF check after the checks on 815 and 820?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is possible for ComputerName or HostName to exist but contain only space characters. So the check would have to be a contains coupled with a not-empty check. It is easier to do the single check here.

#region Supress PSRemotingBaseCmdlet SSH hash parameter set

/// <summary>
/// Connection

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suppress?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes. Enter-PSSession cmdlet derives from a base cmdlet that defined SSHConnection parameter, which is not applicable here and must be suppressed. This is done throughout our code base.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

My comment was specific to the content of the comment on line 180. It is not clear. In other places you state, "Suppress Connection"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Got it. Fixed.

<value>The SSH client session has ended with no error message.</value>
</data>
<data name="MissingRequiredSSHParameter" xml:space="preserve">
<value>The provided SSHConnection hash table is missing the required ComputerName or HostName parameter.</value>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hashtable is a single word since it is referring to System.Collections.Hashtable

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

## SSH Remoting cmdlet tests
##

Describe "SSHTransport switch parameter value" -Tags 'CI' {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These should be "Feature" tests because they are all negative.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

}
catch { $paramError = $_ }

$paramError.FullyQualifiedErrorId | Should Match "ParameterArgumentValidationError"

@mirichmo mirichmo Nov 21, 2016

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do this check within the catch block and make it explicit:

$_.FullyQualifiedErrorId | Should Be "ParameterArgumentValidationError,<...>" <--Needs additional stuff to match the FQEID

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed catch block. We need "Should Match" because FQEIDs can and are augmented over time, which breaks tests.

}
}

Describe "SSHConnection parameter hashtable error conditions" -Tags 'CI' {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same comments for the previous Describe apply here too.

Are you going to add any positive test cases for this feature? If so, those should be added as "CI."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Functional tests will be added when SSH remoting can be enabled via Enable-SSHRemoting. Currently it is a manual process. See RFC.

throw new PSArgumentException(RemotingErrorIdStrings.InvalidSSHConnectionParameter);
}

if (paramName.Equals("ComputerName", StringComparison.OrdinalIgnoreCase) || paramName.Equals("HostName", StringComparison.OrdinalIgnoreCase))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should return error if we encounter both ComputerName and HostName (should be mutually exclusive) as it's ambiguous of the intent and probably a mistake.

{
connectionInfo.UserName = paramValue;
}
else if (paramName.Equals("KeyFilePath", StringComparison.OrdinalIgnoreCase) || paramName.Equals("IdentityFilePath", StringComparison.OrdinalIgnoreCase))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

KeyFilePath and IdentityFilePath should also be mutually exclusive

ParameterSetName = EnterPSSessionCommand.VMNameParameterSet)]
public String ConfigurationName { get; set; }

#region Supress PSRemotingBaseCmdlet SSH hash parameter set

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

'supress' is spelled wrong, but not sure why this word is even here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed. This cmdlet derives from a base cmdlet that includes the SSHConnection parameter. But this cmdlet cannot support SSHConnection hashtable (since Enter-PSSession works only on single session) and we have to remove it from the parameter set. This is common in our code base and the word "suppress" is used for this and I continued using the term here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This has not been addressed yet

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Not sure how I missed that. Fixed now.

…ers to no longer work. This fix separates the SSH parameter sets from the existing WinRM parameter sets.
@PowerShellTeam PowerShellTeam added Review - Needed The PR is being reviewed and removed Review - Waiting on Author labels Dec 1, 2016
@mirichmo

mirichmo commented Dec 2, 2016

Copy link
Copy Markdown
Member

@SteveL-MSFT Do you have any other comments or concerns? If not, I'd like to merge this PR.

@mirichmo mirichmo merged commit d2bf629 into PowerShell:master Dec 2, 2016
@PaulHigin PaulHigin deleted the RFCRemoteCmdlets branch December 7, 2016 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review - Needed The PR is being reviewed WG-Remoting PSRP issues with any transport layer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.