-
Notifications
You must be signed in to change notification settings - Fork 775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to run commandline-based AppX (Store Apps) #1632
Comments
If you want to run python scripts remotely, then you'll need to use fabric. This will still require python to be installed on the Linux host. Also keep in mind the latest fabric is different syntax than older ones but the newer one will still work on older python. Running fabric using win32 openssh does work as I've done it. |
That is a workaround, just as installing Python from the Python website rather than the Windows Store is a workaround. I've done the latter and everything is working for me now but that doesn't mean there's no bug in the way Win32-OpenSSH interacts with Store apps. I always had the idea that the Store was marketed as an analogue to Linux package managers, though over the last few months I've started to question that given the limitations imposed on and quirks experienced with Store apps.
Cmd over RDP:
Edit: Verified it myself:
|
That looks to be an issue with your PATH. Yes I'm using Python 3.8 from the Store, running a fabric task that also requires a password prompt due to use of sudo using win32-openssh to execute scripts(can be bash, python, etc.) on a remote Linux server using PS7 in Windows Terminal (but I have tested cmd as well). Be sure to follow the wiki installation for ssh and by the same token, ensure your python Scripts folder is also on PATH. Fabric and a number of other python packages go into the Script directory. CMD or PS rely on PATH in order to execute any number of tasks and is more obvious when a programming language like Python is being used. Additionally, most of the scripts I ran were used on a remote server. I only did the bare minimum on Windows for a connection to be established and execute each of the scripts on multiple hosts from a remote Linux server responsible for hosting those scripts |
Are you using Python 3.8 from the Store to invoke fab (locally) so that it executes Python code on another machine, which is running some Python not from the Store? Can you test from some machine A with my fabfile to some other machine B (MACHINENAME) which has Python 3.8 from the Store and correctly setup PATH? I explicitly added wronghello to show that there'd be a different error in case my PATH were wrong. The three test cases show correct execution of normal executables, no execution of python and a different error message for missing executables, respectively. Additionally, I got the same DesktopAppXProcess Error in the Event Log just like in the original bug report. My test setup for my previous comment was: To explicitly clear this up, the Scripts directory (%USERPROFILE%\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\Scripts) has been in my PATH during each test, on both machines. |
Just an FYI and clarification that I'm going to assume WSLUser is using OpenSSH client from Windows to a Linux box rather than server on Windows from Linux to Windows (my situation) to do this. I have still not been able to run Python from the Windows Store on a Windows machine through OpenSSH-Server. |
I have encountered a very similar issue, although not with OpenSSH, but with my own service that runs Python from the Windows Store. I believe it's the service part that is important - that is, Windows seems to be prohibiting services from running Windows Store apps. I tested this by writing a trivial program that just runs Python using This issue appeared after I updated to Windows 10 version 2004, so I assume that's where the change (bug?) was introduced. |
I can confirm that this is an issue with appx apps running remotely via OpenSSH. For me, it occurs when I try to run MS Store Installed winget via OpenSSH Server |
I installed PowerShell 7 from the Store on my Windows desktop (that basically acts as a server), and I couldn't set it as the default shell. Well, I could set it on the regkey, but trying to connect would give me a "session was closed" or something like that on client-side. Now I see that OpenSSH on the server could not load up pwsh.exe from WindowsApps or even my user folder symlink (store version creates it on install process). Installing the MSI from GitHub worked. If this is a limitation of Win32-OpenSSH, firstly that should be stated on Wiki or some doc, and then be fixed by Microsoft. |
@brunovieira97 - I guess the installation path is different when you try MSI vs windows store.
|
Hi all. Sorry for intruding on this conversation. I'm not using the same stuff, but I ran into a similar problem where using Python from a service was working fine before I upgraded Windows 10 from 1909 to 20H2. I ran across this topic while searching for the error message "The system cannot execute the specified program." Although I haven't tried it yet, I think the solution (at least for me) is to uninstall the Python "package" from the Microsoft Store and use the "Full Install" from python.org instead. FYI, see: https://docs.python.org/3/using/windows.html#the-microsoft-store-package |
As per SpecLad's comment:
What I've managed to find and experience is that there's some sort of sandbox that's transparently built up around any AppX that's executed, and that that, for some reason, does not work when it's ran in the OpenSSH service context. So for whatever reason, probably some obscure security thing, this won't work in the current state and that's a bad design choice IMO if one of the end goals is to have the Microsoft Store as the de facto place to install programs from in the future, because it breaks a lot of interoperability. It seems that it's the AppX subsystem that's disallowing this so it may need to be addressed there, but it also feels like the OpenSSH service isn't opening a proper login session for the connecting user, because the command is only started after authentication. In any case, none of my attempts at any layers of indirection have succeeded besides running a custom service in the context of the user itself, and that's not a solution I'd personally like to go with. So the AppX subsystem must not like the session I'm logged in to and the permission tokens granted to it, despite the user being on Admin level. I don't have enough knowledge of the inner working of Windows to debug this, nor do I have the time to figure it out. And yes @pnbruckner, doing a normal install by downloading and installing it manually from the Python website "solves the problem". Since it's not executed from the protected AppX environment, it has none of the artificial restrictions. I got fed up with this and needed to go on with my work, so I went that route. But it's not specific to Python, any AppX seems to suffer from the same problem. So while it is a workaround that allows me to do what I want, it is not (IMO) the best way to solve it because it defeats one of the goals of the MS Store: (aiding in) keeping software up-to-date (possibly automatically) without having to manually go into each package's publisher's website regularly. Despite the "workaround", this bug persists. |
I actually run OpenSSH manually via Task Scheduler in my user account so that I can login with my AzureAD account (not supported with the default service install) I still get the same error - so it's definitely related to security, but not to services in particular. |
Isn't Task Scheduler a service? :-) |
Task scheduler isn't More info too - running a cmd shell returns
Running a powershell shell returns
|
One more issue related to openssh on windows! Yay! :) |
This hit me on a CI VM where the jobs where started ssh-ing in. I had Python installed the default way (from the microsoft store), the link in
and python would start from the CMD ... but not in the CI job while in a ssh session! |
Store-distributed cli tools are exposed via a special type of reparsed points, so it needs an explicit support like cygwin/cygwin@e6d1078, libuv/libuv#2812, or python/cpython#15231. I guess SSH needs the same type of work. |
The comments are all over the place. Previously in windows 10, the store was confined to MSIX packages only. the problem is , MSIX packages are exposed in PATH through App Execution Aliases which itself are undocumented special NTFS reparse points which are stored in ~\appdata\local\microsoft\windowsapps\ directory; these Mysterious special reparse points seem to not launch from OpenSSH. that's the reason you can't launch MSIX packaged Cli tools directly without providing absolute path. |
It's kinda documented, although not well enough:
I think we'll want to fix somewhere around this function. |
@saschanaz - The issue is happening in an interactive SSH session i.e., the code in fileio.c wouldn't get executed. |
Windowsows Package Manager aka winget is a MSIX packaged tool and can't be run over SSH. this whole time some users including myself have been blaming MSIX for this only to know that the reason is openssh program itself. |
@mshaikhcool Welcome to bug triage in the open-source world! Since Windows has so many components, we often have to move bugs between a few owners before we can tell what's really going on. As the owner of conhost: We don't have any control over what processes get to run, but looking at that error report (specifically, that there is an issue in If I had to guess: the MSIX platform requires a different sort of user session than the one SSH provides; perhaps it needs interactive logon, perhaps it needs something else. We'll have to engage with somebody from the MSIX team! EDIT: This also suggests a possible cause for @SpecLad's service troubles, and is in line with @DataGhost's suspicion in #1632 (comment) |
TL;DR: given executable absolute path, if you(user who installed the app and NETWORK group) have read and execute permission on the whole PATH and the executable and it's dependencies, you can launch a packaged Cli app from OpenSSH session regardless of the it's only App Execution Aliases/special NTFS reparse points where all the trouble begin for OpenSSH. On a local Interactive login,
on a OpenSSH session,
Both 1. & 2. step are directly related to App Execution Aliases/special NTFS reparse point. that means OpenSSH is not handling these aliases. |
@mshaikhcool What's actually happening when you launch the executable through its direct path (in Before app execution aliases, the only way to execute an application that lived in a package was to explicitly break the package. That's all you're accomplishing this way, too. 😄 Further, launching a "Low IL" or "AppContainer" console application directly out of |
(Also: modifying the permissions on |
Nice, so mystery unfolded. that means it will require heavy engineering around NT Kernel's AppContainer SID. 'modifying the permissions' purpose was to see if openssh would launch it or not. |
@DHowett |
Ah. Even if they're using unvirtualized resources and are otherwise uncontained, they still get launched with a process token that includes their "package identity." This is necessary to support package ACLs and capabilities, even if the process isn't going to use them. |
Nice. Loving these App Execution Alias Mystery unfoldings. Thanks. |
I would like to add this datapoint: I spent quite a few hours last night trying to figure out why trying to execute When I Last night I thought this must be due to sshd running as "local system" in the service case, but based on this thread it looks like there might be additional complications due to the interaction between store apps and the openssh service? There seems to be a known "access is denied" issue with WSL specifically when it runs from local system (i.e. openssh service): microsoft/WSL#4803 -- also note the work-around implemented by tailscale in net/dns to start the child process in a different user context: tailscale/tailscale@6b9f820 |
Just to signal boost this: after updates (I think
I would appreciate any advice or workarounds. EDIT My issue is specifically related to this known issue: https://learn.microsoft.com/en-us/windows/wsl/store-release-notes#known-issues. Fix: uninstall the Windows Store version of WSL. Related issue: microsoft/WSL#7900 |
Has this been resolved? I am able to run WSL and store-installed apps, as documented in microsoft/WSL#7900 (comment) |
"OpenSSH for Windows" version
((Get-Item (Get-Command sshd).Source).VersionInfo.FileVersion)
7.7.2.3 (Installed through optional features)
8.1.0.0 (Installed manually)
Server OperatingSystem
((Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion\" -Name ProductName).ProductName)
Windows 10 Pro (x64, 2004, 10.0.19041.329), freshly-installed from an ISO created with the Media Creation Tool yesterday, fully updated and no other software installed.
Client OperatingSystem
Linux (Kubuntu 20.04)
What is failing
I installed Python 3.8 through the Windows Store, expecting to be able to execute Python scripts remotely through ssh. Everything works fine on the machine itself (directly or over RDP) but the interpreter won't start over ssh. One or more log entries appear in Event Viewer\Applications and Services Logs\Microsoft\Windows\AppModel-Runtime\Admin in either case. I have tried both the OpenSSH server version bundled with Windows, and the latest 8.1.0.0p1-Beta release. I have not had them installed side-by-side.
Expected output
Using cmd over RDP, both in regular and elevated prompts, in powershell as well:
or
Event log (excerpts):
Actual output
Using cmd over ssh:
or
Event log (excerpts):
Note the Chinese/garbled characters here as opposed to the cmd over RDP case.
Using powershell over ssh:
or
Event log shows the same as cmd over ssh, but three times (all identical) in the same second instead of once.
Oddity
Maybe interesting is that the Chinese/garbled characters in the Event Log are identical for each log entry in the same boot, even when changing OpenSSH versions (without reboot), restarting OpenSSH or reconnecting to it, also with different user accounts. After a reboot, the characters remain the same in all EventData fields except for ImageName, which gets different characters. Seems to be some uninitialised, though constant, buffer or pointer. None of the fields have garbled characters when starting python successfully (i.e. over RDP).
The text was updated successfully, but these errors were encountered: