Repository navigation
go-archive:tarfs: test relative and absolute symlink extraction - #9655
taylorsilva merged 1 commit into
Conversation
- verify extracted symlinks preserve their expected targets across platforms. - regression test for: concourse#9609 and golang/go#80073
|
|
||
| Expect(emptyDirInfo.IsDir()).To(BeTrue()) | ||
|
|
||
| target, err := os.Readlink(filepath.Join(extractionDest, "some-symlink")) |
There was a problem hiding this comment.
These 3 lines are not removed, they are just generalized in the verifySymlink helper function to avoid repetition.
e.g as you can see, these checks were done only for 1 out of 3 symlinks in the archive.
| Expect(err).NotTo(HaveOccurred()) | ||
|
|
||
| if runtime.GOOS != "windows" { | ||
| Expect(symlinkInfo.Mode() & 0755).To(Equal(os.FileMode(0755))) |
There was a problem hiding this comment.
This was catched by @odormond during the review in Pix4D fork: Pix4D#829 (comment)
If symlink was successfully created (already confirmed with os.Readlink) the mode must also match, so there is no need to even call os.Lstat.
I am quoting him here:
there is no way to change the mode bits of symlink. So if it is a symlink as os.Readlink succeeded, then its mode is 0755.
chmod() changes the mode of the file specified, whose pathname is given in pathname, which is dereferenced if it is a symbolic link.
-- man 2 open
go-archive:tarfs: test relative and absolute symlink extraction
os.Root.Symlinkpath separator bug (Go #80073) #9609 and os: Root.Symlink does not normalize target path separators on Windows golang/go#80073