diff options
| author | WxNzEMof <143541718+WxNzEMof@users.noreply.github.com> | 2024-01-17 09:41:49 +0000 |
|---|---|---|
| committer | github-actions[bot] <github-actions[bot]@users.noreply.github.com> | 2024-02-19 08:01:32 +0000 |
| commit | b7025962432605f36cec0510805b7282409bc197 (patch) | |
| tree | 9143fa808e449ecf644eb473a4a531c3d8f0c6cd | |
| parent | Merge pull request #289837 from NixOS/backport-289580-to-release-23.11 (diff) | |
| download | nixpkgs-origin/backport-281520-to-release-23.11.tar.gz | |
dockerTools: Add chown testorigin/backport-281520-to-release-23.11
proot's --root-id "allows" chown only in the sense that it makes it
succeed vacuously, i.e. a no-op. This is undesired if the goal is to
actually create a layer with some files owned by different users.
Fortunately, fakeroot does allow persistence of emulated file owners,
and it is possible to combine fakeroot with proot, so replace proot
--root-id with fakeroot to do so.
This was fixed recently in d538fefb62a2dc0e40235606bb02615b47d02583,
so this commit just adds a test.
(cherry picked from commit 84b5bcae2667942984b5e8ee3ae9b14f48f7d0a6)
| -rw-r--r-- | nixos/tests/docker-tools.nix | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/nixos/tests/docker-tools.nix b/nixos/tests/docker-tools.nix index fcdfa586fd55..a671cac610d1 100644 --- a/nixos/tests/docker-tools.nix +++ b/nixos/tests/docker-tools.nix @@ -46,6 +46,18 @@ let echo 'runAsRoot has run.' ''; }; + + chownTestImage = + pkgs.dockerTools.streamLayeredImage { + name = "chown-test"; + tag = "latest"; + enableFakechroot = true; + fakeRootCommands = '' + touch /testfile + chown 12345:12345 /testfile + ''; + config.Cmd = [ "${pkgs.coreutils}/bin/stat" "-c" "%u:%g" "/testfile" ]; + }; in { name = "docker-tools"; meta = with pkgs.lib.maintainers; { @@ -550,5 +562,11 @@ in { "${examples.nix-shell-build-derivation} | docker load", "docker run --rm -it nix-shell-build-derivation" ) + + with subtest("streamLayeredImage: chown is persistent in fakeRootCommands"): + docker.succeed( + "${chownTestImage} | docker load", + "docker run --rm ${chownTestImage.imageName} | diff /dev/stdin <(echo 12345:12345)" + ) ''; }) |
