X Tutup
Skip to content

Commit e776989

Browse files
committed
add SandboxOptions to the Lauch event
1 parent b28d479 commit e776989

File tree

8 files changed

+232
-7
lines changed

8 files changed

+232
-7
lines changed

butlerd/generous/docs/README.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5970,6 +5970,12 @@ cave identifier.</p>
59705970
<td><p><span class="tag">Optional</span> Enable sandbox (regardless of manifest opt-in)</p>
59715971
</td>
59725972
</tr>
5973+
<tr>
5974+
<td><code>sandboxOptions</code></td>
5975+
<td><code class="typename"><span class="type" data-tip-selector="#SandboxOptions__TypeHint">SandboxOptions</span></code></td>
5976+
<td><p><span class="tag">Optional</span> Sandbox configuration options. Only applied when sandbox is enabled.</p>
5977+
</td>
5978+
</tr>
59735979
</table>
59745980

59755981

@@ -6004,6 +6010,10 @@ cave identifier.</p>
60046010
<td><code>sandbox</code></td>
60056011
<td><code class="typename"><span class="type builtin-type">boolean</span></code></td>
60066012
</tr>
6013+
<tr>
6014+
<td><code>sandboxOptions</code></td>
6015+
<td><code class="typename"><span class="type">SandboxOptions</span></code></td>
6016+
</tr>
60076017
</table>
60086018

60096019
</div>
@@ -9027,6 +9037,123 @@ performed whenever <code class="typename"><span class="type">Downloads.Drive</sp
90279037

90289038
</div>
90299039

9040+
### SandboxType (enum)
9041+
9042+
9043+
9044+
<p>
9045+
<span class="header">Values</span>
9046+
</p>
9047+
9048+
9049+
<table class="field-table">
9050+
<tr>
9051+
<td><code>""</code></td>
9052+
<td></td>
9053+
</tr>
9054+
<tr>
9055+
<td><code>"bubblewrap"</code></td>
9056+
<td></td>
9057+
</tr>
9058+
<tr>
9059+
<td><code>"firejail"</code></td>
9060+
<td></td>
9061+
</tr>
9062+
<tr>
9063+
<td><code>"flatpak"</code></td>
9064+
<td></td>
9065+
</tr>
9066+
<tr>
9067+
<td><code>"fuji"</code></td>
9068+
<td></td>
9069+
</tr>
9070+
</table>
9071+
9072+
9073+
<div id="SandboxType__TypeHint" class="tip-content">
9074+
<p>SandboxType (enum) <a href="#/?id=sandboxtype-enum">(Go to definition)</a></p>
9075+
9076+
9077+
<table class="field-table">
9078+
<tr>
9079+
<td><code>""</code></td>
9080+
</tr>
9081+
<tr>
9082+
<td><code>"bubblewrap"</code></td>
9083+
</tr>
9084+
<tr>
9085+
<td><code>"firejail"</code></td>
9086+
</tr>
9087+
<tr>
9088+
<td><code>"flatpak"</code></td>
9089+
</tr>
9090+
<tr>
9091+
<td><code>"fuji"</code></td>
9092+
</tr>
9093+
</table>
9094+
9095+
</div>
9096+
9097+
### SandboxOptions (struct)
9098+
9099+
9100+
<p>
9101+
<p>Options for controlling sandbox behavior.</p>
9102+
9103+
</p>
9104+
9105+
<p>
9106+
<span class="header">Fields</span>
9107+
</p>
9108+
9109+
9110+
<table class="field-table">
9111+
<tr>
9112+
<td><code>type</code></td>
9113+
<td><code class="typename"><span class="type" data-tip-selector="#SandboxType__TypeHint">SandboxType</span></code></td>
9114+
<td><p><span class="tag">Optional</span> Which sandbox runner to use. Empty string means auto-detect.</p>
9115+
</td>
9116+
</tr>
9117+
<tr>
9118+
<td><code>noNetwork</code></td>
9119+
<td><code class="typename"><span class="type builtin-type">boolean</span></code></td>
9120+
<td><p><span class="tag">Optional</span> (Linux Only) If true, disable network access within the sandbox.</p>
9121+
</td>
9122+
</tr>
9123+
<tr>
9124+
<td><code>allowEnv</code></td>
9125+
<td><code class="typename"><span class="type builtin-type">string</span>[]</code></td>
9126+
<td><p><span class="tag">Optional</span> (Linux Only) List of environment variable names to allow through from the host into the sandbox.</p>
9127+
</td>
9128+
</tr>
9129+
</table>
9130+
9131+
9132+
<div id="SandboxOptions__TypeHint" class="tip-content">
9133+
<p>SandboxOptions (struct) <a href="#/?id=sandboxoptions-struct">(Go to definition)</a></p>
9134+
9135+
<p>
9136+
<p>Options for controlling sandbox behavior.</p>
9137+
9138+
</p>
9139+
9140+
<table class="field-table">
9141+
<tr>
9142+
<td><code>type</code></td>
9143+
<td><code class="typename"><span class="type">SandboxType</span></code></td>
9144+
</tr>
9145+
<tr>
9146+
<td><code>noNetwork</code></td>
9147+
<td><code class="typename"><span class="type builtin-type">boolean</span></code></td>
9148+
</tr>
9149+
<tr>
9150+
<td><code>allowEnv</code></td>
9151+
<td><code class="typename"><span class="type builtin-type">string</span>[]</code></td>
9152+
</tr>
9153+
</table>
9154+
9155+
</div>
9156+
90309157
### Log (notification)
90319158

