From 593b260b0233013ce7bbd5acf39263ab83244a14 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 10 Dec 2018 14:47:32 +0100 Subject: pkg/ipc: move sandbox helpers from ipcconfig Currently syz-runtest fails to start because -debug flag is defined both in syz-runtest and ipcconfig. But moving sandbox functions we prevent ipcconfig from being imported into syz-runtest. --- pkg/ipc/ipcconfig/ipcconfig.go | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) (limited to 'pkg/ipc/ipcconfig') diff --git a/pkg/ipc/ipcconfig/ipcconfig.go b/pkg/ipc/ipcconfig/ipcconfig.go index b94579102..f2bd2028e 100644 --- a/pkg/ipc/ipcconfig/ipcconfig.go +++ b/pkg/ipc/ipcconfig/ipcconfig.go @@ -5,7 +5,6 @@ package ipcconfig import ( "flag" - "fmt" "github.com/google/syzkaller/pkg/ipc" "github.com/google/syzkaller/prog" @@ -33,7 +32,7 @@ func Default(target *prog.Target) (*ipc.Config, *ipc.ExecOpts, error) { if *flagDebug { c.Flags |= ipc.FlagDebug } - sandboxFlags, err := SandboxToFlags(*flagSandbox) + sandboxFlags, err := ipc.SandboxToFlags(*flagSandbox) if err != nil { return nil, nil, err } @@ -58,29 +57,3 @@ func Default(target *prog.Target) (*ipc.Config, *ipc.ExecOpts, error) { return c, opts, nil } - -func SandboxToFlags(sandbox string) (ipc.EnvFlags, error) { - switch sandbox { - case "none": - return 0, nil - case "setuid": - return ipc.FlagSandboxSetuid, nil - case "namespace": - return ipc.FlagSandboxNamespace, nil - case "android_untrusted_app": - return ipc.FlagSandboxAndroidUntrustedApp, nil - default: - return 0, fmt.Errorf("sandbox must contain one of none/setuid/namespace/android_untrusted_app") - } -} - -func FlagsToSandbox(flags ipc.EnvFlags) string { - if flags&ipc.FlagSandboxSetuid != 0 { - return "setuid" - } else if flags&ipc.FlagSandboxNamespace != 0 { - return "namespace" - } else if flags&ipc.FlagSandboxAndroidUntrustedApp != 0 { - return "android_untrusted_app" - } - return "none" -} -- cgit mrf-deployment