Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

container: remove manual dup operation #1554

Merged
merged 2 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading