mirror of
https://github.com/containers/podman.git
synced 2025-08-06 11:32:07 +08:00
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>
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user