From 6c5fffc01934da12bad67aad9ebe6eb02b2e20ca Mon Sep 17 00:00:00 2001 From: jonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com> Date: Wed, 21 Jul 2021 09:09:08 -0700 Subject: [PATCH] [infra][build] Reset HOME using env instead of bash. (#6079) Followup on #6069. --- infra/build/functions/build_project.py | 8 +++-- .../build/functions/expected_build_steps.json | 33 ++++++++++++------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/infra/build/functions/build_project.py b/infra/build/functions/build_project.py index 29b0a4d80..9568f9343 100644 --- a/infra/build/functions/build_project.py +++ b/infra/build/functions/build_project.py @@ -195,6 +195,10 @@ def get_build_steps(project_name, project_yaml_file, dockerfile_lines, env.append('ARCHITECTURE=' + architecture) env.append('FUZZING_LANGUAGE=' + language) + # Set HOME so that it doesn't point to a persisted volume (see + # https://github.com/google/oss-fuzz/issues/6035). + env.append('HOME=/root') + workdir = workdir_from_dockerfile(dockerfile_lines) if not workdir: workdir = '/src' @@ -224,9 +228,7 @@ def get_build_steps(project_name, project_yaml_file, dockerfile_lines, # `cd /src && cd {workdir}` (where {workdir} is parsed from # the Dockerfile). Container Builder overrides our workdir # so we need to add this step to set it back. - # Reset HOME so that it doesn't point to a persisted volume - # (see https://github.com/google/oss-fuzz/issues/6035). - ('export HOME=/root; rm -r /out && cd /src && cd {workdir} ' + ('rm -r /out && cd /src && cd {workdir} ' '&& mkdir -p {out} && compile || (echo "{failure_msg}" ' '&& false)').format(workdir=workdir, out=out, diff --git a/infra/build/functions/expected_build_steps.json b/infra/build/functions/expected_build_steps.json index d2e676269..271e43fe0 100644 --- a/infra/build/functions/expected_build_steps.json +++ b/infra/build/functions/expected_build_steps.json @@ -44,12 +44,13 @@ "OUT=/workspace/out/address", "MSAN_LIBS_PATH=/workspace/msan", "ARCHITECTURE=x86_64", - "FUZZING_LANGUAGE=c++" + "FUZZING_LANGUAGE=c++", + "HOME=/root" ], "args": [ "bash", "-c", - "export HOME=/root; rm -r /out && cd /src && cd /src && mkdir -p /workspace/out/address && compile || (echo \"********************************************************************************\nFailed to build.\nTo reproduce, run:\npython infra/helper.py build_image test-project\npython infra/helper.py build_fuzzers --sanitizer address --engine afl --architecture x86_64 test-project\n********************************************************************************\" && false)" + "rm -r /out && cd /src && cd /src && mkdir -p /workspace/out/address && compile || (echo \"********************************************************************************\nFailed to build.\nTo reproduce, run:\npython infra/helper.py build_image test-project\npython infra/helper.py build_fuzzers --sanitizer address --engine afl --architecture x86_64 test-project\n********************************************************************************\" && false)" ] }, { @@ -60,7 +61,8 @@ "OUT=/workspace/out/address", "MSAN_LIBS_PATH=/workspace/msan", "ARCHITECTURE=x86_64", - "FUZZING_LANGUAGE=c++" + "FUZZING_LANGUAGE=c++", + "HOME=/root" ], "args": [ "bash", @@ -76,7 +78,8 @@ "OUT=/workspace/out/address", "MSAN_LIBS_PATH=/workspace/msan", "ARCHITECTURE=x86_64", - "FUZZING_LANGUAGE=c++" + "FUZZING_LANGUAGE=c++", + "HOME=/root" ], "args": [ "bash", @@ -141,12 +144,13 @@ "OUT=/workspace/out/address", "MSAN_LIBS_PATH=/workspace/msan", "ARCHITECTURE=x86_64", - "FUZZING_LANGUAGE=c++" + "FUZZING_LANGUAGE=c++", + "HOME=/root" ], "args": [ "bash", "-c", - "export HOME=/root; rm -r /out && cd /src && cd /src && mkdir -p /workspace/out/address && compile || (echo \"********************************************************************************\nFailed to build.\nTo reproduce, run:\npython infra/helper.py build_image test-project\npython infra/helper.py build_fuzzers --sanitizer address --engine honggfuzz --architecture x86_64 test-project\n********************************************************************************\" && false)" + "rm -r /out && cd /src && cd /src && mkdir -p /workspace/out/address && compile || (echo \"********************************************************************************\nFailed to build.\nTo reproduce, run:\npython infra/helper.py build_image test-project\npython infra/helper.py build_fuzzers --sanitizer address --engine honggfuzz --architecture x86_64 test-project\n********************************************************************************\" && false)" ] }, { @@ -157,7 +161,8 @@ "OUT=/workspace/out/address", "MSAN_LIBS_PATH=/workspace/msan", "ARCHITECTURE=x86_64", - "FUZZING_LANGUAGE=c++" + "FUZZING_LANGUAGE=c++", + "HOME=/root" ], "args": [ "bash", @@ -173,7 +178,8 @@ "OUT=/workspace/out/address", "MSAN_LIBS_PATH=/workspace/msan", "ARCHITECTURE=x86_64", - "FUZZING_LANGUAGE=c++" + "FUZZING_LANGUAGE=c++", + "HOME=/root" ], "args": [ "bash", @@ -238,12 +244,13 @@ "OUT=/workspace/out/address", "MSAN_LIBS_PATH=/workspace/msan", "ARCHITECTURE=x86_64", - "FUZZING_LANGUAGE=c++" + "FUZZING_LANGUAGE=c++", + "HOME=/root" ], "args": [ "bash", "-c", - "export HOME=/root; rm -r /out && cd /src && cd /src && mkdir -p /workspace/out/address && compile || (echo \"********************************************************************************\nFailed to build.\nTo reproduce, run:\npython infra/helper.py build_image test-project\npython infra/helper.py build_fuzzers --sanitizer address --engine libfuzzer --architecture x86_64 test-project\n********************************************************************************\" && false)" + "rm -r /out && cd /src && cd /src && mkdir -p /workspace/out/address && compile || (echo \"********************************************************************************\nFailed to build.\nTo reproduce, run:\npython infra/helper.py build_image test-project\npython infra/helper.py build_fuzzers --sanitizer address --engine libfuzzer --architecture x86_64 test-project\n********************************************************************************\" && false)" ] }, { @@ -254,7 +261,8 @@ "OUT=/workspace/out/address", "MSAN_LIBS_PATH=/workspace/msan", "ARCHITECTURE=x86_64", - "FUZZING_LANGUAGE=c++" + "FUZZING_LANGUAGE=c++", + "HOME=/root" ], "args": [ "bash", @@ -270,7 +278,8 @@ "OUT=/workspace/out/address", "MSAN_LIBS_PATH=/workspace/msan", "ARCHITECTURE=x86_64", - "FUZZING_LANGUAGE=c++" + "FUZZING_LANGUAGE=c++", + "HOME=/root" ], "args": [ "bash",