Remove umask, replace with explicit chmod after create
Call chmod on all open files and created directories to ensure permission is set as expected without changing umask. Fixes #1608 Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
@@ -43,20 +43,28 @@ func open(p string) (*os.File, error) {
|
||||
}
|
||||
|
||||
func openFile(name string, flag int, perm os.FileMode) (*os.File, error) {
|
||||
return os.OpenFile(name, flag, perm)
|
||||
f, err := os.OpenFile(name, flag, perm)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Call chmod to avoid permission mask
|
||||
if err := os.Chmod(name, perm); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return f, err
|
||||
}
|
||||
|
||||
func mkdirAll(path string, perm os.FileMode) error {
|
||||
return os.MkdirAll(path, perm)
|
||||
}
|
||||
|
||||
func prepareApply() func() {
|
||||
// Unset unmask before doing an apply operation,
|
||||
// restore unmask when complete
|
||||
oldmask := unix.Umask(0)
|
||||
return func() {
|
||||
unix.Umask(oldmask)
|
||||
func mkdir(path string, perm os.FileMode) error {
|
||||
if err := os.Mkdir(path, perm); err != nil {
|
||||
return err
|
||||
}
|
||||
// Only final created directory gets explicit permission
|
||||
// call to avoid permission mask
|
||||
return os.Chmod(path, perm)
|
||||
}
|
||||
|
||||
func skipFile(*tar.Header) bool {
|
||||
|
Reference in New Issue
Block a user