Skip to content

Error loading pwsh when home directory is Read Only. #6675

Closed

Description

@MichaelStankiewicz

Steps to reproduce

NOTE: Only validated this on a Linux host, but suspect it would be the same on Windows.

- Logon to a Linux endpoint.
- Set the HOME env var to a RO location (Read or Read/Execute).
- Launch pwsh

Interestingly, this seems to be caused by the fact that the PSREADLINE history file cannot be written.  However, if this is the case, the failure should be graceful and not halt the shell.  Further, the exception thrown is not indicative of the reason why pwsh is not loading.

Expected behavior

pwsh should load as exected.

Actual behavior

Receive the following error:
The shell cannot be started. A failure occurred during initialization:
The static PrimaryRunspace property can only be set once, and has already been set.


Environment data

Name                           Value
----                           -----
PSVersion                      6.0.0
PSEdition                      Core
GitCommitId                    v6.0.0
OS                             Linux 3.10.0-693.11.6.el7.x86_64 #1 SMP Thu Dec 28 14:23:39 EST 2017
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0


Activity

  1. MaximoTrinidad commented on Apr 18, 2018

    @MaximoTrinidad

    Hum!! Which Linux distro you're using? Redhat, Ubuntu, Kali..

    Also, have you try it with the latest version available for download? 6.1.0-preview.1

    :)

  2. psmulovics commented on Apr 18, 2018

    @psmulovics

    This with RHEL7, using the official 6.0.0 package

  3. MaximoTrinidad commented on Apr 18, 2018

    @MaximoTrinidad

    I'm may be misunderstanding this. So, before using pwsh, you're setting the user home to read / read execute. Why not leaving it system default permission for the user(s)?

    :)

  4. psmulovics commented on Apr 18, 2018

    @psmulovics

    We are having the user's home locked down. Eg. not writable by the user - this is a common approach for enterprises. That is just to provide repro steps.

  5. MaximoTrinidad commented on Apr 18, 2018

    @MaximoTrinidad

    Ah! Gotcha!!

  6. MaximoTrinidad commented on Apr 18, 2018

    @MaximoTrinidad

    I haven't try it at that level of security (yet). Interesting!
    Thanks for providing this point of view.
    :)

  7. psmulovics commented on Apr 18, 2018

    @psmulovics

    Sure thing. Another related problem (probably a separate issue in github) is the visibility of the files - both .cache and .local and all the files below has a filemask of 775/664 instead of 700/600. This opens a can of worms when comes to security.

  8. MaximoTrinidad commented on Apr 18, 2018

    @MaximoTrinidad

    Thank You for sharing! I'm getting to learn more about Linux after PowerShell became Open Source.
    I'll be checking this post. I know some of the PowerShell Team will post something. They good in responding.
    :)
    cc: Steve Lee (@SteveL-MSFT)

  9. SteveL-MSFT commented on Apr 20, 2018

    @SteveL-MSFT
    Member

    I tried this on Ubuntu and macOS and although I get errors from PSReadline complaining it can't write to the history file, pwsh still works. Can you try 6.1.0-Preview1?

  10. leojonathanoh commented on Apr 23, 2018

    @leojonathanoh

    like Steve Lee (@SteveL-MSFT), I'm on Ubuntu 16.04 with 6.1.0-Preview.

    On a service account user (with no writeable home), running interactively works:

    sudo -u svc_user -s pwsh
    PowerShell v6.1.0-preview.1
    Copyright (c) Microsoft Corporation. All rights reserved.
    
    https://aka.ms/pscore6-docs
    Type 'help' to get help.
    
    PS /root> exit
    Error reading or writing history file '/root/.local/share/powershell/PSReadLine/ConsoleHost_history.txt': Access to the path '/root/.local/share/powershell/PSReadLine/ConsoleHost_history.txt' is denied.

    That error message is about the not being able to write to the history file, but it doesn't prevent pwsh from being able to run.

  11. SteveL-MSFT commented on Apr 23, 2018

    @SteveL-MSFT
    Member

    Ok, if the concern is just that error message, you should open an issue in the PSReadline repo: https://github.com/lzybkr/PSReadLine

  12. added
    WG-Interactive-PSReadLine
    Resolution-External
    on Apr 23, 2018
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

    Resolution-ExternalWG-Interactive-PSReadLine

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions