Skip to content

Investigate why Start-Job fails #452

Closed

Description

No description provided.

Activity

  1. palladia commented on Feb 2, 2016

    @palladia
    ContributorAuthor

    This is blocked by several issues (that I have found so far):

    1. LoadUserProfile doesn't work on Linux, and PoweShell executable does not have ".exe" suffix on Linux:

    --- a/monad/src/engine/hostifaces/PowerShellProcessInstance.cs
    +++ b/monad/src/engine/hostifaces/PowerShellProcessInstance.cs
    @@ -37,8 +37,9 @@ namespace System.Management.Automation.Runspaces
    ///

         static PowerShellProcessInstance()
         {
    
    •        string executable = Platform.IsWindows() ? "powershell.exe" : "powershell";^M
           PSExePath = Path.Combine(Utils.GetApplicationBase(Utils.DefaultPowerShellShellID),
      
    •                        "powershell.exe");
      
    •                        executable);^M
       }
      
       /// <summary>
      

      @@ -112,9 +113,13 @@ namespace System.Management.Automation.Runspaces
      RedirectStandardOutput = true,
      RedirectStandardError = true,
      CreateNoWindow = true,

    •                            LoadUserProfile = true,
                           };
      
    •        if (Platform.IsWindows())^M
      
    •        {^M
      
    •            _startInfo.LoadUserProfile = true;^M
      
    •        }^M
      

      +^M

    1. PowerShell is invoked with -s and -EncodedCommand, neither of which is supported by PSL. The "-s" option is undocumented. From PSCore Slack group:

    andrew [4:18 PM] 
    ServerMode aka 'OutOfProcessServer'
    ps_dev\admin\monad\src\host\msh\CommandLineParameterParser.cs(393): else if (MatchSwitch(switchKey, "servermode", "s"))

    andrew [4:25 PM] 
    basically this option runs
    System.Management.Automation.Remoting.Server.OutOfProcessMediator.Run(cpp.InitialCommand);
    in ps_dev\admin\monad\src\host\msh\ConsoleHost.cs

    paulhi [7:28 AM] 
    The -s option is to run PowerShell in server mode for out of process (background) jobs. There are two other server modes: socketservermode (-so), namedpipeservermode (-nam) that are used for Hyper-V/Container remoting. These modes are only used internally and so the switches are undocumented.

    1. To implement "-s" option mentioned in Import issues from VSO #2 above, you will hit a dependency on native WindowsIdentify. This is one possible workaround:

      --- a/monad/src/engine/remoting/server/OutOfProcServerMediator.cs
      +++ b/monad/src/engine/remoting/server/OutOfProcServerMediator.cs
      @@ -298,8 +298,20 @@ namespace System.Management.Automation.Remoting.Server

       protected OutOfProcessServerSessionTransportManager CreateSessionTransportManager(string configurationName)
       {
      
    2.        WindowsIdentity currentIdentity = WindowsIdentity.GetCurrent();
      
    3.        PSPrincipal userPrincipal = new PSPrincipal(new PSIdentity("", true, currentIdentity.Name, null),
      
    4.        string name;^M
      
    5.        WindowsIdentity currentIdentity;^M
      
    6.        if (Platform.IsWindows())^M
      
    7.        {^M
      
    8.            currentIdentity = WindowsIdentity.GetCurrent();^M
      
    9.            name = currentIdentity.Name;^M
      
    10.        }^M
      
    11.        else^M
      
    12.        {^M
      
    13.            currentIdentity = null;^M
      
    14.            name = Platform.NonWindowsGetUserName();^M
      
    15.        }^M
      

      +^M

    16.        PSPrincipal userPrincipal = new PSPrincipal(new PSIdentity("", true, name, null),^M
      
    17. Another native WIndows problem to be hit is related to CryptoLibrary. In monad/src/utils/CryptoUtils.cs, the constructor PSRSACryptoServiceProvider pinvokes Windows's CrytoAcquireContext(). The ideal way around this is to re-write the PSCrytoNativeUtils class with System.Security.Crytography.AesCryptoServiceProvider.

  2. palladia commented on Feb 2, 2016

    @palladia
    ContributorAuthor

    It looks like Waffle totally messed up the formatting of the comment.

  3. added
    Blocked
    and removed on Feb 2, 2016
  4. andyleejordan commented on Apr 8, 2016

    @andyleejordan
    Member

    Joey Aiello (@joeyaiello) This is the issue tracking start/stop job.

  5. modified the milestones: Preview 2, on Apr 20, 2016
  6. 14 remaining items

  7. added
    Issue-Bug
    WG-Cmdlets
    WG-Engine
    on Sep 1, 2016
  8. modified the milestones: , post-6.0.0 on Oct 17, 2016
  9. added
    Review - Needed
    and removed
    Review - Needed
    on Dec 1, 2016
  10. joeyaiello commented on Feb 8, 2017

    @joeyaiello
    Contributor

    According to jeffbi, this works fine now. He should be adding tests soon.

  11. added
    Resolution-Fixed
    and removed
    Review - Needed
    on Feb 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugResolution-FixedWG-CmdletsWG-Engine

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions