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:

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 July 15, 2020 12:31
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 <[email protected]>
(cherry picked from commit 22a291f)
Signed-off-by: Brian Goff <[email protected]>
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 <[email protected]>
(cherry picked from commit d021730)
Signed-off-by: Brian Goff <[email protected]>
package configfile

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: what would be the implementation for windows?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thaJeztah thaJeztah merged commit 5e05ef3 into docker:19.03 Jul 16, 2020
@cpuguy83 cpuguy83 deleted the 19.03_handle_close_error_on_save branch July 27, 2020 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants