-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix parent directory permissions #619
Merged
dlorenc
merged 4 commits into
GoogleContainerTools:master
from
dtaniwaki:add-parent-dirs
Mar 19, 2019
+70
−46
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5ebcb20
Add parent directories of adding files
dtaniwaki 2a3a9a8
Add integration Dockerfile to test parent directory permissions
dtaniwaki 93e05b9
Remove unnecessary helper method
dtaniwaki 3298b79
Use a file on the internet for integration Dockerfile
dtaniwaki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM busybox | ||
|
||
RUN adduser --disabled-password --gecos "" --uid 1000 user | ||
RUN mkdir -p /home/user/foo | ||
RUN chown -R user /home/user | ||
RUN chmod 700 /home/user/foo | ||
ADD Makefile /home/user/foo/Makefile | ||
RUN chown -R user /home/user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ import ( | |
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
"sort" | ||
"testing" | ||
|
||
"github.com/GoogleContainerTools/kaniko/pkg/util" | ||
|
@@ -60,6 +61,12 @@ func TestSnapshotFSFileChange(t *testing.T) { | |
fooPath: "newbaz1", | ||
batPath: "baz", | ||
} | ||
for _, dir := range util.ParentDirectories(fooPath) { | ||
snapshotFiles[dir] = "" | ||
} | ||
for _, dir := range util.ParentDirectories(batPath) { | ||
snapshotFiles[dir] = "" | ||
} | ||
numFiles := 0 | ||
for { | ||
hdr, err := tr.Next() | ||
|
@@ -75,7 +82,7 @@ func TestSnapshotFSFileChange(t *testing.T) { | |
t.Fatalf("Contents of %s incorrect, expected: %s, actual: %s", hdr.Name, snapshotFiles[hdr.Name], string(contents)) | ||
} | ||
} | ||
if numFiles != 2 { | ||
if numFiles != len(snapshotFiles) { | ||
t.Fatalf("Incorrect number of files were added, expected: 2, actual: %v", numFiles) | ||
} | ||
} | ||
|
@@ -105,6 +112,9 @@ func TestSnapshotFSChangePermissions(t *testing.T) { | |
snapshotFiles := map[string]string{ | ||
batPath: "baz2", | ||
} | ||
for _, dir := range util.ParentDirectories(batPath) { | ||
snapshotFiles[dir] = "" | ||
} | ||
numFiles := 0 | ||
for { | ||
hdr, err := tr.Next() | ||
|
@@ -120,7 +130,7 @@ func TestSnapshotFSChangePermissions(t *testing.T) { | |
t.Fatalf("Contents of %s incorrect, expected: %s, actual: %s", hdr.Name, snapshotFiles[hdr.Name], string(contents)) | ||
} | ||
} | ||
if numFiles != 1 { | ||
if numFiles != len(snapshotFiles) { | ||
t.Fatalf("Incorrect number of files were added, expected: 1, got: %v", numFiles) | ||
} | ||
} | ||
|
@@ -147,7 +157,10 @@ func TestSnapshotFiles(t *testing.T) { | |
} | ||
defer os.Remove(tarPath) | ||
|
||
expectedFiles := []string{"/", "/tmp", filepath.Join(testDir, "foo")} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually don't know why |
||
expectedFiles := []string{ | ||
filepath.Join(testDir, "foo"), | ||
} | ||
expectedFiles = append(expectedFiles, util.ParentDirectories(filepath.Join(testDir, "foo"))...) | ||
|
||
f, err := os.Open(tarPath) | ||
if err != nil { | ||
|
@@ -166,6 +179,8 @@ func TestSnapshotFiles(t *testing.T) { | |
} | ||
actualFiles = append(actualFiles, hdr.Name) | ||
} | ||
sort.Strings(expectedFiles) | ||
sort.Strings(actualFiles) | ||
testutil.CheckErrorAndDeepEqual(t, false, nil, expectedFiles, actualFiles) | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you remove this line? We don't have a Makefile in the context which is causing the integration test build to fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line cannot be deleted because having ADD between chowns causes this issue. Is there any file available in the environment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, maybe we can use some URL to download a file because it’s ADD. let me update the PR.