Assign ImageSpec User if SecurityContext is not set
By default the SecurityContext for Container activation can contain a Username UID, GID. The order of precedences is username, UID, GID. If none of these options are specified as a last resort attempt to set the ImageSpec username. Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
This commit is contained in:
@@ -169,6 +169,11 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to generate user string")
|
||||
}
|
||||
if userstr == "" {
|
||||
// Lastly, since no user override was passed via CRI try to set via OCI
|
||||
// Image
|
||||
userstr = image.ImageSpec.Config.User
|
||||
}
|
||||
if userstr != "" {
|
||||
specOpts = append(specOpts, oci.WithUser(userstr))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user