Skip to content
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(mount): creating directory with 0755 permission #262

Merged
merged 2 commits into from
Dec 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions pkg/zfs/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

n_: can we add a comment on why 0755 is being used as the default permissions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added the comment @kmova

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)
Expand Down