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

Fix 'force' semantics in 'utils.filesystem.mkdir' #177

Merged
merged 1 commit into from Nov 22, 2018

Conversation

Projects
None yet
2 participants
@airwoodix
Contributor

airwoodix commented Nov 22, 2018

Problem

In utils.filesystem.mkdir, the force argument is intended to enforce directory ownership / mode even if the target path already exists. However, the current implementation calls os.mkdir which raises OSError if the target path exists.

Proposed solution

Mimic Python 3.2+ os.makedirs exist_ok behaviour when creating the leaf.
This is a temporary patch waiting for a migration to Python 3.

Status

Ready for review.

Context

Problem identified in combination with yunohost user ssh add-key called when $HOME/.ssh/authorized_keys doesn't exit but $HOME/.ssh does. The yunohost code correctly calls mkdir with force=True but fails because of the problem addressed by this PR.

@alexAubin

This comment has been minimized.

Member

alexAubin commented Nov 22, 2018

Sounds legit to me, merging as a micro decision 👍

Thanks a lot 👍

@alexAubin alexAubin merged commit c2f02cd into YunoHost:stretch-unstable Nov 22, 2018

1 check failed

continuous-integration/travis-ci/pr The Travis CI build failed
Details

@alexAubin alexAubin added this to the 3.3.x milestone Nov 22, 2018

@airwoodix airwoodix deleted the airwoodix:fix-mkdir-force-leaf-exists branch Nov 22, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment