Skip to content

tests/int: don't remove a directory we did not create - #5445

Open
kolyshkin wants to merge 2 commits into
opencontainers:mainfrom
kolyshkin:kir/test-root-guard
Open

tests/int: don't remove a directory we did not create#5445
kolyshkin wants to merge 2 commits into
opencontainers:mainfrom
kolyshkin:kir/test-root-guard

Conversation

@kolyshkin

Copy link
Copy Markdown
Contributor

teardown_bundle removes $ROOT recursively, guarded only by a check that
the variable is set. Since ROOT can be inherited from the environment
(setup_bundle overwrites it, but is not called by every test), a stray
ROOT in the environment makes the teardown remove an arbitrary
directory. Please don't ask me how I know all this.

Add some protection:

  • helpers.bash now unsets ROOT if it comes from the environment;
  • setup_bundle marks the directory it creates with a marker file, and
    teardown_bundle only removes a directory which has that marker and
    is located under $BATS_RUN_TMPDIR.

Here, ROOT is the root of the runc source tree, while in the integration
tests ROOT is a temporary directory which teardown_bundle removes
recursively. The variable is not exported, so nothing is broken today,
but the name clash is a trap waiting to happen; use a distinct name.

Signed-off-by: Kir Kolyshkin <[email protected]>
teardown_bundle removes $ROOT recursively, guarded only by a check that
the variable is set. Since ROOT can be inherited from the environment
(setup_bundle overwrites it, but is not called by every test), a stray
ROOT in the environment makes the teardown remove an arbitrary
directory. Please don't ask me how I know all this.

Add some protection:

 - helpers.bash now unsets ROOT if it comes from the environment;
 - setup_bundle marks the directory it creates with a marker file, and
   teardown_bundle only removes a directory which has that marker and
   is located under $BATS_RUN_TMPDIR.

Signed-off-by: Kir Kolyshkin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants