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

config: preserve ownership and permissions on configfile #2228

Merged
merged 1 commit into from
Jan 9, 2020

Conversation

thaJeztah
Copy link
Member

fixes moby/moby#40175

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.

- What I did

- How I did it

- How to verify it

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

@thaJeztah thaJeztah changed the title config: preserve ownership and permissions on configfile [WIP] config: preserve ownership and permissions on configfile 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 <[email protected]>
@thaJeztah thaJeztah changed the title [WIP] config: preserve ownership and permissions on configfile config: preserve ownership and permissions on configfile Dec 17, 2019
Copy link
Contributor

@silvin-lubecki silvin-lubecki left a comment

Choose a reason for hiding this comment

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

LGTM

@silvin-lubecki silvin-lubecki merged commit af097b2 into docker:master Jan 9, 2020
@thaJeztah thaJeztah deleted the config_permissions branch January 9, 2020 14:27
@thaJeztah thaJeztah added this to the next milestone Feb 5, 2020
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.

Bug: sudo docker login changes .docker/config.json permissions
3 participants