Commit 3ad6bddb authored by Amos Wenger's avatar Amos Wenger

Don't rely on RequestContext

parent c31e0a8e
Pipeline #10372 failed with stage
in 35 seconds
package firejail
type Settings struct {
FirejailBinary string
}
......@@ -39,7 +39,7 @@ func (ar *appRunner) Run() error {
}
func RunAppBundle(params *RunnerParams, bundlePath string) error {
consumer := params.RequestContext.Consumer
consumer := params.Consumer
var args = []string{
"-W",
......
......@@ -16,7 +16,7 @@ import (
)
func getAttachRunner(params *RunnerParams) (Runner, error) {
consumer := params.RequestContext.Consumer
consumer := params.Consumer
snapshot, err := syscallex.CreateToolhelp32Snapshot(
syscallex.TH32CS_SNAPPROCESS,
......@@ -133,7 +133,7 @@ func (ar *attachRunner) Prepare() error {
}
func (ar *attachRunner) Run() error {
consumer := ar.params.RequestContext.Consumer
consumer := ar.params.Consumer
cancel := make(chan struct{})
defer close(cancel)
......
......@@ -20,9 +20,14 @@ type firejailRunner struct {
var _ Runner = (*firejailRunner)(nil)
func newFirejailRunner(params *RunnerParams) (Runner, error) {
if params.FirejailSettings == nil {
return nil, errors.Errorf("FirejailSettings must be set")
}
fr := &firejailRunner{
params: params,
}
return fr, nil
}
......@@ -33,10 +38,9 @@ func (fr *firejailRunner) Prepare() error {
func (fr *firejailRunner) Run() error {
params := fr.params
consumer := params.RequestContext.Consumer
consumer := params.Consumer
firejailName := fmt.Sprintf("firejail-%s", params.Runtime.Arch())
firejailPath := filepath.Join(params.PrereqsDir, firejailName, "firejail")
firejailPath := params.FirejailSettings.FirejailBinary
sandboxProfilePath := filepath.Join(params.InstallFolder, ".itch", "isolate-app.profile")
consumer.Opf("Writing sandbox profile to (%s)", sandboxProfilePath)
......
......@@ -37,7 +37,7 @@ func newFujiRunner(params *RunnerParams) (Runner, error) {
}
func (wr *fujiRunner) Prepare() error {
consumer := wr.params.RequestContext.Consumer
consumer := wr.params.Consumer
nullConsumer := &state.Consumer{}
err := fuji.Check(nullConsumer)
......@@ -98,7 +98,7 @@ func (wr *fujiRunner) Prepare() error {
func (wr *fujiRunner) Run() error {
var err error
params := wr.params
consumer := params.RequestContext.Consumer
consumer := params.Consumer
pd := wr.Credentials
consumer.Infof("Running as user (%s)", pd.Username)
......@@ -163,7 +163,7 @@ func (wr *fujiRunner) Run() error {
func (wr *fujiRunner) getSharingPolicy() (*winox.SharingPolicy, error) {
params := wr.params
pd := wr.Credentials
consumer := params.RequestContext.Consumer
consumer := params.Consumer
sp := &winox.SharingPolicy{
Trustee: pd.Username,
......
......@@ -6,13 +6,15 @@ import (
"io"
"runtime"
"github.com/itchio/butler/butlerd"
"github.com/itchio/butler/manager"
"github.com/itchio/smaug/firejail"
"github.com/itchio/smaug/fuji"
"github.com/itchio/wharf/state"
)
type RunnerParams struct {
RequestContext *butlerd.RequestContext
Ctx context.Context
Consumer *state.Consumer
Ctx context.Context
Sandbox bool
......@@ -25,10 +27,11 @@ type RunnerParams struct {
Stdout io.Writer
Stderr io.Writer
PrereqsDir string
Credentials *butlerd.GameCredentials
InstallFolder string
Runtime *manager.Runtime
FujiSettings *fuji.Settings
FirejailSettings *firejail.Settings
}
type Runner interface {
......@@ -37,7 +40,7 @@ type Runner interface {
}
func GetRunner(params *RunnerParams) (Runner, error) {
consumer := params.RequestContext.Consumer
consumer := params.Consumer
attachRunner, err := getAttachRunner(params)
if attachRunner != nil {
......@@ -50,7 +53,7 @@ func GetRunner(params *RunnerParams) (Runner, error) {
switch runtime.GOOS {
case "windows":
if params.Sandbox {
return newWinSandboxRunner(params)
return newFujiRunner(params)
}
return newSimpleRunner(params)
case "linux":
......
......@@ -32,7 +32,7 @@ func newSandboxExecRunner(params *RunnerParams) (Runner, error) {
}
func (ser *sandboxExecRunner) Prepare() error {
consumer := ser.params.RequestContext.Consumer
consumer := ser.params.Consumer
// make sure we have sandbox-exec
{
......@@ -49,7 +49,7 @@ func (ser *sandboxExecRunner) Prepare() error {
func (ser *sandboxExecRunner) Run() error {
params := ser.params
consumer := params.RequestContext.Consumer
consumer := params.Consumer
consumer.Infof("Creating shim app bundle to enable sandboxing")
realBundlePath := params.FullTargetPath
......
......@@ -28,7 +28,7 @@ func (sr *simpleRunner) Prepare() error {
func (sr *simpleRunner) Run() error {
params := sr.params
consumer := params.RequestContext.Consumer
consumer := params.Consumer
cmd := exec.Command(params.FullTargetPath, params.Args...)
cmd.Dir = params.Dir
......
......@@ -28,7 +28,7 @@ func (sr *simpleRunner) Prepare() error {
func (sr *simpleRunner) Run() error {
params := sr.params
consumer := params.RequestContext.Consumer
consumer := params.Consumer
cmd := execas.Command(params.FullTargetPath, params.Args...)
cmd.Dir = params.Dir
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment