mirror of https://github.com/containers/podman.git
container: do not chown to dest target with U
if the 'U' option is provided, do not chown the destination target to the existing target in the image. Closes: https://github.com/containers/podman/issues/22224 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
parent
7d68362cf5
commit
519a66c6a9
|
@ -2882,8 +2882,13 @@ func (c *Container) fixVolumePermissions(v *ContainerNamedVolume) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the new volume matches the permissions of the target directory.
|
// Make sure the new volume matches the permissions of the target directory unless 'U' is
|
||||||
|
// provided (since the volume was already chowned in this case).
|
||||||
// https://github.com/containers/podman/issues/10188
|
// https://github.com/containers/podman/issues/10188
|
||||||
|
if slices.Contains(v.Options, "U") {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
st, err := os.Lstat(filepath.Join(c.state.Mountpoint, v.Dest))
|
st, err := os.Lstat(filepath.Join(c.state.Mountpoint, v.Dest))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if stat, ok := st.Sys().(*syscall.Stat_t); ok {
|
if stat, ok := st.Sys().(*syscall.Stat_t); ok {
|
||||||
|
|
|
@ -750,6 +750,12 @@ VOLUME /test/`, ALPINE)
|
||||||
Expect(session).Should(ExitCleanly())
|
Expect(session).Should(ExitCleanly())
|
||||||
Expect(session.OutputToString()).To(ContainSubstring("888:888"))
|
Expect(session.OutputToString()).To(ContainSubstring("888:888"))
|
||||||
|
|
||||||
|
// test with an existing directory in the image
|
||||||
|
session = podmanTest.Podman([]string{"run", "--rm", "--user", "881:882", "-v", "NAMED-VOLUME:/mnt:U", ALPINE, "stat", "-c", "%u:%g", "/mnt"})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session).Should(ExitCleanly())
|
||||||
|
Expect(session.OutputToString()).To(ContainSubstring("881:882"))
|
||||||
|
|
||||||
session = podmanTest.Podman([]string{"run", "--rm", "--user", "888:888", "--userns", "auto", "-v", vol, ALPINE, "stat", "-c", "%u:%g", dest})
|
session = podmanTest.Podman([]string{"run", "--rm", "--user", "888:888", "--userns", "auto", "-v", vol, ALPINE, "stat", "-c", "%u:%g", dest})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(ExitCleanly())
|
Expect(session).Should(ExitCleanly())
|
||||||
|
|
Loading…
Reference in New Issue