summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2022-07-06 07:23:36 -0400
committerMatthew Heon <matthew.heon@pm.me>2022-07-26 13:32:54 -0400
commit183fdea5f595886c799f804d3e7483d3bb0139c8 (patch)
treef24adeedb17afad2f0f1bdabd926ef84e51cffae /libpod
parent17dbce2fb060b4803b2dae4eb6b78fdebea5b61f (diff)
downloadpodman-183fdea5f595886c799f804d3e7483d3bb0139c8.tar.gz
podman-183fdea5f595886c799f804d3e7483d3bb0139c8.tar.bz2
podman-183fdea5f595886c799f804d3e7483d3bb0139c8.zip
Use SafeChown rather then chown for volumes on NFS
NFS Servers will thrown ENOTSUPP error if you attempt to chown a directory to the same UID and GID as the directory already has. If volumes are stored on NFS directories this throws an ugly error and then works on the next try. Bottom line don't chown directories that already have the correct UID and GID. Fixes: https://github.com/containers/podman/issues/14766 [NO NEW TESTS NEEDED] Difficult to setup an NFS Server in testing. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/runtime_volume_linux.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/libpod/runtime_volume_linux.go b/libpod/runtime_volume_linux.go
index d2fe9f2fb..1f354e41b 100644
--- a/libpod/runtime_volume_linux.go
+++ b/libpod/runtime_volume_linux.go
@@ -16,6 +16,7 @@ import (
"github.com/containers/podman/v4/libpod/events"
volplugin "github.com/containers/podman/v4/libpod/plugin"
"github.com/containers/storage/drivers/quota"
+ "github.com/containers/storage/pkg/idtools"
"github.com/containers/storage/pkg/stringid"
pluginapi "github.com/docker/go-plugins-helpers/volume"
"github.com/sirupsen/logrus"
@@ -101,14 +102,14 @@ func (r *Runtime) newVolume(noCreatePluginVolume bool, options ...VolumeCreateOp
if err := os.MkdirAll(volPathRoot, 0700); err != nil {
return nil, fmt.Errorf("creating volume directory %q: %w", volPathRoot, err)
}
- if err := os.Chown(volPathRoot, volume.config.UID, volume.config.GID); err != nil {
+ if err := idtools.SafeChown(volPathRoot, volume.config.UID, volume.config.GID); err != nil {
return nil, fmt.Errorf("chowning volume directory %q to %d:%d: %w", volPathRoot, volume.config.UID, volume.config.GID, err)
}
fullVolPath := filepath.Join(volPathRoot, "_data")
if err := os.MkdirAll(fullVolPath, 0755); err != nil {
return nil, fmt.Errorf("creating volume directory %q: %w", fullVolPath, err)
}
- if err := os.Chown(fullVolPath, volume.config.UID, volume.config.GID); err != nil {
+ if err := idtools.SafeChown(fullVolPath, volume.config.UID, volume.config.GID); err != nil {
return nil, fmt.Errorf("chowning volume directory %q to %d:%d: %w", fullVolPath, volume.config.UID, volume.config.GID, err)
}
if err := LabelVolumePath(fullVolPath); err != nil {