Skip to content

Commit

Permalink
zfs: fix folder permissions after dataset creation
Browse files Browse the repository at this point in the history
Closes canonical#3090.

Signed-off-by: Christian Brauner <[email protected]>
  • Loading branch information
Christian Brauner committed May 23, 2017
1 parent d705f0b commit 005e6f5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
4 changes: 0 additions & 4 deletions lxd/storage_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,3 @@ const containersDirMode os.FileMode = 0755
const customDirMode os.FileMode = 0755
const imagesDirMode os.FileMode = 0700
const snapshotsDirMode os.FileMode = 0700

// Driver permissions for driver specific folders in ${LXD_DIR}
// zfs
const deletedDirMode os.FileMode = 0700
34 changes: 34 additions & 0 deletions lxd/storage_zfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1806,6 +1806,12 @@ func (s *storageZfs) zfsPoolCreate() error {
return err
}

fixperms := shared.VarPath("storage-pools", s.pool.Name, "containers")
err = os.Chmod(fixperms, containersDirMode)
if err != nil {
logger.Warnf("failed to chmod \"%s\" to \"0%s\": %s", fixperms, strconv.FormatInt(int64(containersDirMode), 8), err)
}

err = s.zfsPoolVolumeCreate("images")
if err != nil {
return err
Expand All @@ -1816,6 +1822,12 @@ func (s *storageZfs) zfsPoolCreate() error {
return err
}

fixperms = shared.VarPath("storage-pools", s.pool.Name, "images")
err = os.Chmod(fixperms, imagesDirMode)
if err != nil {
logger.Warnf("failed to chmod \"%s\" to \"0%s\": %s", fixperms, strconv.FormatInt(int64(imagesDirMode), 8), err)
}

err = s.zfsPoolVolumeCreate("custom")
if err != nil {
return err
Expand All @@ -1826,6 +1838,12 @@ func (s *storageZfs) zfsPoolCreate() error {
return err
}

fixperms = shared.VarPath("storage-pools", s.pool.Name, "custom")
err = os.Chmod(fixperms, customDirMode)
if err != nil {
logger.Warnf("failed to chmod \"%s\" to \"0%s\": %s", fixperms, strconv.FormatInt(int64(customDirMode), 8), err)
}

err = s.zfsPoolVolumeCreate("deleted")
if err != nil {
return err
Expand All @@ -1836,6 +1854,22 @@ func (s *storageZfs) zfsPoolCreate() error {
return err
}

err = s.zfsPoolVolumeCreate("snapshots")
if err != nil {
return err
}

err = s.zfsPoolVolumeSet("snapshots", "mountpoint", "none")
if err != nil {
return err
}

fixperms = shared.VarPath("storage-pools", s.pool.Name, "snapshots")
err = os.Chmod(fixperms, snapshotsDirMode)
if err != nil {
logger.Warnf("failed to chmod \"%s\" to \"0%s\": %s", fixperms, strconv.FormatInt(int64(snapshotsDirMode), 8), err)
}

return nil
}

Expand Down

0 comments on commit 005e6f5

Please sign in to comment.