Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[19.03] handle close error on save #2631

Merged
merged 2 commits into from Jul 16, 2020

Conversation

@cpuguy83
Copy link
Collaborator

@cpuguy83 cpuguy83 commented Jul 15, 2020

Backports:

  • 22a291f #2228 config: preserve ownership and permissions on configfile
    • fixes moby/moby#40175 Bug: sudo docker login changes .docker/config.json permissions
  • d021730 #2595 Handle errors on close in config file write

The first because it seemed at least relevant and the fact that it was missing caused a merge conflict (simple to fix, but still).
Can remove if needed.

thaJeztah and others added 2 commits Dec 17, 2019
When running `docker login` or `docker logout`, the CLI updates
the configuration file by creating a temporary file, to replace
the old one (if exists).

When using `sudo`, this caused the file to be created as `root`,
making it inaccessible to the current user.

This patch updates the CLI to fetch permissions and ownership of
the existing configuration file, and applies those permissions
to the new file, so that it has the same permissions as the
existing file (if any).

Currently, only done for "Unix-y" systems (Mac, Linux), but
can be implemented for Windows in future if there's a need.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 22a291f)
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
I'm not sure if this fixes anything, however I have seen some weird
behavior on Windows where temp config files are left around and there
doesn't seem to be any errors reported.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
(cherry picked from commit d021730)
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
@cpuguy83 cpuguy83 requested review from thaJeztah and silvin-lubecki Jul 15, 2020
package configfile

func copyFilePermissions(src, dst string) {
// TODO implement for Windows

This comment has been minimized.

@silvin-lubecki

silvin-lubecki Jul 15, 2020
Contributor

Question: what would be the implementation for windows?

This comment has been minimized.

@thaJeztah

thaJeztah Jul 16, 2020
Member

Not sure how to copy permissions and/or ownership on Windows. Perhaps @simonferquel would know.

Also not sure if the problem that this was fixing happens on Windows as well

This comment has been minimized.

@simonferquel

simonferquel Jul 16, 2020
Contributor

Hmm, I am not sure about the correct "Windows" way to do that. But anyway I don't think it applies (when you create a file on Windows, by default you inherit ACLs from the parent directory).

This comment has been minimized.

@thaJeztah

thaJeztah Jul 16, 2020
Member

Thx! Perhaps I should update the comment and remove "todo"

This comment has been minimized.

@simonferquel

simonferquel Jul 16, 2020
Contributor

also renaming the function would be welcome, because on the windows implementation it does not do what it claims to do (in the general case it does not copy the permissions, which is fine in this specific case, but could be confusing in the future). Maybe renaming it to replicateConfigFilePermissions or something like this would be preferable.

This comment has been minimized.

@thaJeztah

thaJeztah Jul 16, 2020
Member

Don't think it's needed to include "configfile" in the name, as it's already in this package, and in itself, it's not specific to configfiles.

I'll have a look for changing the comment (and possibly name) on master

@thaJeztah thaJeztah added this to the 19.03.13 milestone Jul 16, 2020
Copy link
Member

@thaJeztah thaJeztah left a comment

LGTM

@thaJeztah thaJeztah merged commit 5e05ef3 into docker:19.03 Jul 16, 2020
6 checks passed
6 checks passed
DCO DCO
Details
ci/circleci: cross Your tests passed on CircleCI!
Details
ci/circleci: lint Your tests passed on CircleCI!
Details
ci/circleci: test Your tests passed on CircleCI!
Details
ci/circleci: validate Your tests passed on CircleCI!
Details
continuous-integration/jenkins/pr-merge This commit looks good
Details
@cpuguy83 cpuguy83 deleted the cpuguy83:19.03_handle_close_error_on_save branch Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.