wsl profile cannot have startingDirectory set to folder whose contents are unreadable #15763

Closed
opened 2026-01-31 04:47:45 +00:00 by claunia · 7 comments
Owner

Originally created by @jsb19gh on GitHub (Nov 2, 2021).

Windows Terminal version (or Windows build number)

1.11.2921.0

Other Software

No response

Steps to reproduce

Create a profile with

"commandline": "wsl -u root"
"startingDirectory": "\\\\wsl$\\Distro\\root"

Open a tab from that profile. Assumption is that /root is only readable by root in the Linux distribution.

Expected Behavior

A root prompt in Distro, with /root as the current directory.

Actual Behavior

No interactive prompt, and terminal tab has the text:

Access is denied.

[process exited with code 4294967295]

More info:
This worked in earlier Windows Terminal versions.
If I set that startingDirectory for a powershell tab, it works fine.
If I set the startingDirectory to "\\\\wsl$\\Distro", it works fine

Originally created by @jsb19gh on GitHub (Nov 2, 2021). ### Windows Terminal version (or Windows build number) 1.11.2921.0 ### Other Software _No response_ ### Steps to reproduce Create a profile with ``` "commandline": "wsl -u root" "startingDirectory": "\\\\wsl$\\Distro\\root" ``` Open a tab from that profile. Assumption is that /root is only readable by root in the Linux distribution. ### Expected Behavior A root prompt in Distro, with `/root` as the current directory. ### Actual Behavior No interactive prompt, and terminal tab has the text: ``` Access is denied. [process exited with code 4294967295] ``` More info: This worked in earlier Windows Terminal versions. If I set that startingDirectory for a powershell tab, it works fine. If I set the startingDirectory to `"\\\\wsl$\\Distro"`, it works fine
Author
Owner

@zadjii-msft commented on GitHub (Nov 2, 2021):

4294967295 is ERROR_UNHANDLED_ERROR, cool, that's useless.

Seems to work just fine from the commandline,

image

So this should work. huh.

@zadjii-msft commented on GitHub (Nov 2, 2021): `4294967295` is `ERROR_UNHANDLED_ERROR`, cool, that's useless. Seems to work just fine from the commandline, ![image](https://user-images.githubusercontent.com/18356694/139856418-9cab353d-71ff-4a18-be07-f3834b047173.png) So this _should_ work. huh.
Author
Owner

@DHowett commented on GitHub (Nov 3, 2021):

This is an interesting outcome from promoting the starting directory to --cd, actually.

Terminal ends up calling wsl --cd \\wsl$\Distro\root, not wsl --cd /root. wsl.exe attempts to open \\wsl$\Distro\root, fails because the Plan9 server throws it an access error, and then just aborts.

The thing is... at this point, Terminal is fully out of the equation. It doesn't control whether wsl aborts when it encounters this issue.

My only question is ...

This worked in earlier Windows Terminal versions.

What did it do? Where did it put you? That directory is illegal to access 😄

@DHowett commented on GitHub (Nov 3, 2021): This is an interesting outcome from promoting the starting directory to `--cd`, actually. Terminal ends up calling `wsl --cd \\wsl$\Distro\root`, _not_ `wsl --cd /root`. `wsl.exe` attempts to open `\\wsl$\Distro\root`, fails because the Plan9 server throws it an access error, and then just aborts. The thing is... at this point, Terminal is fully out of the equation. It doesn't control whether `wsl` aborts when it encounters this issue. My only question is ... > This worked in earlier Windows Terminal versions. _What did it do?_ Where did it put you? That directory is illegal to access :smile:
Author
Owner

@jsb19gh commented on GitHub (Nov 4, 2021):

It did what I wanted, I had a root prompt and the working directory was /root. You may not be able to access anything in the directory, but apparently you can still set it as your current folder. If you set that path as startingDirectory for a powershell instance instead, it will happily give you a powershell prompt. Get-ChildItem will give access denied of course, but it has no objections to making it the current folder. I suppose previously, Terminal set the current folder then started the wsl instance.

