summaryrefslogtreecommitdiff
path: root/libpod/runtime_volume_linux.go
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2019-03-22 12:15:26 +0100
committerGiuseppe Scrivano <gscrivan@redhat.com>2019-03-29 14:04:44 +0100
commitf7e72bc86aff2ff986290f190309deceb7f22099 (patch)
treed6fc24ed50db3437a90944299af4a4436ca6fe7c /libpod/runtime_volume_linux.go
parent9b789359f17f22bdd2ed49087c23eebf39f338f3 (diff)
downloadpodman-f7e72bc86aff2ff986290f190309deceb7f22099.tar.gz
podman-f7e72bc86aff2ff986290f190309deceb7f22099.tar.bz2
podman-f7e72bc86aff2ff986290f190309deceb7f22099.zip
volumes: push the chown logic to runtime_volume_linux.go
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'libpod/runtime_volume_linux.go')
-rw-r--r--libpod/runtime_volume_linux.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/libpod/runtime_volume_linux.go b/libpod/runtime_volume_linux.go
index 5767a99e7..db5c29242 100644
--- a/libpod/runtime_volume_linux.go
+++ b/libpod/runtime_volume_linux.go
@@ -51,10 +51,20 @@ func (r *Runtime) newVolume(ctx context.Context, options ...VolumeCreateOption)
}
// Create the mountpoint of this volume
- fullVolPath := filepath.Join(r.config.VolumePath, volume.config.Name, "_data")
- if err := os.MkdirAll(fullVolPath, 0755); err != nil {
+ volPathRoot := filepath.Join(r.config.VolumePath, volume.config.Name)
+ if err := os.MkdirAll(volPathRoot, 0700); err != nil {
+ return nil, errors.Wrapf(err, "error creating volume directory %q", volPathRoot)
+ }
+ if err := os.Chown(volPathRoot, volume.config.UID, volume.config.GID); err != nil {
+ return nil, errors.Wrapf(err, "error chowning volume directory %q to %d:%d", volPathRoot, volume.config.UID, volume.config.GID)
+ }
+ fullVolPath := filepath.Join(volPathRoot, "_data")
+ if err := os.Mkdir(fullVolPath, 0755); err != nil {
return nil, errors.Wrapf(err, "error creating volume directory %q", fullVolPath)
}
+ if err := os.Chown(fullVolPath, volume.config.UID, volume.config.GID); err != nil {
+ return nil, errors.Wrapf(err, "error chowning volume directory %q to %d:%d", fullVolPath, volume.config.UID, volume.config.GID)
+ }
if err := LabelVolumePath(fullVolPath, true); err != nil {
return nil, err
}