Skip to content

go-archive:tarfs: test relative and absolute symlink extraction - #9655

Merged
taylorsilva merged 1 commit into
concourse:masterfrom
Pix4D:pci-4898-goarchive-tarfs-regression-tests-upstream
Jul 27, 2026
Merged

taylorsilva merged 1 commit into
concourse:masterfrom
Pix4D:pci-4898-goarchive-tarfs-regression-tests-upstream

Conversation

@aliculPix4D

Copy link
Copy Markdown
Contributor

go-archive:tarfs: test relative and absolute symlink extraction

- 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"))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)))

@aliculPix4D aliculPix4D Jul 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@aliculPix4D

Copy link
Copy Markdown
Contributor Author

@odormond @marco-m-pix4d FYI

@aliculPix4D
aliculPix4D deleted the pci-4898-goarchive-tarfs-regression-tests-upstream branch July 24, 2026 08:07
@aliculPix4D
aliculPix4D restored the pci-4898-goarchive-tarfs-regression-tests-upstream branch July 24, 2026 08:08
@aliculPix4D aliculPix4D reopened this Jul 24, 2026
@taylorsilva
taylorsilva merged commit 7e616fc into concourse:master Jul 27, 2026
12 checks passed
@aliculPix4D
aliculPix4D deleted the pci-4898-goarchive-tarfs-regression-tests-upstream branch July 28, 2026 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants