-
Notifications
You must be signed in to change notification settings - Fork 56
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: add chmod to mkdir to ignore umask settings #405
fix: add chmod to mkdir to ignore umask settings #405
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments. Happy to discuss further too.
I'm not 100% sure we should add the flag. Maybe we should just always chmod it? But there is a precedent for the flag in the AtomicWrite functions, so that's what made me think we should add it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't reviewed in detail yet, but just a couple of comments that might unblock you.
I've looked at this more closely -- sorry for the delay. The function signatures, as well as the number of functions in the implementation, is getting unwieldy. I think we should go back to the drawing board and design a better function. How about this: make the two required arguments positional (path and perm) and put everything else in an options struct (which can be nil or the zero value for defaults): package osutil
func Mkdir(path string, perm os.FileMode, options *MkdirOptions) error { ... }
type MkdirOptions struct {
// True to create any parent directories if they don't already exist.
//
// If false and path already exists, Mkdir returns an error that wraps os.ErrExist (like os.Mkdir).
// If true and path already exists, Mkdir does nothing and returns nil (like os.MkdirAll).
MakeParents bool
// True to perform an explicit chmod on any directories created.
Chmod bool
// True to call chown on any directories created, using the user ID and group ID provided.
Chown bool // NOTE: additional bool is needed because 0 is a valid value for UserID and GroupID (root)
UserID sys.UserID
GroupID sys.GroupID
} I'm not sure about the "clever" The above is somewhat modelled after https://docs.python.org/3/library/pathlib.html#pathlib.Path.mkdir |
Closing this PR for now, see the new PR which does the refactor and implements the feature here. |
Add a flag so that pebble mkdir won't be affected by umask settings.
Closes #372.