You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 26, 2020. It is now read-only.
Repository navigation
This repository was archived by the owner on Jun 26, 2020. It is now read-only.
Give the embedded terminal access to host system #5
For the terminal to be really useful it should be able to use host access (through the HostCommand mechanism in flatpak). This requires upstream work but I report here as I guess it is the place where I might actually have an answer about the problem).
Reacted by Martijn Kruiten, Paul Ouellette and Claudio Cocciarelli
I think this and other tool running scenarios could be enabled by the following:
A D-Bus service that would (with some user-controlled whitelisting) run host binaries attached to caller-provided file descriptors for stdin/stdout/stderr, and provide lifecycle controls and signal proxying.
A "tool proxy" executable inside the container, which uses the D-Bus service to run the actual tool and serves as its container-side stand-in with regard to signals and exit status.
That's a complicated way to solve the issue, but I don't know any means for a child process to migrate from the container's namespaces out to the host.
@amtlib-dot-dll Is it possible to use bwrap inside the sandbox to get out of it? The binary is not currently available in the sandbox. Most tools also need access to the host filesystem.
I've done some reading up, which should have been a prerequisite... So 1. above could be provided by HostCommand API or its suitably "portalized" derivative. What about 2? Is it feasible to provide a generic tool wrapper that would use the Flatpak D-Bus service to run processes on the host, so that Visual Studio Code and other IDEs would not need modifications for running in a sandbox? Note that the embedded terminal widget itself does not need to run on the host.
Flatpak uses bubblewrap (a.k.a bwrap) for isolation
Flatpak instructs bubblewrap to create a new PID namespace and therefore you cannot see other processes in the host system
Flatpak instructs bubblewrap to create a new mount namespace and replace the /usr, /app, $(XDG_DATA_HOME) and so on directories with the sandboxed ones, so you cannot access the real /usr directory
You can call bubblewrap directly instead of running Flatpak
Personally I use Flatpak for isolation and I don't think that interacting with the outside world is a good idea. Why not use the non-Flatpaked version if you don't need isolation?
Yea it is certainly impossible to be sandboxed and not be sandboxed at the same time as they request. But as mentioned this requires deep redesign in the project, this isn't a toggle somebody can just make.
I'm thinking of a possible future where Flatpak is the way to distribute desktop applications. That future needs to have a solution for IDEs, terminal emulators, and the like.
The requirements on host filesystem access differ between the "tool runner" application itself and the tools the user may want to run from it. The former needs the sandbox runtime /usr to work, but the user-specified tools, shells, etc. are often expected to run outside the app container's namespace (at least until it's containers all the way down and the user doesn't ever need to access the host system).
This affects more than the pid namespace. It prevents access to header files and alternative tools that aren't part of the project but aren't in the permission list. For example, this compiler exists:
But the shell prompt in Visual Studio - OSS gives:
$ file /usr/bin/x86_64-w64-mingw32-gcc-win32
/usr/bin/x86_64-w64-mingw32-gcc-win32: cannot open `/usr/bin/x86_64-w64-mingw32-gcc-win32' (No such file or directory)
Some include files end up at unexpected locations, like the following. Again, the first output is from a terminal session and the second from the
Honestly I'm just going to close this as there seems to be a misunderstanding:
In order to run host binaries you must go through an abstraction like flatpak-spawn --host some-tool.
In order for the terminal to run on the host by default it requires contributing to vscode directly. This is not a package issue and cannot be resolved here.
Activity
TingPing commentedon Apr 9, 2018
That is very much not trivial work and would require upstream to genuinely care about the sandbox'd use-case in general.
thiblahute commentedon Apr 9, 2018
True, but without that this flatpak is mostly useless to me :-)
amtlib-dot-dll commentedon Apr 9, 2018
Sounds nice, but this might not be a priority for me. 😀 If you have a patch you can submit it here or directly to the upstream @thiblahute
juhp commentedon Apr 14, 2018
Actually not just the terminal, various extensions also need to run host system tools.
mzabaluev commentedon May 5, 2018
I think this and other tool running scenarios could be enabled by the following:
That's a complicated way to solve the issue, but I don't know any means for a child process to migrate from the container's namespaces out to the host.
amtlib-dot-dll commentedon May 5, 2018
@mzabaluev You may just run
bwrapdirectly and don't unshare the PID namespace https://github.com/projectatomic/bubblewrap/blob/master/bwrap.xml#L110mzabaluev commentedon May 5, 2018
@amtlib-dot-dll Is it possible to use bwrap inside the sandbox to get out of it? The binary is not currently available in the sandbox. Most tools also need access to the host filesystem.
mzabaluev commentedon May 5, 2018
I've done some reading up, which should have been a prerequisite... So 1. above could be provided by
HostCommandAPI or its suitably "portalized" derivative. What about 2? Is it feasible to provide a generic tool wrapper that would use the Flatpak D-Bus service to run processes on the host, so that Visual Studio Code and other IDEs would not need modifications for running in a sandbox? Note that the embedded terminal widget itself does not need to run on the host.amtlib-dot-dll commentedon May 5, 2018
No, I meant that
bwrap) for isolation/usr,/app,$(XDG_DATA_HOME)and so on directories with the sandboxed ones, so you cannot access the real/usrdirectoryMore info here and here
Personally I use Flatpak for isolation and I don't think that interacting with the outside world is a good idea. Why not use the non-Flatpaked version if you don't need isolation?
mzabaluev commentedon May 5, 2018
@amtlib-dot-dll I see. I'd like a solution that would work out of the box in Flatpak without giving the app the keys to the whole kingdom.
amtlib-dot-dll commentedon May 5, 2018
@mzabaluev Anyway, if you want something work out of the box, it should be insecure. It is hard to have both security and convenience.
TingPing commentedon May 5, 2018
An IDE is one tool where you simply have to forego security for usablity. See GNOME-Builder on how to handle this.
amtlib-dot-dll commentedon May 5, 2018
🤷♀️ Personally this is not essential to me so I added "help wanted" tag looking for someone else to deal with this
TingPing commentedon May 5, 2018
Yea it is certainly impossible to be sandboxed and not be sandboxed at the same time as they request. But as mentioned this requires deep redesign in the project, this isn't a toggle somebody can just make.
mzabaluev commentedon May 7, 2018
I'm thinking of a possible future where Flatpak is the way to distribute desktop applications. That future needs to have a solution for IDEs, terminal emulators, and the like.
The requirements on host filesystem access differ between the "tool runner" application itself and the tools the user may want to run from it. The former needs the sandbox runtime
/usrto work, but the user-specified tools, shells, etc. are often expected to run outside the app container's namespace (at least until it's containers all the way down and the user doesn't ever need to access the host system).amtlib-dot-dll commentedon May 7, 2018
Hmmm, can you add an option to share the PID namespace with the host in Flatpak? That is, remove the
--unshare-pidofbwrap@TingPing @alexlarsson 🤔TingPing commentedon May 7, 2018
@mzabaluev Again this is possible today, see GNOME-Builder, the tool just has to do it...
G-Ray commentedon Oct 15, 2018
Any update on this ? I switched back to the proprietary vscode binary because some extensions need to access the host.
Ben-Voris commentedon May 17, 2019
This affects more than the pid namespace. It prevents access to header files and alternative tools that aren't part of the project but aren't in the permission list. For example, this compiler exists:
But the shell prompt in Visual Studio - OSS gives:
Some include files end up at unexpected locations, like the following. Again, the first output is from a terminal session and the second from the
TingPing commentedon May 18, 2019
Honestly I'm just going to close this as there seems to be a misunderstanding:
In order to run host binaries you must go through an abstraction like
flatpak-spawn --host some-tool.In order for the terminal to run on the host by default it requires contributing to vscode directly. This is not a package issue and cannot be resolved here.