Skip to content

Commit f807b6a

Browse files
authored
[orchestrator] Handles symbolic links when extracting cvd-host_package.tar.gz (google#225)
1 parent ab0e510 commit f807b6a

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed
Binary file not shown.

frontend/src/host_orchestrator/orchestrator/userartifacts.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ func untar(dst string, src string) error {
189189
return err
190190
}
191191
f.Close()
192+
case tar.TypeSymlink:
193+
if err := os.Symlink(header.Linkname, target); err != nil {
194+
return err
195+
}
192196
}
193197
}
194198
}

frontend/src/host_orchestrator/orchestrator/userartifacts_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ func TestUploadCVDHostPackageSucceds(t *testing.T) {
190190
if diff := cmp.Diff("foo\n", string(b)); diff != "" {
191191
t.Errorf("aritfact content mismatch (-want +got):\n%s", diff)
192192
}
193+
b, _ = ioutil.ReadFile(am.GetDirPath("foo") + "/foo_dir/link_foo.txt")
194+
if diff := cmp.Diff("foo\n", string(b)); diff != "" {
195+
t.Errorf("symlink content mismatch (-want +got):\n%s", diff)
196+
}
193197
if ok, _ := fileExist(am.GetFilePath("foo", "cvd-host_package.tar.gz")); ok {
194198
t.Error("cvd-host_package.tar.gz was not cleaned up")
195199
}

0 commit comments

Comments
 (0)