wsld icon indicating copy to clipboard operation
wsld copied to clipboard

WSL2: (os error 10013)

Open kayg04 opened this issue 3 years ago • 9 comments

Hello, as stated in the previous issue. I'm unable to run wsldhost.exe --daemon nor am I able to run wsldhost.exe <VMID>. Both of them result in the same error which is:

Failed to listen: An attempt was made to access a socket in a way forbidden by its access permissions. (os error 10013)

I have absolutely no idea what could be causing the issue. My own account is a standard account and I have a separate account which is in the administrator group. I am running the command in an elevated powershell prompt opened as an administrator.

EDIT1:

I downloaded the wsldhost.exe from the build artifact of your latest commit. wsld on the WSL2 instance has been installed using the command specified in the README. Additionally, I have tried excluding the exe from Windows Defender but that hasn't changed the result.

EDIT2:

Running wsld on the WSL2 instance obviously results in:

Cannot connect to wsldhost: Connection timed out (os error 110)

kayg04 avatar Jan 31 '21 15:01 kayg04

Hmm, I guess maybe you couldn't listen on another user's VM's socket? Have you tried to run wsldhost.exe <VMID> in the standard user under which the WSL2 run?

nbdd0121 avatar Jan 31 '21 18:01 nbdd0121

You're right.

Getting the VMID with hcsdiag list and then using it as the standard user worked. I also tested if the session would survive a hibernate or not, and it works beautifully.

But I think there would be an issue when I would reboot my PC, I'll have to manually get the VMID everytime?

kayg04 avatar Feb 01 '21 04:02 kayg04

Reboot will change VMID so yes.

I believe you don't need to be admin for the API. Can you try to add the standard user into the Hyper-V administrators group to see if hcsdiag list can be run without privilege elevation?

nbdd0121 avatar Feb 01 '21 04:02 nbdd0121

I also have this issue using wsl2. I added my account to Hyper-V Administrator group I still got the same error. (10013)

I have an LDAP account, and I tried with a Local Administrator account (which I putted in Hyper-V admins as you suggested, but without success) Any ways I cannot run the program the results is:

wsldhost.exe AB4A63F1-79B4-482E-AB9E-2CCD11314700 Failed to listen: Une tentative d’accès à un socket de manière interdite par ses autorisations d’accès a été tentée. (os error 10013)

Kwaadpepper avatar Apr 23 '21 04:04 Kwaadpepper

Can you try to add the standard user into the Hyper-V administrators group to see if hcsdiag list can be run without privilege elevation?

It does. I can also run wsldhost.exe without admin privileges after adding myself to the Hyper-V administrators.

Is it possible to just run wsldhost.exe as admin from a standard user account? I don't want to give my account privileges that are not needed.

kayg04 avatar Jun 02 '21 07:06 kayg04

It certainly is possible, e.g. by launching a service from admin that just report VMIDs, and let wsldhost retrieve VMID from that service.

Unfortunately this would require significant change and I don't have time for that; I also don't use a setup that allows me to test it.

nbdd0121 avatar Jun 02 '21 23:06 nbdd0121

The VMID is stored in registry under the key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\HostComputeService\VolatileStore\ComputeSystem. I found it quite by accident. I can get the VMID via regedit without admin privileges.

elebeaup avatar Sep 08 '21 16:09 elebeaup

Thanks for the note! I'll have a look.

nbdd0121 avatar Sep 08 '21 17:09 nbdd0121

Latest commit on the master branch has switched the VMID retrieval mechanism to registry.

nbdd0121 avatar Sep 09 '21 00:09 nbdd0121