From 51eeae36408b018a6ece2d0db69e6297542bb160 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Wed, 28 Jul 2021 19:18:38 +0300 Subject: [PATCH] [#727] util: Add `MkdirAllX` func Add `MkdirAllX` function that wraps `os.MkdirAll` and adds `x` permission for user and group. This is used to make all created dirs openable for user and group regardless of the read config permissions. Signed-off-by: Pavel Karpy --- pkg/util/os.go | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 pkg/util/os.go diff --git a/pkg/util/os.go b/pkg/util/os.go new file mode 100644 index 00000000..03b97766 --- /dev/null +++ b/pkg/util/os.go @@ -0,0 +1,10 @@ +package util + +import "os" + +// MkdirAllX calls os.MkdirAll with passed permissions +// but with +x for user and group. This makes created +// dir openable regardless of the passed permissions. +func MkdirAllX(path string, perm os.FileMode) error { + return os.MkdirAll(path, perm|0110) +}