tar: prefix hard link destination with extraction target #1827
Conversation
Egads. Great catch. LGTM. Can we test, though? |
Also s/extration/extraction/ |
3257ece
to
dab49f3
Compare
Test added, and as a bonus all tests now run against both |
func TestExtractTarHardLink(t *testing.T) { | ||
for _, insecure := range []bool{false, true} { | ||
if !insecure && !sys.HasChrootCapability() { | ||
t.Skipf("chroot capability not available. Disabling test.") |
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 isn't quite right because you're skipping both test cases (insecure && !insecure)
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.
whoops
dab49f3
to
a332e03
Compare
No longer unintentionally skipping parts of tests. |
func extractTarInsecureHelper(t *testing.T, tr *tar.Reader, target string) error { | ||
editor, err := NewUidShiftingFilePermEditor(uid.NewBlankUidRange()) | ||
if err != nil { | ||
t.Errorf("unexpected error: %v", err) |
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.
return err
8976829
to
a2a3117
Compare
} | ||
for _, insecure := range []bool{false, true} { | ||
if !insecure && !sys.HasChrootCapability() { | ||
t.Logf("chroot capability not available. Skipping part of test.") |
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.
I think splitting these out is preferable, they're quite distinct paths conceptually:
func TestExtractTarFoldersChroot(t *testing.T) {
if !sys.HasChrootCapability() {
t.Skipf(...)
}
testExtractTarFolders(t, true)
}
func TestExtractTarFoldersInsecure(t *testing.T) {
testExtractTarFolders(t, false)
}
func testExtractTarFolders(t *testing.T, chroot bool)
(The bool is kinda icky, ideally testExtractTarFolders could have a nicer signature with some kind of func() but I'm not sure what it looks like off the top of my head)
Someone should kick semaphore for me :/ |
If the extraction is not running in a chroot, the file to hard link against must be prefaced by the target for the extraction, otherwise the file that's being linked to will not exist and the link will fail.
a2a3117
to
ed10afe
Compare
Tests split. |
Semaphore decided to remove the branch from testing as seen on https://semaphoreci.com/coreos/rkt/ I guess you'll need to create a new PR. :/ |
It needs to be rebased too. |
After closing/reopening the PR, we cannot kick Semaphore anymore... For next time, Semaphore can be kicked by pushing the branch again ;)
|
LGTM if it is rebased and if Semaphore is green. |
If the extraction is not running in a chroot, the file to hard link
against must be prefaced by the target for the extraction, otherwise the
file that's being linked to will not exist and the link will fail.
Fixes containers/build#139.