diff --git a/fileutil/fileutil_suite_test.go b/fileutil/fileutil_suite_test.go index 0c60ad39..6d6a467d 100644 --- a/fileutil/fileutil_suite_test.go +++ b/fileutil/fileutil_suite_test.go @@ -59,10 +59,12 @@ func localCopyFSForGo122(dir string, fsys fs.FS) error { var _ = BeforeEach(func() { assetsDirFS := os.DirFS(filepath.Join(".", "test_assets")) - testAssetsDir = GinkgoT().TempDir() + var err error + testAssetsDir, err = filepath.EvalSymlinks(GinkgoT().TempDir()) + Expect(err).ToNot(HaveOccurred()) // TODO: use `os.CopyFS` instead of `localCopyFSForGo122` once we upgrade Golang versions - err := localCopyFSForGo122(testAssetsDir, assetsDirFS) + err = localCopyFSForGo122(testAssetsDir, assetsDirFS) Expect(err).NotTo(HaveOccurred()) testAssetsFixtureDir = filepath.Join(testAssetsDir, "fixture_dir") diff --git a/fileutil/tarball_compressor.go b/fileutil/tarball_compressor.go index df65d144..997f1f3c 100644 --- a/fileutil/tarball_compressor.go +++ b/fileutil/tarball_compressor.go @@ -57,7 +57,11 @@ func (c tarballCompressor) DecompressFileToDir(tarballPath string, dir string, o sameOwnerOption = "--same-owner" } - args := []string{sameOwnerOption, "-xzf", tarballPath, "-C", dir} + resolvedTarballPath, err := c.fs.ReadAndFollowLink(tarballPath) + if err != nil { + return bosherr.WrapError(err, "Resolving tarball path") + } + args := []string{sameOwnerOption, "-xzf", resolvedTarballPath, "-C", dir} if options.StripComponents != 0 { args = append(args, fmt.Sprintf("--strip-components=%d", options.StripComponents)) } @@ -65,7 +69,7 @@ func (c tarballCompressor) DecompressFileToDir(tarballPath string, dir string, o if options.PathInArchive != "" { args = append(args, options.PathInArchive) } - _, _, _, err := c.cmdRunner.RunCommand("tar", args...) + _, _, _, err = c.cmdRunner.RunCommand("tar", args...) if err != nil { return bosherr.WrapError(err, "Shelling out to tar") } diff --git a/fileutil/tarball_compressor_test.go b/fileutil/tarball_compressor_test.go index eace9202..2a80682e 100644 --- a/fileutil/tarball_compressor_test.go +++ b/fileutil/tarball_compressor_test.go @@ -35,7 +35,9 @@ var _ = Describe("tarballCompressor", func() { cmdRunner = boshsys.NewExecCmdRunner(logger) fs = boshsys.NewOsFileSystem(logger) - dstDir = GinkgoT().TempDir() + var err error + dstDir, err = filepath.EvalSymlinks(GinkgoT().TempDir()) + Expect(err).ToNot(HaveOccurred()) compressor = NewTarballCompressor(cmdRunner, fs) fixtureSrcTgz = filepath.Join(testAssetsDir, "compressor-decompress-file-to-dir.tgz") diff --git a/system/os_file_system_test.go b/system/os_file_system_test.go index 5bdc56fe..2de7115d 100644 --- a/system/os_file_system_test.go +++ b/system/os_file_system_test.go @@ -58,7 +58,7 @@ var _ = Describe("OS FileSystem", func() { Expect(err).ToNot(HaveOccurred()) // If a regular user, the home directory will end with the username - expDir := fmt.Sprintf(`\%s`, filepath.Base(currentUser.Name)) + expDir := fmt.Sprintf(`\%s`, filepath.Base(currentUser.Username)) // If a System or LocalSystem user, the home directory will be different // ref: https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-security-identifiers