mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-06 13:41:36 +00:00
Reduce permissions changes scope after ADD/COPY
Permissions after an ADD or COPY build instructions are now restricted to the scope of files potentially modified by the operation rather than the entire impacted tree. Fixes #9401. Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
This commit is contained in:
@@ -1065,6 +1065,31 @@ ADD . /`,
|
||||
logDone("build - add etc directory to root")
|
||||
}
|
||||
|
||||
// Testing #9401
|
||||
func TestBuildAddPreservesFilesSpecialBits(t *testing.T) {
|
||||
name := "testaddpreservesfilesspecialbits"
|
||||
defer deleteImages(name)
|
||||
ctx, err := fakeContext(`FROM busybox
|
||||
ADD suidbin /usr/bin/suidbin
|
||||
RUN chmod 4755 /usr/bin/suidbin
|
||||
RUN [ $(ls -l /usr/bin/suidbin | awk '{print $1}') = '-rwsr-xr-x' ]
|
||||
ADD ./data/ /
|
||||
RUN [ $(ls -l /usr/bin/suidbin | awk '{print $1}') = '-rwsr-xr-x' ]`,
|
||||
map[string]string{
|
||||
"suidbin": "suidbin",
|
||||
"/data/usr/test_file": "test1",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer ctx.Close()
|
||||
|
||||
if _, err := buildImageFromContext(name, ctx, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
logDone("build - add preserves files special bits")
|
||||
}
|
||||
|
||||
func TestBuildCopySingleFileToRoot(t *testing.T) {
|
||||
name := "testcopysinglefiletoroot"
|
||||
defer deleteImages(name)
|
||||
|
||||
Reference in New Issue
Block a user