Skip to content

Commit

Permalink
Merge pull request #12528 from flouthoc/dont_modify_mount_permissions
Browse files Browse the repository at this point in the history
volume: apply exact permission of target directory without adding extra `0111`
  • Loading branch information
openshift-merge-robot authored Dec 7, 2021
2 parents 2f11e2a + 7d0fd17 commit 4307729
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libpod/container_internal_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -2784,7 +2784,7 @@ func (c *Container) fixVolumePermissions(v *ContainerNamedVolume) error {
return err
}
}
if err := os.Chmod(mountPoint, st.Mode()|0111); err != nil {
if err := os.Chmod(mountPoint, st.Mode()); err != nil {
return err
}
stat := st.Sys().(*syscall.Stat_t)
Expand Down
12 changes: 12 additions & 0 deletions test/e2e/run_volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,18 @@ USER testuser`, fedoraMinimal)

})

It("podman run with named volume check if we honor permission of target dir", func() {
session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "stat", "-c", "%a %Y", "/var/tmp"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
perms := session.OutputToString()

session = podmanTest.Podman([]string{"run", "--rm", "-v", "test:/var/tmp", ALPINE, "stat", "-c", "%a %Y", "/var/tmp"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session.OutputToString()).To(Equal(perms))
})

It("podman volume with uid and gid works", func() {
volName := "testVol"
volCreate := podmanTest.Podman([]string{"volume", "create", "--opt", "o=uid=1000", volName})
Expand Down

0 comments on commit 4307729

Please sign in to comment.