aboutsummaryrefslogtreecommitdiff
path: root/filesystem
diff options
context:
space:
mode:
Diffstat (limited to 'filesystem')
-rw-r--r--filesystem/path.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/filesystem/path.go b/filesystem/path.go
index 5fd3fdf..cfc3dc0 100644
--- a/filesystem/path.go
+++ b/filesystem/path.go
@@ -24,9 +24,19 @@ import (
"os"
"path/filepath"
+ "golang.org/x/sys/unix"
+
"github.com/pkg/errors"
)
+// OpenFileOverridingUmask calls os.OpenFile but with the umask overridden so
+// that no permission bits are masked out if the file is created.
+func OpenFileOverridingUmask(name string, flag int, perm os.FileMode) (*os.File, error) {
+ oldMask := unix.Umask(0)
+ defer unix.Umask(oldMask)
+ return os.OpenFile(name, flag, perm)
+}
+
// We only check the unix permissions and the sticky bit
const permMask = os.ModeSticky | os.ModePerm