cd / before generating build.ninja .

This is so that soong_build doesn't know the current directory, thereby
avoiding one way to leak information.

Test: Manual.
Change-Id: I976a8663b11d99c5382726487102df10043c5a61
This commit is contained in:
Lukacs T. Berki 2021-02-17 11:59:10 +01:00
parent 8d9d43c46c
commit f802ffcd12

View file

@ -125,7 +125,10 @@ var (
generateBuildNinja = pctx.StaticRule("build.ninja", generateBuildNinja = pctx.StaticRule("build.ninja",
blueprint.RuleParams{ blueprint.RuleParams{
Command: "$builder $extra -b $buildDir -n $ninjaBuildDir -d $out.d -globFile $globFile -o $out $in", // TODO: it's kinda ugly that some parameters are computed from
// environment variables and some from Ninja parameters, but it's probably
// better to not to touch that while Blueprint and Soong are separate
Command: "cd $$(dirname $builder) && BUILDER=$$PWD/$$(basename $builder) && cd / && env -i $$BUILDER $extra --top \"$$TOP\" --out \"$$SOONG_OUTDIR\" -b $buildDir -n $ninjaBuildDir -d $out.d -globFile $globFile -o $out $in",
CommandDeps: []string{"$builder"}, CommandDeps: []string{"$builder"},
Description: "$builder $out", Description: "$builder $out",
Deps: blueprint.DepsGCC, Deps: blueprint.DepsGCC,
@ -730,7 +733,6 @@ func (s *singleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
// Get the filename of the top-level Blueprints file to pass to minibp. // Get the filename of the top-level Blueprints file to pass to minibp.
topLevelBlueprints := filepath.Join("$srcDir", topLevelBlueprints := filepath.Join("$srcDir",
filepath.Base(s.config.topLevelBlueprintsFile)) filepath.Base(s.config.topLevelBlueprintsFile))
ctx.SetNinjaBuildDir(pctx, "${ninjaBuildDir}") ctx.SetNinjaBuildDir(pctx, "${ninjaBuildDir}")
if s.config.stage == StagePrimary { if s.config.stage == StagePrimary {