-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
If a non-empty directory gets replaced with a link, the files in that directory also get deleted. However, there should not be any whiteout files for them in the layer. If there were, the resulting tar file would not be extractable. Fixes GoogleContainerTools#2308
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -224,6 +224,14 @@ func writeToTar(t util.Tar, files, whiteouts []string) error { | |
addedPaths := make(map[string]bool) | ||
|
||
for _, path := range whiteouts { | ||
skipWhiteout, err := parentPathIsLink(path) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
andreasf
Author
Owner
|
||
if err != nil { | ||
return err | ||
} | ||
if skipWhiteout { | ||
continue | ||
} | ||
|
||
if err := addParentDirectories(t, addedPaths, path); err != nil { | ||
return err | ||
} | ||
|
@@ -247,6 +255,21 @@ func writeToTar(t util.Tar, files, whiteouts []string) error { | |
return nil | ||
} | ||
|
||
func parentPathIsLink(path string) (bool, error) { | ||
for _, parentPath := range util.ParentDirectories(path) { | ||
lstat, err := os.Lstat(parentPath) | ||
if err != nil { | ||
return false, err | ||
} | ||
|
||
isLink := lstat.Mode()&os.ModeSymlink != 0 | ||
if isLink { | ||
return true, err | ||
} | ||
} | ||
return false, nil | ||
} | ||
|
||
func addParentDirectories(t util.Tar, addedPaths map[string]bool, path string) error { | ||
for _, parentPath := range util.ParentDirectories(path) { | ||
if _, pathAdded := addedPaths[parentPath]; pathAdded { | ||
|
No this is the wrong way arround IMO:
If the parent path chain contains ANY link, no parent paths should be added before the whiteout.
The whiteout must be added always.