mirror of
https://github.com/containers/podman.git
synced 2025-06-25 20:26:51 +08:00
podman cp: ignore EPERMs in rootless mode
Ignore permission errors when copying from a rootless container. TTY devices inside rootless containers are owned by the host's root user which is "nobody" inside the container's user namespace rendering us unable to even read them. Enable the integration test which was temporarily disabled for rootless users. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
@ -57,6 +57,8 @@ If you use a : in a local machine path, you must be explicit with a relative or
|
|||||||
|
|
||||||
Using `-` as the *src_path* streams the contents of STDIN as a tar archive. The command extracts the content of the tar to the *DEST_PATH* in the container. In this case, *dest_path* must specify a directory. Using `-` as the *dest_path* streams the contents of the resource (can be a directory) as a tar archive to STDOUT.
|
Using `-` as the *src_path* streams the contents of STDIN as a tar archive. The command extracts the content of the tar to the *DEST_PATH* in the container. In this case, *dest_path* must specify a directory. Using `-` as the *dest_path* streams the contents of the resource (can be a directory) as a tar archive to STDOUT.
|
||||||
|
|
||||||
|
Note that `podman cp` ignores permission errors when copying from a running rootless container. The TTY devices inside a rootless container are owned by the host's root user and hence cannot be read inside the container's user namespace.
|
||||||
|
|
||||||
## OPTIONS
|
## OPTIONS
|
||||||
|
|
||||||
## ALTERNATIVES
|
## ALTERNATIVES
|
||||||
|
@ -14,6 +14,7 @@ import (
|
|||||||
"github.com/containers/buildah/pkg/chrootuser"
|
"github.com/containers/buildah/pkg/chrootuser"
|
||||||
"github.com/containers/buildah/util"
|
"github.com/containers/buildah/util"
|
||||||
"github.com/containers/podman/v3/libpod/define"
|
"github.com/containers/podman/v3/libpod/define"
|
||||||
|
"github.com/containers/podman/v3/pkg/rootless"
|
||||||
"github.com/containers/storage"
|
"github.com/containers/storage"
|
||||||
"github.com/containers/storage/pkg/idtools"
|
"github.com/containers/storage/pkg/idtools"
|
||||||
"github.com/docker/docker/pkg/archive"
|
"github.com/docker/docker/pkg/archive"
|
||||||
@ -139,6 +140,11 @@ func (c *Container) copyToArchive(ctx context.Context, path string, writer io.Wr
|
|||||||
ChownDirs: idPair,
|
ChownDirs: idPair,
|
||||||
ChownFiles: idPair,
|
ChownFiles: idPair,
|
||||||
Excludes: []string{"dev", "proc", "sys"},
|
Excludes: []string{"dev", "proc", "sys"},
|
||||||
|
// Ignore EPERMs when copying from rootless containers
|
||||||
|
// since we cannot read TTY devices. Those are owned
|
||||||
|
// by the host's root and hence "nobody" inside the
|
||||||
|
// container's user namespace.
|
||||||
|
IgnoreUnreadable: rootless.IsRootless() && c.state.State == define.ContainerStateRunning,
|
||||||
}
|
}
|
||||||
return c.joinMountAndExec(ctx,
|
return c.joinMountAndExec(ctx,
|
||||||
func() error {
|
func() error {
|
||||||
|
@ -212,7 +212,6 @@ var _ = Describe("Podman cp", func() {
|
|||||||
|
|
||||||
// Copy the root dir "/" of a container to the host.
|
// Copy the root dir "/" of a container to the host.
|
||||||
It("podman cp the root directory from the ctr to an existing directory on the host ", func() {
|
It("podman cp the root directory from the ctr to an existing directory on the host ", func() {
|
||||||
SkipIfRootless("cannot copy tty devices in rootless mode")
|
|
||||||
container := "copyroottohost"
|
container := "copyroottohost"
|
||||||
session := podmanTest.RunTopContainer(container)
|
session := podmanTest.RunTopContainer(container)
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
|
Reference in New Issue
Block a user