{"action":"created","comment":{"url":"https://api.github.com/repos/coreos/rkt/pulls/comments/46891973","id":46891973,"diff_hunk":"@@ -692,3 +729,85 @@ func checkTime(path string, time time.Time) error {\n \t}\n \treturn nil\n }\n+\n+func TestExtractTarHardLink(t *testing.T) {\n+\tfor _, insecure := range []bool{false, true} {\n+\t\tif !insecure && !sys.HasChrootCapability() {\n+\t\t\tt.Logf(\"chroot capability not available. Skipping part of test.\")\n+\t\t\tcontinue\n+\t\t}\n+\n+\t\tentries := []*testTarEntry{\n+\t\t\t{\n+\t\t\t\tcontents: \"foo\",\n+\t\t\t\theader: &tar.Header{\n+\t\t\t\t\tName: \"/foo.txt\",\n+\t\t\t\t\tSize: 3,\n+\t\t\t\t},\n+\t\t\t},\n+\t\t\t{\n+\t\t\t\theader: &tar.Header{\n+\t\t\t\t\tName:     \"foolink\",\n+\t\t\t\t\tTypeflag: tar.TypeLink,\n+\t\t\t\t\tLinkname: \"/foo.txt\",\n+\t\t\t\t},\n+\t\t\t},\n+\t\t}\n+\n+\t\ttestTarPath, err := newTestTar(entries)\n+\t\tif err != nil {\n+\t\t\tt.Errorf(\"unexpected error: %v\", err)\n+\t\t}\n+\t\tdefer os.Remove(testTarPath)\n+\t\tcontainerTar, err := os.Open(testTarPath)\n+\t\tif err != nil {\n+\t\t\tt.Errorf(\"unexpected error: %v\", err)\n+\t\t}\n+\t\tdefer containerTar.Close()\n+\t\ttmpdir, err := ioutil.TempDir(\"\", \"rkt-temp-dir\")\n+\t\tif err != nil {\n+\t\t\tt.Errorf(\"unexpected error: %v\", err)\n+\t\t}\n+\t\tos.RemoveAll(tmpdir)\n+\t\terr = os.MkdirAll(tmpdir, 0755)\n+\t\tif err != nil {\n+\t\t\tt.Errorf(\"unexpected error: %v\", err)\n+\t\t}\n+\t\tdefer os.RemoveAll(tmpdir)\n+\t\tif insecure {\n+\t\t\terr = extractTarInsecureHelper(t, tar.NewReader(containerTar), tmpdir)\n+\t\t} else {\n+\t\t\terr = ExtractTar(containerTar, tmpdir, false, uid.NewBlankUidRange(), nil)\n+\t\t}\n+\t\tif err != nil {\n+\t\t\tt.Errorf(\"unexpected error: %v\", err)\n+\t\t}\n+\t\tvar origFile syscall.Stat_t\n+\t\terr = syscall.Stat(filepath.Join(tmpdir, \"/foo.txt\"), &origFile)\n+\t\tif err != nil {\n+\t\t\tt.Errorf(\"unexpected error: %v\", err)\n+\t\t}\n+\t\tvar linkedFile syscall.Stat_t\n+\t\terr = syscall.Stat(filepath.Join(tmpdir, \"/foolink\"), &linkedFile)\n+\t\tif err != nil {\n+\t\t\tt.Errorf(\"unexpected error: %v\", err)\n+\t\t}\n+\t\tif origFile.Nlink != 2 {\n+\t\t\tt.Errorf(\"wrong number of nlinks on original file, expecting: 2, actual: %d\", origFile.Nlink)\n+\t\t}\n+\t\tif linkedFile.Nlink != 2 {\n+\t\t\tt.Errorf(\"wrong number of nlinks on linked file, expecting: 2, actual: %d\", origFile.Nlink)\n+\t\t}\n+\t\tif origFile.Ino != linkedFile.Ino {\n+\t\t\tt.Errorf(\"original file and linked file have different inodes\")\n+\t\t}\n+\t}\n+}\n+\n+func extractTarInsecureHelper(t *testing.T, tr *tar.Reader, target string) error {\n+\teditor, err := NewUidShiftingFilePermEditor(uid.NewBlankUidRange())\n+\tif err != nil {\n+\t\tt.Errorf(\"unexpected error: %v\", err)","path":"pkg/tar/tar_test.go","position":1003,"original_position":1003,"commit_id":"a332e0330afd4e7f4376dfde46095dea99dd7fa0","original_commit_id":"a332e0330afd4e7f4376dfde46095dea99dd7fa0","user":{"login":"jonboulle","id":2601015,"avatar_url":"https://avatars.githubusercontent.com/u/2601015?v=3","gravatar_id":"","url":"https://api.github.com/users/jonboulle","html_url":"https://github.com/jonboulle","followers_url":"https://api.github.com/users/jonboulle/followers","following_url":"https://api.github.com/users/jonboulle/following{/other_user}","gists_url":"https://api.github.com/users/jonboulle/gists{/gist_id}","starred_url":"https://api.github.com/users/jonboulle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonboulle/subscriptions","organizations_url":"https://api.github.com/users/jonboulle/orgs","repos_url":"https://api.github.com/users/jonboulle/repos","events_url":"https://api.github.com/users/jonboulle/events{/privacy}","received_events_url":"https://api.github.com/users/jonboulle/received_events","type":"User","site_admin":false},"body":"return err","created_at":"2015-12-07T23:00:35Z","updated_at":"2015-12-07T23:00:35Z","html_url":"https://github.com/coreos/rkt/pull/1827#discussion_r46891973","pull_request_url":"https://api.github.com/repos/coreos/rkt/pulls/1827","_links":{"self":{"href":"https://api.github.com/repos/coreos/rkt/pulls/comments/46891973"},"html":{"href":"https://github.com/coreos/rkt/pull/1827#discussion_r46891973"},"pull_request":{"href":"https://api.github.com/repos/coreos/rkt/pulls/1827"}}},"pull_request":{"url":"https://api.github.com/repos/coreos/rkt/pulls/1827","id":52444845,"html_url":"https://github.com/coreos/rkt/pull/1827","diff_url":"https://github.com/coreos/rkt/pull/1827.diff","patch_url":"https://github.com/coreos/rkt/pull/1827.patch","issue_url":"https://api.github.com/repos/coreos/rkt/issues/1827","number":1827,"state":"open","locked":false,"title":"tar: prefix hard link destination with extraction target","user":{"login":"dgonyeo","id":2439413,"avatar_url":"https://avatars.githubusercontent.com/u/2439413?v=3","gravatar_id":"","url":"https://api.github.com/users/dgonyeo","html_url":"https://github.com/dgonyeo","followers_url":"https://api.github.com/users/dgonyeo/followers","following_url":"https://api.github.com/users/dgonyeo/following{/other_user}","gists_url":"https://api.github.com/users/dgonyeo/gists{/gist_id}","starred_url":"https://api.github.com/users/dgonyeo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgonyeo/subscriptions","organizations_url":"https://api.github.com/users/dgonyeo/orgs","repos_url":"https://api.github.com/users/dgonyeo/repos","events_url":"https://api.github.com/users/dgonyeo/events{/privacy}","received_events_url":"https://api.github.com/users/dgonyeo/received_events","type":"User","site_admin":false},"body":"If the extraction is not running in a chroot, the file to hard link\r\nagainst must be prefaced by the target for the extraction, otherwise the\r\nfile that's being linked to will not exist and the link will fail.\r\n\r\nFixes https://github.com/appc/acbuild/issues/139.","created_at":"2015-12-02T19:49:27Z","updated_at":"2015-12-07T23:00:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ff8dbc984b580a5f556a4c18bb371d03822a4655","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/coreos/rkt/pulls/1827/commits","review_comments_url":"https://api.github.com/repos/coreos/rkt/pulls/1827/comments","review_comment_url":"https://api.github.com/repos/coreos/rkt/pulls/comments{/number}","comments_url":"https://api.github.com/repos/coreos/rkt/issues/1827/comments","statuses_url":"https://api.github.com/repos/coreos/rkt/statuses/a332e0330afd4e7f4376dfde46095dea99dd7fa0","head":{"label":"dgonyeo:tar-fix-hardlinks","ref":"tar-fix-hardlinks","sha":"a332e0330afd4e7f4376dfde46095dea99dd7fa0","user":{"login":"dgonyeo","id":2439413,"avatar_url":"https://avatars.githubusercontent.com/u/2439413?v=3","gravatar_id":"","url":"https://api.github.com/users/dgonyeo","html_url":"https://github.com/dgonyeo","followers_url":"https://api.github.com/users/dgonyeo/followers","following_url":"https://api.github.com/users/dgonyeo/following{/other_user}","gists_url":"https://api.github.com/users/dgonyeo/gists{/gist_id}","starred_url":"https://api.github.com/users/dgonyeo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgonyeo/subscriptions","organizations_url":"https://api.github.com/users/dgonyeo/orgs","repos_url":"https://api.github.com/users/dgonyeo/repos","events_url":"https://api.github.com/users/dgonyeo/events{/privacy}","received_events_url":"https://api.github.com/users/dgonyeo/received_events","type":"User","site_admin":false},"repo":{"id":42482618,"name":"rkt","full_name":"dgonyeo/rkt","owner":{"login":"dgonyeo","id":2439413,"avatar_url":"https://avatars.githubusercontent.com/u/2439413?v=3","gravatar_id":"","url":"https://api.github.com/users/dgonyeo","html_url":"https://github.com/dgonyeo","followers_url":"https://api.github.com/users/dgonyeo/followers","following_url":"https://api.github.com/users/dgonyeo/following{/other_user}","gists_url":"https://api.github.com/users/dgonyeo/gists{/gist_id}","starred_url":"https://api.github.com/users/dgonyeo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgonyeo/subscriptions","organizations_url":"https://api.github.com/users/dgonyeo/orgs","repos_url":"https://api.github.com/users/dgonyeo/repos","events_url":"https://api.github.com/users/dgonyeo/events{/privacy}","received_events_url":"https://api.github.com/users/dgonyeo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dgonyeo/rkt","description":"rkt is an App Container runtime for Linux","fork":true,"url":"https://api.github.com/repos/dgonyeo/rkt","forks_url":"https://api.github.com/repos/dgonyeo/rkt/forks","keys_url":"https://api.github.com/repos/dgonyeo/rkt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dgonyeo/rkt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dgonyeo/rkt/teams","hooks_url":"https://api.github.com/repos/dgonyeo/rkt/hooks","issue_events_url":"https://api.github.com/repos/dgonyeo/rkt/issues/events{/number}","events_url":"https://api.github.com/repos/dgonyeo/rkt/events","assignees_url":"https://api.github.com/repos/dgonyeo/rkt/assignees{/user}","branches_url":"https://api.github.com/repos/dgonyeo/rkt/branches{/branch}","tags_url":"https://api.github.com/repos/dgonyeo/rkt/tags","blobs_url":"https://api.github.com/repos/dgonyeo/rkt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dgonyeo/rkt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dgonyeo/rkt/git/refs{/sha}","trees_url":"https://api.github.com/repos/dgonyeo/rkt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dgonyeo/rkt/statuses/{sha}","languages_url":"https://api.github.com/repos/dgonyeo/rkt/languages","stargazers_url":"https://api.github.com/repos/dgonyeo/rkt/stargazers","contributors_url":"https://api.github.com/repos/dgonyeo/rkt/contributors","subscribers_url":"https://api.github.com/repos/dgonyeo/rkt/subscribers","subscription_url":"https://api.github.com/repos/dgonyeo/rkt/subscription","commits_url":"https://api.github.com/repos/dgonyeo/rkt/commits{/sha}","git_commits_url":"https://api.github.com/repos/dgonyeo/rkt/git/commits{/sha}","comments_url":"https://api.github.com/repos/dgonyeo/rkt/comments{/number}","issue_comment_url":"https://api.github.com/repos/dgonyeo/rkt/issues/comments{/number}","contents_url":"https://api.github.com/repos/dgonyeo/rkt/contents/{+path}","compare_url":"https://api.github.com/repos/dgonyeo/rkt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dgonyeo/rkt/merges","archive_url":"https://api.github.com/repos/dgonyeo/rkt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dgonyeo/rkt/downloads","issues_url":"https://api.github.com/repos/dgonyeo/rkt/issues{/number}","pulls_url":"https://api.github.com/repos/dgonyeo/rkt/pulls{/number}","milestones_url":"https://api.github.com/repos/dgonyeo/rkt/milestones{/number}","notifications_url":"https://api.github.com/repos/dgonyeo/rkt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dgonyeo/rkt/labels{/name}","releases_url":"https://api.github.com/repos/dgonyeo/rkt/releases{/id}","created_at":"2015-09-14T23:20:28Z","updated_at":"2015-09-14T23:20:29Z","pushed_at":"2015-12-07T22:52:50Z","git_url":"git://github.com/dgonyeo/rkt.git","ssh_url":"git@github.com:dgonyeo/rkt.git","clone_url":"https://github.com/dgonyeo/rkt.git","svn_url":"https://github.com/dgonyeo/rkt","homepage":"","size":17687,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"coreos:master","ref":"master","sha":"757025dd6e5527975bd041eef1808e737f11214e","user":{"login":"coreos","id":3730757,"avatar_url":"https://avatars.githubusercontent.com/u/3730757?v=3","gravatar_id":"","url":"https://api.github.com/users/coreos","html_url":"https://github.com/coreos","followers_url":"https://api.github.com/users/coreos/followers","following_url":"https://api.github.com/users/coreos/following{/other_user}","gists_url":"https://api.github.com/users/coreos/gists{/gist_id}","starred_url":"https://api.github.com/users/coreos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreos/subscriptions","organizations_url":"https://api.github.com/users/coreos/orgs","repos_url":"https://api.github.com/users/coreos/repos","events_url":"https://api.github.com/users/coreos/events{/privacy}","received_events_url":"https://api.github.com/users/coreos/received_events","type":"Organization","site_admin":false},"repo":{"id":26509369,"name":"rkt","full_name":"coreos/rkt","owner":{"login":"coreos","id":3730757,"avatar_url":"https://avatars.githubusercontent.com/u/3730757?v=3","gravatar_id":"","url":"https://api.github.com/users/coreos","html_url":"https://github.com/coreos","followers_url":"https://api.github.com/users/coreos/followers","following_url":"https://api.github.com/users/coreos/following{/other_user}","gists_url":"https://api.github.com/users/coreos/gists{/gist_id}","starred_url":"https://api.github.com/users/coreos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreos/subscriptions","organizations_url":"https://api.github.com/users/coreos/orgs","repos_url":"https://api.github.com/users/coreos/repos","events_url":"https://api.github.com/users/coreos/events{/privacy}","received_events_url":"https://api.github.com/users/coreos/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/coreos/rkt","description":"rkt is an App Container runtime for Linux","fork":false,"url":"https://api.github.com/repos/coreos/rkt","forks_url":"https://api.github.com/repos/coreos/rkt/forks","keys_url":"https://api.github.com/repos/coreos/rkt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coreos/rkt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coreos/rkt/teams","hooks_url":"https://api.github.com/repos/coreos/rkt/hooks","issue_events_url":"https://api.github.com/repos/coreos/rkt/issues/events{/number}","events_url":"https://api.github.com/repos/coreos/rkt/events","assignees_url":"https://api.github.com/repos/coreos/rkt/assignees{/user}","branches_url":"https://api.github.com/repos/coreos/rkt/branches{/branch}","tags_url":"https://api.github.com/repos/coreos/rkt/tags","blobs_url":"https://api.github.com/repos/coreos/rkt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coreos/rkt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coreos/rkt/git/refs{/sha}","trees_url":"https://api.github.com/repos/coreos/rkt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coreos/rkt/statuses/{sha}","languages_url":"https://api.github.com/repos/coreos/rkt/languages","stargazers_url":"https://api.github.com/repos/coreos/rkt/stargazers","contributors_url":"https://api.github.com/repos/coreos/rkt/contributors","subscribers_url":"https://api.github.com/repos/coreos/rkt/subscribers","subscription_url":"https://api.github.com/repos/coreos/rkt/subscription","commits_url":"https://api.github.com/repos/coreos/rkt/commits{/sha}","git_commits_url":"https://api.github.com/repos/coreos/rkt/git/commits{/sha}","comments_url":"https://api.github.com/repos/coreos/rkt/comments{/number}","issue_comment_url":"https://api.github.com/repos/coreos/rkt/issues/comments{/number}","contents_url":"https://api.github.com/repos/coreos/rkt/contents/{+path}","compare_url":"https://api.github.com/repos/coreos/rkt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coreos/rkt/merges","archive_url":"https://api.github.com/repos/coreos/rkt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coreos/rkt/downloads","issues_url":"https://api.github.com/repos/coreos/rkt/issues{/number}","pulls_url":"https://api.github.com/repos/coreos/rkt/pulls{/number}","milestones_url":"https://api.github.com/repos/coreos/rkt/milestones{/number}","notifications_url":"https://api.github.com/repos/coreos/rkt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coreos/rkt/labels{/name}","releases_url":"https://api.github.com/repos/coreos/rkt/releases{/id}","created_at":"2014-11-11T23:13:18Z","updated_at":"2015-12-07T22:42:37Z","pushed_at":"2015-12-07T22:52:50Z","git_url":"git://github.com/coreos/rkt.git","ssh_url":"git@github.com:coreos/rkt.git","clone_url":"https://github.com/coreos/rkt.git","svn_url":"https://github.com/coreos/rkt","homepage":"","size":21539,"stargazers_count":4913,"watchers_count":4913,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":418,"mirror_url":null,"open_issues_count":197,"forks":418,"open_issues":197,"watchers":4913,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/coreos/rkt/pulls/1827"},"html":{"href":"https://github.com/coreos/rkt/pull/1827"},"issue":{"href":"https://api.github.com/repos/coreos/rkt/issues/1827"},"comments":{"href":"https://api.github.com/repos/coreos/rkt/issues/1827/comments"},"review_comments":{"href":"https://api.github.com/repos/coreos/rkt/pulls/1827/comments"},"review_comment":{"href":"https://api.github.com/repos/coreos/rkt/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/coreos/rkt/pulls/1827/commits"},"statuses":{"href":"https://api.github.com/repos/coreos/rkt/statuses/a332e0330afd4e7f4376dfde46095dea99dd7fa0"}}}}