Skip to content

Commit

Permalink
tests/docker-tools: Adds regression test for NixOS#34779
Browse files Browse the repository at this point in the history
(cherry picked from commit 902b059)
  • Loading branch information
samueldr authored and globin committed May 26, 2018
1 parent ac35333 commit dc2ac5f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions nixos/tests/docker-tools.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,11 @@ import ./make-test.nix ({ pkgs, ... }: {
$docker->succeed("docker load --input='${pkgs.dockerTools.examples.onTopOfPulledImage}'");
$docker->succeed("docker run --rm ontopofpulledimage hello");
$docker->succeed("docker rmi ontopofpulledimage");
# Regression test for issue #34779
$docker->succeed("docker load --input='${pkgs.dockerTools.examples.runAsRootExtraCommands}'");
$docker->succeed("docker run --rm runasrootextracommands cat extraCommands");
$docker->succeed("docker run --rm runasrootextracommands cat runAsRoot");
$docker->succeed("docker rmi '${pkgs.dockerTools.examples.runAsRootExtraCommands.imageName}'");
'';
})
12 changes: 12 additions & 0 deletions pkgs/build-support/docker/examples.nix
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,16 @@ rec {
fromImage = nixFromDockerHub;
contents = [ pkgs.hello ];
};

# 8. regression test for erroneous use of eval and string expansion.
# See issue #34779 and PR #40947 for details.
runAsRootExtraCommands = pkgs.dockerTools.buildImage {
name = "runAsRootExtraCommands";
contents = [ pkgs.coreutils ];
# The parens here are to create problematic bash to embed and eval. In case
# this is *embedded* into the script (with nix expansion) the initial quotes
# will close the string and the following parens are unexpected
runAsRoot = ''echo "(runAsRoot)" > runAsRoot'';
extraCommands = ''echo "(extraCommand)" > extraCommands'';
};
}

0 comments on commit dc2ac5f

Please sign in to comment.