summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorMatej Vasek <mvasek@redhat.com>2021-07-12 14:56:55 +0200
committerMatej Vasek <mvasek@redhat.com>2021-07-12 14:56:55 +0200
commit6cac65c841bc1b52780d8784c3fcca752d03eb1d (patch)
tree4fa6a640074e73d2dc5d6c670999a11fcf5df4a9 /libpod
parentbef1f03d3ca8bfd90f4cbb295d99bf97df74a815 (diff)
downloadpodman-6cac65c841bc1b52780d8784c3fcca752d03eb1d.tar.gz
podman-6cac65c841bc1b52780d8784c3fcca752d03eb1d.tar.bz2
podman-6cac65c841bc1b52780d8784c3fcca752d03eb1d.zip
fix: uid/gid for volume mounted to existing dir
If mounting to existing directory the uid/gid should be preserved. Primary uid/gid of container shouldn't be used. Signed-off-by: Matej Vasek <mvasek@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_internal_linux.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go
index 850af235f..b69ad4105 100644
--- a/libpod/container_internal_linux.go
+++ b/libpod/container_internal_linux.go
@@ -2490,6 +2490,11 @@ func (c *Container) fixVolumePermissions(v *ContainerNamedVolume) error {
// https://github.com/containers/podman/issues/10188
st, err := os.Lstat(filepath.Join(c.state.Mountpoint, v.Dest))
if err == nil {
+ if stat, ok := st.Sys().(*syscall.Stat_t); ok {
+ if err := os.Lchown(mountPoint, int(stat.Uid), int(stat.Gid)); err != nil {
+ return err
+ }
+ }
if err := os.Chmod(mountPoint, st.Mode()|0111); err != nil {
return err
}