From e82ccdf958820574d3ed77556340200afef71276 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Wed, 27 Oct 2021 11:26:10 -0700 Subject: [PATCH] containerdexecutor: fix setting user Signed-off-by: Tonis Tiigi --- executor/containerdexecutor/executor.go | 32 +++++++++++-------------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/executor/containerdexecutor/executor.go b/executor/containerdexecutor/executor.go index d85fa806..cd4bc1d2 100644 --- a/executor/containerdexecutor/executor.go +++ b/executor/containerdexecutor/executor.go @@ -119,27 +119,23 @@ func (w *containerdExecutor) Run(ctx context.Context, id string, root executor.M defer lm.Unmount() defer executor.MountStubsCleaner(rootfsPath, mounts)() - var sgids []uint32 - uid, gid, err := oci.ParseUIDGID(meta.User) + uid, gid, sgids, err := oci.GetUser(rootfsPath, meta.User) if err != nil { - uid, gid, sgids, err = oci.GetUser(rootfsPath, meta.User) - if err != nil { - return err - } + return err + } - identity := idtools.Identity{ - UID: int(uid), - GID: int(gid), - } + identity := idtools.Identity{ + UID: int(uid), + GID: int(gid), + } - newp, err := fs.RootPath(rootfsPath, meta.Cwd) - if err != nil { - return errors.Wrapf(err, "working dir %s points to invalid target", newp) - } - if _, err := os.Stat(newp); err != nil { - if err := idtools.MkdirAllAndChown(newp, 0755, identity); err != nil { - return errors.Wrapf(err, "failed to create working directory %s", newp) - } + newp, err := fs.RootPath(rootfsPath, meta.Cwd) + if err != nil { + return errors.Wrapf(err, "working dir %s points to invalid target", newp) + } + if _, err := os.Stat(newp); err != nil { + if err := idtools.MkdirAllAndChown(newp, 0755, identity); err != nil { + return errors.Wrapf(err, "failed to create working directory %s", newp) } }