Skip to content

Commit

Permalink
Merge pull request #1554 from giuseppe/simplify-dup-user
Browse files Browse the repository at this point in the history
container: remove manual dup operation
  • Loading branch information
rhatdan committed Sep 6, 2024
2 parents 4467dd9 + 228ad7c commit c1226eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 27 deletions.
2 changes: 1 addition & 1 deletion libocispec
31 changes: 5 additions & 26 deletions src/libcrun/container.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,31 +554,6 @@ make_container (runtime_spec_schema_config_schema *container_def, const char *pa
return container;
}

runtime_spec_schema_config_schema_process_user *
process_user_dup (const runtime_spec_schema_config_schema_process_user *const src)
{
runtime_spec_schema_config_schema_process_user *const dst = xmalloc0 (sizeof (runtime_spec_schema_config_schema_process_user));

dst->uid = src->uid;
dst->uid_present = src->uid_present;
dst->gid = src->gid;
dst->gid_present = src->gid_present;
dst->umask = src->umask;
dst->umask_present = src->umask_present;

if (src->additional_gids)
{
dst->additional_gids_len = src->additional_gids_len;
const size_t additional_gids_size = src->additional_gids_len * sizeof (gid_t);
dst->additional_gids = xmalloc (additional_gids_size);
memcpy (dst->additional_gids, src->additional_gids, additional_gids_size);
}

dst->username = xstrdup (src->username);

return dst;
}

libcrun_container_t *
libcrun_container_load_from_memory (const char *json, libcrun_error_t *err)
{
Expand Down Expand Up @@ -3662,7 +3637,11 @@ libcrun_container_exec_with_options (libcrun_context_t *context, const char *id,
process->apparmor_profile = xstrdup (container->container_def->process->apparmor_profile);

if (process->user == NULL && container->container_def->process->user)
process->user = process_user_dup (container->container_def->process->user);
{
process->user = clone_runtime_spec_schema_config_schema_process_user (container->container_def->process->user);
if (process->user == NULL)
OOM ();
}
}

ret = initialize_security (process, err);
Expand Down

0 comments on commit c1226eb

Please sign in to comment.