Skip to content

Commit

Permalink
Immediately exit if not running as a Flatpak
Browse files Browse the repository at this point in the history
  • Loading branch information
sonnyp committed Feb 28, 2023
1 parent da782e9 commit 230b011
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
17 changes: 6 additions & 11 deletions README.md
Expand Up @@ -14,12 +14,14 @@ Among other things, Workbench comes with

- realtime GTK/CSS preview
- library of examples
- 1000+ icons
- JavaScript and Vala support
- XML and Blueprint for describing user interface
- syntax highlighting, undo/redo, autosave, session restore
- code formatter
- console logs
- code linter and formatter
- terminal output
- 1000+ icons

ℹ️ Workbench is made possible by Flatpak. Only Flathub Workbench is supported.

**Testimonials**

Expand Down Expand Up @@ -62,18 +64,11 @@ Use GNOME Builder to start a new project using the appropriate GNOME Application

</details>


## Packaging

Please do not attempt to package Workbench any other way than as a Flatpak application.

It is unsupported and may put users at risk.

## Credits

Workbench would not be possible without

GTK, GLib, Flatpak, GtkSourceView, libadwaita, VTE, GJS, Blueprint, icon-development-kit, Vala
Flatpak, GTK, GLib, GtkSourceView, libadwaita, VTE, GJS, Blueprint, icon-development-kit, Vala

and the GNOME community 🖤

Expand Down
4 changes: 2 additions & 2 deletions data/app.metainfo.xml
Expand Up @@ -18,8 +18,8 @@
<li>JavaScript and Vala support</li>
<li>XML and Blueprint for describing user interface</li>
<li>syntax highlighting, undo/redo, autosave, session restore</li>
<li>code formatter, linter</li>
<li>console logs</li>
<li>code linter and formatter</li>
<li>terminal output</li>
<li>1000+ icons</li>
</ul>
</description>
Expand Down
8 changes: 8 additions & 0 deletions src/bin.js
Expand Up @@ -4,6 +4,7 @@ import { exit } from "system";
import GLib from "gi://GLib";
import { setConsoleLogDomain } from "console";
import Gio from "gi://Gio";
import Xdp from "gi://Xdp";

imports.package.init({
name: "@app_id@",
Expand All @@ -15,6 +16,13 @@ imports.package.init({
setConsoleLogDomain(pkg.name);
GLib.set_application_name("Workbench");

if (!Xdp.Portal.running_under_flatpak()) {
console.error(
"Workbench is only meant to be run sandboxed as a Flatpak and a specific target environment.\nBypassing this will exposes users to arbitrary code execution and breakage.",
);
exit(1);
}

const resource = Gio.resource_load("@pkgdatadir@/@app_id@.gresource");
Gio.resources_register(resource);

Expand Down

0 comments on commit 230b011

Please sign in to comment.