From d8336833514c8d2fd456ad000c2ab83450e2e78a Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 16 Feb 2023 18:01:43 +0100 Subject: tools/syz-kconf: support env variables in shell commands Required for ChromeOS update. --- tools/syz-kconf/kconf.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/syz-kconf/kconf.go b/tools/syz-kconf/kconf.go index 2bf66532c..0d8c48ac2 100644 --- a/tools/syz-kconf/kconf.go +++ b/tools/syz-kconf/kconf.go @@ -239,6 +239,7 @@ func (ctx *Context) generate() error { } func (ctx *Context) executeShell() error { + envRe := regexp.MustCompile("^[A-Z0-9_]+=") for _, shell := range ctx.Inst.Shell { if !ctx.Inst.Features.Match(shell.Constraints) { continue @@ -253,7 +254,18 @@ func (ctx *Context) executeShell() error { } continue } - if _, err := osutil.RunCmd(10*time.Minute, ctx.SourceDir, args[0], args[1:]...); err != nil { + env := os.Environ() + for len(args) > 1 { + if !envRe.MatchString(args[0]) { + break + } + env = append(env, args[0]) + args = args[1:] + } + cmd := osutil.Command(args[0], args[1:]...) + cmd.Dir = ctx.SourceDir + cmd.Env = env + if _, err := osutil.Run(10*time.Minute, cmd); err != nil { return err } } -- cgit mrf-deployment