{"action":"created","issue":{"url":"https://api.github.com/repos/moby/moby/issues/35874","repository_url":"https://api.github.com/repos/moby/moby","labels_url":"https://api.github.com/repos/moby/moby/issues/35874/labels{/name}","comments_url":"https://api.github.com/repos/moby/moby/issues/35874/comments","events_url":"https://api.github.com/repos/moby/moby/issues/35874/events","html_url":"https://github.com/moby/moby/pull/35874","id":284467992,"number":35874,"title":"Fix ownership-regression in docker cp to container","user":{"login":"javabrett","id":1103477,"avatar_url":"https://avatars1.githubusercontent.com/u/1103477?v=4","gravatar_id":"","url":"https://api.github.com/users/javabrett","html_url":"https://github.com/javabrett","followers_url":"https://api.github.com/users/javabrett/followers","following_url":"https://api.github.com/users/javabrett/following{/other_user}","gists_url":"https://api.github.com/users/javabrett/gists{/gist_id}","starred_url":"https://api.github.com/users/javabrett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javabrett/subscriptions","organizations_url":"https://api.github.com/users/javabrett/orgs","repos_url":"https://api.github.com/users/javabrett/repos","events_url":"https://api.github.com/users/javabrett/events{/privacy}","received_events_url":"https://api.github.com/users/javabrett/received_events","type":"User","site_admin":false},"labels":[{"id":175375407,"url":"https://api.github.com/repos/moby/moby/labels/status/2-code-review","name":"status/2-code-review","color":"fad8c7","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-12-25T20:34:53Z","updated_at":"2017-12-26T08:41:05Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/moby/moby/pulls/35874","html_url":"https://github.com/moby/moby/pull/35874","diff_url":"https://github.com/moby/moby/pull/35874.diff","patch_url":"https://github.com/moby/moby/pull/35874.patch"},"body":"Following the addition of the `-a` (archive, owner, permissions) option to `docker cp` (#28923), the command behaviour _without_ the new option has changed, and files are no-longer copied into the container as _root_, but as a UID/GID of the user running the command in the host.\r\n\r\n**- What I did**\r\n\r\n* Added a (failng) integration-test `TestCpToContainerWithoutPermissions`, the inverse of the new test `TestCpToContainerWithPermissions` added in #28923) . Pre-existing test seemed to not correctly check permissions as this test does (by shelling-in to the container and running `stat`).\r\n* Back-ported that test to the parent commit before #28923 landed, https://github.com/javabrett/moby/tree/34096-before-cp-a-option-added , where the test passes.\r\n* Found that the logic added for `docker cp -a` seems accidentally inverted and depends on whether `container.Config.User` is set, when it then tries to not apply owner-logic.  However `NoLchown` was not test in `defaultTarCopyOptions`, so the reverse occurs.\r\n* Set `NoLchown=true` in `defaultTarCopyOptions` to deactivate the `chown` when the option is not present.\r\n* Reactivated with `NoLchown=false` in `tarCopyOptions` when `-a` is set.\r\n\r\n**- How to verify it**\r\nRun updated tests.  Run current Docker CLI `docker cp` as non-root and note incorrect permissions in container.  Run patched and check files are owned by `root:root`.  Check `docker cp -a` still sets UID/GID.\r\n\r\n**- Description for the changelog**\r\nFixed regression in `docker cp` where files copied to the container are no longer owned by `root:root`.  `docker cp -a` should be used to set file-ownership in-container.\r\n\r\nFixes #34096."},"comment":{"url":"https://api.github.com/repos/moby/moby/issues/comments/353939583","html_url":"https://github.com/moby/moby/pull/35874#issuecomment-353939583","issue_url":"https://api.github.com/repos/moby/moby/issues/35874","id":353939583,"user":{"login":"coolljt0725","id":8232360,"avatar_url":"https://avatars3.githubusercontent.com/u/8232360?v=4","gravatar_id":"","url":"https://api.github.com/users/coolljt0725","html_url":"https://github.com/coolljt0725","followers_url":"https://api.github.com/users/coolljt0725/followers","following_url":"https://api.github.com/users/coolljt0725/following{/other_user}","gists_url":"https://api.github.com/users/coolljt0725/gists{/gist_id}","starred_url":"https://api.github.com/users/coolljt0725/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coolljt0725/subscriptions","organizations_url":"https://api.github.com/users/coolljt0725/orgs","repos_url":"https://api.github.com/users/coolljt0725/repos","events_url":"https://api.github.com/users/coolljt0725/events{/privacy}","received_events_url":"https://api.github.com/users/coolljt0725/received_events","type":"User","site_admin":false},"created_at":"2017-12-26T08:41:05Z","updated_at":"2017-12-26T08:41:05Z","author_association":"CONTRIBUTOR","body":"@javabrett  Hi, please squash your commits. "}}
{"actor":{"display_login":"coolljt0725"}}