Skip to content

Commit a846e67

Browse files
committed
feat: enable sandbox as a stable feature
(not all expected features are enabled but it works so let's give it to people as it is for now)
1 parent 018e84d commit a846e67

File tree

8 files changed

+16
-48
lines changed

8 files changed

+16
-48
lines changed

bottles/backend/managers/sandbox.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ def __init__(
4040
self.envs = envs
4141
self.chdir = chdir
4242
self.clear_env = clear_env
43-
self.share_paths_ro = share_paths_ro
44-
self.share_paths_rw = share_paths_rw
43+
self.share_paths_ro = list(share_paths_ro or [])
44+
self.share_paths_rw = list(share_paths_rw or [])
4545
self.share_net = share_net
4646
self.share_user = share_user
4747
self.share_host_ro = share_host_ro
@@ -74,7 +74,7 @@ def __get_bwrap(self, cmd: str):
7474

7575
if self.share_paths_rw:
7676
_cmd += [
77-
f"--bind {shlex.quote(p)} {shlex.quote(p)}" for p in self.share_paths_ro
77+
f"--bind {shlex.quote(p)} {shlex.quote(p)}" for p in self.share_paths_rw
7878
]
7979

8080
if self.share_sound:
@@ -95,21 +95,21 @@ def __get_bwrap(self, cmd: str):
9595
return _cmd
9696

9797
def __get_flatpak_spawn(self, cmd: str):
98-
_cmd = ["flatpak-spawn"]
98+
_cmd = ["flatpak-spawn", "--sandbox"]
9999

100100
if self.envs:
101101
_cmd += [f"--env={k}={shlex.quote(v)}" for k, v in self.envs.items()]
102102

103-
if self.share_host_ro:
104-
_cmd.append("--sandbox")
105-
_cmd.append("--sandbox-expose-path-ro=/")
103+
if self.clear_env:
104+
_cmd.append("--clear-env")
106105

107106
if self.chdir:
108-
_cmd.append(f"--directory={shlex.quote(self.chdir)}")
109-
_cmd.append(f"--sandbox-expose-path={shlex.quote(self.chdir)}")
107+
quoted_dir = shlex.quote(self.chdir)
108+
_cmd.append(f"--directory={quoted_dir}")
109+
_cmd.append(f"--sandbox-expose-path={quoted_dir}")
110110

111-
if self.clear_env:
112-
_cmd.append("--clear-env")
111+
if self.share_host_ro:
112+
_cmd.append("--sandbox-expose-path-ro=/")
113113

114114
if self.share_paths_ro:
115115
_cmd += [
@@ -122,7 +122,8 @@ def __get_flatpak_spawn(self, cmd: str):
122122
f"--sandbox-expose-path={shlex.quote(p)}" for p in self.share_paths_rw
123123
]
124124

125-
if not self.share_net:
125+
share_net = self.share_net or self.share_bluetooth
126+
if not share_net:
126127
_cmd.append("--no-network")
127128

128129
if self.share_display:

bottles/backend/wine/winecommand.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ def _get_sandbox_manager(self) -> SandboxManager:
681681
envs=self.env,
682682
chdir=self.cwd,
683683
share_paths_rw=[ManagerUtils.get_bottle_path(self.config)],
684-
share_paths_ro=[Paths.runners, Paths.temp],
684+
share_paths_ro=[p for p in [Paths.runners, Paths.temp] if p],
685685
share_net=self.config.Sandbox.share_net,
686686
share_sound=self.config.Sandbox.share_sound,
687687
)

bottles/frontend/ui/details-preferences.blp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,6 @@ template $DetailsPreferences: Adw.PreferencesPage {
290290

291291
Adw.ActionRow row_sandbox {
292292
activatable-widget: switch_sandbox;
293-
visible: false;
294293
title: _("Dedicated Sandbox");
295294
subtitle: _("Use a restricted/managed environment for this bottle.");
296295

bottles/frontend/ui/dialog-sandbox.blp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ template $SandboxDialog: Adw.Window {
3838
valign: center;
3939
}
4040
}
41+
4142
}
43+
4244
}
4345
}
4446
}

bottles/frontend/ui/preferences.blp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -284,22 +284,4 @@ template $PreferencesWindow: Adw.PreferencesWindow {
284284
}
285285
}
286286

287-
Adw.PreferencesPage {
288-
icon-name: "applications-science-symbolic";
289-
title: _("Experiments");
290-
291-
Adw.PreferencesGroup {
292-
description: _("These features are under heavy development and may be unstable, expect bugs and breakage.");
293-
294-
Adw.ActionRow {
295-
title: _("Sandbox per bottle");
296-
subtitle: _("In early development.");
297-
activatable-widget: switch_sandbox;
298-
299-
Switch switch_sandbox {
300-
valign: center;
301-
}
302-
}
303-
}
304-
}
305287
}

bottles/frontend/views/bottle_preferences.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,3 @@ def __set_steam_rules(self):
998998
]:
999999
w.set_visible(status)
10001000
w.set_sensitive(status)
1001-
1002-
self.row_sandbox.set_visible(
1003-
self.window.settings.get_boolean("experiments-sandbox")
1004-
)

bottles/frontend/views/preferences.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class PreferencesWindow(Adw.PreferencesWindow):
4747
switch_temp = Gtk.Template.Child()
4848
switch_release_candidate = Gtk.Template.Child()
4949
switch_steam = Gtk.Template.Child()
50-
switch_sandbox = Gtk.Template.Child()
5150
switch_auto_close = Gtk.Template.Child()
5251
switch_update_date = Gtk.Template.Child()
5352
switch_steam_programs = Gtk.Template.Child()
@@ -117,12 +116,6 @@ def __init__(self, window, **kwargs):
117116
"active",
118117
Gio.SettingsBindFlags.DEFAULT,
119118
)
120-
self.settings.bind(
121-
"experiments-sandbox",
122-
self.switch_sandbox,
123-
"active",
124-
Gio.SettingsBindFlags.DEFAULT,
125-
)
126119
self.settings.bind(
127120
"auto-close-bottles",
128121
self.switch_auto_close,

data/com.usebottles.bottles.gschema.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,6 @@
7676
<summary>Steam Proton Support</summary>
7777
<description>Toggle Steam Proton prefixes support.</description>
7878
</key>
79-
<key type="b" name="experiments-sandbox">
80-
<default>false</default>
81-
<summary>Experiments:sandbox</summary>
82-
<description>Toggle experimental Sandbox per bottle.</description>
83-
</key>
8479
<key type="b" name="auto-close-bottles">
8580
<default>false</default>
8681
<summary>Automatically close Bottles</summary>

0 commit comments

Comments
 (0)