PSReadLine icon indicating copy to clipboard operation
PSReadLine copied to clipboard

sudo su <user> to a user with pwsh as their default shell leads to an exception around PSReadLineHistoryFile

Open stoic-tcramer opened this issue 2 years ago • 0 comments

Prerequisites

  • [X] Write a descriptive title.
  • [X] Make sure you are able to repro it on the latest released version
  • [X] Search the existing issues, especially the pinned issues.

Exception report

Oops, something went wrong.
Please report this bug with ALL the details below, including both the 'Environment' and 'Exception' sections.
Please report on GitHub: https://github.com/PowerShell/PSReadLine/issues/new?template=Bug_Report.yaml
Thank you!

### Environment
PSReadLine: 2.2.6
PowerShell: 7.3.4
OS: Linux 5.15.0-1019-azure #24~20.04.1-Ubuntu SMP Tue Aug 23 15:52:52 UTC 2022
BufferWidth: 299
BufferHeight: 68

Last 0 Keys:



### Exception

System.IO.IOException: The system cannot open the device or file specified. : 'PSReadLineHistoryFile_3434894495'
   at System.Threading.Mutex.CreateMutexCore(Boolean initiallyOwned, String name, Boolean& createdNew)
   at Microsoft.PowerShell.PSConsoleReadLine.DelayedOneTimeInitialize()
   at Microsoft.PowerShell.PSConsoleReadLine.Initialize(Runspace runspace, EngineIntrinsics engineIntrinsics)
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics, CancellationToken cancellationToken, Nullable`1 lastRunStatus)

Screenshot

PS /p4/tcramer/root> whoami
tcramer PS /p4/tcramer/root> sudo su user2 PowerShell 7.3.4 PS /p4/user2/root> Oops, something went wrong.

Environment data

PS Version: 7.3.4
PS HostName: ConsoleHost
PSReadLine Version: 2.2.6
PSReadLine EditMode: Emacs
OS: Linux bf-p4scratch 5.15.0-1019-azure #24~20.04.1-Ubuntu SMP Tue Aug 23 15:52:52 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
BufferWidth: 299
BufferHeight: 68

Steps to reproduce

Install Powershell on Ubuntu Set a user's shell to pwsh (in the above it's set to /snap/powershell/current/opt/powershell/pwsh) sudo su from another user with sudo access

Expected behavior

A powershell prompt running under the provided to the sudo su command with no exceptions

Actual behavior

The above exception is thrown

stoic-tcramer avatar May 18 '23 04:05 stoic-tcramer