90329159

butlerd/generous/spec/butlerd.json

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,6 +1915,11 @@
19151915
"name": "sandbox",
19161916
"doc": "Enable sandbox (regardless of manifest opt-in)",
19171917
"type": "boolean"
1918+
},
1919+
{
1920+
"name": "sandboxOptions",
1921+
"doc": "Sandbox configuration options. Only applied when sandbox is enabled.",
1922+
"type": "SandboxOptions"
19181923
}
19191924
]
19201925
},
@@ -3050,6 +3055,27 @@
30503055
}
30513056
]
30523057
},
3058+
{
3059+
"name": "SandboxOptions",
3060+
"doc": "Options for controlling sandbox behavior.",
3061+
"fields": [
3062+
{
3063+
"name": "type",
3064+
"doc": "Which sandbox runner to use. Empty string means auto-detect.",
3065+
"type": "SandboxType"
3066+
},
3067+
{
3068+
"name": "noNetwork",
3069+
"doc": "(Linux Only) If true, disable network access within the sandbox.",
3070+
"type": "boolean"
3071+
},
3072+
{
3073+
"name": "allowEnv",
3074+
"doc": "(Linux Only) List of environment variable names to allow through from the host into the sandbox.",
3075+
"type": "string[]"
3076+
}
3077+
]
3078+
},
30533079
{
30543080
"name": "Host",
30553081
"doc": "",
@@ -4329,6 +4355,37 @@
43294355
}
43304356
]
43314357
},
4358+
{
4359+
"name": "SandboxType",
4360+
"doc": "",
4361+
"values": [
4362+
{
4363+
"name": "Auto",
4364+
"doc": "",
4365+
"value": ""
4366+
},
4367+
{
4368+
"name": "Bubblewrap",
4369+
"doc": "",
4370+
"value": "bubblewrap"
4371+
},
4372+
{
4373+
"name": "Firejail",
4374+
"doc": "",
4375+
"value": "firejail"
4376+
},
4377+
{
4378+
"name": "Flatpak",
4379+
"doc": "",
4380+
"value": "flatpak"
4381+
},
4382+
{
4383+
"name": "Fuji",
4384+
"doc": "",
4385+
"value": "fuji"
4386+
}
4387+
]
4388+
},
43324389
{
43334390
"name": "LogLevel",
43344391
"doc": "",

butlerd/types.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2350,6 +2350,35 @@ type LaunchParams struct {
23502350
// Enable sandbox (regardless of manifest opt-in)
23512351
// @optional
23522352
Sandbox bool `json:"sandbox,omitempty"`
2353+
2354+
// Sandbox configuration options. Only applied when sandbox is enabled.
2355+
// @optional
2356+
SandboxOptions *SandboxOptions `json:"sandboxOptions,omitempty"`
2357+
}
2358+
2359+
type SandboxType string
2360+
2361+
const (
2362+
SandboxTypeAuto SandboxType = ""
2363+
SandboxTypeBubblewrap SandboxType = "bubblewrap"
2364+
SandboxTypeFirejail SandboxType = "firejail"
2365+
SandboxTypeFlatpak SandboxType = "flatpak"
2366+
SandboxTypeFuji SandboxType = "fuji"
2367+
)
2368+
2369+
// Options for controlling sandbox behavior.
2370+
type SandboxOptions struct {
2371+
// Which sandbox runner to use. Empty string means auto-detect.
2372+
// @optional
2373+
Type SandboxType `json:"type,omitempty"`
2374+
2375+
// (Linux Only) If true, disable network access within the sandbox.
2376+
// @optional
2377+
NoNetwork bool `json:"noNetwork,omitempty"`
2378+
2379+
// (Linux Only) List of environment variable names to allow through from the host into the sandbox.
2380+
// @optional
2381+
AllowEnv []string `json:"allowEnv,omitempty"`
23532382
}
23542383

23552384
func (p LaunchParams) Validate() error {

endpoints/launch/launch.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ func Launch(rc *butlerd.RequestContext, params butlerd.LaunchParams) (*butlerd.L
253253
AppManifest: targetRes.appManifest,
254254
Action: target.Action,
255255
Sandbox: sandbox,
256+
SandboxOptions: params.SandboxOptions,
256257
WorkingDirectory: workingDirectory,
257258
Args: args,
258259
Env: env,

endpoints/launch/launchers/native/native.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,22 @@ func (l *Launcher) Do(params launch.LauncherParams) error {
190190
consumer.Infof("Console launch requested")
191191
}
192192

193+
var sandboxConfig runner.SandboxConfig
194+
if params.SandboxOptions != nil {
195+
sandboxConfig = runner.SandboxConfig{
196+
Type: runner.SandboxType(string(params.SandboxOptions.Type)),
197+
NoNetwork: params.SandboxOptions.NoNetwork,
198+
AllowEnv: params.SandboxOptions.AllowEnv,
199+
}
200+
}
201+
193202
runParams := runner.RunnerParams{
194203
Consumer: consumer,
195204
Ctx: params.Ctx,
196205

197-
Sandbox: params.Sandbox,
198-
Console: console,
206+
Sandbox: params.Sandbox,
207+
SandboxConfig: sandboxConfig,
208+
Console: console,
199209

200210
FullTargetPath: fullTargetPath,
201211

endpoints/launch/types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ type LauncherParams struct {
4444
// If true, enable sandbox
4545
Sandbox bool
4646

47+
// Sandbox configuration options (may be nil)
48+
SandboxOptions *butlerd.SandboxOptions
49+
4750
// Additional command-line arguments
4851
Args []string
4952

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ require (
3232
github.com/itchio/pelican v0.0.0-20200626221820-739b3d7708d2
3333
github.com/itchio/savior v0.0.0-20260128212141-556ab9757054
3434
github.com/itchio/screw v0.0.0-20200301160148-75fc2d65fb38
35-
github.com/itchio/smaug v0.0.0-20260216213017-90029cd51343
35+
github.com/itchio/smaug v0.0.0-20260217205404-17f32f5b4643
3636
github.com/itchio/spellbook v0.0.0-20200301161431-a4bdbea6b725
3737
github.com/itchio/wharf v0.0.0-20260121214545-5e5efc838cdb
3838
github.com/itchio/wizardry v0.0.0-20200301161332-e8c8c4a5a488

go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,8 @@ github.com/itchio/screw v0.0.0-20200301160148-75fc2d65fb38 h1:Mn30eeqfaJDXRxiQzH
178178
github.com/itchio/screw v0.0.0-20200301160148-75fc2d65fb38/go.mod h1:niqRh/zemDC1HOJiMwUHIsmbgw4t3NTAogGD53Uleqs=
179179
github.com/itchio/sevenzip-go v0.0.0-20260201233743-2dbe441fd43c h1:Mo6j+q53lWHsX+39KWfYudUX2fv8O0Rg1XnQBRX1aOU=
180180
github.com/itchio/sevenzip-go v0.0.0-20260201233743-2dbe441fd43c/go.mod h1:j77mJOxTb3sD0+h/c7nqwth7Y7DcI8TyBhxUI2ZEs0o=
181-
github.com/itchio/smaug v0.0.0-20260212201406-1bd5f3fc1c90 h1:dsoZB0unSz/hWHE01megcNC6wzrruPr7U6vuoZ+G1rU=
182-
github.com/itchio/smaug v0.0.0-20260212201406-1bd5f3fc1c90/go.mod h1:cvvHbM3mtzDynJyUcb8mwpinK14Sy691ch1CV1D8jjE=
183-
github.com/itchio/smaug v0.0.0-20260216213017-90029cd51343 h1:5sozkSGt5lvtUSKgho9jUxV7mZyEKlRNvSoqge6XlDY=
184-
github.com/itchio/smaug v0.0.0-20260216213017-90029cd51343/go.mod h1:cvvHbM3mtzDynJyUcb8mwpinK14Sy691ch1CV1D8jjE=
181+
github.com/itchio/smaug v0.0.0-20260217205404-17f32f5b4643 h1:kysKu9JibfQPkv1bI9t/5FKscEEckU7vGd9ukxlOhBw=
182+
github.com/itchio/smaug v0.0.0-20260217205404-17f32f5b4643/go.mod h1:cvvHbM3mtzDynJyUcb8mwpinK14Sy691ch1CV1D8jjE=
185183
github.com/itchio/spellbook v0.0.0-20200301161431-a4bdbea6b725 h1:zD1SEqqiqaCgJnSauy1+LBq1tDrXFGymk09v90Wr0bA=
186184
github.com/itchio/spellbook v0.0.0-20200301161431-a4bdbea6b725/go.mod h1:rrZhjXwnFHxTTvfrzI0aeIQDCGqlbGFu7SXam+QcJ94=
187185
github.com/itchio/wharf v0.0.0-20200305150844-3ed0814c4e98/go.mod h1:ZTnhOpjGKeKcysGbew3pIIQWgjHIFSHRGznCORTiA6w=

0 commit comments

Comments
 (0)
X Tutup