Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Conversation

@nkubala
Copy link
Contributor

@nkubala nkubala commented Mar 21, 2018

When unpacking image tars, sometimes we run into directories that were unwriteable in the image. The directories will get created by container-diff, but then any subsequent files being written to the directory will fail. To fix this, we set the world-writable bit on the directory when we create it, then defer resetting the permissions so we can write all of its contents.

Fixes #168

@nkubala nkubala requested a review from dlorenc March 21, 2018 20:51
logrus.Debugf("Write permission bit not set on %s by default; setting manually", target)
originalMode := mode
mode = mode | (1 << uint(7))
defer os.Chmod(target, originalMode)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Chmod can return an Error, might be worth not deferring it and handling the error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good call

dlorenc
dlorenc previously approved these changes Mar 27, 2018
@nkubala
Copy link
Contributor Author

nkubala commented Mar 30, 2018

Unfortunately this only partially solves this issue, because once we reset the permissions outside of the scope of the user we can't remove or modify any of the files, meaning that we can't properly clean up the image on the filesystem. Still, this is better than what we had before, so I changed the message to a warn. The only real way to fix this issue is by moving the unpacked image from disk to memory, which is well outside the scope of this PR.

@nkubala nkubala merged commit 5a276f0 into GoogleContainerTools:master Apr 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

3 participants