@jsb19gh commented on GitHub (Nov 4, 2021): It did what I wanted, I had a root prompt and the working directory was `/root`. You may not be able to access anything in the directory, but apparently you can still set it as your current folder. If you set that path as `startingDirectory` for a powershell instance instead, it will happily give you a powershell prompt. Get-ChildItem will give access denied of course, but it has no objections to making it the current folder. I suppose previously, Terminal set the current folder then started the wsl instance.
Author
Owner

@elsaco commented on GitHub (Nov 5, 2021):

WSL Ubuntu has /root permission set to 700. Relaxing it a bit (like 755) it will allow /root access.

Here's sample output from pwsh prompt after changing permission:

PS C:\Users\tux> ls '\\wsl$\Ubuntu-20.04\root'

    Directory: \\wsl$\Ubuntu-20.04\root

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----            5/3/2021  8:38 AM                .cache
-----           11/4/2021  6:26 PM            346 .bash_history
-----           12/5/2019  6:39 AM           3106 .bashrc
-----           11/4/2021  6:06 PM              0 .motd_shown
-----           12/5/2019  6:39 AM            161 .profile

PS C:\Users\tux>

Profile setting:

            {
                "colorScheme": "Campbell",
                "commandline": "C:\\Windows\\system32\\wsl.exe -d Ubuntu-20.04 -u root",
                "guid": "{ddd8505c-b727-4659-8496-a060f860cb7b}",
                "hidden": false,
                "icon": "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png",
                "name": "Ubuntu-Test",
                "startingDirectory": "\\\\wsl$\\Ubuntu-20.04\\root"
            }

However, relaxing /root file permissions might become a security issue.

@elsaco commented on GitHub (Nov 5, 2021): WSL Ubuntu has `/root` permission set to `700`. Relaxing it a bit (like `755`) it will allow `/root` access. Here's sample output from pwsh prompt after changing permission: ``` PS C:\Users\tux> ls '\\wsl$\Ubuntu-20.04\root' Directory: \\wsl$\Ubuntu-20.04\root Mode LastWriteTime Length Name ---- ------------- ------ ---- d---- 5/3/2021 8:38 AM .cache ----- 11/4/2021 6:26 PM 346 .bash_history ----- 12/5/2019 6:39 AM 3106 .bashrc ----- 11/4/2021 6:06 PM 0 .motd_shown ----- 12/5/2019 6:39 AM 161 .profile PS C:\Users\tux> ``` Profile setting: ``` { "colorScheme": "Campbell", "commandline": "C:\\Windows\\system32\\wsl.exe -d Ubuntu-20.04 -u root", "guid": "{ddd8505c-b727-4659-8496-a060f860cb7b}", "hidden": false, "icon": "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png", "name": "Ubuntu-Test", "startingDirectory": "\\\\wsl$\\Ubuntu-20.04\\root" } ``` However, relaxing `/root` file permissions might become a security issue.
Author
Owner

@Yangly0 commented on GitHub (Dec 24, 2021):

I have the same problems. l fixed it:
First, for terminal command

$ wsl
$ cd /
$ sudo chmod 755 root

Then, for terminal settings:

"commandline": "wsl.exe -d Ubuntu-16.04 -u root",  
"startingDirectory": "\\\\wsl$\\Ubuntu-16.04/root",  
@Yangly0 commented on GitHub (Dec 24, 2021): I have the same problems. l fixed it: First, for terminal command ```bash $ wsl $ cd / $ sudo chmod 755 root ```` Then, for terminal settings: ```json "commandline": "wsl.exe -d Ubuntu-16.04 -u root", "startingDirectory": "\\\\wsl$\\Ubuntu-16.04/root", ```
Author
Owner

@carlos-zamora commented on GitHub (Feb 8, 2023):

Is this still happening? Nowadays, we're recommending linux style paths for these kinds of scenarios.

@carlos-zamora commented on GitHub (Feb 8, 2023): Is this still happening? Nowadays, we're recommending linux style paths for these kinds of scenarios.
Author
Owner

@jsb19gh commented on GitHub (Feb 20, 2023):

It works fine if the Linux path is used. Continues to fail when specifying the Windows path, but that's harmless enough as long as it is clear in any documentation that the Linux path should be specified.

@jsb19gh commented on GitHub (Feb 20, 2023): It works fine if the Linux path is used. Continues to fail when specifying the Windows path, but that's harmless enough as long as it is clear in any documentation that the Linux path should be specified.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#15763