From 2e5e61d25503697efdf64b4116cb96cfa681b640 Mon Sep 17 00:00:00 2001 From: Pawan Prakash Sharma Date: Wed, 23 Dec 2020 08:31:17 +0530 Subject: [PATCH] fix(mount): creating directory with 0755 permission (#262) Signed-off-by: Pawan --- pkg/zfs/mount.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pkg/zfs/mount.go b/pkg/zfs/mount.go index b80c478..0c988c9 100644 --- a/pkg/zfs/mount.go +++ b/pkg/zfs/mount.go @@ -254,16 +254,12 @@ func MountDataset(vol *apis.ZFSVolume, mount *MountInfo) error { // MountFilesystem mounts the disk to the specified path func MountFilesystem(vol *apis.ZFSVolume, mount *MountInfo) error { - if err := os.MkdirAll(mount.MountPath, 0000); err != nil { + // creating the directory with 0755 permission so that it can be accessed by other person. + // if the directory already exist(old k8s), the creator should set the proper permission. + if err := os.MkdirAll(mount.MountPath, 0755); err != nil { return status.Errorf(codes.Internal, "Could not create dir {%q}, err: %v", mount.MountPath, err) } - // in case if the dir already exists, above call returns nil - // so permission needs to be updated - if err := os.Chmod(mount.MountPath, 0000); err != nil { - return status.Errorf(codes.Internal, "Could not change mode of dir {%q}, err: %v", mount.MountPath, err) - } - switch vol.Spec.VolumeType { case VolTypeDataset: return MountDataset(vol, mount)