Skip to content

Commit 08a8429

Browse files
committed
libpod: avoid chowning the rundir to root in the userns
so it is possible to remove the code to make the entire directory world accessible. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
1 parent c81f075 commit 08a8429

File tree

3 files changed

+0
-19
lines changed

3 files changed

+0
-19
lines changed

libpod/container_internal.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -544,16 +544,6 @@ func (c *Container) setupStorage(ctx context.Context) error {
544544
c.config.StaticDir = containerInfo.Dir
545545
c.state.RunDir = containerInfo.RunDir
546546

547-
if len(c.config.IDMappings.UIDMap) != 0 || len(c.config.IDMappings.GIDMap) != 0 {
548-
if err := idtools.SafeChown(containerInfo.RunDir, c.RootUID(), c.RootGID()); err != nil {
549-
return err
550-
}
551-
552-
if err := idtools.SafeChown(containerInfo.Dir, c.RootUID(), c.RootGID()); err != nil {
553-
return err
554-
}
555-
}
556-
557547
// Set the default Entrypoint and Command
558548
if containerInfo.Config != nil {
559549
// Set CMD in the container to the default configuration only if ENTRYPOINT is not set by the user.

libpod/container_internal_common.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,10 +1834,6 @@ func (c *Container) mountIntoRootDirs(mountName string, mountPath string) error
18341834

18351835
// Make standard bind mounts to include in the container
18361836
func (c *Container) makeBindMounts() error {
1837-
if err := idtools.SafeChown(c.state.RunDir, c.RootUID(), c.RootGID()); err != nil {
1838-
return fmt.Errorf("cannot chown run directory: %w", err)
1839-
}
1840-
18411837
if c.state.BindMounts == nil {
18421838
c.state.BindMounts = make(map[string]string)
18431839
}

libpod/oci_conmon_common.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,6 @@ func hasCurrentUserMapped(ctr *Container) bool {
183183

184184
// CreateContainer creates a container.
185185
func (r *ConmonOCIRuntime) CreateContainer(ctr *Container, restoreOptions *ContainerCheckpointOptions) (int64, error) {
186-
// always make the container directory accessible to the current user so that the PID files can be read without
187-
// being in the rootless user namespace.
188-
if err := makeAccessible(ctr.state.RunDir, 0, 0); err != nil {
189-
return 0, err
190-
}
191186
if !hasCurrentUserMapped(ctr) {
192187
if err := makeAccessible(ctr.state.Mountpoint, ctr.RootUID(), ctr.RootGID()); err != nil {
193188
return 0, err

0 commit comments

Comments
 (0)