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

Drop umask to 0 when writing files to disk #155

Merged
merged 3 commits into from
Nov 30, 2017

Conversation

nkubala
Copy link
Contributor

@nkubala nkubala commented Nov 29, 2017

Previously, files were being written from an image to disk with incorrect permissions because of the default umask value (022). Temporarily dropping this to 0 allows the files to get written with their true permissions.

@nkubala nkubala requested a review from dlorenc November 29, 2017 21:10
// drop the umask temporarily to 0, so we can create all files with correct permissions
// otherwise the default (022) will cause file permission inconsistencies
oldMask := syscall.Umask(0)
defer syscall.Umask(oldMask)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explicitly call os.Chmod instead of this? It should be more cross platform.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, done

@vrothberg
Copy link
Contributor

👍 for this change. I ran quite often into this issue.

@@ -80,6 +80,12 @@ func unpackTar(tr *tar.Reader, path string) error {
logrus.Errorf("Error opening file %s", target)
return err
}
// manually set permissions on file, since the default umask (022) will interfere
err = os.Chmod(target, mode)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: inline the err/if statement here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@nkubala nkubala merged commit 3d6d468 into GoogleContainerTools:master Nov 30, 2017
@nkubala nkubala deleted the umask branch November 30, 2017 23:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants